I found an Amazon Gem that I want to use https://github.com/hakanensari/vacuum/.
I've only ever used gems with in depth tutorials or following a RailsCast. I'm looking for tips on using gems I find online. I'll explain the steps I'm doing, and hopefully someone can give me some ideas on what else I should be doing when using a new gem. Also, if you have a good tutorial or explanation on gems, that would be great too.
I started off examining the Gem on Github, I'll point out the things I took notice of. Let me know if there are things I'm missing I should notice.
Examining Gem on Github
- Go to the examples and look at "examples/product_advertising/basic_lookup.rb"
- Follow the required file, and checkout "examples/product_advertising/shared.rb"
- Notice, I need to install "pry"
- Notice, the examples expand on the "lib" folder
- Check out "credentials.yml"
- Notice a "@req" is instantiated as a new Vacuum object.
- Then back in basic_lookup.rb, it looks like it's assigning the lookup value, then binding the response to some kind of "pry" view.
Next, I'll try implementing these examples in my own project. Here's where I'm not sure what to do as far, as files are concerned.
Attempt Implementing Example
Install vacuum gem
gem install vacuum
Install pry gem
gem install pry
- Added "shared.rb" and "credentials.yml" to my "app/controllers" directory
- Replaced the information in "credentials.yml" with my information
Attempt to copy the information from "basic_lookup.rb" into an existing controller
def amazon require File.expand_path('../shared.rb', __FILE__) res = @req.look_up '0816614024' items = res.find 'Item' binding.pry end
Create a route
match '/test' => 'products#amazon'
Go to test page and receive the following error
undefined method 'look_up' for nil:NilClass
I would like to point out, at this point I haven't added the lib folder.
Questions
- I like the credentials.yml is separated out, when I want to add this to my project, where should I save that file?
- I like the shared.rb file, should I just put that in the controller folder?
- Why is it referencing the "lib" folder in "shared.rb"? Do I need to copy that directory into my project?
I appreciate you sticking around and reading all of this. I'm still trying to get a handle on using a gems, so any help or tips are great. Really, I'm just trying to figure out, how do I find any gem and start using it appropriately.
Thanks for any help you can give me!