fcoury / octopi

A Ruby interface to GitHub API v2
http://hasmany.info/2009/4/18/ruby-interface-to-github-api
MIT License
216 stars 47 forks source link

undefined method ‘code’ for #<String:0x118ab90> #27

Closed beamercola closed 15 years ago

beamercola commented 15 years ago

Hey there, so I'm trying to get set up with this - and I keep getting the same error whenever I try anything

authenticated_with "BeamerCola", "[api_token]" do |g|
  puts g.repository("test")
end

Any method I call that hits the Api::get method keeps returning:

raise RetryableAPIError, resp.code.to_i if RETRYABLE_STATUS.include? resp.code.to_i

Am I missing something? It's driving me nuts. It doesn't work when doing non-authentication either.

user = User.find("fcoury")

Gives me the same error.

When I curl myself - everything works great - so I'm not seeing an issue with my API token or anything

fcoury commented 15 years ago

I will take a look at this tomorrow and let you know. I have recently pulled some code from other folks, so that can be the cause. Are you using the gem or using it from source? If gem, what is the version? Thanks!

fcoury commented 15 years ago

I just tested it with my token and it works just fine. Here's the code I used:

include Octopi

puts User.find("fcoury").inspect

authenticated_with "fcoury", "token-here" do |g| puts g.repository("octopi").inspect end

And here's the output:

#<Octopi::User:0x12eedc4 @location="Campinas, SP, Brazil", 
  @blog="http://felipecoury.com", 
  @keys=["company", "name", "following_count", "blog", 
  "public_repo_count", "public_gist_count", "id", "login", 
  "followers_count", "created_at", "email", "location"], 
  @followers_count=5, @company="FelipeCoury.com", 
  @api=#<Octopi::Api:0x39bffc>, @login="fcoury", 
  @id=1371, @email="felipe.coury@gmail.com", 
  @public_repo_count=30, @created_at=Wed Feb 27 22:03:42 -0300 2008, 
  @following_count=12, @name="Felipe Coury", @public_gist_count=10>
#<Octopi::Repository:0x12da6e4 
  @keys=[:homepage, :owner, :forks, :name, :url, :private, 
  :watchers, :fork, :description], @private=false, 
  @api=#<Octopi::Api:0x12ed528 @token="f1cd3eb17a20835f054ac1da8beb709b", 
  @login="fcoury", @read_only=false, @format="yaml">, 
  @url="http://github.com/fcoury/octopi", 
  @fork=false, @forks=5, 
  @homepage="http://hasmany.info/2009/4/18/ruby-interface-to-github-api", 
  @name="octopi", @watchers=55, 
  @description="A Ruby interface to GitHub API v2", @owner="fcoury">

I tried the code both with the latest source and latest gem (0.0.9) and both worked the same, and as expected.

Not sure what can be your problem!

beamercola commented 15 years ago

Wow, so strange! I'm using the gem "fcoury-octopi (0.0.9)"

My second shot at a test:

require "rubygems"
require "octopi"
include Octopi
puts User.find("fcoury").inspect
# NoMethodError: undefined method ‘code’ for #<String:0x118a320>

Like I said, the error is still hitting on

      raise RetryableAPIError, resp.code.to_i if RETRYABLE_STATUS.include? resp.code.to_i
fcoury commented 15 years ago

Here's how it works for me: http://screencast.com/t/uQhSRksbB4B

However, something just occurred: what's the version of httparty gem you're using?

Here's mine:

[fcoury@macbook 16:14]:~$ gem list httparty
*** LOCAL GEMS ***
httparty (0.4.2)

If you have the very same version, could you try to clone the git repo locally, and add a line just above that with

puts "Response: #{resp}"

To see if we can try to understand what's happening?

Sorry this is being such a pain for you, really.

Best regards,

-- Felipe

beamercola commented 15 years ago

ooaahahahaha httparty was out of date. Way to spot those raccoons.

Thanks!!

fcoury commented 15 years ago

Awesome man, I am happy now :-)

Closing the issue. Hope you enjoy octopi...

merbjedi commented 14 years ago

Seems like it might be a good idea to add httparty 0.4.4 to the gem dependencies