Active 0.0.4 → 0.0.5
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/Active.gemspec +6 -6
- data/README.txt +1 -1
- data/bin/Active +0 -0
- data/lib/services/search.rb +156 -236
- data/spec/search_spec.rb +42 -12
- data/version.txt +1 -1
- metadata +11 -6
- data/lib/.DS_Store +0 -0
data/Active.gemspec
CHANGED
|
@@ -2,22 +2,22 @@
|
|
|
2
2
|
|
|
3
3
|
Gem::Specification.new do |s|
|
|
4
4
|
s.name = %q{Active}
|
|
5
|
-
s.version = "0.0.
|
|
5
|
+
s.version = "0.0.5"
|
|
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"]
|
|
9
|
-
s.date = %q{2010-09-
|
|
9
|
+
s.date = %q{2010-09-02}
|
|
10
10
|
s.default_executable = %q{Active}
|
|
11
11
|
s.description = %q{Search api for Active Network}
|
|
12
12
|
s.email = %q{jspooner [at] gmail.com}
|
|
13
13
|
s.executables = ["Active"]
|
|
14
|
-
s.extra_rdoc_files = ["History.txt", "README.txt", "bin/Active", "
|
|
15
|
-
s.files = [".bnsignore", "Active.gemspec", "History.txt", "README.txt", "Rakefile", "bin/Active", "lib
|
|
14
|
+
s.extra_rdoc_files = ["History.txt", "README.txt", "bin/Active", "version.txt"]
|
|
15
|
+
s.files = [".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"]
|
|
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"]
|
|
19
19
|
s.rubyforge_project = %q{Active}
|
|
20
|
-
s.rubygems_version = %q{1.3.
|
|
20
|
+
s.rubygems_version = %q{1.3.7}
|
|
21
21
|
s.summary = %q{Search api for Active Network}
|
|
22
22
|
s.test_files = ["test/test_Active.rb"]
|
|
23
23
|
|
|
@@ -25,7 +25,7 @@ Gem::Specification.new do |s|
|
|
|
25
25
|
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
|
26
26
|
s.specification_version = 3
|
|
27
27
|
|
|
28
|
-
if Gem::Version.new(Gem::
|
|
28
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
|
29
29
|
s.add_development_dependency(%q<bones>, [">= 3.4.7"])
|
|
30
30
|
else
|
|
31
31
|
s.add_dependency(%q<bones>, [">= 3.4.7"])
|
data/README.txt
CHANGED
data/bin/Active
CHANGED
|
File without changes
|
data/lib/services/search.rb
CHANGED
|
@@ -8,6 +8,7 @@ require 'active_record'
|
|
|
8
8
|
module Active
|
|
9
9
|
module Services
|
|
10
10
|
|
|
11
|
+
# we should remove this class and just replace with symbols
|
|
11
12
|
class Sort
|
|
12
13
|
def self.DATE_ASC
|
|
13
14
|
"date_asc"
|
|
@@ -19,7 +20,8 @@ module Active
|
|
|
19
20
|
"relevance"
|
|
20
21
|
end
|
|
21
22
|
end
|
|
22
|
-
|
|
23
|
+
|
|
24
|
+
# we should remove this class and just replace with symbols
|
|
23
25
|
class Facet
|
|
24
26
|
def self.ACTIVITIES
|
|
25
27
|
"activities"
|
|
@@ -35,220 +37,127 @@ module Active
|
|
|
35
37
|
|
|
36
38
|
def self.CHANNELS
|
|
37
39
|
{
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
:boat_licensing_departments => "travel%5Cboat_licensing_departments",
|
|
160
|
-
:lodges_bandbs_country_inns_hostels => "travel%5Clodges_bandbs_country_inns_hostels",
|
|
161
|
-
:hotels_resorts_motels => "travel%5Chotels_resorts_motels",
|
|
162
|
-
:condo_rental_time_share => "travel%5Ccondo_rental_time_share",
|
|
163
|
-
:charters_tours => "travel%5Ccharters_tours",
|
|
164
|
-
:cruises => "travel%5Ccruises",
|
|
165
|
-
:gear => "gear",
|
|
166
|
-
:sony_gps => "gear%5Csony_gps",
|
|
167
|
-
:mind_and_body => "mind_and_body",
|
|
168
|
-
:meditation => "mind_and_body%5Cmeditation",
|
|
169
|
-
:pilates => "mind_and_body%5Cpilates",
|
|
170
|
-
:yoga => "mind_and_body%5Cyoga",
|
|
171
|
-
:women => "women",
|
|
172
|
-
:gift_guide => "women%5Cgift_guide",
|
|
173
|
-
:fit_pregnancy => "women%5Cfit_pregnancy",
|
|
174
|
-
:lifestyle_vehicles => "lifestyle_vehicles",
|
|
175
|
-
:community_services => "community_services",
|
|
176
|
-
:parks_and_recs => "community_services%5Cparks_and_recs",
|
|
177
|
-
:private_gated_community_rec => "community_services%5Cprivate_gated_community_rec",
|
|
178
|
-
:summer_and_day_camps => "community_services%5Csummer_and_day_camps",
|
|
179
|
-
:military_recreation => "community_services%5Cmilitary_recreation",
|
|
180
|
-
:libraries => "community_services%5Clibraries",
|
|
181
|
-
:business_training_professional_and_personal_development => "community_services%5Cbusiness_training_professional_and_personal_development",
|
|
182
|
-
:art_music_voice_dance_acting => "community_services%5Cart_music_voice_dance_acting",
|
|
183
|
-
:flea_markets_swap_meets => "community_services%5Cflea_markets_swap_meets",
|
|
184
|
-
:non_profit_services => "non_profit_services",
|
|
185
|
-
:ymca_jcc_boys_and_girls_clubs => "non_profit_services%5Cymca_jcc_boys_and_girls_clubs",
|
|
186
|
-
:boy_scouts_girls_scouts => "non_profit_services%5Cboy_scouts_girls_scouts",
|
|
187
|
-
:religious => "non_profit_services%5Creligious",
|
|
188
|
-
:giving_and_fundraising => "giving_and_fundraising",
|
|
189
|
-
:health_and_disease => "giving_and_fundraising%5Chealth_and_disease",
|
|
190
|
-
:political => "giving_and_fundraising%5Cpolitical",
|
|
191
|
-
:environment => "giving_and_fundraising%5Cenvironment",
|
|
192
|
-
:faith => "giving_and_fundraising%5Cfaith",
|
|
193
|
-
:animals => "giving_and_fundraising%5Canimals",
|
|
194
|
-
:educational_support => "giving_and_fundraising%5Ceducational_support",
|
|
195
|
-
:international => "giving_and_fundraising%5Cinternational",
|
|
196
|
-
:other => "giving_and_fundraising%5Cother",
|
|
197
|
-
:attractions => "attractions",
|
|
198
|
-
:aquatic_parks => "attractions%5Caquatic_parks",
|
|
199
|
-
:amusement_parks => "attractions%5Camusement_parks",
|
|
200
|
-
:zoos => "attractions%5Czoos",
|
|
201
|
-
:aquariums => "attractions%5Caquariums",
|
|
202
|
-
:science_and_nature_centers => "attractions%5Cscience_and_nature_centers",
|
|
203
|
-
:museums => "attractions%5Cmuseums",
|
|
204
|
-
:general_admission_concerts_and_events => "attractions%5Cgeneral_admission_concerts_and_events",
|
|
205
|
-
:ski_resorts => "attractions%5Cski_resorts",
|
|
206
|
-
:carnivals => "attractions%5Ccarnivals",
|
|
207
|
-
:miniature_golf => "attractions%5Cminiature_golf",
|
|
208
|
-
:education => "education",
|
|
209
|
-
:universities => "education%5Cuniversities",
|
|
210
|
-
:community_junior_colleges => "education%5Ccommunity_junior_colleges",
|
|
211
|
-
:public_school_boards => "education%5Cpublic_school_boards",
|
|
212
|
-
:continuing_education_departments => "education%5Ccontinuing_education_departments",
|
|
213
|
-
:high_schools => "education%5Chigh_schools",
|
|
214
|
-
:private_schools => "education%5Cprivate_schools",
|
|
215
|
-
:pre_schools => "education%5Cpre_schools",
|
|
216
|
-
:youth_academic_extracurricular => "education%5Cyouth_academic_extracurricular",
|
|
217
|
-
:government => "government",
|
|
218
|
-
:city_hall => "government%5Ccity_hall",
|
|
219
|
-
:parking => "government%5Cparking",
|
|
220
|
-
:animal_licensing => "government%5Canimal_licensing",
|
|
221
|
-
:municipal_business_licensing => "government%5Cmunicipal_business_licensing",
|
|
222
|
-
:traffic_ticketing => "government%5Ctraffic_ticketing",
|
|
223
|
-
:utility_billing => "government%5Cutility_billing",
|
|
224
|
-
:building_permits => "government%5Cbuilding_permits",
|
|
225
|
-
:taxes => "government%5Ctaxes",
|
|
226
|
-
:state_dmvs => "government%5Cstate_dmvs",
|
|
227
|
-
:federal_government => "government%5Cfederal_government",
|
|
228
|
-
:business_and_commerce => "business_and_commerce",
|
|
229
|
-
:corporations => "business_and_commerce%5Ccorporations",
|
|
230
|
-
:conferences_and_conventions => "business_and_commerce%5Cconferences_and_conventions",
|
|
231
|
-
:affinity_groups => "business_and_commerce%5Caffinity_groups",
|
|
232
|
-
:counseling_therapy => "business_and_commerce%5Ccounseling_therapy",
|
|
233
|
-
:pet_care => "business_and_commerce%5Cpet_care",
|
|
234
|
-
:beauty_and_personal_care => "business_and_commerce%5Cbeauty_and_personal_care",
|
|
235
|
-
:restaurants => "business_and_commerce%5Crestaurants",
|
|
236
|
-
:high_school => "high_school",
|
|
237
|
-
:hs_activities => "high_school%5Chs_activities",
|
|
238
|
-
:hs_varsity_sports_club_sports => "high_school%5Chs_varsity_sports_club_sports",
|
|
239
|
-
:continuing_education => "high_school%5Ccontinuing_education",
|
|
240
|
-
:scouts => "scouts",
|
|
241
|
-
:bsa => "scouts%5Cbsa",
|
|
242
|
-
:gsus4h => "scouts%5Cgsus4h",
|
|
243
|
-
:'4h' => "scouts%5C4h",
|
|
244
|
-
:campfire => "scouts%5Ccampfire",
|
|
245
|
-
:sea_scouts => "scouts%5Csea_scouts",
|
|
246
|
-
:fccla => "scouts%5Cfccla",
|
|
247
|
-
:reunions => "reunions",
|
|
248
|
-
:teams => "teams",
|
|
249
|
-
:gift_guide => "teams%5Cgift_guide",
|
|
250
|
-
:golf_tennis => "golf_tennis",
|
|
251
|
-
:gift_guide => "golf_tennis%5Cgift_guide"
|
|
40
|
+
:active_lifestyle => '',
|
|
41
|
+
:fitness => 'Fitness',
|
|
42
|
+
:body_building => 'Fitness\Body Building',
|
|
43
|
+
:boxing => 'Fitness\Boxing',
|
|
44
|
+
:weight_lifting => 'Fitness\Weight Lifting',
|
|
45
|
+
:gear => 'Gear',
|
|
46
|
+
:lifestyle_vehicles => 'Lifestyle Vehicles',
|
|
47
|
+
:mind_mody => 'Mind & Body',
|
|
48
|
+
:meditation => 'Mind & Body\Meditation',
|
|
49
|
+
:pilates => 'Mind & Body\Pilates',
|
|
50
|
+
:yoga => 'Mind & Body\Yoga',
|
|
51
|
+
:nutrition => 'Nutrition',
|
|
52
|
+
:travel => 'Travel',
|
|
53
|
+
:women => 'Women',
|
|
54
|
+
:other => 'Other',
|
|
55
|
+
:corporate => 'Corporate',
|
|
56
|
+
:not_specified => 'Not Specified',
|
|
57
|
+
:unknown => 'Unknown',
|
|
58
|
+
:special_interest => 'Special+Interest',
|
|
59
|
+
:giving => 'Giving',
|
|
60
|
+
:parks_recreation => 'Parks & Recreation',
|
|
61
|
+
:gear => 'Parks & Recreation\Gear',
|
|
62
|
+
:mind_body => 'Parks & Recreation\Mind & Body',
|
|
63
|
+
:travel => 'Parks & Recreation\Travel',
|
|
64
|
+
:vehicles => 'Parks & Recreation\Vehicles',
|
|
65
|
+
:women => 'Parks & Recreation\Women',
|
|
66
|
+
:reunions => 'Reunions',
|
|
67
|
+
:sports => 'Sports',
|
|
68
|
+
:action_sports => 'Action Sports',
|
|
69
|
+
:auto_racing => 'Action Sports\Auto Racing',
|
|
70
|
+
:bmx => 'Action Sports\BMX',
|
|
71
|
+
:dirt_bike_racing => 'Action Sports\Dirt Bike Racing',
|
|
72
|
+
:motocross => 'Action Sports\Motocross',
|
|
73
|
+
:motorcycle_racing => 'Action Sports\Motorcycle Racing',
|
|
74
|
+
:skateboarding => 'Action Sports\Skateboarding',
|
|
75
|
+
:skydiving => 'Action Sports\Skydiving',
|
|
76
|
+
:surfing => 'Action Sports\Surfing',
|
|
77
|
+
:wake_kite_boarding => 'Action Sports\Wake/Kite Boarding',
|
|
78
|
+
:water_skiing => 'Action Sports\Water Skiing',
|
|
79
|
+
:wind_surfing => 'Action Sports\Wind Surfing',
|
|
80
|
+
:baseball => 'Baseball',
|
|
81
|
+
:little_league_baseball => 'Baseball\Little League Baseball',
|
|
82
|
+
:tee_ball => 'Baseball\Tee Ball',
|
|
83
|
+
:basketball => 'Basketball',
|
|
84
|
+
:cheerleading => 'Cheerleading',
|
|
85
|
+
:cycling => 'Cycling',
|
|
86
|
+
:field_hockey => 'Field Hockey',
|
|
87
|
+
:football => 'Football',
|
|
88
|
+
:flag_football => 'Football\Flag Football',
|
|
89
|
+
:football_au => 'Football\Football-AU',
|
|
90
|
+
:golf => 'Golf',
|
|
91
|
+
:ice_hockey => 'Ice Hockey',
|
|
92
|
+
:lacrosse => 'Lacrosse',
|
|
93
|
+
:more_sports => 'More Sports',
|
|
94
|
+
:adventure_racing => 'More Sports\Adventure Racing',
|
|
95
|
+
:archery => 'More Sports\Archery',
|
|
96
|
+
:badminton => 'More Sports\Badminton',
|
|
97
|
+
:billiards => 'More Sports\Billiards',
|
|
98
|
+
:bowling => 'More Sports\Bowling',
|
|
99
|
+
:cricket => 'More Sports\Cricket',
|
|
100
|
+
:croquet => 'More Sports\Croquet',
|
|
101
|
+
:curling => 'More Sports\Curling',
|
|
102
|
+
:dance => 'More Sports\Dance',
|
|
103
|
+
:disc_sports => 'More Sports\Disc Sports',
|
|
104
|
+
:dodgeball => 'More Sports\Dodgeball',
|
|
105
|
+
:duathlon => 'More Sports\Duathlon',
|
|
106
|
+
:equestrian => 'More Sports\Equestrian',
|
|
107
|
+
:fencing => 'More Sports\Fencing',
|
|
108
|
+
:figure_skating => 'More Sports\Figure Skating',
|
|
109
|
+
:gymnastics => 'More Sports\Gymnastics',
|
|
110
|
+
:inline_hockey => 'More Sports\Inline Hockey',
|
|
111
|
+
:inline_skating => 'More Sports\Inline Skating',
|
|
112
|
+
:kickball => 'More Sports\Kickball',
|
|
113
|
+
:martial_arts => 'More Sports\Martial Arts',
|
|
114
|
+
:paintball => 'More Sports\Paintball',
|
|
115
|
+
:polo => 'More Sports\Polo',
|
|
116
|
+
:racquetball => 'More Sports\Racquetball',
|
|
117
|
+
:rowing => 'More Sports\Rowing',
|
|
118
|
+
:rugby => 'More Sports\Rugby',
|
|
119
|
+
:scouting => 'More Sports\Scouting',
|
|
120
|
+
:scuba_diving => 'More Sports\Scuba Diving',
|
|
121
|
+
:skating => 'More Sports\Skating',
|
|
122
|
+
:squash => 'More Sports\Squash',
|
|
123
|
+
:ultimate_frisbee => 'More Sports\Ultimate Frisbee',
|
|
124
|
+
:water_polo => 'More Sports\Water Polo',
|
|
125
|
+
:mountain_biking => 'Mountain Biking',
|
|
126
|
+
:outdoors => 'Outdoors',
|
|
127
|
+
:canoeing => 'Outdoors\Canoeing',
|
|
128
|
+
:climbing => 'Outdoors\Climbing',
|
|
129
|
+
:hiking => 'Outdoors\Hiking',
|
|
130
|
+
:kayaking => 'Outdoors\Kayaking',
|
|
131
|
+
:orienteering => 'Outdoors\Orienteering',
|
|
132
|
+
:outrigging => 'Outdoors\Outrigging',
|
|
133
|
+
:rafting => 'Outdoors\Rafting',
|
|
134
|
+
:racquetball => 'Racquetball',
|
|
135
|
+
:rugby => 'Rugby',
|
|
136
|
+
:running => 'Running',
|
|
137
|
+
:cross_country => 'Running\Cross Country',
|
|
138
|
+
:marathon_running => 'Running\Marathon Running',
|
|
139
|
+
:track_field => 'Running\Track & Field',
|
|
140
|
+
:trail_running => 'Running\Trail Running',
|
|
141
|
+
:sailing => 'Sailing',
|
|
142
|
+
:snow_sports => 'Snow Sports',
|
|
143
|
+
:skiing => 'Snow Sports\Skiing',
|
|
144
|
+
:snowboarding => 'Snow Sports\Snowboarding',
|
|
145
|
+
:snowshoeing => 'Snow Sports\Snowshoeing',
|
|
146
|
+
:soccer => 'Soccer',
|
|
147
|
+
:softball => 'Softball',
|
|
148
|
+
:softball_dixie => 'Softball\Softball-Dixie',
|
|
149
|
+
:softball_fast_pitch => 'Softball\Softball-Fast Pitch',
|
|
150
|
+
:softball_slow_pitch => 'Softball\Softball-Slow Pitch',
|
|
151
|
+
:squash => 'Squash',
|
|
152
|
+
:swimming => 'Swimming',
|
|
153
|
+
:diving => 'Swimming\Diving',
|
|
154
|
+
:tennis => 'Tennis',
|
|
155
|
+
:other_tennis => 'Tennis\Other Tennis',
|
|
156
|
+
:usta => 'Tennis\USTA',
|
|
157
|
+
:triathlon => 'Triathlon',
|
|
158
|
+
:volleyball => 'Volleyball',
|
|
159
|
+
:walking => 'Walking',
|
|
160
|
+
:wrestling => 'Wrestling'
|
|
252
161
|
}
|
|
253
162
|
end
|
|
254
163
|
|
|
@@ -275,20 +184,20 @@ module Active
|
|
|
275
184
|
|
|
276
185
|
def self.construct_url(arg_options={})
|
|
277
186
|
options = {
|
|
278
|
-
:api_key
|
|
279
|
-
:view
|
|
280
|
-
:facet
|
|
281
|
-
:sort
|
|
282
|
-
:radius
|
|
283
|
-
:meta
|
|
187
|
+
:api_key => "",
|
|
188
|
+
:view => "json",
|
|
189
|
+
:facet => Facet.ACTIVITIES,
|
|
190
|
+
:sort => Sort.DATE_ASC,
|
|
191
|
+
:radius => "10",
|
|
192
|
+
:meta => "",
|
|
284
193
|
:num_results => "10",
|
|
285
|
-
:page
|
|
286
|
-
:location
|
|
287
|
-
:search
|
|
288
|
-
:keywords
|
|
289
|
-
:channels
|
|
290
|
-
:start_date
|
|
291
|
-
:end_date
|
|
194
|
+
:page => "1",
|
|
195
|
+
:location => "",
|
|
196
|
+
:search => "",
|
|
197
|
+
:keywords => [],
|
|
198
|
+
:channels => nil,
|
|
199
|
+
:start_date => "today",
|
|
200
|
+
:end_date => "+"
|
|
292
201
|
}
|
|
293
202
|
options.merge!(arg_options)
|
|
294
203
|
|
|
@@ -298,11 +207,17 @@ module Active
|
|
|
298
207
|
options[:keywords] = options[:keywords].split(",")
|
|
299
208
|
options[:keywords].each { |k| k.strip! }
|
|
300
209
|
end
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
210
|
+
if options[:channels] != nil
|
|
211
|
+
|
|
212
|
+
channel_keys = []
|
|
213
|
+
options[:channels].each do |c|
|
|
214
|
+
c.to_sym
|
|
215
|
+
if self.CHANNELS.include?(c)
|
|
216
|
+
channel_keys << self.CHANNELS[c]
|
|
217
|
+
end
|
|
218
|
+
end
|
|
219
|
+
|
|
220
|
+
channels_a = channel_keys.collect { |channel| "meta:channel=#{Search.double_encode_channel(channel)}" }
|
|
306
221
|
end
|
|
307
222
|
|
|
308
223
|
meta_data = ""
|
|
@@ -318,18 +233,23 @@ module Active
|
|
|
318
233
|
end
|
|
319
234
|
meta_data += "meta:startDate:daterange:#{options[:start_date]}..#{options[:end_date]}"
|
|
320
235
|
|
|
321
|
-
#
|
|
322
236
|
# if @asset_type_id!=nil
|
|
323
237
|
# @meta = @meta + "+AND+" if @meta!=""
|
|
324
238
|
# @meta = @meta + "inmeta:assetTypeId=#{@asset_type_id}"
|
|
325
239
|
# end
|
|
326
240
|
#
|
|
327
241
|
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}"
|
|
328
|
-
puts url
|
|
242
|
+
# puts url
|
|
329
243
|
url
|
|
330
244
|
end
|
|
331
245
|
|
|
332
|
-
|
|
246
|
+
private
|
|
247
|
+
def self.double_encode_channel str
|
|
248
|
+
str = URI.escape(str, Regexp.new("[^#{URI::PATTERN::UNRESERVED}]"))
|
|
249
|
+
str = URI.escape(str, Regexp.new("[^#{URI::PATTERN::UNRESERVED}]"))
|
|
250
|
+
str.gsub!(/\-/,"%252D")
|
|
251
|
+
str
|
|
252
|
+
end
|
|
333
253
|
|
|
334
254
|
end
|
|
335
255
|
end
|
data/spec/search_spec.rb
CHANGED
|
@@ -48,15 +48,30 @@ describe "Search URL Construction" do
|
|
|
48
48
|
uri.query.include?("num=10").should be_true
|
|
49
49
|
uri.query.include?("daterange:today..+").should be_true
|
|
50
50
|
end
|
|
51
|
+
|
|
52
|
+
it "should construct a valid url with channels array" do
|
|
53
|
+
uri = URI.parse( Search.construct_url( {:channels => [:running, :tri,:cycling, :yoga]} ) )
|
|
54
|
+
uri.query.include?("m=meta:channel=Running+OR+meta:channel=Cycling+OR+meta:channel=Mind%2520%2526%2520Mody%255CYoga").should be_true
|
|
55
|
+
end
|
|
51
56
|
|
|
52
57
|
it "should send valid channel info" do
|
|
53
|
-
uri = URI.parse( Search.construct_url({:channels => [
|
|
54
|
-
uri.query.include?("meta:channel=Running+OR+meta:channel=Triathlon").should be_true
|
|
58
|
+
uri = URI.parse( Search.construct_url({:channels => [:running,:triathlon]}) )
|
|
59
|
+
uri.query.include?("meta:channel=Running+OR+meta:channel=Triathlon").should be_true
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
it "should send the correct channel value for everything in Search.CHANNELS" do
|
|
63
|
+
Search.CHANNELS.each do |key,value|
|
|
64
|
+
uri = URI.parse( Search.construct_url({:channels => [key]}) )
|
|
65
|
+
value = URI.escape(value, Regexp.new("[^#{URI::PATTERN::UNRESERVED}]"))
|
|
66
|
+
value = URI.escape(value, Regexp.new("[^#{URI::PATTERN::UNRESERVED}]"))
|
|
67
|
+
value.gsub!(/\-/,"%252D")
|
|
68
|
+
uri.query.include?("meta:channel=#{value}").should be_true
|
|
69
|
+
end
|
|
55
70
|
end
|
|
56
71
|
|
|
57
72
|
it "should send a valid start and end date" do
|
|
58
|
-
uri = URI.parse( Search.construct_url() )
|
|
59
|
-
uri.query.include?("daterange:today..+").should be_true
|
|
73
|
+
uri = URI.parse( Search.construct_url() )
|
|
74
|
+
uri.query.include?("daterange:today..+").should be_true
|
|
60
75
|
end
|
|
61
76
|
|
|
62
77
|
it "should send a valid start and end date" do
|
|
@@ -65,11 +80,16 @@ describe "Search URL Construction" do
|
|
|
65
80
|
end
|
|
66
81
|
|
|
67
82
|
it "should be valid with date range and channels" do
|
|
68
|
-
uri = URI.parse( Search.construct_url({:channels => [
|
|
69
|
-
:start_date => Date.new(2010, 11, 1),
|
|
83
|
+
uri = URI.parse( Search.construct_url({:channels => [:running, :triathlon],
|
|
84
|
+
:start_date => Date.new(2010, 11, 1),
|
|
70
85
|
:end_date => Date.new(2010, 11, 15)}) )
|
|
71
|
-
uri.query.include?("meta:channel=Running+OR+meta:channel=Triathlon").should be_true
|
|
72
|
-
uri.query.include?("daterange:11%2F01%2F2010..11%2F15%2F2010").should be_true
|
|
86
|
+
uri.query.include?("meta:channel=Running+OR+meta:channel=Triathlon").should be_true
|
|
87
|
+
uri.query.include?("daterange:11%2F01%2F2010..11%2F15%2F2010").should be_true
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
it "should pass the search radius" do
|
|
91
|
+
uri = URI.parse( Search.construct_url({:radius => '666'}) )
|
|
92
|
+
uri.query.include?("r=666").should be_true
|
|
73
93
|
end
|
|
74
94
|
|
|
75
95
|
end
|
|
@@ -122,7 +142,7 @@ end
|
|
|
122
142
|
|
|
123
143
|
describe "Call Live Data" do
|
|
124
144
|
it "should find only events in the future" do
|
|
125
|
-
results = Search.search( {} )
|
|
145
|
+
results = Search.search( { :keywords => ["swim"]} )
|
|
126
146
|
results.should have(10).items
|
|
127
147
|
results.each do |a|
|
|
128
148
|
a.start_date.should satisfy { |d|
|
|
@@ -151,8 +171,10 @@ describe "Call Live Data" do
|
|
|
151
171
|
end
|
|
152
172
|
end
|
|
153
173
|
|
|
174
|
+
# our model should be updated to handle multiple categories
|
|
175
|
+
# I'm sure running is with in all of these events but we're only storing 1.
|
|
154
176
|
it "should find only running activities" do
|
|
155
|
-
results = Search.search( {:channels => [
|
|
177
|
+
results = Search.search( {:channels => [:running],
|
|
156
178
|
:start_date => Date.new(2010,1,1), :num_results => 20} )
|
|
157
179
|
results.should have(20).items
|
|
158
180
|
results.each do |a|
|
|
@@ -161,16 +183,24 @@ describe "Call Live Data" do
|
|
|
161
183
|
d.include?('Running' )
|
|
162
184
|
}
|
|
163
185
|
end
|
|
164
|
-
|
|
165
|
-
|
|
166
186
|
end
|
|
167
187
|
|
|
188
|
+
it "should find yoga activities by channel" do
|
|
189
|
+
results = Search.search( {:channels => [:yoga]} )
|
|
190
|
+
results.should have(10).items
|
|
191
|
+
end
|
|
192
|
+
|
|
193
|
+
|
|
168
194
|
it "should find activities that have been recently added"
|
|
169
195
|
|
|
170
196
|
it "should find upcoming events"
|
|
171
197
|
|
|
172
198
|
it "should find popular events"
|
|
173
199
|
|
|
200
|
+
it "should order by trending with params"
|
|
201
|
+
# results = Search.search( {:channels => ['Running'], :sort => 'trending'} )
|
|
202
|
+
# end
|
|
203
|
+
|
|
174
204
|
it "should order by RELEVANCE"
|
|
175
205
|
|
|
176
206
|
it "should order by date DATE_ASC"
|
data/version.txt
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
0.0.
|
|
1
|
+
0.0.5
|
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: 21
|
|
4
5
|
prerelease: false
|
|
5
6
|
segments:
|
|
6
7
|
- 0
|
|
7
8
|
- 0
|
|
8
|
-
-
|
|
9
|
-
version: 0.0.
|
|
9
|
+
- 5
|
|
10
|
+
version: 0.0.5
|
|
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-
|
|
18
|
+
date: 2010-09-02 00:00:00 -07:00
|
|
18
19
|
default_executable:
|
|
19
20
|
dependencies:
|
|
20
21
|
- !ruby/object:Gem::Dependency
|
|
21
22
|
name: bones
|
|
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: 25
|
|
27
30
|
segments:
|
|
28
31
|
- 3
|
|
29
32
|
- 4
|
|
@@ -41,7 +44,6 @@ extra_rdoc_files:
|
|
|
41
44
|
- History.txt
|
|
42
45
|
- README.txt
|
|
43
46
|
- bin/Active
|
|
44
|
-
- lib/.DS_Store
|
|
45
47
|
- version.txt
|
|
46
48
|
files:
|
|
47
49
|
- .bnsignore
|
|
@@ -50,7 +52,6 @@ files:
|
|
|
50
52
|
- README.txt
|
|
51
53
|
- Rakefile
|
|
52
54
|
- bin/Active
|
|
53
|
-
- lib/.DS_Store
|
|
54
55
|
- lib/Active.rb
|
|
55
56
|
- lib/services/activity.rb
|
|
56
57
|
- lib/services/search.rb
|
|
@@ -72,23 +73,27 @@ rdoc_options:
|
|
|
72
73
|
require_paths:
|
|
73
74
|
- lib
|
|
74
75
|
required_ruby_version: !ruby/object:Gem::Requirement
|
|
76
|
+
none: false
|
|
75
77
|
requirements:
|
|
76
78
|
- - ">="
|
|
77
79
|
- !ruby/object:Gem::Version
|
|
80
|
+
hash: 3
|
|
78
81
|
segments:
|
|
79
82
|
- 0
|
|
80
83
|
version: "0"
|
|
81
84
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
85
|
+
none: false
|
|
82
86
|
requirements:
|
|
83
87
|
- - ">="
|
|
84
88
|
- !ruby/object:Gem::Version
|
|
89
|
+
hash: 3
|
|
85
90
|
segments:
|
|
86
91
|
- 0
|
|
87
92
|
version: "0"
|
|
88
93
|
requirements: []
|
|
89
94
|
|
|
90
95
|
rubyforge_project: Active
|
|
91
|
-
rubygems_version: 1.3.
|
|
96
|
+
rubygems_version: 1.3.7
|
|
92
97
|
signing_key:
|
|
93
98
|
specification_version: 3
|
|
94
99
|
summary: Search api for Active Network
|
data/lib/.DS_Store
DELETED
|
Binary file
|