Won't work
Opened this issue · 4 comments
dani@devel1-datatrends:~/app/didit-cli-client$ alias did='~/app/didit-cli-client/didit.rb'
dani@devel1-datatrends:~/app/didit-cli-client$ did
/usr/lib/ruby/1.9.1/net/http.rb:1861:in `initialize': undefined method `empty?' for #<URI::HTTPS:0x0000000166b5b0> (NoMethodError)
from /usr/lib/ruby/1.9.1/net/http.rb:2094:in `initialize'
from /home/dani/app/didit-cli-client/didit.rb:90:in `new'
from /home/dani/app/didit-cli-client/didit.rb:90:in `discover_urls'
from /home/dani/app/didit-cli-client/didit.rb:156:in `<main>'
More info:
I did a bundle install as specified
dani@devel1-datatrends:~/app/didit-cli-client$ bundle install
Fetching gem metadata from https://rubygems.org/...
Resolving dependencies...
Using highline (1.7.2)
Using bundler (1.3.5)
Your bundle is complete!
Use `bundle show [gemname]` to see where a bundled gem is installed.
I also tried executing the .rb file directly, and it fails too.
Even more info:
dani@devel1-datatrends:~/app/didit-cli-client$ ll
total 36
drwxrwxr-x 3 dani dani 4096 abr 20 13:55 ./
drwxrwxr-x 4 dani dani 4096 abr 20 13:55 ../
-rwxrwxr-x 1 dani dani 5328 abr 20 13:55 didit.rb*
-rw-rw-r-- 1 dani dani 46 abr 20 13:55 Gemfile
-rw-rw-r-- 1 dani dani 109 abr 20 13:55 Gemfile.lock
drwxrwxr-x 8 dani dani 4096 abr 20 13:55 .git/
-rw-rw-r-- 1 dani dani 1076 abr 20 13:55 LICENSE
-rw-rw-r-- 1 dani dani 1036 abr 20 13:55 README.md
dani@devel1-datatrends:~/app/didit-cli-client$ bundle show highline
/var/lib/gems/1.9.1/gems/highline-1.7.2
dani@devel1-datatrends:~/app/didit-cli-client$ ./didit.rb
/usr/lib/ruby/1.9.1/net/http.rb:1861:in `initialize': undefined method `empty?' for #<URI::HTTPS:0x000000022768f0> (NoMethodError)
from /usr/lib/ruby/1.9.1/net/http.rb:2094:in `initialize'
from ./didit.rb:90:in `new'
from ./didit.rb:90:in `discover_urls'
from ./didit.rb:156:in `<main>'
dani@devel1-datatrends:~/app/didit-cli-client$
Thanks for the report @DaniGuardiola! It seems this is a change in how Net::HTTP::Get.new takes arguments starting in Ruby 2: https://bugs.ruby-lang.org/issues/7973
Can you find a way to get this to work that is compatible with both Ruby version? For now, I'll edit the README to mention that Ruby 2.0.0 or later is required.
Just stumbled across this issue and since it hasn't been closed, thought I'd offer a suggestion - for Ruby 1.9.3 at least. I was encountering the same issue with some code of mine and after referring to the documentation here found that I needed to be more specific. To explain, I refer you to lines 56, 90 and 109 of didit.rb which each read:
req = Net::HTTP::Get.new(url)
Simply specifying the request_uri
attribute of the url
as the variable data to pass to Net::HTTP::Get.new
resolved this issue for me:
req = Net::HTTP::Get.new(url.request_uri)
NOTE: not tested in 2.0+ but can happily confirm it works for 1.9.3.