Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rest-core [3.0.0] and Ruby 2.4.0. Not able to build client #23

Open
VivekTamtaFluke opened this issue May 11, 2017 · 5 comments
Open

rest-core [3.0.0] and Ruby 2.4.0. Not able to build client #23

VivekTamtaFluke opened this issue May 11, 2017 · 5 comments
Labels

Comments

@VivekTamtaFluke
Copy link

VivekTamtaFluke commented May 11, 2017

While working on Ruby 2.4.0 and using rest-core 3.0.0 I am not able to build client as per the document goes.

=> YourClient 
2.4.0 :008 > YourClient.new
=> #<struct YourClient site=nil, json_response=nil, log_method=nil, cache=nil, expires_in=nil>

Getting response as above

Please guide me on how to resolve this.
Thanks in advance.

@godfat
Copy link
Owner

godfat commented May 11, 2017

Sorry, I am not exactly sure what's the issue you're seeing? Could you describe it? I don't see any errors in your post, and I just tried it and it worked fine.

@godfat godfat added the help label May 11, 2017
@VivekTamtaFluke
Copy link
Author

VivekTamtaFluke commented May 12, 2017

Thanks for looking into it.
Earlier I meant I am getting response as NIL for the mentioned

require 'rest-core'
 YourClient = RC::Builder.client do
 use RC::DefaultSite , 'https://api.github.com/users/'
 use RC::JsonResponse, true
 use RC::CommonLogger, method(:puts)
 use RC::Cache       , nil, 3600 # :expires_in if cache store supports
end

Well this is what I am doing

m-bang-vtamta:sw-web vivek$ irb
2.4.0 :001 > require 'rest-core'
 => true 
2.4.0 :002 > YourClient = RC::Builder.client do
2.4.0 :003 >       use RC::DefaultSite , 'https://api.github.com/users/'
2.4.0 :004?>     use RC::JsonResponse, true
2.4.0 :005?>     use RC::CommonLogger, method(:puts)
2.4.0 :006?>     use RC::Cache       , nil, 3600 # :expires_in if cache store supports
2.4.0 :007?>   end
/Users/vivek/.rvm/gems/ruby-2.4.0/gems/rest-core-3.2.0/lib/rest-core/client.rb:158: warning: circular argument reference - app
/Users/vivek/.rvm/gems/ruby-2.4.0/gems/rest-core-3.2.0/lib/rest-core/client.rb:166: warning: circular argument reference - app
/Users/vivek/.rvm/gems/ruby-2.4.0/gems/rest-core-3.2.0/lib/rest-core/middleware.rb:52: warning: circular argument reference - app
/Users/vivek/.rvm/gems/ruby-2.4.0/gems/rest-core-3.2.0/lib/rest-core/client.rb:49: warning: circular argument reference - app
/Users/vivek/.rvm/gems/ruby-2.4.0/gems/rest-core-3.2.0/lib/rest-core/client.rb:73: warning: circular argument reference - app
/Users/vivek/.rvm/gems/ruby-2.4.0/gems/rest-core-3.2.0/lib/rest-core/client.rb:97: warning: circular argument reference - app
/Users/vivek/.rvm/gems/ruby-2.4.0/gems/rest-core-3.2.0/lib/rest-core/client.rb:121: warning: circular argument reference - app
/Users/vivek/.rvm/gems/ruby-2.4.0/gems/rest-core-3.2.0/lib/rest-core/client.rb:145: warning: circular argument reference - app
 => YourClient 
2.4.0 :008 > YourClient.new
 => #<struct YourClient site=nil, json_response=nil, log_method=nil, cache=nil, expires_in=nil> 
2.4.0 :009 > 

Please let me know if anything you want to know more. And thanks again for you time.

@godfat
Copy link
Owner

godfat commented May 12, 2017

@VivekTamtaFluke Sorry that I edited your post to fix the format, otherwise it's very hard to read it.

First that you're using an very old version, so please upgrade to 4.0.0.

And I am still not sure why you're saying that you got nil for the response. In the code you posted, it's not making any requests, it's only making a client, which could be used to make a request.

In your case, you might want to:

client = YourClient.new
client.get('VivekTamtaFluke')

So then you're making a request to https://api.github.com/users/VivekTamtaFluke, which should give you the response.

Please try it and let me know if you have other questions.

@VivekTamtaFluke
Copy link
Author

@godfat Thanks for editing the post.

Yes I am using old version. Since in the later versions the middleware and wrapper layer is combined and we have a legacy code which I am currently not authorised to change.
And yes we do have to update at sometime.

Meanwhile what I am trying here is to get the same output which I get when I run this with Ruby 2.0.0. and rest-core 2.1.2

require 'rest-core'
 YourClient = RC::Builder.client do
 use RC::DefaultSite , 'https://api.github.com/users/VivekTamtaFluke'
 use RC::JsonResponse, true
 use RC::CommonLogger, method(:puts)
 use RC::Cache       , nil, 3600 # :expires_in if cache store supports
end

and getting this

m-bang-vtamta:sw-web vivek$ irb
2.0.0-p247 :001 > require 'rest-core'
 => true 
2.0.0-p247 :002 >  YourClient = RC::Builder.client do
2.0.0-p247 :003 >      use RC::DefaultSite , 'https://api.github.com/users/VivekTamtaFluke'
2.0.0-p247 :004?>    use RC::JsonResponse, true
2.0.0-p247 :005?>    use RC::CommonLogger, method(:puts)
2.0.0-p247 :006?>    use RC::Cache       , nil, 3600 # :expires_in if cache store supports
2.0.0-p247 :007?>   end
 => YourClient 
2.0.0-p247 :008 > YourClient.new
 => #<struct YourClient site="https://api..., json_response=true, log_method=#<Method: Re..., cache=nil, expires_in=3600> 
2.0.0-p247 :009 > 

You can see here I am getting something in response, which is not the case with Ruby 2.4.0 and rest-core 3.0.0

Can you help me to understand what wrong I am doing here.

@godfat
Copy link
Owner

godfat commented May 12, 2017

@VivekTamtaFluke ok, we could forget about upgrading for now, but if you're going to use Ruby 2.4.0, I am not very sure if that would work, because the warnings you're seeing.

I still don't understand what's the response you're talking about? You didn't make any requests in the code you posted, so of course you're not getting any response. This should be the same across any of the versions.

Like I said before, you would want to make a request like this:

client.get('VivekTamtaFluke')

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants