limores_hopstop 0.2.0 → 0.2.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.
- data/lib/app_id.rb +1 -1
- data/lib/hopstop.rb +12 -1
- data/spec/hopstop_spec.rb +9 -0
- metadata +2 -2
data/lib/app_id.rb
CHANGED
data/lib/hopstop.rb
CHANGED
|
@@ -5,6 +5,14 @@ require File.expand_path(File.dirname(__FILE__) + '/app_id')
|
|
|
5
5
|
module Limores
|
|
6
6
|
module Mashups
|
|
7
7
|
module Hopstop
|
|
8
|
+
def self.log(string)
|
|
9
|
+
begin
|
|
10
|
+
@@dont_log ? puts( string ) : RAILS_DEFAULT_LOGGER.debug(string)
|
|
11
|
+
rescue
|
|
12
|
+
@@dont_log=true
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
|
|
8
16
|
def self.populate_with_response_status(result, doc)
|
|
9
17
|
result.result_code =
|
|
10
18
|
(doc.root.elements["//ResponseStatus/ResultCode"] || doc.root.elements["//ResponseStatus/FaultCode"]).text.to_i
|
|
@@ -48,6 +56,7 @@ module Limores
|
|
|
48
56
|
|
|
49
57
|
def self.fetch_cities
|
|
50
58
|
url = "http://www.hopstop.com/ws/GetCities?licenseKey=#{Limores::Mashups::Hopstop::APP_ID}"
|
|
59
|
+
Hopstop.log("HOPSTOP GET: #{url}")
|
|
51
60
|
|
|
52
61
|
begin
|
|
53
62
|
xml = open(URI.encode(url)).read
|
|
@@ -56,6 +65,7 @@ module Limores
|
|
|
56
65
|
rescue
|
|
57
66
|
raise ConnectionException.new("Unable to connect to HopStop REST service")
|
|
58
67
|
end
|
|
68
|
+
Hopstop.log("HOPSTOP RESPONSE: #{xml}")
|
|
59
69
|
xml
|
|
60
70
|
end
|
|
61
71
|
end
|
|
@@ -151,7 +161,7 @@ module Limores
|
|
|
151
161
|
params.each do |param, value|
|
|
152
162
|
url += "&#{param.to_s}=#{value}"
|
|
153
163
|
end
|
|
154
|
-
|
|
164
|
+
Hopstop.log("HOPSTOP GET: #{url}")
|
|
155
165
|
begin
|
|
156
166
|
xml = open(URI.encode(url)).read
|
|
157
167
|
rescue OpenURI::HTTPError => error
|
|
@@ -159,6 +169,7 @@ module Limores
|
|
|
159
169
|
rescue
|
|
160
170
|
raise ConnectionException.new("Unable to connect to HopStop REST service")
|
|
161
171
|
end
|
|
172
|
+
Hopstop.log("HOPSTOP RESPONSE: #{xml}")
|
|
162
173
|
xml
|
|
163
174
|
end
|
|
164
175
|
|
data/spec/hopstop_spec.rb
CHANGED
|
@@ -70,6 +70,15 @@ describe Route do
|
|
|
70
70
|
route.should be_valid
|
|
71
71
|
end
|
|
72
72
|
|
|
73
|
+
it "should be valid if address is full name of airport" do
|
|
74
|
+
|
|
75
|
+
route = Route.find :address1 => 'General Edward Lawrence Logan International Airport, Boston, MA 02128, USA',
|
|
76
|
+
:address2 => '940 2ND ave, Manhattan',
|
|
77
|
+
:day => 1, :time => '09:30'
|
|
78
|
+
|
|
79
|
+
route.should be_valid
|
|
80
|
+
end
|
|
81
|
+
|
|
73
82
|
it "should be invalid / multi-choice for valid but multi choice request" do
|
|
74
83
|
|
|
75
84
|
route = Route.find :address1 => 'jfk', :address2 => '2nd Ave', :day => 1, :time => '09:30'
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: limores_hopstop
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.2.
|
|
4
|
+
version: 0.2.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Milan Burmaja
|
|
@@ -9,7 +9,7 @@ autorequire:
|
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
11
|
|
|
12
|
-
date: 2009-
|
|
12
|
+
date: 2009-12-03 00:00:00 +01:00
|
|
13
13
|
default_executable:
|
|
14
14
|
dependencies: []
|
|
15
15
|
|