Active 0.0.9 → 0.0.11

Sign up to get free protection for your applications and to get access to all the features.
data/.bnsignore ADDED
@@ -0,0 +1,19 @@
1
+ # The list of files that should be ignored by Mr Bones.
2
+ # Lines that start with '#' are comments.
3
+ #
4
+ # A .gitignore file can be used instead by setting it as the ignore
5
+ # file in your Rakefile:
6
+ #
7
+ # Bones {
8
+ # ignore_file '.gitignore'
9
+ # }
10
+ #
11
+ # For a project with a C extension, the following would be a good set of
12
+ # exclude patterns (uncomment them if you want to use them):
13
+ # *.[oa]
14
+ # *~
15
+ announcement.txt
16
+ coverage
17
+ doc
18
+ pkg
19
+ .DS_Store
data/bin/Active CHANGED
File without changes
data/lib/services/ats.rb CHANGED
@@ -68,7 +68,7 @@ module Active
68
68
 
69
69
  def start_date
70
70
  load_metadata unless @metadata_loaded
71
- if @data.has_key? ("startDate")
71
+ if @data.has_key?("startDate")
72
72
  (DateTime.parse @data["startDate"]).to_date
73
73
  else
74
74
  nil
@@ -87,7 +87,7 @@ module Active
87
87
 
88
88
  def end_date
89
89
  load_metadata unless @metadata_loaded
90
- DateTime.parse @data["endDate"] if @data.has_key? ("endDate")
90
+ DateTime.parse @data["endDate"] if @data.has_key?("endDate")
91
91
  end
92
92
 
93
93
  def category
@@ -97,9 +97,9 @@ module Active
97
97
 
98
98
  def desc
99
99
  load_metadata unless @metadata_loaded
100
- if @data.has_key? ("allText")
100
+ if @data.has_key?("allText")
101
101
  @data["allText"]
102
- elsif @data.has_key? ("summary")
102
+ elsif @data.has_key?("summary")
103
103
  @data["summary"]
104
104
  end
105
105
  end
@@ -114,7 +114,7 @@ module Active
114
114
 
115
115
  def start_date
116
116
  load_metadata unless @metadata_loaded
117
- DateTime.parse @data["startDate"] if @data.has_key? ("startDate")
117
+ DateTime.parse @data["startDate"] if @data.has_key?("startDate")
118
118
  end
119
119
 
120
120
  def start_time
@@ -129,7 +129,7 @@ module Active
129
129
 
130
130
  def end_date
131
131
  load_metadata unless @metadata_loaded
132
- DateTime.parse @data["endDate"] if @data.has_key? ("endDate")
132
+ DateTime.parse @data["endDate"] if @data.has_key?("endDate")
133
133
  end
134
134
 
135
135
  def category
@@ -148,9 +148,9 @@ module Active
148
148
  ret
149
149
  else
150
150
  load_metadata unless @metadata_loaded
151
- if @data.has_key? ("allText")
151
+ if @data.has_key?("allText")
152
152
  @data["allText"]
153
- elsif @data.has_key? ("summary")
153
+ elsif @data.has_key?("summary")
154
154
  @data["summary"]
155
155
  end
156
156
  end
@@ -29,7 +29,7 @@ module Active
29
29
  end
30
30
 
31
31
  class Search
32
- attr_accessor :api_key, :start_date, :end_date, :location, :channels, :keywords, :search, :radius, :limit, :sort, :page, :offset,
32
+ attr_accessor :api_key, :start_date, :end_date, :location, :channels, :keywords, :search, :radius, :limit, :sort, :page, :offset, :latitude, :longitude,
33
33
  :view, :facet, :sort, :num_results, :asset_ids
34
34
 
35
35
  attr_reader :results, :endIndex, :pageSize, :searchTime, :numberOfResults, :end_point, :meta
@@ -40,6 +40,7 @@ module Active
40
40
  def initialize(data={})
41
41
  self.api_key = data[:api_key] || ""
42
42
  self.location = data[:location] || ""
43
+ self.zips = data[:zips] || []
43
44
  self.channels = data[:channels] || []
44
45
  self.keywords = data[:keywords] || []
45
46
  self.radius = data[:radius] || "50"
@@ -55,7 +56,24 @@ module Active
55
56
  self.end_date = data[:end_date] || "+"
56
57
  self.asset_ids = data[:asset_ids] || []
57
58
  self.asset_id = data[:asset_id] || ""
58
-
59
+ self.latitude = data[:latitude]
60
+ self.longitude = data[:longitude]
61
+ end
62
+
63
+ # Example
64
+ # Search.search( {:zips => "92121, 92078, 92114"} )
65
+ # or
66
+ # Search.new( {:zips => [92121, 92078, 92114]} )
67
+ def zips=(value)
68
+ if value.class == String
69
+ @zips = value.split(",").each { |k| k.strip! }
70
+ else
71
+ @zips = value
72
+ end
73
+ end
74
+
75
+ def zips
76
+ @zips
59
77
  end
60
78
 
61
79
  def location=(value)
@@ -98,10 +116,7 @@ module Active
98
116
  end
99
117
  end
100
118
  meta_data = channel_keys.collect { |channel| "meta:channel=#{Search.double_encode_channel(channel)}" }.join("+OR+")
101
- puts meta_data
102
119
  # ASSET IDS
103
-
104
-
105
120
  unless asset_ids.empty?
106
121
  meta_data += "+AND+" unless meta_data == ""
107
122
  temp_ids = []
@@ -110,22 +125,19 @@ module Active
110
125
  end
111
126
  meta_data += temp_ids.join("+OR+")
112
127
  end
128
+ # LOCATION
129
+ # 1 Look for zip codes
130
+ # 2 Look for lat lng
131
+ # 3 Look for a formatted string "San Diego, CA, US"
132
+ if not @zips.empty?
133
+ loc_str = @zips.join(",")
134
+ elsif @latitude and @longitude
135
+ loc_str = "#{@latitude};#{@longitude}"
136
+ else
137
+ loc_str = @location
138
+ end
113
139
 
114
140
 
115
- # trending_asset_order=[]
116
- # trending.each do |asset_id|
117
- # trending_asset_order << asset_id[0]
118
- # @m = @m + "+OR+" if @m!=""
119
- #
120
- # str = "assetId=#{asset_id[0].gsub("-","%2d")}"
121
- # str = CGI.escape(str)
122
- # @m = @m + "meta:#{str}"
123
- # end
124
-
125
-
126
-
127
-
128
- # meta_data = self.channels.join("+OR+")
129
141
  # AND DATE
130
142
  meta_data += "+AND+" unless meta_data == ""
131
143
  if @start_date.class == Date
@@ -136,7 +148,7 @@ module Active
136
148
  end
137
149
  meta_data += "meta:startDate:daterange:#{@start_date}..#{@end_date}"
138
150
 
139
- url = "#{SEARCH_URL}/search?api_key=#{@api_key}&num=#{@num_results}&page=#{@page}&l=#{@location}&f=#{@facet}&v=#{@view}&r=#{@radius}&s=#{@sort}&k=#{@keywords.join("+")}&m=#{meta_data}"
151
+ url = "#{SEARCH_URL}/search?api_key=#{@api_key}&num=#{@num_results}&page=#{@page}&l=#{loc_str}&f=#{@facet}&v=#{@view}&r=#{@radius}&s=#{@sort}&k=#{@keywords.join("+")}&m=#{meta_data}"
140
152
  end
141
153
 
142
154
  def search
@@ -151,13 +163,23 @@ module Active
151
163
  http.get("#{searchurl.path}?#{searchurl.query}")
152
164
  }
153
165
 
154
- if (200..307).include?(res.code.to_i)
155
- parsed_json = JSON.parse(res.body)
156
- @endIndex = parsed_json["endIndex"]
157
- @pageSize = parsed_json["pageSize"]
158
- @searchTime = parsed_json["searchTime"]
159
- @numberOfResults = parsed_json["numberOfResults"]
160
- @results = parsed_json['_results'].collect { |a| Activity.new(a) }
166
+ if (200..307).include?(res.code.to_i)
167
+ begin
168
+ parsed_json = JSON.parse(res.body)
169
+ @endIndex = parsed_json["endIndex"]
170
+ @pageSize = parsed_json["pageSize"]
171
+ @searchTime = parsed_json["searchTime"]
172
+ @numberOfResults = parsed_json["numberOfResults"]
173
+ @results = parsed_json['_results'].collect { |a| Activity.new(a) }
174
+ rescue JSON::ParserError => e
175
+ raise RuntimeError, "JSON::ParserError json=#{res.body}"
176
+ @endIndex = 0
177
+ @pageSize = 0
178
+ @searchTime = 0
179
+ @numberOfResults = 0
180
+ @results = []
181
+ end
182
+
161
183
  else
162
184
  raise RuntimeError, "Active Search responded with a #{res.code} for your query."
163
185
  end
@@ -165,13 +187,30 @@ module Active
165
187
 
166
188
  # examples
167
189
  #
168
- # Search.new({:location => "San Diego"})
169
190
  #
191
+ # = Keywords =
170
192
  # Keywords can be set like this
171
193
  # Search.new({:keywords => "Dog,Cat,Cow"})
172
194
  # Search.new({:keywords => %w(Dog Cat Cow)})
173
195
  # Search.new({:keywords => ["Dog","Cat","Cow"]})
174
196
  #
197
+ # = Location =
198
+ # The location will be set in this order and will override other values. For example is you set a zip code and a location only the zip will be used.
199
+ #
200
+ # 1 Look for zip codes
201
+ # Search.search( {:zips => "92121, 92078, 92114"} )
202
+ # Search.search( {:zips => %w(92121, 92078, 92114)} )
203
+ # Search.search( {:zips => [92121, 92078, 92114]} )
204
+ #
205
+ # 2 Look for lat lng
206
+ # Search.search( {:latitude=>"37.785895", :longitude=>"-122.40638"} )
207
+ #
208
+ # 3 Look for a formatted string "San Diego, CA, US"
209
+ # Search.search( {:location = "San Diego, CA, US"} )
210
+ #
211
+ # = How to look at the results =
212
+ #
213
+ #
175
214
  # http://developer.active.com/docs/Activecom_Search_API_Reference
176
215
  # returns an array of results and query info
177
216
  def self.search(data=nil)
@@ -180,46 +219,9 @@ module Active
180
219
  return search
181
220
  end
182
221
 
183
- # def self.construct_url(arg_options={})
184
- # return arg_options[:url] if arg_options.keys.index(:url) #todo use has_key? #a search url was specified - bypass parsing the options (trending)
185
- # # self.merge!(arg_options)
186
- #
187
- # # options[:location] = CGI.escape(options[:location]) if options[:location]
188
- #
189
- # # if options[:keywords].class == String
190
- # # options[:keywords] = options[:keywords].split(",")
191
- # # options[:keywords].each { |k| k.strip! }
192
- # # end
193
- #
194
- # # if options[:channels] != nil
195
- # # channel_keys = []
196
- # # options[:channels].each do |c|
197
- # # c.to_sym
198
- # # if self.CHANNELS.include?(c)
199
- # # channel_keys << self.CHANNELS[c]
200
- # # end
201
- # # end
202
- # # channels_a = channel_keys.collect { |channel| "meta:channel=#{Search.double_encode_channel(channel)}" }
203
- # # end
204
- #
205
- # meta_data = ""
206
- # meta_data = channels_a.join("+OR+") if channels_a
207
- #
208
- # meta_data += "+AND+" unless meta_data == ""
209
- # if options[:start_date].class == Date
210
- # options[:start_date] = URI.escape(options[:start_date].strftime("%m/%d/%Y")).gsub(/\//,"%2F")
211
- # end
212
- #
213
- # if options[:end_date].class == Date
214
- # options[:end_date] = URI.escape(options[:end_date].strftime("%m/%d/%Y")).gsub(/\//,"%2F")
215
- # end
216
- # meta_data += "meta:startDate:daterange:#{options[:start_date]}..#{options[:end_date]}"
217
- #
218
- # url = "#{SEARCH_URL}/search?api_key=#{options[:api_key]}&num=#{options[:num_results]}&page=#{options[:page]}&l=#{options[:location]}&f=#{options[:facet]}&v=#{options[:view]}&r=#{options[:radius]}&s=#{options[:sort]}&k=#{options[:keywords].join("+")}&m=#{meta_data}"
219
- # puts url
220
- # url
221
- # self.end_point = url
222
- # end
222
+ def []
223
+ @results
224
+ end
223
225
 
224
226
  private
225
227
  def self.double_encode_channel str
data/spec/search_spec.rb CHANGED
@@ -14,6 +14,13 @@ end
14
14
 
15
15
  describe "Search URL Construction" do
16
16
  include CustomMatchers
17
+
18
+ it "should place lat and lng in the l param" do
19
+ location = {:latitude=>"37.785895", :longitude=>"-122.40638"}
20
+ uri = URI.parse( Search.new(location).end_point )
21
+ uri.query.should have_param("l=37.785895;-122.40638")
22
+ end
23
+
17
24
  it "should escape the location" do
18
25
  s = Search.new()
19
26
  s.location.should eql("")
@@ -64,6 +71,13 @@ describe "Search URL Construction" do
64
71
  uri.query.should have_param("l=#{CGI.escape("San Diego, CA, US")}")
65
72
  end
66
73
 
74
+ it "should send an array of zips" do
75
+ uri = URI.parse( Search.new( {:zips => "92121, 92078, 92114"} ).end_point )
76
+ uri.query.should have_param("l=92121,92078,92114")
77
+ uri = URI.parse( Search.new( {:zips => [92121, 92078, 92114]} ).end_point )
78
+ uri.query.should have_param("l=92121,92078,92114")
79
+ end
80
+
67
81
  # it "should construct a valid url from a zip code" do
68
82
  # s = Search.new( {:zip => "92121"} )
69
83
  # uri = URI.parse(s.end_point)
@@ -137,8 +151,9 @@ describe "Search URL Construction" do
137
151
  end
138
152
 
139
153
  it "should pass a query" do
140
- uri = URI.parse( Search.search({:num_results => 50, :radius => "50", :query => "soccer"}).end_point )
141
- uri.query.should have_param("q=soccer")
154
+ # uri = URI.parse( Search.search({:num_results => 50, :radius => "50", :query => "soccer"}).end_point )
155
+ # uri.query.should have_param("q=soccer")
156
+ pending
142
157
  end
143
158
 
144
159
  it "should probably encode the query value" do
@@ -147,6 +162,15 @@ describe "Search URL Construction" do
147
162
  # uri.query.should have_param("q=soccer+balls") What kind of encoding do we need
148
163
  end
149
164
 
165
+ it "should decode this JSON" do
166
+ # if the location is not in the correct format there is a json error.
167
+ # s = Active::Services::Search.search({:location => "belvedere-tiburon-ca"})
168
+ # /search?api_key=&num=10&page=1&l=belvedere-tiburon-ca&f=activities&v=json&r=50&s=date_asc&k=&m=meta:startDate:daterange:today..+
169
+ # I think the JSON spec says that only arrays or objects can be at the top level.
170
+ # JSON::ParserError: A JSON text must at least contain two octets!
171
+ pending
172
+ end
173
+
150
174
  end
151
175
 
152
176
  describe "Handle http server codes" do
@@ -226,6 +250,16 @@ describe Search do
226
250
  end
227
251
  end
228
252
 
253
+ it "should handle this json error" do
254
+ # FakeWeb.register_uri(:get, "http://search.active.com/search?api_key=&num=10&page=1&l=San+Diego%2C+CA%2C+US&f=activities&v=json&r=50&s=date_asc&k=&m=meta:startDate:daterange:today..+",
255
+ # :body => '{"endIndex":10,"numberOfResults":2790,"pageSize":10,"searchTime":0.253913,"_results":[{"escapedUrl":"http://www.active.com/running/myrtle-beach-sc/myrtle-beach-mini-marathon-2010","language":"en","title":"Myrtle Beach Mini Marathon | Myrtle Beach, South Carolina \u003cb\u003e...\u003c/b\u003e","url":"http://www.active.com/running/myrtle-beach-sc/myrtle-beach-mini-marathon-2010","summary":"","meta":{"eventDate":"2010-10-24T07:00:00-07:00","location":"Myrtle Beach, South Carolina","tag":["event:10","Running:10"],"endDate":"2010-10-24","eventLongitude":"-78.92921","splitMediaType":["Event","5K","Half Marathon","Marathon","\u003ddifficulty:Advanced","\u003ddifficulty:Beginner","\u003ddifficulty:Intermediate"],"lastModifiedDateTime":"2010-09-13 18:15:04.753","locationName":"Myrtle Beach, South Carolina","endTime":"7:00:00","google-site-verification":"","city":"Myrtle Beach","startTime":"7:00:00","eventId":"1797753","description":"","longitude":"-78.92921","substitutionUrl":"1797753","eventLatitude":"33.75043","eventState":"South Carolina","sortDate":"2000-10-24","keywords":"Event","eventAddress":"Medieval Times","dma":"Florence - Myrtle Beach","seourl":"http://www.active.com/running/myrtle-beach-sc/myrtle-beach-mini-marathon-2010","country":"United States","category":"Activities","market":"Florence - Myrtle Beach","assetTypeId":"EA4E860A-9DCD-4DAA-A7CA-4A77AD194F65","contactName":"Robert Pozo","eventZip":"29579","latitude":"33.75043","UpdateDateTime":"9/1/2010 6:09:21 PM","startDate":"2010-10-24","state":"South Carolina","mediaType":["Event","Event\\5K","Event\\Half Marathon","Event\\Marathon","\u003ddifficulty:Advanced","\u003ddifficulty:Beginner","\u003ddifficulty:Intermediate"],"estParticipants":"6000","assetId":["008540A9-C2AB-4D7F-BE68-298758B324CD","008540a9-c2ab-4d7f-be68-298758b324cd"],"participationCriteria":"Adult,Men,Women","onlineDonationAvailable":"1","assetName":["Myrtle Beach Mini Marathon","Myrtle Beach Mini Marathon"],"eventURL":"http://runmyrtlebeach.com","zip":"29579","contactPhone":"1-800-733-7089","contactEmail":"info@runmyrtlebeach.com","onlineMembershipAvailable":"0","trackbackurl":"http://www.active.com/running/myrtle-beach-sc/myrtle-beach-mini-marathon-2010","onlineRegistrationAvailable":"1","image1":"http://www.active.com/images/events/hotrace.gif","lastModifiedDate":"2010-09-13","channel":"Running"}},{"escapedUrl":"http://www.active.com/running/denver-co/fans-on-the-field-denver-stadium-5k10k-2010","language":"en","title":"Fans on the Field 2010 - Denver Stadium 5K/10K | Denver \u003cb\u003e...\u003c/b\u003e","url":"http://www.active.com/running/denver-co/fans-on-the-field-denver-stadium-5k10k-2010","summary":"","meta":{"startDate":"2010-10-10","eventDate":"2010-10-10T00:00:00-07:00","location":"INVESCO Field at Mile High","tag":["event:10","Running:10"],"state":"Colorado","eventLongitude":"-105.0265","endDate":"2010-10-10","lastModifiedDateTime":"2010-08-05 16:15:18.14","splitMediaType":["Event","10K","5K"],"locationName":"INVESCO Field at Mile High","endTime":"0:00:00","mediaType":["Event","Event\\10K","Event\\5K"],"city":"Denver","google-site-verification":"","startTime":"0:00:00","assetId":["4850BB73-3701-493D-936C-C38CC0B3FD4C","4850bb73-3701-493d-936c-c38cc0b3fd4c"],"eventId":"1869635","participationCriteria":"All","description":"","longitude":"-105.0265","onlineDonationAvailable":"false","substitutionUrl":"1869635","assetName":["Fans on the Field 2010 - Denver Stadium 5K/10K","Fans on the Field 2010 - Denver Stadium 5K/10K"],"zip":"80204","contactPhone":"303-293-5315","eventLatitude":"39.73804","eventState":"Colorado","sortDate":"2000-10-10","keywords":"Event","eventAddress":"1801 Bryant Street","contactEmail":"ahinkle@nscd.org","onlineMembershipAvailable":"false","trackbackurl":"http://www.active.com/running/denver-co/fans-on-the-field-denver-stadium-5k10k-2010","country":"United States","onlineRegistrationAvailable":"true","category":"Activities","image1":"http://www.active.com/images/events/hotrace.gif","assetTypeId":"EA4E860A-9DCD-4DAA-A7CA-4A77AD194F65","lastModifiedDate":"2010-08-05","eventZip":"80204","UpdateDateTime":"9/1/2010 6:09:21 PM","latitude":"39.73804","channel":["Running","Walking"]}},{"escapedUrl":"http://www.active.com/triathlon/sedalia-mo/sedalia-duathlon-2010","language":"en","title":"Sedalia Duathlon | Sedalia, Missouri 65301 | Sunday \u003cb\u003e...\u003c/b\u003e","url":"http://www.active.com/triathlon/sedalia-mo/sedalia-duathlon-2010","summary":"","meta":{"startDate":"2010-09-26","eventDate":"2010-09-26T08:00:00-07:00","location":"Centennial Park/Parview School","state":"Missouri","endDate":"2010-09-26","eventLongitude":"-93.22826","lastModifiedDateTime":"2010-07-29 17:15:03.313","splitMediaType":["Event","Sprint"],"locationName":"Centennial Park/Parview School","endTime":"8:00:00","mediaType":["Event","Event\\Sprint"],"city":"Sedalia","google-site-verification":"","startTime":"8:00:00","assetId":["F11300A4-0A56-4321-AD4C-17502CEE8503","f11300a4-0a56-4321-ad4c-17502cee8503"],"eventId":"1879447","participationCriteria":"All","description":"","longitude":"-93.22826","onlineDonationAvailable":"false","substitutionUrl":"1879447","assetName":["Sedalia Duathlon","Sedalia Duathlon"],"zip":"65301","contactPhone":"660-827-6809","eventLatitude":"38.70446","eventState":"Missouri","sortDate":"2000-09-26","keywords":"Event","eventAddress":"1901 S. New York","contactEmail":"jamm@iland.net","onlineMembershipAvailable":"false","trackbackurl":"http://www.active.com/triathlon/sedalia-mo/sedalia-duathlon-2010","country":"United States","onlineRegistrationAvailable":"true","category":"Activities","image1":"http://www.active.com/images/events/hotrace.gif","assetTypeId":"EA4E860A-9DCD-4DAA-A7CA-4A77AD194F65","lastModifiedDate":"2010-07-29","eventZip":"65301","UpdateDateTime":"9/1/2010 6:09:21 PM","latitude":"38.70446","channel":["More Sports\\Duathlon","Triathlon"]}},{"escapedUrl":"http://www.active.com/triathlon/tempe-az/pbr-urban-dirt-duathlon-2010","language":"en","title":"PBR Urban Dirt Duathlon | Tempe, Arizona 85281 | Sunday \u003cb\u003e...\u003c/b\u003e","url":"http://www.active.com/triathlon/tempe-az/pbr-urban-dirt-duathlon-2010","summary":"","meta":{"eventDate":"2010-10-10T07:30:00-07:00","location":"North side of Tempe Town Lake near sand Volleyball courts, east of Mill Ave. Race thru Papago!","tag":["event:10","Triathlon:10"],"endDate":"2010-10-10","eventLongitude":"-111.9305","splitMediaType":["Event","Off-Road","Sprint","\u003ddifficulty:Advanced","\u003ddifficulty:Beginner","\u003ddifficulty:Intermediate"],"lastModifiedDateTime":"2010-09-08 15:15:42.507","locationName":"North side of Tempe Town Lake near sand Volleyball courts, east of Mill Ave. Race thru Papago!","endTime":"7:30:00","google-site-verification":"","city":"Tempe","startTime":"7:30:00","eventId":"1814945","description":"","longitude":"-111.9305","substitutionUrl":"1814945","eventLatitude":"33.42507","eventState":"Arizona","sortDate":"2000-10-10","keywords":"Event","eventAddress":"54 West Rio Salado Parkway","dma":"Phoenix","seourl":"http://www.active.com/triathlon/tempe-az/pbr-urban-dirt-duathlon-2010","country":"United States","category":"Activities","market":"Phoenix","assetTypeId":"EA4E860A-9DCD-4DAA-A7CA-4A77AD194F65","contactName":"Red Rock Co","eventZip":"85281","latitude":"33.42507","UpdateDateTime":"9/1/2010 6:09:21 PM","startDate":"2010-10-10","state":"Arizona","mediaType":["Event","Event\\Off-Road","Event\\Sprint","\u003ddifficulty:Advanced","\u003ddifficulty:Beginner","\u003ddifficulty:Intermediate"],"estParticipants":"400","assetId":["C47BA275-BFFF-41F1-8915-42F9159456B6","c47ba275-bfff-41f1-8915-42f9159456b6"],"participationCriteria":"Adult,Family,Kids,Men,Women","onlineDonationAvailable":"0","assetName":["PBR Urban Dirt Duathlon","PBR Urban Dirt Duathlon"],"eventURL":"http://www.redrockco.com","zip":"85281","contactPhone":"877-681-7223","contactEmail":"mike@redrockco.com","onlineMembershipAvailable":"0","trackbackurl":"http://www.active.com/triathlon/tempe-az/pbr-urban-dirt-duathlon-2010","onlineRegistrationAvailable":"1","image1":"http://www.active.com/images/events/hotrace.gif","lastModifiedDate":"2010-09-08","channel":["More Sports\\Duathlon","Triathlon"]}},{"escapedUrl":"http://www.active.com/triathlon/hayesville-nc/fall-chill-duathlon-2010","language":"en","title":"Fall Chill Duathlon 2010 | Hayesville, North Carolina 28904 \u003cb\u003e...\u003c/b\u003e","url":"http://www.active.com/triathlon/hayesville-nc/fall-chill-duathlon-2010","summary":"","meta":{"eventDate":"2010-10-24T10:00:00-07:00","location":"Clay County Recreation Park: 5 miles from Hiawassee Ga","tag":["event:10","Triathlon:10"],"endDate":"2010-10-24","eventLongitude":"-83.73081","splitMediaType":["Event","Sprint","\u003ddifficulty:Intermediate"],"lastModifiedDateTime":"2010-09-16 03:11:56.37","locationName":"Clay County Recreation Park: 5 miles from Hiawassee Ga","endTime":"10:00:00","google-site-verification":"","city":"Hayesville","startTime":"10:00:00","eventId":"1816551","description":"","longitude":"-83.73081","substitutionUrl":"1816551","eventLatitude":"35.04112","eventState":"North Carolina","sortDate":"2000-10-24","keywords":"Event","eventAddress":"Clay County Recreation Park Road, Hayesville, NC 28904","dma":"Atlanta","seourl":"http://www.active.com/triathlon/hayesville-nc/fall-chill-duathlon-2010","country":"United States","category":"Activities","market":"Atlanta","assetTypeId":"EA4E860A-9DCD-4DAA-A7CA-4A77AD194F65","contactName":"Scott Hanna","eventZip":"28904","latitude":"35.04112","UpdateDateTime":"9/1/2010 6:09:21 PM","startDate":"2010-10-24","state":"North Carolina","mediaType":["Event","Event\\Sprint","\u003ddifficulty:Intermediate"],"estParticipants":"150","assetId":["2B2DD142-23EA-42AE-A86A-C3BAAF8089F0","2b2dd142-23ea-42ae-a86a-c3baaf8089f0"],"participationCriteria":"Adult","onlineDonationAvailable":"0","assetName":["Fall Chill Duathlon 2010","Fall Chill Duathlon 2010"],"eventURL":"http://www.thebeastoftheeast.net","zip":"28904","contactPhone":"828-389-6982","contactEmail":"tri20001@msn.com","onlineMembershipAvailable":"0","trackbackurl":"http://www.active.com/triathlon/hayesville-nc/fall-chill-duathlon-2010","onlineRegistrationAvailable":"true","image1":"http://www.active.com/images/events/hotrace.gif","lastModifiedDate":"2010-09-16","channel":["More Sports\\Duathlon","Triathlon"]}},{"escapedUrl":"http://www.active.com/triathlon/congers-ny/fall-toga-duathlon-2010","language":"en","title":"2010 Fall Toga Duathlon | Congers, New York 10920 \u003cb\u003e...\u003c/b\u003e","url":"http://www.active.com/triathlon/congers-ny/fall-toga-duathlon-2010","summary":"","meta":{"startDate":"2010-10-17","eventDate":"2010-10-17T08:30:00-07:00","location":"Rockland Lake","tag":["event:10","Triathlon:10"],"state":"New York","endDate":"2010-10-17","eventLongitude":"-73.93904","splitMediaType":["Event","Sprint"],"locationName":"Rockland Lake","endTime":"8:30:00","mediaType":["Event","Event\\Sprint"],"city":"Congers","google-site-verification":"","startTime":"8:30:00","assetId":["096853C1-151A-4EED-9931-79275795AAA9","096853c1-151a-4eed-9931-79275795aaa9"],"eventId":"1821127","participationCriteria":"All","description":"","longitude":"-73.93904","onlineDonationAvailable":"false","substitutionUrl":"1821127","assetName":["2010 Fall Toga Duathlon","2010 Fall Toga Duathlon"],"zip":"10920","contactPhone":"8453538331","eventLatitude":"41.15644","eventState":"New York","sortDate":"2000-10-17","keywords":"Event","eventAddress":"Rt 9W","contactEmail":"Lonny@Togabikes.com","onlineMembershipAvailable":"false","trackbackurl":"http://www.active.com/triathlon/congers-ny/fall-toga-duathlon-2010","country":"United States","onlineRegistrationAvailable":"true","category":"Activities","image1":"http://www.active.com/images/events/hotrace.gif","assetTypeId":"EA4E860A-9DCD-4DAA-A7CA-4A77AD194F65","lastModifiedDate":"2010-03-02 15:22:22.54","eventZip":"10920","UpdateDateTime":"9/1/2010 6:09:21 PM","latitude":"41.15644","channel":["More Sports\\Duathlon","Triathlon"]}},{"escapedUrl":"http://www.active.com/triathlon/mendon-ny/rochester-autumn-classic-duathlon-2010","language":"en","title":"Rochester Autumn Classic Duathlon 2010 | Mendon, New \u003cb\u003e...\u003c/b\u003e","url":"http://www.active.com/triathlon/mendon-ny/rochester-autumn-classic-duathlon-2010","summary":"","meta":{"eventDate":"2010-10-03T08:30:00-07:00","location":"Stewart Lodge, Mendon Ponds Park","tag":["event:10","Triathlon:10"],"endDate":"2010-10-03","eventLongitude":"-77.49951","splitMediaType":["Event","Sprint"],"lastModifiedDateTime":"2010-08-30 13:15:51.837","locationName":"Stewart Lodge, Mendon Ponds Park","endTime":"8:30:00","google-site-verification":"","city":"Mendon","startTime":"8:30:00","eventId":"1821816","description":"","longitude":"-77.49951","substitutionUrl":"1821816","eventLatitude":"42.99441","eventState":"New York","sortDate":"2000-10-03","keywords":"Event","eventAddress":"Douglas Rd.","dma":"Rochester, NY","seourl":"http://www.active.com/triathlon/mendon-ny/rochester-autumn-classic-duathlon-2010","country":"United States","category":"Activities","market":"Rochester, NY","contactName":"Dave or Ellen Boutillier","assetTypeId":"EA4E860A-9DCD-4DAA-A7CA-4A77AD194F65","eventZip":"14506","latitude":"42.99441","UpdateDateTime":"9/1/2010 6:09:21 PM","startDate":"2010-10-03","state":"New York","mediaType":["Event","Event\\Sprint"],"estParticipants":"250","assetId":["39F96A49-A188-4592-A04C-755D12D5D8BB","39f96a49-a188-4592-a04c-755d12d5d8bb"],"participationCriteria":"All","onlineDonationAvailable":"0","assetName":["Rochester Autumn Classic Duathlon 2010","Rochester Autumn Classic Duathlon 2010"],"eventURL":"http://www.yellowjacketracing.com","zip":"14506","contactPhone":"585-697-3338","contactEmail":"elleneabrenner@aol.com","onlineMembershipAvailable":"0","trackbackurl":"http://www.active.com/triathlon/mendon-ny/rochester-autumn-classic-duathlon-2010","onlineRegistrationAvailable":"1","image1":"http://www.active.com/images/events/hotrace.gif","lastModifiedDate":"2010-08-30","channel":["More Sports\\Duathlon","Triathlon"]}},{"escapedUrl":"http://www.active.com/triathlon/miami-fl/ironman-703-miami-2010","language":"en","title":"IRONMAN 70.3 MIAMI | Miami, Florida 33132 | Saturday \u003cb\u003e...\u003c/b\u003e","url":"http://www.active.com/triathlon/miami-fl/ironman-703-miami-2010","summary":"","meta":{"startDate":"2010-10-30","eventDate":"2010-10-30T07:00:00-07:00","location":"Bayfront Park - Downtown Miami","tag":["event:10","Triathlon:10"],"state":"Florida","eventLongitude":"-80.18975","endDate":"2010-10-30","lastModifiedDateTime":"2010-05-10 11:16:04.46","splitMediaType":["Event","Ironman","Long Course","\u003ddifficulty:Advanced","\u003ddifficulty:Intermediate"],"locationName":"Bayfront Park - Downtown Miami","endTime":"7:00:00","mediaType":["Event","Event\\Ironman","Event\\Long Course","\u003ddifficulty:Advanced","\u003ddifficulty:Intermediate"],"city":"Miami","google-site-verification":"","startTime":"7:00:00","assetId":["72FAE9F7-5C68-4DF8-B01C-B63AC188A06A","72fae9f7-5c68-4df8-b01c-b63ac188a06a"],"eventId":"1800302","participationCriteria":"Adult,Family,Men,Women","description":"","longitude":"-80.18975","onlineDonationAvailable":"false","substitutionUrl":"1800302","assetName":["IRONMAN 70.3 MIAMI","IRONMAN 70.3 MIAMI"],"zip":"33132","contactPhone":"3053072285","eventLatitude":"25.78649","eventState":"Florida","sortDate":"2000-10-30","keywords":"Event","eventAddress":"301 N. Biscayne Blvd.","contactEmail":"jennifer@miamitrievents.com","onlineMembershipAvailable":"false","trackbackurl":"http://www.active.com/triathlon/miami-fl/ironman-703-miami-2010","country":"United States","onlineRegistrationAvailable":"true","category":"Activities","image1":"http://www.active.com/images/events/hotrace.gif","assetTypeId":"EA4E860A-9DCD-4DAA-A7CA-4A77AD194F65","lastModifiedDate":"2010-05-10","eventZip":"33132","UpdateDateTime":"9/1/2010 6:09:21 PM","latitude":"25.78649","channel":"Triathlon"}},{"escapedUrl":"http://www.active.com/triathlon/austin-tx/austin-oyster-urban-adventure-race-2010","language":"en","title":"Austin Oyster Urban Adventure Race | Austin, Texas 78704 \u003cb\u003e...\u003c/b\u003e","url":"http://www.active.com/triathlon/austin-tx/austin-oyster-urban-adventure-race-2010","summary":"","meta":{"eventDate":"2010-10-16T08:00:00-07:00","location":"Runtex","tag":["event:10","Triathlon:10"],"endDate":"2010-10-16","eventLongitude":"-97.76204","splitMediaType":"Event","lastModifiedDateTime":"2010-09-17 10:16:19.03","locationName":"Runtex","endTime":"8:00:00","google-site-verification":"","city":"Austin","startTime":"8:00:00","eventId":"1831863","description":"","longitude":"-97.76204","substitutionUrl":"1831863","eventLatitude":"30.24495","eventState":"Texas","sortDate":"2000-10-16","keywords":"Event","eventAddress":"422 W. Riverside","dma":"Austin","seourl":"http://www.active.com/triathlon/austin-tx/austin-oyster-urban-adventure-race-2010","country":"United States","category":"Activities","market":"Austin","assetTypeId":"EA4E860A-9DCD-4DAA-A7CA-4A77AD194F65","contactName":"Luann Morris","eventZip":"78704","latitude":"30.24495","UpdateDateTime":"9/1/2010 6:09:21 PM","startDate":"2010-10-16","state":"Texas","mediaType":"Event","estParticipants":"500","assetId":["5BCA2E67-05F8-49FA-911B-EA007A08A7ED","5bca2e67-05f8-49fa-911b-ea007a08a7ed"],"participationCriteria":"All","onlineDonationAvailable":"0","assetName":["Austin Oyster Urban Adventure Race","Austin Oyster Urban Adventure Race"],"eventURL":"http://OysterRacingSeries.com","zip":"78704","contactPhone":"3037776887","contactEmail":"luann@teamsage.com","onlineMembershipAvailable":"0","trackbackurl":"http://www.active.com/triathlon/austin-tx/austin-oyster-urban-adventure-race-2010","onlineRegistrationAvailable":"true","image1":"http://www.active.com/images/events/hotrace.gif","lastModifiedDate":"2010-09-17","channel":["More Sports\\Adventure Racing","Triathlon"]}},{"escapedUrl":"http://www.active.com/running/colorado-springs-co/fall-series-kids-2010-ov251","language":"en","title":"Fall Series 2010 (Kids) | Colorado Springs, Colorado 80903 \u003cb\u003e...\u003c/b\u003e","url":"http://www.active.com/running/colorado-springs-co/fall-series-kids-2010-ov251","summary":"","meta":{"startDate":"2010-10-03","eventDate":"2010-10-03T13:30:00-07:00","location":"Various sites","tag":["event:10","Running:10"],"state":"Colorado","eventLongitude":"-104.8163","endDate":"2010-10-03","lastModifiedDateTime":"2010-08-12 11:19:31.73","splitMediaType":["Event","1 mile","\u003ddifficulty:Advanced","\u003ddifficulty:Beginner","\u003ddifficulty:Intermediate"],"locationName":"Various sites","endTime":"13:30:00","mediaType":["Event","Event\\1 mile","\u003ddifficulty:Advanced","\u003ddifficulty:Beginner","\u003ddifficulty:Intermediate"],"city":"Colorado Springs","google-site-verification":"","estParticipants":"400","startTime":"13:30:00","assetId":["54A4A562-2A34-4345-8A20-7084EC435C57","54a4a562-2a34-4345-8a20-7084ec435c57"],"eventId":"1882757","participationCriteria":"Kids","description":"","longitude":"-104.8163","onlineDonationAvailable":"true","substitutionUrl":"1882757","assetName":["Fall Series 2010 (Kids)","Fall Series 2010 (Kids)"],"zip":"80903","eventURL":"http://pprrun.org","contactPhone":"719-590-7086","sortDate":"2000-10-03","eventState":"Colorado","eventLatitude":"38.84134","keywords":"Event","contactEmail":"fallseries@aol.com","onlineMembershipAvailable":"false","trackbackurl":"http://www.active.com/running/colorado-springs-co/fall-series-kids-2010-ov251","country":"United States","onlineRegistrationAvailable":"true","category":"Activities","image1":"http://www.active.com/images/events/hotrace.gif","market":"Colorado Springs - Pueblo","contactName":"Larry Miller","assetTypeId":"EA4E860A-9DCD-4DAA-A7CA-4A77AD194F65","lastModifiedDate":"2010-08-12","eventZip":"80903","UpdateDateTime":"9/1/2010 6:09:21 PM","latitude":"38.84134","channel":["Running","Walking"]}}]}',
256
+ # :status => ["200", "Found"])
257
+ # s = Search.search( {:zips=>["92198", "92199", "91901", "91902", "91903", "91905", "91906", "91908", "91909", "91910", "91911", "91912", "91913", "91914", "91915", "91916", "91917", "91921", "91931", "91932", "91933", "91934", "91935", "91941", "91942", "91943", "91944", "91945", "91946", "91947", "91948", "91950", "91951", "91962", "91963", "91976", "91977", "91978", "91979", "91980", "91987", "91990", "92003", "92004", "92007", "92008", "92009", "92013", "92014", "92018", "92019", "92020", "92021", "92022", "92023", "92024", "92025", "92026", "92027", "92028", "92029", "92030", "92033", "92036", "92037", "92038", "92039", "92040", "92046", "92049", "92051", "92052", "92054", "92055", "92056", "92057", "92058", "92059", "92060", "92061", "92064", "92065", "92066", "92067", "92068", "92069", "92070", "92071", "92072", "92074", "92075", "92078", "92079", "92082", "92083", "92084", "92085", "92086", "92088", "92090", "92091", "92092", "92093", "92096", "92101", "92102", "92103", "92104", "92105", "92106", "92107", "92108", "92109", "92110", "92111", "92112", "92113", "92114", "92115", "92116", "92117", "92118", "92119", "92120", "92121", "92122", "92123", "92124", "92126", "92127", "92128", "92129", "92130", "92131", "92132", "92133", "92134", "92135", "92136", "92137", "92138", "92139", "92140", "92142", "92143", "92145", "92147", "92149", "92150", "92152", "92153", "92154", "92155", "92158", "92159", "92160", "92161", "92162", "92163", "92164", "92165", "92166", "92167", "92168", "92169", "92170", "92171", "92172", "92173", "92174", "92175", "92176", "92177", "92178", "92179", "92182", "92184", "92186", "92187", "92190", "92191", "92192", "92193", "92194", "92195", "92196", "92197", "92081"]} )
258
+ s = Search.search( {:zips=>["92198", "92199", "91901"]} )
259
+ s.results.should have(10).items
260
+ s.results.should_not be_empty
261
+ end
262
+
229
263
  it "should handle a JSON parse error" do
230
264
  # /search?api_key=&num=10&page=1&l=0&f=activities&v=json&r=50&s=trending&k=&m=meta:startDate:daterange:today..+
231
265
  # FakeWeb.register_uri(:get, "http://search.active.com/search?api_key=&num=10&page=1&l=San+Diego%2C+CA%2C+US&f=activities&v=json&r=50&s=date_asc&k=&m=meta:startDate:daterange:today..+",
@@ -293,8 +327,15 @@ describe "Call Live Data" do
293
327
  end
294
328
 
295
329
  it "should not set sort to an empty string" do
296
- s = Search.search( {:sort => ""} )
297
- s.sort.should_not be_empty
330
+ # s = Search.search( {:sort => ""} )
331
+ # s.sort.should_not be_empty
332
+ pending
333
+ end
334
+
335
+ it "should get results given these area codes" do
336
+ s = Search.search( {:zips => "92121, 92078, 92114"} )
337
+ s.should be_an_instance_of Search
338
+ s.results.should_not be_empty
298
339
  end
299
340
 
300
341
  it "should find activities that have been recently added"
@@ -331,5 +372,18 @@ describe "Parametric search" do
331
372
  end
332
373
  end
333
374
 
375
+ describe "Find things within X miles to me" do
376
+ it "should find activities within 20 miles of me" do
377
+ location = {:latitude=>"37.785895", :longitude=>"-122.40638"}
378
+ Search.search(location).results.should_not be_empty
379
+ end
380
+ it "shoule be near this location"
381
+ end
382
+
383
+
384
+
385
+
386
+
387
+
334
388
 
335
389
 
data/version.txt CHANGED
@@ -1 +1 @@
1
- 0.0.9
1
+ 0.0.11
metadata CHANGED
@@ -1,12 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: Active
3
3
  version: !ruby/object:Gem::Version
4
+ hash: 9
4
5
  prerelease: false
5
6
  segments:
6
7
  - 0
7
8
  - 0
8
- - 9
9
- version: 0.0.9
9
+ - 11
10
+ version: 0.0.11
10
11
  platform: ruby
11
12
  authors:
12
13
  - Jonathan Spooner, Brian Levine
@@ -14,16 +15,18 @@ autorequire:
14
15
  bindir: bin
15
16
  cert_chain: []
16
17
 
17
- date: 2010-09-17 00:00:00 -07:00
18
+ date: 2010-09-20 00:00:00 -07:00
18
19
  default_executable:
19
20
  dependencies:
20
21
  - !ruby/object:Gem::Dependency
21
22
  name: savon
22
23
  prerelease: false
23
24
  requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
24
26
  requirements:
25
27
  - - ">="
26
28
  - !ruby/object:Gem::Version
29
+ hash: 17
27
30
  segments:
28
31
  - 0
29
32
  - 7
@@ -35,9 +38,11 @@ dependencies:
35
38
  name: bones
36
39
  prerelease: false
37
40
  requirement: &id002 !ruby/object:Gem::Requirement
41
+ none: false
38
42
  requirements:
39
43
  - - ">="
40
44
  - !ruby/object:Gem::Version
45
+ hash: 25
41
46
  segments:
42
47
  - 3
43
48
  - 4
@@ -55,18 +60,15 @@ extra_rdoc_files:
55
60
  - History.txt
56
61
  - README.txt
57
62
  - bin/Active
58
- - lib/.DS_Store
59
- - lib/services/.DS_Store
60
63
  - version.txt
61
64
  files:
65
+ - .bnsignore
62
66
  - Active.gemspec
63
67
  - History.txt
64
68
  - README.txt
65
69
  - Rakefile
66
70
  - bin/Active
67
- - lib/.DS_Store
68
71
  - lib/Active.rb
69
- - lib/services/.DS_Store
70
72
  - lib/services/IActivity.rb
71
73
  - lib/services/activity.rb
72
74
  - lib/services/ats.rb
@@ -94,23 +96,27 @@ rdoc_options:
94
96
  require_paths:
95
97
  - lib
96
98
  required_ruby_version: !ruby/object:Gem::Requirement
99
+ none: false
97
100
  requirements:
98
101
  - - ">="
99
102
  - !ruby/object:Gem::Version
103
+ hash: 3
100
104
  segments:
101
105
  - 0
102
106
  version: "0"
103
107
  required_rubygems_version: !ruby/object:Gem::Requirement
108
+ none: false
104
109
  requirements:
105
110
  - - ">="
106
111
  - !ruby/object:Gem::Version
112
+ hash: 3
107
113
  segments:
108
114
  - 0
109
115
  version: "0"
110
116
  requirements: []
111
117
 
112
118
  rubyforge_project: Active
113
- rubygems_version: 1.3.6
119
+ rubygems_version: 1.3.7
114
120
  signing_key:
115
121
  specification_version: 3
116
122
  summary: Search api for Active Network
data/lib/.DS_Store DELETED
Binary file
Binary file