Socket
Book a DemoInstallSign in
Socket

roverjoe

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

roverjoe

0.0.10
bundlerRubygems
Version published
Maintainers
1
Created
Source

RoverJoe

RoverJoe

RoverJoe: A ruby gem that wraps the HostelWorld API, providing:

  • Recovery from network issuses like timeout and connection reset by peer.
  • Recovery from quota exceeded conditions
  • Request and Response objects
  • Objects for RemoteProperty (work-in-progress) ...

Installation

Assuming bundler, edit Gemfile to include

gem 'roverjoe', '>=0.0.7', git: 'git@github.com:lonelyplanet/roverjoe.git'

Use

Configuration by file

Include in your initialization

RoverJoe.configure_from_file

Then create config/hostelworld_api.yml something like this.

params: 
  format: 'json'
  consumer_key: 'lonelyplanet.com'
  consumer_signature: 'somethingverysecret'
  Language: 'English'
uri: 'https://affiliate.xsapi.webresint.com/1.1/'

Only consumer_key and consumer_signature are required, the rest have defaults.

Hardcoded configuration

RoverJoe.configure do |c|
  c.consumer_key = 'lonelyplanet.com'
  c.consumer_signature = 'asecretsignature'
  c.logger = MyApp.logger
end

The default logger does nothing, override if you want to see log output.

Logging quota delay stats

Use the after_delay callback to capture the stats however you want.

RoverJoe.configure do |c|
  c.after_delay { |delay|  Stats.capture( "the delay was #{delay}" }
end

Calling the API - RemoteProperty

rp = RoverJoe::RemoteProperty( :id => hostel_number )
star_rating = rp.star_rating      # this triggers API call

or

hw_property = RoverJoe::RemoteProperty( :id => hostel_number ).response 
lp_property.name = hw_property['PropertyName']

Calling the API - Request

req = RoverJoe::Request.new( :propertyInformation, :propertyNumber => hostel_number ) 
result = req.execute    

Result is a hash of all the attributes of the property

Calling the API - Availability/Location search example

a = RoverJoe::Request.new( :propertylocationsearch,  
                           :City => 'Athens',
                           :DateStart => (Date.today+21).iso8601, 
                           :NumNights => 7
                         ).execute

Development

$ git clone git@github.com:lonelyplanet/roverjoe.git
$ cd roverjoe

RVM

$ cp .rvmrc.example .rvmrc
$ source .rvmrc
$ bundle install

Specs

$ rake                            # all tests
$ rspec                           # all tests
$ bundle exec guard               # all tests

$ rspec spec/lib                  # unit tests
$ rspec spec/integration          # integration tests

FAQs

Package last updated on 21 Aug 2012

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.