Posts Tagged ‘ Ruby

Error install nokogiri

Fetching: mini_portile-0.6.2.gem (100%)
Fetching: nokogiri- (100%)
Building native extensions.  This could take a while...
ERROR:  Error installing nokogiri:
	ERROR: Failed to build gem native extension.
        /usr/bin/ruby1.9.1 extconf.rb
checking if the C compiler accepts ... yes
Building nokogiri using packaged libraries.
checking for gzdopen() in -lz... no
zlib is missing; necessary for building libxml2
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers.  Check the mkmf.log file for more
details.  You may need configuration options.
Provided configuration options:
Gem files will remain installed in /var/lib/gems/1.9.1/gems/nokogiri- for inspection.
Results logged to /var/lib/gems/1.9.1/gems/nokogiri-

Read more

Telegram Bot on ruby

apt-get install ruby gem ruby-dev make
gem install telegram-bot-ruby

Теперь необходимо получить токен для бота.
Заходим в Telegram, добавляем бота @BotFather, и создаем бота:

Telegram Bot

Telegram Bot

So, let’s write to out bot and get updates

curl -s -X POST

And we have:

# encoding: utf-8
require 'telegram/bot'
#require_relative 'getimg'
#inputMess = ARGV[0]
puts "fff" do |bot|
    #  bot.listen do |chat|
    bot.api.sendMessage(chat_id: "<>", text: "Hello")

XML парсер на Ruby

Парсить XML можно с помощью библиотеки Nokogiri
Ставим Ruby-dev

aptitude install ruby-dev
tar xvf rubygems-1.5.0.tgz
cd rubygems-1.5.0
sudo ruby setup.rb
gem install optparse-command

А после Nokogiri
gem install nokogiri