suitcase 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,3 @@
1
+ module Suitcase
2
+ COUNTRY_CODES = {"AF"=>"Afghanistan", "AX"=>"Aland Islands", "AL"=>"Albania", "DZ"=>"Algeria", "AS"=>"American Samoa", "AD"=>"Andorra", "AO"=>"Angola", "AI"=>"Anguilla", "AQ"=>"Antarctica", "AG"=>"Antigua and Barbuda", "AR"=>"Argentina", "AM"=>"Armenia", "AW"=>"Aruba", "AC"=>"Ascension Island", "AU"=>"Australia", "AT"=>"Austria", "AZ"=>"Azerbaijan", "BS"=>"Bahamas", "BH"=>"Bahrain", "BB"=>"Barbados", "BD"=>"Bangladesh", "BY"=>"Belarus", "BE"=>"Belgium", "BZ"=>"Belize", "BJ"=>"Benin", "BM"=>"Bermuda", "BT"=>"Bhutan", "BW"=>"Botswana", "BO"=>"Bolivia", "BA"=>"Bosnia and Herzegovina", "BV"=>"Bouvet Island", "BR"=>"Brazil", "IO"=>"British Indian Ocean Territory", "BN"=>"Brunei Darussalam", "BG"=>"Bulgaria", "BF"=>"Burkina Faso", "BI"=>"Burundi", "KH"=>"Cambodia", "CM"=>"Cameroon", "CA"=>"Canada", "CV"=>"Cape Verde", "KY"=>"Cayman Islands", "CF"=>"Central African Republic", "TD"=>"Chad", "CL"=>"Chile", "CN"=>"China", "CX"=>"Christmas Island", "CC"=>"Cocos (Keeling) Islands", "CO"=>"Colombia", "KM"=>"Comoros", "CG"=>"Congo", "CD"=>"Congo, Democratic Republic", "CK"=>"Cook Islands", "CR"=>"Costa Rica", "CI"=>"Cote D'Ivoire (Ivory Coast)", "HR"=>"Croatia (Hrvatska)", "CU"=>"Cuba", "CY"=>"Cyprus", "CZ"=>"Czech Republic", "CS"=>"Czechoslovakia (former)", "DK"=>"Denmark", "DJ"=>"Djibouti", "DM"=>"Dominica", "DO"=>"Dominican Republic", "TP"=>"East Timor", "EC"=>"Ecuador", "EG"=>"Egypt", "SV"=>"El Salvador", "GQ"=>"Equatorial Guinea", "ER"=>"Eritrea", "EE"=>"Estonia", "ET"=>"Ethiopia", "EU"=>"European Union", "FK"=>"Falkland Islands (Malvinas)", "FO"=>"Faroe Islands", "FJ"=>"Fiji", "FI"=>"Finland", "FR"=>"France", "FX"=>"France, Metropolitan", "GF"=>"French Guiana", "PF"=>"French Polynesia", "TF"=>"French Southern Territories", "MK"=>"F.Y.R.O.M. (Macedonia)", "GA"=>"Gabon", "GM"=>"Gambia", "GE"=>"Georgia", "DE"=>"Germany", "GH"=>"Ghana", "GI"=>"Gibraltar", "GB"=>"Great Britain (UK)", "GR"=>"Greece", "GL"=>"Greenland", "GD"=>"Grenada", "GP"=>"Guadeloupe", "GU"=>"Guam", "GT"=>"Guatemala", "GG"=>"Guernsey", "GN"=>"Guinea", "GW"=>"Guinea-Bissau", "GY"=>"Guyana", "HT"=>"Haiti", "HM"=>"Heard and McDonald Islands", "HN"=>"Honduras", "HK"=>"Hong Kong", "HU"=>"Hungary", "IS"=>"Iceland", "IN"=>"India", "ID"=>"Indonesia", "IR"=>"Iran", "IQ"=>"Iraq", "IE"=>"Ireland", "IL"=>"Israel", "IM"=>"Isle of Man", "IT"=>"Italy", "JE"=>"Jersey", "JM"=>"Jamaica", "JP"=>"Japan", "JO"=>"Jordan", "KZ"=>"Kazakhstan", "KE"=>"Kenya", "KI"=>"Kiribati", "KP"=>"Korea (North)", "KR"=>"Korea (South)", "XK"=>"Kosovo*", "KW"=>"Kuwait", "KG"=>"Kyrgyzstan", "LA"=>"Laos", "LV"=>"Latvia", "LB"=>"Lebanon", "LI"=>"Liechtenstein", "LR"=>"Liberia", "LY"=>"Libya", "LS"=>"Lesotho", "LT"=>"Lithuania", "LU"=>"Luxembourg", "MO"=>"Macau", "MG"=>"Madagascar", "MW"=>"Malawi", "MY"=>"Malaysia", "MV"=>"Maldives", "ML"=>"Mali", "MT"=>"Malta", "MH"=>"Marshall Islands", "MQ"=>"Martinique", "MR"=>"Mauritania", "MU"=>"Mauritius", "YT"=>"Mayotte", "MX"=>"Mexico", "FM"=>"Micronesia", "MC"=>"Monaco", "MD"=>"Moldova", "MN"=>"Mongolia", "ME"=>"Montenegro", "MS"=>"Montserrat", "MA"=>"Morocco", "MZ"=>"Mozambique", "MM"=>"Myanmar", "NA"=>"Namibia", "NR"=>"Nauru", "NP"=>"Nepal", "NL"=>"Netherlands", "AN"=>"Netherlands Antilles", "NT"=>"Neutral Zone", "NC"=>"New Caledonia", "NZ"=>"New Zealand (Aotearoa)", "NI"=>"Nicaragua", "NE"=>"Niger", "NG"=>"Nigeria", "NU"=>"Niue", "NF"=>"Norfolk Island", "MP"=>"Northern Mariana Islands", "NO"=>"Norway", "OM"=>"Oman", "PK"=>"Pakistan", "PW"=>"Palau", "PS"=>"Palestinian Territory, Occupied", "PA"=>"Panama", "PG"=>"Papua New Guinea", "PY"=>"Paraguay", "PE"=>"Peru", "PH"=>"Philippines", "PN"=>"Pitcairn", "PL"=>"Poland", "PT"=>"Portugal", "PR"=>"Puerto Rico", "QA"=>"Qatar", "RE"=>"Reunion", "RO"=>"Romania", "RU"=>"Russian Federation", "RW"=>"Rwanda", "GS"=>"S. Georgia and S. Sandwich Isls.", "SH"=>"Saint Helena", "KN"=>"Saint Kitts and Nevis", "LC"=>"Saint Lucia", "MF"=>"Saint Martin", "VC"=>"Saint Vincent & the Grenadines", "WS"=>"Samoa", "SM"=>"San Marino", "ST"=>"Sao Tome and Principe", "SA"=>"Saudi Arabia", "SN"=>"Senegal", "RS"=>"Serbia", "YU"=>"Serbia and Montenegro (former)", "SC"=>"Seychelles", "SL"=>"Sierra Leone", "SG"=>"Singapore", "SI"=>"Slovenia", "SK"=>"Slovak Republic", "SB"=>"Solomon Islands", "SO"=>"Somalia", "ZA"=>"South Africa", "SS"=>"South Sudan", "ES"=>"Spain", "LK"=>"Sri Lanka", "SD"=>"Sudan", "SR"=>"Suriname", "SJ"=>"Svalbard & Jan Mayen Islands", "SZ"=>"Swaziland", "SE"=>"Sweden", "CH"=>"Switzerland", "SY"=>"Syria", "TW"=>"Taiwan", "TJ"=>"Tajikistan", "TZ"=>"Tanzania", "TH"=>"Thailand", "TG"=>"Togo", "TK"=>"Tokelau", "TO"=>"Tonga", "TT"=>"Trinidad and Tobago", "TN"=>"Tunisia", "TR"=>"Turkey", "TM"=>"Turkmenistan", "TC"=>"Turks and Caicos Islands", "TV"=>"Tuvalu", "UG"=>"Uganda", "UA"=>"Ukraine", "AE"=>"United Arab Emirates", "UK"=>"United Kingdom", "US"=>"United States", "UM"=>"US Minor Outlying Islands", "UY"=>"Uruguay", "SU"=>"USSR (former)", "UZ"=>"Uzbekistan", "VU"=>"Vanuatu", "VA"=>"Vatican City State (Holy See)", "VE"=>"Venezuela", "VN"=>"Viet Nam", "VG"=>"British Virgin Islands", "VI"=>"Virgin Islands (U.S.)", "WF"=>"Wallis and Futuna Islands", "EH"=>"Western Sahara", "YE"=>"Yemen", "ZM"=>"Zambia", "ZW"=>"Zimbabwe"}
3
+ end
@@ -0,0 +1,49 @@
1
+ require 'net/http'
2
+ require 'uri'
3
+ require 'json'
4
+ require File.dirname(__FILE__) + '/../country_codes'
5
+
6
+ module Suitcase
7
+ class Hotel
8
+ attr_accessor :id, :name, :address, :city, :postal_code, :country, :airport_code, :rating, :confidence_rating, :description, :high_rate, :low_rate, :tripadvisor_rating, :currency_code, :latitude, :longitude
9
+
10
+ def self.find(hash)
11
+ hotels = []
12
+ json = JSON.parse Net::HTTP.get_response(URI.parse(URI.escape("http://api.ean.com/ean-services/rs/hotel/v3/list?apiKey=#{Suitcase::Hotel::API_KEY}&city=#{hash[:near]}&numberOfResults=#{hash[:results]}"))).body
13
+ if json["HotelListResponse"]["HotelList"]
14
+ json["HotelListResponse"]["HotelList"]["HotelSummary"].each do |hotel_data|
15
+ h = Hotel.new
16
+ h.id = hotel_data["hotelId"]
17
+ h.name = hotel_data["name"]
18
+ h.address = hotel_data["address1"]
19
+ h.city = hotel_data["city"]
20
+ h.postal_code = hotel_data["postalCode"]
21
+ h.country = COUNTRY_CODES[hotel_data["countryCode"]]
22
+ h.airport_code = hotel_data["airportCode"]
23
+ h.rating = hotel_data["hotelRating"]
24
+ h.confidence_rating = hotel_data["confidenceRating"]
25
+ h.tripadvisor_rating = hotel_data["tripAdvisorRating"]
26
+ h.currency_code = hotel_data["rateCurrencyCode"]
27
+ h.latitude = hotel_data["latitude"]
28
+ h.longitude = hotel_data["longitude"]
29
+ h.high_rate = hotel_data["highRate"]
30
+ h.low_rate = hotel_data["lowRate"]
31
+ hotels.push(h)
32
+ end
33
+ hotels[0..hash[:results]-1]
34
+ else
35
+ if json["HotelListResponse"]["EanWsError"]
36
+ raise "An error occured. Check data."
37
+ end
38
+ end
39
+ end
40
+
41
+ def geolocation
42
+ latitude + ", " + longitude
43
+ end
44
+
45
+ def complete_address
46
+ address + " " + city + ", " + country + " " + postal_code
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,3 @@
1
+ module Suitcase
2
+ VERSION = "1.0.1"
3
+ end
data/lib/suitcase.rb ADDED
@@ -0,0 +1,7 @@
1
+ require 'suitcase/version'
2
+ require 'suitcase/hotel/hotel'
3
+ require 'suitcase/air/air'
4
+
5
+ module Suitcase
6
+
7
+ end
@@ -0,0 +1,23 @@
1
+ require 'spec_helper'
2
+
3
+ include Suitcase
4
+
5
+ describe Hotel do
6
+ before(:each) do
7
+ @attr = { :near => "Boston", :results => 50 }
8
+ end
9
+
10
+ describe "find method" do
11
+ it "should return the correct number of results" do
12
+ Hotel.find(@attr).count.should eq(50)
13
+ end
14
+
15
+ it "should return an array of hotels" do
16
+ Hotel.find(@attr).class.should eq(Array)
17
+ end
18
+
19
+ it "should return all hotels" do
20
+ Hotel.find(@attr).map { |x| x.class }.should eq([Hotel] * 50)
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,4 @@
1
+ require File.dirname(__FILE__) + '/../lib/suitcase'
2
+ require 'api_key'
3
+
4
+ Suitcase::Hotel::API_KEY = HOTEL_API_KEY
data/suitcase.gemspec ADDED
@@ -0,0 +1,24 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "suitcase/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "suitcase"
7
+ s.version = Suitcase::VERSION
8
+ s.authors = ["Walter Nelson"]
9
+ s.email = ["walter.john.nelson@gmail.com"]
10
+ s.homepage = "http://github.com/thoughtfusion/suitcase"
11
+ s.summary = %q{Locates available hotels, rental cars, and flights}
12
+ s.description = %q{Suitcase utilizes the EAN API for locating available hotels, rental cars, and flights.}
13
+
14
+ s.rubyforge_project = "suitcase"
15
+
16
+ s.files = `git ls-files`.split("\n")
17
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
18
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
19
+ s.require_paths = ["lib"]
20
+
21
+ s.add_development_dependency "rspec"
22
+ s.add_runtime_dependency "json"
23
+ s.add_runtime_dependency "nokogiri"
24
+ end
metadata ADDED
@@ -0,0 +1,92 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: suitcase
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Walter Nelson
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2011-11-05 00:00:00.000000000Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rspec
16
+ requirement: &11887140 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: *11887140
25
+ - !ruby/object:Gem::Dependency
26
+ name: json
27
+ requirement: &11886720 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: *11886720
36
+ - !ruby/object:Gem::Dependency
37
+ name: nokogiri
38
+ requirement: &11886300 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
44
+ type: :runtime
45
+ prerelease: false
46
+ version_requirements: *11886300
47
+ description: Suitcase utilizes the EAN API for locating available hotels, rental cars,
48
+ and flights.
49
+ email:
50
+ - walter.john.nelson@gmail.com
51
+ executables: []
52
+ extensions: []
53
+ extra_rdoc_files: []
54
+ files:
55
+ - .gitignore
56
+ - Gemfile
57
+ - README.md
58
+ - Rakefile
59
+ - lib/suitcase.rb
60
+ - lib/suitcase/air/air.rb
61
+ - lib/suitcase/airport_codes.rb
62
+ - lib/suitcase/country_codes.rb
63
+ - lib/suitcase/hotel/hotel.rb
64
+ - lib/suitcase/version.rb
65
+ - spec/hotel_spec.rb
66
+ - spec/spec_helper.rb
67
+ - suitcase.gemspec
68
+ homepage: http://github.com/thoughtfusion/suitcase
69
+ licenses: []
70
+ post_install_message:
71
+ rdoc_options: []
72
+ require_paths:
73
+ - lib
74
+ required_ruby_version: !ruby/object:Gem::Requirement
75
+ none: false
76
+ requirements:
77
+ - - ! '>='
78
+ - !ruby/object:Gem::Version
79
+ version: '0'
80
+ required_rubygems_version: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ! '>='
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
86
+ requirements: []
87
+ rubyforge_project: suitcase
88
+ rubygems_version: 1.8.6
89
+ signing_key:
90
+ specification_version: 3
91
+ summary: Locates available hotels, rental cars, and flights
92
+ test_files: []