Active 0.0.11 → 0.0.12

Sign up to get free protection for your applications and to get access to all the features.
data/bin/Active CHANGED
File without changes
data/lib/.DS_Store ADDED
Binary file
Binary file
@@ -0,0 +1,151 @@
1
+ module Active
2
+ module Services
3
+
4
+ class ActiveWorksError < StandardError; end
5
+
6
+ class ActiveWorks < IActivity
7
+ require 'nokogiri'
8
+ require 'open-uri'
9
+ attr_accessor :asset_type_id
10
+
11
+ def initialize(data={})
12
+ # need to hold on to original data
13
+ @data = HashWithIndifferentAccess.new(data) || HashWithIndifferentAccess.new
14
+ @api_data_loaded = false
15
+ @asset_type_id = "DFAA997A-D591-44CA-9FB7-BF4A4C8984F1"
16
+ get_app_api
17
+ end
18
+
19
+ def source
20
+ :active_works
21
+ end
22
+
23
+ def asset_id
24
+ if @data.has_key?("eventDetailDto") && @data["eventDetailDto"].has_key?("id")
25
+ @data["eventDetailDto"]["id"]
26
+ end
27
+ end
28
+
29
+
30
+ def title
31
+ if @data.has_key?("eventDetailDto") && @data["eventDetailDto"].has_key?("name")
32
+ @data["eventDetailDto"]["name"]
33
+ end
34
+ end
35
+
36
+ def event_image_url
37
+ if @data.has_key?("eventDetailDto") && @data["eventDetailDto"].has_key?("logoUrl")
38
+ @data["eventDetailDto"]["logoUrl"]
39
+ end
40
+ end
41
+
42
+ def url
43
+ if @data.has_key?("eventDetailDto") && @data["eventDetailDto"].has_key?("registrationUrl")
44
+ @data["eventDetailDto"]["registrationUrl"]
45
+ end
46
+ end
47
+
48
+ def categories
49
+ [@data["eventDetailDto"]["channels"]]
50
+ end
51
+
52
+ def primary_category
53
+ categories.first
54
+ end
55
+
56
+ def address
57
+ @address = {
58
+ :address => @data["eventDetailDto"]["addressLine1"],
59
+ :city => @data["eventDetailDto"]["addressCity"],
60
+ :state => @data["eventDetailDto"]["state"],
61
+ :zip => @data["eventDetailDto"]["addressPostalCode"],
62
+ :country => @data["eventDetailDto"]["countryName"]
63
+ }
64
+ end
65
+
66
+ def start_date
67
+ DateTime.parse @data["eventDetailDto"]["startDateTimeWithTZ"] if @data.has_key?("eventDetailDto") && @data["eventDetailDto"].has_key?("startDateTimeWithTZ")
68
+ end
69
+
70
+ def start_time
71
+ start_date
72
+ end
73
+
74
+ def end_date
75
+ DateTime.parse @data["eventDetailDto"]["endDateTime"] if @data.has_key?("eventDetailDto") && @data["eventDetailDto"].has_key?("endDateTime")
76
+ end
77
+
78
+ def end_time
79
+ end_date
80
+ end
81
+
82
+
83
+ def category
84
+ primary_category
85
+ end
86
+
87
+ def desc
88
+ if @data.has_key?("eventDetailDto") && @data["eventDetailDto"].has_key?("description")
89
+ # @data["eventDetailDto"]["description"].gsub('\"','"')
90
+ @data["eventDetailDto"]["description"]
91
+ end
92
+ end
93
+
94
+
95
+ # EXAMPLE
96
+ # lazy load the data for some_crazy_method
97
+ # def some_crazy
98
+ # return @some_crazy unless @some_crazy.nil?
99
+ # @some_crazy = @data[:some_crazy_method_from_ats].split replace twist bla bla bla
100
+ # end
101
+
102
+ def self.find_by_id(id) #local id
103
+ return ActiveWorks.new({:id=>id})
104
+ end
105
+
106
+ private
107
+ # def self.get_asset_metadata(id)
108
+ # c = Savon::Client.new("http://api.amp.active.com/asset-service/services/AssetService?wsdl")
109
+ # c.request.headers["Api-Key"] = "6npky9t57235vps5cetm3s7k"
110
+ # r = c.get_asset_metadata do |soap|
111
+ # soap.namespace = "http://api.asset.services.active.com"
112
+ # soap.body = "<context><userId></userId><applicationId></applicationId></context><assetId>#{id}</assetId>"
113
+ # end
114
+ # puts "==========="
115
+ # puts r.to_hash[:get_asset_metadata_response][:out].inspect
116
+ # return r
117
+ # end
118
+ #
119
+ # def self.get_asset_by_id(id)
120
+ # puts "loading ATS"
121
+ # c = Savon::Client.new("http://api.amp.active.com/asset-service/services/AssetService")
122
+ # c.request.headers["Api-Key"] = "6npky9t57235vps5cetm3s7k"
123
+ # r = c.get_asset_by_id! do |soap|
124
+ # soap.namespace = "http://api.asset.services.active.com"
125
+ # soap.body = "<context><userId></userId><applicationId></applicationId></context><assetId>#{id}</assetId>"
126
+ # end
127
+ # return r
128
+ # end
129
+ #
130
+ # def load_metadata
131
+ # puts "loading ATS metadata"
132
+ # metadata = ATS.get_asset_metadata(@asset_id)
133
+ # @data.merge! Hash.from_xml(metadata.to_hash[:get_asset_metadata_response][:out])["importSource"]["asset"]
134
+ # @metadata_loaded=true
135
+ # end
136
+
137
+ def get_app_api
138
+ puts "loading active works api"
139
+ begin
140
+ doc = Nokogiri::XML(open("http://apij.active.com/activeworks/event/#{@data[:id]}"))
141
+ @data.merge! Hash.from_xml doc.to_s
142
+ @api_data_loaded=true
143
+ rescue
144
+ raise ActiveWorksError, "Couldn't find ActiveWorks activity with the id of #{id}"
145
+ return
146
+ end
147
+ end
148
+
149
+ end # end ats
150
+ end
151
+ end
data/lib/services/ats.rb CHANGED
@@ -15,7 +15,7 @@ module Active
15
15
  @data = data || {}
16
16
  @asset_id = data[:asset_id]
17
17
  @url = data[:url]
18
- @asset_id_type = data[:asset_type_id]
18
+ @asset_type_id = data[:asset_type_id]
19
19
  @title = data[:asset_name] if data[:asset_name]
20
20
  @substitution_url = data[:substitution_url]
21
21
  @metadata_loaded = false
@@ -33,7 +33,6 @@ module Active
33
33
  else
34
34
  @title
35
35
  end
36
-
37
36
  end
38
37
 
39
38
  def url
@@ -46,10 +45,15 @@ module Active
46
45
  @url
47
46
  end
48
47
  end
49
-
48
+
50
49
  def categories
51
50
  load_metadata unless @metadata_loaded
52
- @data["channel"]
51
+ categories = @data["channel"]
52
+ if categories.class==String
53
+ [@data["channel"]]
54
+ else
55
+ @data["channel"]
56
+ end
53
57
  end
54
58
 
55
59
  def address
@@ -63,36 +67,46 @@ module Active
63
67
  :lat => @data["latitude"],
64
68
  :lng => @data["longitude"],
65
69
  :country => @data["country"]
66
- }
70
+ }
67
71
  end
68
72
 
69
73
  def start_date
70
74
  load_metadata unless @metadata_loaded
71
75
  if @data.has_key?("startDate")
72
- (DateTime.parse @data["startDate"]).to_date
76
+ if @data.has_key?("startTime")
77
+ (DateTime.parse "#{@data["startDate"]} #{@data["startTime"]}")
78
+ else
79
+ (DateTime.parse @data["startDate"])
80
+ end
73
81
  else
74
82
  nil
75
83
  end
76
84
  end
77
85
 
78
86
  def start_time
79
- load_metadata unless @metadata_loaded
80
- @data["startTime"]
87
+ start_date
81
88
  end
82
89
 
83
- def end_time
90
+ def end_date
84
91
  load_metadata unless @metadata_loaded
85
- @data["endTime"]
92
+ if @data.has_key?("endDate")
93
+ if @data.has_key?("endTime")
94
+ (DateTime.parse "#{@data["endDate"]} #{@data["endTime"]}")
95
+ else
96
+ (DateTime.parse @data["endDate"])
97
+ end
98
+ else
99
+ nil
100
+ end
86
101
  end
87
102
 
88
- def end_date
89
- load_metadata unless @metadata_loaded
90
- DateTime.parse @data["endDate"] if @data.has_key?("endDate")
103
+ def end_time
104
+ end_date
91
105
  end
92
106
 
107
+
93
108
  def category
94
- load_metadata unless @metadata_loaded
95
- @data["channel"]
109
+ categories.first
96
110
  end
97
111
 
98
112
  def desc
@@ -6,8 +6,9 @@ module Active
6
6
  class RegCenter < IActivity
7
7
  require 'nokogiri'
8
8
  require 'open-uri'
9
+ attr_accessor :asset_type_id
9
10
 
10
- attr_reader :metadata_loaded
11
+ # attr_reader :metadata_loaded
11
12
  # EXAMPLE Data hash
12
13
  # {:asset_id=>"A9EF9D79-F859-4443-A9BB-91E1833DF2D5", :substitution_url=>"1878023", :asset_type_name=>"Active.com Event Registration",
13
14
  # :asset_name=>"Fitness, Pilates Mat Class (16 Yrs. &amp; Up)", :url=>"http://www.active.com/page/Event_Details.htm?event_id=1878023",
@@ -15,14 +16,9 @@ module Active
15
16
 
16
17
  def initialize(data={})
17
18
  # need to hold on to original data
18
- @data = data || {}
19
- @asset_id = data[:asset_id]
20
- @url = data[:url]
21
- @asset_id_type = data[:asset_type_id]
22
- @title = data[:asset_name] if data[:asset_name]
23
- @substitution_url = data[:substitution_url]
24
- @metadata_loaded = false
19
+ @data = HashWithIndifferentAccess.new(data) || HashWithIndifferentAccess.new
25
20
  @api_data_loaded = false
21
+ @asset_type_id = "EA4E860A-9DCD-4DAA-A7CA-4A77AD194F65"
26
22
  get_app_api
27
23
  end
28
24
 
@@ -31,61 +27,62 @@ module Active
31
27
  end
32
28
 
33
29
  def title
34
- get_app_api unless @api_data_loaded
35
30
  if @data.has_key?("event") && @data["event"].has_key?("eventName")
36
31
  cleanup_reg_string(@data["event"]["eventName"])
37
- else
38
- load_metadata unless @metadata_loaded
39
- if @data.has_key?("assetName")
40
- @data["assetName"]
41
- else
42
- @title
43
- end
44
32
  end
45
33
  end
46
34
 
47
35
  def event_image_url
48
- get_app_api unless @api_data_loaded
49
36
  if @data.has_key?("event") && @data["event"].has_key?("eventImageUrl")
50
37
  @data["event"]["eventImageUrl"]
51
38
  end
52
39
  end
53
40
 
54
41
  def url
55
- # best info is not in API call
56
- load_metadata unless @metadata_loaded
57
- if @data.has_key?("seourl")
58
- @data["seourl"]
59
- elsif @data.has_key?("trackbackurl")
60
- @data["trackbackurl"]
61
- else
62
- @url
42
+ if @data.has_key?("event") && @data["event"].has_key?("eventDetailsPageUrl")
43
+ @data["event"]["eventDetailsPageUrl"]
44
+ elsif @data.has_key?("event") && @data["event"].has_key?("registrationUrl")
45
+ @data["event"]["registrationUrl"]
46
+ elsif @data.has_key?("event") && @data["event"].has_key?("eventContactUrl")
47
+ @data["event"]["eventContactUrl"]
63
48
  end
64
49
  end
65
50
 
66
51
  def categories
67
- get_app_api unless @api_data_loaded
68
- if @data["event"]["channels"]["channel"]!=nil
69
- @data["event"]["channels"]["channel"].collect {|e| e["channelName"]}
70
- else
71
- load_metadata unless @metadata_loaded
72
- @data["channel"]
52
+ if @data.has_key?("event") && @data["event"].has_key?("channels") && @data["event"]["channels"]!=nil && @data["event"]["channels"].has_key?("channel") && @data["event"]["channels"]["channel"]!=nil
53
+ channels = @data["event"]["channels"]["channel"]
54
+ if channels.class==Array
55
+ @data["event"]["channels"]["channel"].collect {|e| e["channelName"]}
56
+ else
57
+ #hash
58
+ [channels["channelName"]]
59
+ end
60
+ end
61
+ end
62
+
63
+ def asset_id
64
+ if @data.has_key?("event") && @data["event"].has_key?("assetID")
65
+ @data["event"]["assetID"]
73
66
  end
74
67
  end
75
68
 
76
69
  def primary_category
77
- get_app_api unless @api_data_loaded
78
70
  if @data["event"]["channels"]["channel"]!=nil
79
- @data["event"]["channels"]["channel"].each do |c|
80
- return c["channelName"] if c.has_key?("primaryChannel")
81
- end
82
- else
83
- categories.first
71
+ channels = @data["event"]["channels"]["channel"]
72
+ if channels.class==Array
73
+ channels.each do |c|
74
+ return c["channelName"] if c.has_key?("primaryChannel") && c["primaryChannel"]=="true"
75
+ end
76
+ else
77
+ #hash
78
+ return channels["channelName"] if channels.has_key?("primaryChannel") && channels["primaryChannel"]=="true"
79
+ end
80
+ #fallback
81
+ return category
84
82
  end
85
83
  end
86
84
 
87
85
  def address
88
- get_app_api unless @api_data_loaded
89
86
  if @data.has_key?("event") && @data["event"].has_key?("eventAddress") && !@data["event"]["eventAddress"].blank?
90
87
  @address = {
91
88
  :name => @data["event"]["eventLocation"],
@@ -97,39 +94,23 @@ module Active
97
94
  :lng => @data["event"]["longitude"],
98
95
  :country => @data["event"]["eventCountry"]
99
96
  }
100
- else
101
- load_metadata unless @metadata_loaded
102
- @address = {
103
- :name => @data["location"],
104
- :address => @data["address"],
105
- :city => @data["city"],
106
- :state => @data["state"],
107
- :zip => @data["zip"],
108
- :lat => @data["latitude"],
109
- :lng => @data["longitude"],
110
- :country => @data["country"]
111
- }
112
97
  end
113
98
  end
114
99
 
115
100
  def start_date
116
- load_metadata unless @metadata_loaded
117
- DateTime.parse @data["startDate"] if @data.has_key?("startDate")
101
+ DateTime.parse @data["event"]["eventDate"] if @data.has_key?("event") && @data["event"].has_key?("eventDate")
118
102
  end
119
103
 
120
104
  def start_time
121
- load_metadata unless @metadata_loaded
122
- @data["startTime"]
105
+ start_date
123
106
  end
124
107
 
125
108
  def end_time
126
- load_metadata unless @metadata_loaded
127
- @data["endTime"]
109
+ nil
128
110
  end
129
111
 
130
112
  def end_date
131
- load_metadata unless @metadata_loaded
132
- DateTime.parse @data["endDate"] if @data.has_key?("endDate")
113
+ nil
133
114
  end
134
115
 
135
116
  def category
@@ -137,22 +118,20 @@ module Active
137
118
  end
138
119
 
139
120
  def desc
140
- get_app_api unless @api_data_loaded
141
121
  if @data.has_key?("event") && @data["event"].has_key?("briefDescription")
142
122
  ret=@data["event"]["briefDescription"]
143
- if data["event"].has_key?("eventDetails")
144
- data["event"]["eventDetails"]["eventDetail"].each do |detail|
145
- ret +="<div><b>" + detail["eventDetailsName"] + ":</b> " + cleanup_reg_string(detail["eventDetailsValue"]) + "</div>"
123
+ if @data["event"].has_key?("eventDetails") && @data["event"]["eventDetails"]!=nil && @data["event"]["eventDetails"].has_key?("eventDetail")
124
+ eventDetail = @data["event"]["eventDetails"]["eventDetail"]
125
+ if eventDetail.class==Array
126
+ @data["event"]["eventDetails"]["eventDetail"].each do |detail|
127
+ ret +="<div><b>" + detail["eventDetailsName"] + ":</b> " + cleanup_reg_string(detail["eventDetailsValue"]) + "</div>"
128
+ end
129
+ else
130
+ #hash
131
+ ret +="<div><b>" + eventDetail["eventDetailsName"] + ":</b> " + cleanup_reg_string(eventDetail["eventDetailsValue"]) + "</div>"
146
132
  end
147
133
  end
148
134
  ret
149
- else
150
- load_metadata unless @metadata_loaded
151
- if @data.has_key?("allText")
152
- @data["allText"]
153
- elsif @data.has_key?("summary")
154
- @data["summary"]
155
- end
156
135
  end
157
136
  end
158
137
 
@@ -168,52 +147,51 @@ module Active
168
147
  # @some_crazy = @data[:some_crazy_method_from_ats].split replace twist bla bla bla
169
148
  # end
170
149
 
171
- def self.find_by_id(id)
172
- begin
173
- r = self.get_asset_by_id(id)
174
- return RegCenter.new(r.to_hash[:get_asset_by_id_response][:out])
175
- rescue Savon::SOAPFault => e
176
- raise RegCenterError, "Couldn't find activity with the id of #{id}"
177
- return
178
- end
150
+ def self.find_by_id(id) #local id
151
+ return RegCenter.new({:id=>id})
179
152
  end
180
153
 
181
154
  private
182
- def self.get_asset_metadata(id)
183
- c = Savon::Client.new("http://api.amp.active.com/asset-service/services/AssetService?wsdl")
184
- c.request.headers["Api-Key"] = "6npky9t57235vps5cetm3s7k"
185
- r = c.get_asset_metadata do |soap|
186
- soap.namespace = "http://api.asset.services.active.com"
187
- soap.body = "<context><userId></userId><applicationId></applicationId></context><assetId>#{id}</assetId>"
188
- end
189
- puts "==========="
190
- puts r.to_hash[:get_asset_metadata_response][:out].inspect
191
- return r
192
- end
193
-
194
- def self.get_asset_by_id(id)
195
- puts "loading ATS"
196
- c = Savon::Client.new("http://api.amp.active.com/asset-service/services/AssetService")
197
- c.request.headers["Api-Key"] = "6npky9t57235vps5cetm3s7k"
198
- r = c.get_asset_by_id! do |soap|
199
- soap.namespace = "http://api.asset.services.active.com"
200
- soap.body = "<context><userId></userId><applicationId></applicationId></context><assetId>#{id}</assetId>"
201
- end
202
- return r
203
- end
204
-
205
- def load_metadata
206
- puts "loading ATS metadata"
207
- metadata = ATS.get_asset_metadata(@asset_id)
208
- @data.merge! Hash.from_xml(metadata.to_hash[:get_asset_metadata_response][:out])["importSource"]["asset"]
209
- @metadata_loaded=true
210
- end
155
+ # def self.get_asset_metadata(id)
156
+ # c = Savon::Client.new("http://api.amp.active.com/asset-service/services/AssetService?wsdl")
157
+ # c.request.headers["Api-Key"] = "6npky9t57235vps5cetm3s7k"
158
+ # r = c.get_asset_metadata do |soap|
159
+ # soap.namespace = "http://api.asset.services.active.com"
160
+ # soap.body = "<context><userId></userId><applicationId></applicationId></context><assetId>#{id}</assetId>"
161
+ # end
162
+ # puts "==========="
163
+ # puts r.to_hash[:get_asset_metadata_response][:out].inspect
164
+ # return r
165
+ # end
166
+ #
167
+ # def self.get_asset_by_id(id)
168
+ # puts "loading ATS"
169
+ # c = Savon::Client.new("http://api.amp.active.com/asset-service/services/AssetService")
170
+ # c.request.headers["Api-Key"] = "6npky9t57235vps5cetm3s7k"
171
+ # r = c.get_asset_by_id! do |soap|
172
+ # soap.namespace = "http://api.asset.services.active.com"
173
+ # soap.body = "<context><userId></userId><applicationId></applicationId></context><assetId>#{id}</assetId>"
174
+ # end
175
+ # return r
176
+ # end
177
+ #
178
+ # def load_metadata
179
+ # puts "loading ATS metadata"
180
+ # metadata = ATS.get_asset_metadata(@asset_id)
181
+ # @data.merge! Hash.from_xml(metadata.to_hash[:get_asset_metadata_response][:out])["importSource"]["asset"]
182
+ # @metadata_loaded=true
183
+ # end
211
184
 
212
185
  def get_app_api
213
186
  puts "loading reg center api"
214
- doc = Nokogiri::XML(open("http://apij.active.com/regcenter/event/#{@substitution_url}"))
215
- @data.merge! Hash.from_xml doc.to_s
216
- @api_data_loaded=true
187
+ begin
188
+ doc = Nokogiri::XML(open("http://apij.active.com/regcenter/event/#{@data[:id]}"))
189
+ @data.merge! Hash.from_xml doc.to_s
190
+ @api_data_loaded=true
191
+ rescue
192
+ raise RegCenterError, "Couldn't find Reg Center activity with the id of #{id}"
193
+ return
194
+ end
217
195
  end
218
196
 
219
197
  end # end ats
@@ -30,7 +30,7 @@ module Active
30
30
 
31
31
  class Search
32
32
  attr_accessor :api_key, :start_date, :end_date, :location, :channels, :keywords, :search, :radius, :limit, :sort, :page, :offset, :latitude, :longitude,
33
- :view, :facet, :sort, :num_results, :asset_ids
33
+ :view, :facet, :sort, :num_results, :asset_ids, :dma
34
34
 
35
35
  attr_reader :results, :endIndex, :pageSize, :searchTime, :numberOfResults, :end_point, :meta
36
36
 
@@ -58,6 +58,7 @@ module Active
58
58
  self.asset_id = data[:asset_id] || ""
59
59
  self.latitude = data[:latitude]
60
60
  self.longitude = data[:longitude]
61
+ self.dma = data[:dma]
61
62
  end
62
63
 
63
64
  # Example
@@ -129,10 +130,15 @@ module Active
129
130
  # 1 Look for zip codes
130
131
  # 2 Look for lat lng
131
132
  # 3 Look for a formatted string "San Diego, CA, US"
133
+ # 4 Look for a dma
132
134
  if not @zips.empty?
133
135
  loc_str = @zips.join(",")
134
136
  elsif @latitude and @longitude
135
137
  loc_str = "#{@latitude};#{@longitude}"
138
+ elsif @dma
139
+ loc_str = ""
140
+ meta_data += "+AND+" unless meta_data == ""
141
+ meta_data += "meta:dma=#{Search.double_encode_channel(@dma)}"
136
142
  else
137
143
  loc_str = @location
138
144
  end
@@ -208,6 +214,9 @@ module Active
208
214
  # 3 Look for a formatted string "San Diego, CA, US"
209
215
  # Search.search( {:location = "San Diego, CA, US"} )
210
216
  #
217
+ # 4 Look for a DMA
218
+ # Search.new({:dma=>"San Francisco - Oakland - San Jose"})
219
+ #
211
220
  # = How to look at the results =
212
221
  #
213
222
  #
@@ -0,0 +1,56 @@
1
+ # Require the spec helper relative to this file
2
+ require File.join(File.dirname(__FILE__), %w[spec_helper])
3
+ require File.join(File.dirname(__FILE__), %w[custom_matchers_spec])
4
+ require File.join(File.dirname(__FILE__), %w[ .. lib services search])
5
+ require File.join(File.dirname(__FILE__), %w[ .. lib services activity])
6
+ require File.join(File.dirname(__FILE__), %w[ .. lib services reg_center])
7
+ include Active::Services
8
+
9
+ describe ActiveWorks do
10
+ before(:each) do
11
+ @valid_id = "E-00072ZDN"
12
+ end
13
+ it "should set find by id" do
14
+ a = ActiveWorks.find_by_id(@valid_id)
15
+ a.data["id"].should == @valid_id
16
+ end
17
+ it "should set the asset_type_id" do
18
+ ActiveWorks.find_by_id(@valid_id).asset_type_id.should_not be_nil
19
+ end
20
+ it "should thorw an ActiveWorksError if no record is found" do
21
+ lambda { ActiveWorks.find_by_id( "666" ) }.should raise_error(ActiveWorksError)
22
+ end
23
+ it "should get the API metadata" do
24
+ a = ActiveWorks.find_by_id(@valid_id)
25
+ a.data["eventDetailDto"].should_not be_nil
26
+ end
27
+ it "should have an address Hash" do
28
+ a = ActiveWorks.find_by_id(@valid_id)
29
+ a.address.should be_an_instance_of(Hash)
30
+ end
31
+ it "should have a desc" do
32
+ a = ActiveWorks.find_by_id(@valid_id)
33
+ a.desc.should_not == ""
34
+ a.desc.should_not == nil
35
+ end
36
+ it "should cleanup desc" do
37
+ a = ActiveWorks.find_by_id(@valid_id)
38
+ puts a.desc
39
+ a.desc.should_not include('\"')
40
+ end
41
+ it "should have a title String" do
42
+ a = ActiveWorks.find_by_id(@valid_id)
43
+ a.title.should be_an_instance_of(String)
44
+ end
45
+ it "should have a start_date DateTime" do
46
+ a = ActiveWorks.find_by_id(@valid_id)
47
+ puts a.start_date
48
+ a.start_date.should be_an_instance_of(DateTime)
49
+ end
50
+ it "should have a start_time DateTime" do
51
+ a = ActiveWorks.find_by_id(@valid_id)
52
+ a.start_time.should be_an_instance_of(DateTime)
53
+ end
54
+
55
+
56
+ end
data/spec/reg_spec.rb CHANGED
@@ -8,14 +8,16 @@ include Active::Services
8
8
 
9
9
  describe RegCenter do
10
10
  before(:each) do
11
- @valid_id = "D9A22F33-8A14-4175-8D5B-D11578212A98"
11
+ @valid_id = "1802851"
12
+ # @valid_id = "1889826"
13
+ # @valid_id = "1847738"
12
14
  end
13
15
  it "should set find by id" do
14
16
  a = RegCenter.find_by_id(@valid_id)
15
- a.asset_id.should == @valid_id
17
+ a.data["id"].should == @valid_id
16
18
  end
17
- it "should get the asset_type_id" do
18
- RegCenter.find_by_id(@valid_id).asset_id_type.should_not be_nil
19
+ it "should set the asset_type_id" do
20
+ RegCenter.find_by_id(@valid_id).asset_type_id.should_not be_nil
19
21
  end
20
22
  it "should thorw an RegCenterError if no record is found" do
21
23
  lambda { RegCenter.find_by_id( "666" ) }.should raise_error(RegCenterError)
@@ -24,30 +26,40 @@ describe RegCenter do
24
26
  a = RegCenter.find_by_id(@valid_id)
25
27
  a.data["event"].should_not be_nil
26
28
  end
27
- it "should have more details than ATS" do
28
- a = ATS.find_by_id(@valid_id)
29
- b = RegCenter.find_by_id(@valid_id)
30
- a.address[:address].should be_nil
31
- b.address[:address].should_not be_nil
32
- end
33
- it "should only load API metadata once" do
34
- a = RegCenter.find_by_id(@valid_id)
35
- puts a.url
36
- puts a.address
37
- RegCenter.should_receive(:get_app_api).once
38
- end
39
29
  it "should have an address Hash" do
40
30
  a = RegCenter.find_by_id(@valid_id)
41
31
  a.address.should be_an_instance_of(Hash)
42
32
  end
33
+ it "should have a desc String" do
34
+ a = RegCenter.find_by_id(@valid_id)
35
+ a.desc.should be_an_instance_of(String)
36
+ end
43
37
  it "should cleanup title" do
44
- a = ATS.find_by_id(@valid_id)
45
- a.title.should_not_contain("\r")
38
+ a = RegCenter.find_by_id(@valid_id)
39
+ a.title.should_not include("\r")
40
+ end
41
+ it "should have a primary category" do
42
+ a = RegCenter.find_by_id(@valid_id)
43
+ puts a.primary_category
44
+ a.primary_category.should_not be_nil
46
45
  end
47
46
  it "should have a title String" do
48
- a = ATS.find_by_id(@valid_id)
47
+ a = RegCenter.find_by_id(@valid_id)
49
48
  a.title.should be_an_instance_of(String)
50
49
  end
50
+ it "should have a categories array" do
51
+ a = RegCenter.find_by_id(@valid_id)
52
+ a.categories.should be_an_instance_of(Array)
53
+ end
54
+ it "should have a start_date DateTime" do
55
+ a = RegCenter.find_by_id(@valid_id)
56
+ puts a.start_date
57
+ a.start_date.should be_an_instance_of(DateTime)
58
+ end
59
+ it "should have a start_time DateTime" do
60
+ a = RegCenter.find_by_id(@valid_id)
61
+ a.start_time.should be_an_instance_of(DateTime)
62
+ end
51
63
 
52
64
 
53
65
  end
data/spec/search_spec.rb CHANGED
@@ -15,6 +15,12 @@ end
15
15
  describe "Search URL Construction" do
16
16
  include CustomMatchers
17
17
 
18
+ it "should search by the SF DMA" do
19
+ uri = URI.parse( Search.new({:dma=>"San Francisco - Oakland - San Jose"}).end_point )
20
+ uri.query.should have_param("meta:dma=San%2520Francisco%2520%252D%2520Oakland%2520%252D%2520San%2520Jose")
21
+ # uri.query.should_not have_param("l=")
22
+ end
23
+
18
24
  it "should place lat and lng in the l param" do
19
25
  location = {:latitude=>"37.785895", :longitude=>"-122.40638"}
20
26
  uri = URI.parse( Search.new(location).end_point )
data/version.txt CHANGED
@@ -1 +1 @@
1
- 0.0.11
1
+ 0.0.12
metadata CHANGED
@@ -1,13 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: Active
3
3
  version: !ruby/object:Gem::Version
4
- hash: 9
5
4
  prerelease: false
6
5
  segments:
7
6
  - 0
8
7
  - 0
9
- - 11
10
- version: 0.0.11
8
+ - 12
9
+ version: 0.0.12
11
10
  platform: ruby
12
11
  authors:
13
12
  - Jonathan Spooner, Brian Levine
@@ -15,18 +14,16 @@ autorequire:
15
14
  bindir: bin
16
15
  cert_chain: []
17
16
 
18
- date: 2010-09-20 00:00:00 -07:00
17
+ date: 2010-09-22 00:00:00 -07:00
19
18
  default_executable:
20
19
  dependencies:
21
20
  - !ruby/object:Gem::Dependency
22
21
  name: savon
23
22
  prerelease: false
24
23
  requirement: &id001 !ruby/object:Gem::Requirement
25
- none: false
26
24
  requirements:
27
25
  - - ">="
28
26
  - !ruby/object:Gem::Version
29
- hash: 17
30
27
  segments:
31
28
  - 0
32
29
  - 7
@@ -38,11 +35,9 @@ dependencies:
38
35
  name: bones
39
36
  prerelease: false
40
37
  requirement: &id002 !ruby/object:Gem::Requirement
41
- none: false
42
38
  requirements:
43
39
  - - ">="
44
40
  - !ruby/object:Gem::Version
45
- hash: 25
46
41
  segments:
47
42
  - 3
48
43
  - 4
@@ -60,22 +55,27 @@ extra_rdoc_files:
60
55
  - History.txt
61
56
  - README.txt
62
57
  - bin/Active
58
+ - lib/.DS_Store
59
+ - lib/services/.DS_Store
63
60
  - version.txt
64
61
  files:
65
- - .bnsignore
66
62
  - Active.gemspec
67
63
  - History.txt
68
64
  - README.txt
69
65
  - Rakefile
70
66
  - bin/Active
67
+ - lib/.DS_Store
71
68
  - lib/Active.rb
69
+ - lib/services/.DS_Store
72
70
  - lib/services/IActivity.rb
71
+ - lib/services/active_works.rb
73
72
  - lib/services/activity.rb
74
73
  - lib/services/ats.rb
75
74
  - lib/services/reg_center.rb
76
75
  - lib/services/search.rb
77
76
  - spec/.DS_Store
78
77
  - spec/Active_spec.rb
78
+ - spec/activeworks_spec.rb
79
79
  - spec/activity_spec.rb
80
80
  - spec/ats_spec.rb
81
81
  - spec/benchmark/search_bench.rb
@@ -96,27 +96,23 @@ rdoc_options:
96
96
  require_paths:
97
97
  - lib
98
98
  required_ruby_version: !ruby/object:Gem::Requirement
99
- none: false
100
99
  requirements:
101
100
  - - ">="
102
101
  - !ruby/object:Gem::Version
103
- hash: 3
104
102
  segments:
105
103
  - 0
106
104
  version: "0"
107
105
  required_rubygems_version: !ruby/object:Gem::Requirement
108
- none: false
109
106
  requirements:
110
107
  - - ">="
111
108
  - !ruby/object:Gem::Version
112
- hash: 3
113
109
  segments:
114
110
  - 0
115
111
  version: "0"
116
112
  requirements: []
117
113
 
118
114
  rubyforge_project: Active
119
- rubygems_version: 1.3.7
115
+ rubygems_version: 1.3.6
120
116
  signing_key:
121
117
  specification_version: 3
122
118
  summary: Search api for Active Network
data/.bnsignore DELETED
@@ -1,19 +0,0 @@
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