Active 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/.bnsignore CHANGED
@@ -16,3 +16,4 @@ announcement.txt
16
16
  coverage
17
17
  doc
18
18
  pkg
19
+ .DS_Store
data/Active-0.0.1.gem ADDED
Binary file
data/Active.gemspec CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{Active}
5
- s.version = "0.0.1"
5
+ s.version = "0.0.2"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Jonathan Spooner, Brian Levine"]
@@ -12,7 +12,7 @@ Gem::Specification.new do |s|
12
12
  s.email = %q{jspooner [at] gmail.com}
13
13
  s.executables = ["Active"]
14
14
  s.extra_rdoc_files = ["History.txt", "README.txt", "bin/Active", "version.txt"]
15
- s.files = [".DS_Store", ".bnsignore", "Active.gemspec", "History.txt", "README.txt", "Rakefile", "bin/Active", "lib/Active.rb", "lib/services/activity.rb", "lib/services/search.rb", "spec/.DS_Store", "spec/Active_spec.rb", "spec/activity_spec.rb", "spec/search_spec.rb", "spec/spec_helper.rb", "test/test_Active.rb", "version.txt"]
15
+ s.files = [".bnsignore", "Active-0.0.0.gem", "Active-0.0.1.gem", "Active.gemspec", "History.txt", "README.txt", "Rakefile", "bin/Active", "lib/Active.rb", "lib/services/activity.rb", "lib/services/search.rb", "spec/.DS_Store", "spec/Active_spec.rb", "spec/activity_spec.rb", "spec/search_spec.rb", "spec/spec_helper.rb", "test/test_Active.rb", "version.txt"]
16
16
  s.homepage = %q{http://developer.active.com/docs/Activecom_Search_API_Reference}
17
17
  s.rdoc_options = ["--main", "README.txt"]
18
18
  s.require_paths = ["lib"]
data/README.txt CHANGED
@@ -26,7 +26,7 @@ Search api for Active Network
26
26
 
27
27
  (The MIT License)
28
28
 
29
- Copyright (c) 2009 FIXME (different license?)
29
+ Copyright (c) 2010 Active Network
30
30
 
31
31
  Permission is hereby granted, free of charge, to any person obtaining
32
32
  a copy of this software and associated documentation files (the
data/lib/Active.rb CHANGED
@@ -60,6 +60,8 @@ module Active
60
60
  end
61
61
 
62
62
  end # module Active
63
-
63
+ puts "FUCK SHIT 2"
64
64
  Active.require_all_libs_relative_to(__FILE__)
65
+ Active.require_all_libs_relative_to(__FILE__, 'services')
66
+
65
67
 
@@ -7,8 +7,8 @@ module Active
7
7
  @title = data[:title]
8
8
 
9
9
  unless data[:meta].nil?
10
- @start_date = data[:meta][:startDate] ||= ""
11
- @end_date = data[:meta][:endDate] ||= ""
10
+ @start_date = Date.parse(data[:meta][:startDate])
11
+ @end_date = Date.parse(data[:meta][:endDate]) if data[:meta][:endDate]
12
12
  @category = data[:meta][:channel] ||= ""
13
13
  @desc = data[:meta][:description] ||= ""
14
14
  @start_time = data[:meta][:startTime] ||= ""
@@ -103,10 +103,11 @@ module Active
103
103
  if options[:start_date].class == Date
104
104
  options[:start_date] = URI.escape(options[:start_date].strftime("%m/%d/%Y")).gsub(/\//,"%2F")
105
105
  end
106
+
106
107
  if options[:end_date].class == Date
107
108
  options[:end_date] = URI.escape(options[:end_date].strftime("%m/%d/%Y")).gsub(/\//,"%2F")
108
109
  end
109
- meta_data += "daterange:#{options[:start_date]}..#{options[:end_date]}"
110
+ meta_data += "meta:startDate:daterange:#{options[:start_date]}..#{options[:end_date]}"
110
111
 
111
112
  #
112
113
  # if @asset_type_id!=nil
@@ -1,6 +1,7 @@
1
1
  # Require the spec helper relative to this file
2
2
  require File.join(File.dirname(__FILE__), %w[spec_helper])
3
3
  require File.join(File.dirname(__FILE__), %w[ .. lib services search])
4
+ require File.join(File.dirname(__FILE__), %w[ .. lib services activity])
4
5
 
5
6
  # No need to type Britify:: before each call
6
7
  include Active::Services
@@ -65,6 +66,9 @@ describe Activity do
65
66
  a.start_time.should_not be_nil
66
67
  a.end_time.should_not be_nil
67
68
 
69
+ a.start_date.should be_a_kind_of(Date)
70
+ a.end_date.should be_a_kind_of(Date)
71
+
68
72
  a.address.should_not be_nil
69
73
  a.address[:city].should_not be_nil
70
74
  a.address[:state].should_not be_nil
data/spec/search_spec.rb CHANGED
@@ -50,7 +50,7 @@ describe "Search URL Construction" do
50
50
 
51
51
  it "should send a valid start and end date" do
52
52
  uri = URI.parse( Search.construct_url({:start_date => Date.new(2010, 11, 1), :end_date => Date.new(2010, 11, 15)}) )
53
- uri.query.include?("daterange:11%2F01%2F2010..11%2F15%2F2010").should be_true
53
+ uri.query.include?("meta:startDate:daterange:11%2F01%2F2010..11%2F15%2F2010").should be_true
54
54
  end
55
55
 
56
56
  it "should be valid with date range and channels" do
@@ -75,13 +75,13 @@ describe Search do
75
75
  # end
76
76
 
77
77
  it "should raise and error during a 404" do
78
- 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=10&s=date_asc&k=&m=daterange:today..+",
78
+ 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=10&s=date_asc&k=&m=meta:startDate:daterange:today..+",
79
79
  :body => "Nothing to be found 'round here", :status => ["404", "Not Found"])
80
80
  lambda { Search.search( {:location => "San Diego, CA, US"} ) }.should raise_error(RuntimeError)
81
81
  end
82
82
 
83
83
  it "should search by location (san diego)" do
84
- 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=10&s=date_asc&k=&m=daterange:today..+",
84
+ 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=10&s=date_asc&k=&m=meta:startDate:daterange:today..+",
85
85
  :body => '{"endIndex":5,"numberOfResults":2,"pageSize":5,"searchTime":0.600205,"_results":[{"escapedUrl": "http://www.active.com/running/calabasas-ca/calabasas-classic-5k-10k-runs-2010","language": "en","title": "Calabasas Classic 2010 - 5k \u003cb\u003e10k\u003c/b\u003e Runs | Calabasas, California 91302 \u003cb\u003e...\u003c/b\u003e","url": "http://www.active.com/running/calabasas-ca/calabasas-classic-5k-10k-runs-2010","summary": "\u003cb\u003e...\u003c/b\u003e Calabasas Classic 2010 - 5k \u003cb\u003e10k\u003c/b\u003e Runs. Based on 0 reviews. \u003cb\u003e...\u003c/b\u003e Recent Reviews Calabasas\u003cbr\u003e Classic 2010 - 5k \u003cb\u003e10k\u003c/b\u003e Runs reviews. Get Directions. Start Address. End Address \u003cb\u003e...\u003c/b\u003e ","meta": {"startDate": "2010-11-14","eventDate": "2010-11-14T08:00:00-08:00","location": "Calabasas Park Centre","tag": ["event:10", "Green:10", "Running:10"],"state": "California","eventLongitude": "-118.6789","endDate": "2010-11-14","locationName": "Calabasas Park Centre","splitMediaType": ["Event", "1 mile", "10K", "5K"],"endTime": "8:00:00","mediaType": ["Event", "Event\\1 mile", "Event\\10K", "Event\\5K"],"google-site-verification": "","city": "Calabasas","startTime": "8:00:00","assetId": ["11B01475-8C65-4F9C-A4AC-2A3FA55FE8CD", "11b01475-8c65-4f9c-a4ac-2a3fa55fe8cd"],"eventId": "1810531","participationCriteria": "All","description": "","longitude": "-118.6789","onlineDonationAvailable": "false","substitutionUrl": "1810531","assetName": ["Calabasas Classic 2010 - 5k 10k Runs", "Calabasas Classic 2010 - 5k 10k Runs"],"zip": "91302","contactPhone": "818-715-0428","sortDate": "2000-11-14","eventState": "California","eventLatitude": "34.12794","keywords": "Event","eventAddress": "23975 Park Sorrento","contactEmail": "rot10kd@yahoo.com","onlineMembershipAvailable": "false","trackbackurl": "http://www.active.com/running/calabasas-ca/calabasas-classic-5k-10k-runs-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-04 07:30:26.307","eventZip": "91302","latitude": "34.12794","UpdateDateTime": "8/18/2010 10:16:26 AM","channel": ["Running", "Walking"]}},
86
86
  {"escapedUrl": "http://www.active.com/10k-race/seattle-wa/fitness-for-vitality-5k10k-3race-series-919-2010","language": "en","title": "Fitness For Vitality 5k/\u003cb\u003e10k\u003c/b\u003e 3-Race Series (9/19, 10/17, 11/21) \u003cb\u003e...\u003c/b\u003e","url": "http://www.active.com/10k-race/seattle-wa/fitness-for-vitality-5k10k-3race-series-919-2010","summary": "\u003cb\u003e...\u003c/b\u003e Fitness For Vitality 5k/\u003cb\u003e10k\u003c/b\u003e 3-Race Series (9/19, 10/17, 11/21). Based on 0 reviews. \u003cb\u003e...\u003c/b\u003e\u003cbr\u003e Reviews of Fitness For Vitality 5k/\u003cb\u003e10k\u003c/b\u003e 3-Race Series (9/19, 10. \u003cb\u003e...\u003c/b\u003e ","meta": {"summary": "\u003cp style\u003dtext-align:left\u003e\u003cfont style\u003dfont-family:UniversEmbedded;font-size:12;color:#000000; LETTERSPACING\u003d0 KERNING\u003d0\u003eRace or walk on a flat, fast, and fun course! The entire event is along the Puget Sound. Do all 3 events in the series and watch your time and fitness improve! Oatmeal post-race. 10% proceeds sh","startDate": "2010-09-19","eventDate": "2010-09-19","location": "Alki Beach Park, Seattle","tag": ["event:10", "Running:10"],"state": "Washington","endDate": "2010-11-22","locationName": "1702 Alki Ave. SW","splitMediaType": ["5K", "difficulty:Beginner", "difficulty:Advanced", "Event", "difficulty:Intermediate", "10K"],"lastModifiedDateTime": "2010-08-19 23:35:50.117","endTime": "07:59:59","mediaType": ["5K", "difficulty:Beginner", "difficulty:Advanced", "Event", "difficulty:Intermediate", "10K"],"google-site-verification": "","city": "Seattle","startTime": "07:00:00","assetId": ["39e8177e-dd0e-42a2-8a2b-24055e5325f3", "39e8177e-dd0e-42a2-8a2b-24055e5325f3"],"eventId": "E-000NGFS9","participationCriteria": "Kids,Family","description": "","longitude": "-122.3912","substitutionUrl": "E-000NGFS9","assetName": ["Fitness For Vitality 5k/10k 3-Race Series (9/19, 10/17, 11/21)", "Fitness For Vitality 5k/10k 3-Race Series (9/19, 10/17, 11/21)"],"zip": "98136","contactPhone": "n/a","eventState": "WA","sortDate": "2000-09-19","keywords": "Event","eventAddress": "1702 Alki Ave. SW","contactEmail": "n/a","dma": "Seattle - Tacoma","trackbackurl": "http://www.active.com/10k-race/seattle-wa/fitness-for-vitality-5k10k-3race-series-919-2010","seourl": "http://www.active.com/10k-race/seattle-wa/fitness-for-vitality-5k10k-3race-series-919-2010","country": "United States","onlineRegistrationAvailable": "true","category": "Activities","image1": "http://photos-images.active.com/file/3/1/optimized/9015e50d-3a2e-4ce4-9ddc-80b05b973b01.jpg","allText": "\u003cp style\u003dtext-align:left\u003e\u003cfont style\u003dfont-family:UniversEmbedded;font-size:12;color:#000000; LETTERSPACING\u003d0 KERNING\u003d0\u003eRace or walk on a flat, fast, and fun course! The entire event is along the Puget Sound. Do all 3 events in the series and watch your time and fitness improve! Oatmeal post-race. 10% proceeds sh","address": "1702 Alki Ave. SW","assetTypeId": "DFAA997A-D591-44CA-9FB7-BF4A4C8984F1","lastModifiedDate": "2010-08-19","eventZip": "98136","latitude": "47.53782","UpdateDateTime": "8/18/2010 10:16:08 AM","channel": "Running"}},
87
87
  {"escapedUrl": "http://www.active.com/running/calabasas-ca/calabasas-classic-5k-10k-runs-2010","language": "en","title": "Calabasas Classic 2010 - 5k \u003cb\u003e10k\u003c/b\u003e Runs | Calabasas, California 91302 \u003cb\u003e...\u003c/b\u003e","url": "http://www.active.com/running/calabasas-ca/calabasas-classic-5k-10k-runs-2010","summary": "\u003cb\u003e...\u003c/b\u003e Calabasas Classic 2010 - 5k \u003cb\u003e10k\u003c/b\u003e Runs. Based on 0 reviews. \u003cb\u003e...\u003c/b\u003e Recent Reviews Calabasas\u003cbr\u003e Classic 2010 - 5k \u003cb\u003e10k\u003c/b\u003e Runs reviews. Get Directions. Start Address. End Address \u003cb\u003e...\u003c/b\u003e ","meta": {"startDate": "2010-11-14","eventDate": "2010-11-14T08:00:00-08:00","location": "Calabasas Park Centre","tag": ["event:10", "Green:10", "Running:10"],"state": "California","eventLongitude": "-118.6789","endDate": "2010-11-14","locationName": "Calabasas Park Centre","splitMediaType": ["Event", "1 mile", "10K", "5K"],"endTime": "8:00:00","mediaType": ["Event", "Event\\1 mile", "Event\\10K", "Event\\5K"],"google-site-verification": "","city": "Calabasas","startTime": "8:00:00","assetId": ["11B01475-8C65-4F9C-A4AC-2A3FA55FE8CD", "11b01475-8c65-4f9c-a4ac-2a3fa55fe8cd"],"eventId": "1810531","participationCriteria": "All","description": "","longitude": "-118.6789","onlineDonationAvailable": "false","substitutionUrl": "1810531","assetName": ["Calabasas Classic 2010 - 5k 10k Runs", "Calabasas Classic 2010 - 5k 10k Runs"],"zip": "91302","contactPhone": "818-715-0428","sortDate": "2000-11-14","eventState": "California","eventLatitude": "34.12794","keywords": "Event","eventAddress": "23975 Park Sorrento","contactEmail": "rot10kd@yahoo.com","onlineMembershipAvailable": "false","trackbackurl": "http://www.active.com/running/calabasas-ca/calabasas-classic-5k-10k-runs-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-04 07:30:26.307","eventZip": "91302","latitude": "34.12794","UpdateDateTime": "8/18/2010 10:16:26 AM","channel": ["Running", "Walking"]}}]}',
@@ -107,6 +107,52 @@ describe Search do
107
107
  a.address[:lng].should_not be_nil
108
108
  end
109
109
  end
110
+
111
+ end
112
+
113
+ describe "Call Live Data" do
114
+ it "should find only events in the future" do
115
+ results = Search.search( {} )
116
+ results.should have(10).items
117
+ results.each do |a|
118
+ a.start_date.should satisfy { |d|
119
+ d >= Date.today
120
+ }
121
+ end
122
+ end
123
+
124
+ it "should find only events with in a range" do
125
+ results = Search.search( {:start_date => Date.new(2010,1,1), :end_date => Date.new(2010,2,1)} )
126
+ results.should have(10).items
127
+ results.each do |a|
128
+ a.start_date.should satisfy { |d|
129
+ d >= Date.new(2010,1,1) and d <= Date.new(2010,2,1)
130
+ }
131
+ end
132
+ end
133
+
134
+ it "should find events after the start date" do
135
+ results = Search.search( {:start_date => Date.new(2010,1,1), :num_results => 50} )
136
+ results.should have(50).items
137
+ results.each do |a|
138
+ a.start_date.should satisfy { |d|
139
+ d >= Date.new(2010,1,1)
140
+ }
141
+ end
142
+ end
110
143
 
144
+ it "should find only running activities" do
145
+ results = Search.search( {:channels => ['Running'],
146
+ :start_date => Date.new(2010,1,1), :num_results => 20} )
147
+ results.should have(20).items
148
+ results.each do |a|
149
+ puts "-#{a.category}-"
150
+ a.category.should satisfy { |d|
151
+ d == 'Running'
152
+ }
153
+ end
154
+
155
+
156
+ end
111
157
 
112
158
  end
data/version.txt CHANGED
@@ -1 +1 @@
1
- 0.0.1
1
+ 0.0.2
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: Active
3
3
  version: !ruby/object:Gem::Version
4
- hash: 29
4
+ hash: 27
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 1
10
- version: 0.0.1
9
+ - 2
10
+ version: 0.0.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Jonathan Spooner, Brian Levine
@@ -46,9 +46,9 @@ extra_rdoc_files:
46
46
  - bin/Active
47
47
  - version.txt
48
48
  files:
49
- - .DS_Store
50
49
  - .bnsignore
51
50
  - Active-0.0.0.gem
51
+ - Active-0.0.1.gem
52
52
  - Active.gemspec
53
53
  - History.txt
54
54
  - README.txt
data/.DS_Store DELETED
Binary file