Active 0.0.27 → 0.0.28

Sign up to get free protection for your applications and to get access to all the features.
@@ -6,9 +6,9 @@ module Active
6
6
  class ActivityFindError < StandardError; end
7
7
 
8
8
  class Activity < IActivity
9
- REG_CENTER_ASSET_TYPE_ID="EA4E860A-9DCD-4DAA-A7CA-4A77AD194F65"
10
- REG_CENTER_ASSET_TYPE_ID2="3BF82BBE-CF88-4E8C-A56F-78F5CE87E4C6"
11
- ACTIVE_WORKS_ASSET_TYPE_ID="DFAA997A-D591-44CA-9FB7-BF4A4C8984F1"
9
+ REG_CENTER_ASSET_TYPE_ID = "EA4E860A-9DCD-4DAA-A7CA-4A77AD194F65"
10
+ REG_CENTER_ASSET_TYPE_ID2 = "3BF82BBE-CF88-4E8C-A56F-78F5CE87E4C6"
11
+ ACTIVE_WORKS_ASSET_TYPE_ID = "DFAA997A-D591-44CA-9FB7-BF4A4C8984F1"
12
12
 
13
13
  attr_accessor :primary, :gsa, :ats
14
14
  attr_reader :datasources_loaded
@@ -48,7 +48,7 @@ module Active
48
48
  elsif @gsa.asset_type_id == ACTIVE_WORKS_ASSET_TYPE_ID
49
49
  return "ActiveWorks id= #{@gsa.asset_id} type= #{@gsa.asset_type_id}"
50
50
  else
51
- return "Unknow id= #{@gsa.asset_id} type= #{@gsa.asset_type_id}"
51
+ return "Undefined id= #{@gsa.asset_id} type= #{@gsa.asset_type_id}"
52
52
  end
53
53
  end
54
54
 
data/lib/services/gsa.rb CHANGED
@@ -38,6 +38,10 @@ module Active
38
38
  @data["url"]
39
39
  end
40
40
  end
41
+
42
+ # def event_url
43
+ # @data["meta"]["organizationWebsite"] rescue
44
+ # end
41
45
 
42
46
  def categories
43
47
  if @data["meta"]["channel"].class==String
@@ -42,10 +42,14 @@ module Active
42
42
  elsif @data.has_key?("event") && @data["event"].has_key?("registrationUrl")
43
43
  @data["event"]["registrationUrl"]
44
44
  elsif @data.has_key?("event") && @data["event"].has_key?("eventContactUrl")
45
- @data["event"]["eventContactUrl"]
45
+ @data["event"]["eventContactUrl"]
46
46
  end
47
47
  end
48
48
 
49
+ def event_url
50
+ @data[:event][:eventUrl]
51
+ end
52
+
49
53
  def categories
50
54
  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
51
55
  channels = @data["event"]["channels"]["channel"]
@@ -108,6 +112,10 @@ module Active
108
112
  def end_date
109
113
  nil
110
114
  end
115
+ # The date and time that registration closes
116
+ def registration_close_date
117
+ DateTime.parse(@data["event"]["eventCloseDate"])
118
+ end
111
119
 
112
120
  def category
113
121
  primary_category
@@ -122,12 +130,12 @@ module Active
122
130
  u
123
131
  end
124
132
 
125
- def desc
133
+ def desc_old
126
134
  if @data.has_key?("event") && @data["event"].has_key?("briefDescription")
127
- ret=@data["event"]["briefDescription"]
128
- if @data["event"].has_key?("eventDetails") && @data["event"]["eventDetails"]!=nil && @data["event"]["eventDetails"].has_key?("eventDetail")
135
+ ret = @data["event"]["briefDescription"]
136
+ if @data["event"].has_key?("eventDetails") && @data["event"]["eventDetails"] != nil && @data["event"]["eventDetails"].has_key?("eventDetail")
129
137
  eventDetail = @data["event"]["eventDetails"]["eventDetail"]
130
- if eventDetail.class==Array
138
+ if eventDetail.class == Array
131
139
  @data["event"]["eventDetails"]["eventDetail"].each do |detail|
132
140
  ret +="<div><b>" + detail["eventDetailsName"] + ":</b> " + cleanup_reg_string(detail["eventDetailsValue"]) + "</div>"
133
141
  end
@@ -142,6 +150,36 @@ module Active
142
150
  end
143
151
  end
144
152
 
153
+ def desc(length = :full)
154
+ if length == :full
155
+ @data["event"]["eventDescription"]
156
+ else
157
+ @data["event"]["briefDescription"]
158
+ end
159
+ end
160
+
161
+ # Content should be a array of hashes.
162
+ # [ {:title => "briefDescription", :type => "html", :content => "..." }]
163
+ #
164
+ # It should contain everything in briefDescription description and eventDetails.
165
+ # It should just be one big happy
166
+ #
167
+ # TODO: Need to order this by detail[:eventDetailsOrder]
168
+ # TODO: Add the other description blocks to this
169
+ def content
170
+ if @data["event"] and @data["event"]["eventDetails"]
171
+
172
+ if @data["event"]["eventDetails"]["eventDetail"].class == Array
173
+ return @data["event"]["eventDetails"]["eventDetail"].collect { |obj| {:title => obj[:eventDetailsName], :content => obj[:eventDetailsValue]} }
174
+ else
175
+ return [{:title => @data["event"]["eventDetails"]["eventDetail"]["eventDetailsName"],:content => @data["event"]["eventDetails"]["eventDetail"]["eventDetailsValue"]}]
176
+ end
177
+
178
+ else
179
+ return []
180
+ end
181
+ end
182
+
145
183
  def cleanup_reg_string(input)
146
184
  input.gsub("\r","").gsub("\n","").gsub("\"","""").gsub("\342\200\234","""").gsub("\342\200\235","""")
147
185
  end
@@ -25,4 +25,4 @@ include Active::Services
25
25
  # puts " "
26
26
  # puts arr
27
27
 
28
- puts Search.search(:asset_id => "FBF1EF76-B8BF-427A-85DD-D310DB9E075D")
28
+ puts Search.search(:asset_ids => ["DD8F427F-6188-465B-8C26-71BBA22D2DB7"]).results.inspect
data/spec/reg_spec.rb CHANGED
@@ -131,5 +131,36 @@ describe RegCenter do
131
131
  a.start_time.should be_an_instance_of(DateTime)
132
132
  end
133
133
 
134
+ it "should have a valid eventURL" do
135
+ r = RegCenter.new(Hash.from_xml("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<event>\n <assetID>7e39ceb4-cebb-471f-ace3-21f697ae9e55</assetID>\n <eventID>1802851</eventID>\n <eventName>Rock 'n' Roll San Jose Half Marathon</eventName>\n <eventDate>2010-10-03T08:00:00-07:00</eventDate>\n <eventTime>08:00 am</eventTime>\n <eventLocation>Downtown</eventLocation>\n <eventAddress>Almaden Blvd &amp; Santa Clara Street</eventAddress>\n <eventCity>San Jose</eventCity>\n <eventState>California</eventState>\n <eventZip>95192</eventZip>\n <eventCountry>USA</eventCountry>\n <briefDescription>Registration Fees:* \t&#13;\n&lt;p&gt;&#13;\n1/2 Marathon&#13;\n&lt;p&gt;&#13;\n * $85.00 \342\200\223 October 2009- July 31, 2010&lt;br&gt;&#13;\n * $100.00 \342\200\223 August 1, 2010- September 26&lt;br&gt;&#13;\n * $120.00 \342\200\223 Expo Price&lt;br&gt;&#13;\n&lt;p&gt;&#13;\n*Registration fees are non-refundable and non-transferable. Fees listed above do not include the Active Network processing fee. NO RACE DAY REGISTRATION</briefDescription>\n <usatSanctioned>false</usatSanctioned>\n <regOnline>false</regOnline>\n <currencyCode>USD</currencyCode>\n <eventTypeID>7</eventTypeID>\n <eventType>Event, Race</eventType>\n <hasEventResults>false</hasEventResults>\n <hasMetaResults>true</hasMetaResults>\n <showMap>true</showMap>\n <longitude>-121.8818</longitude>\n <latitude>37.3359</latitude>\n <eventContactEmail>rnrsj@eliteracing.com</eventContactEmail>\n <eventContactPhone>800-311-1255</eventContactPhone>\n <displayCloseDate>true</displayCloseDate>\n <excludedFromEmailing>false</excludedFromEmailing>\n <metaEventName>Rock 'n' Roll Half Marathon</metaEventName>\n <metaEventID>98616</metaEventID>\n <category>Activities</category>\n <mediaTypes>\n <mediaType>Event</mediaType>\n <mediaType>Event\\Half Marathon</mediaType>\n <mediaType>=difficulty:Advanced</mediaType>\n <mediaType>=difficulty:Beginner</mediaType>\n <mediaType>=difficulty:Intermediate</mediaType>\n </mediaTypes>\n <metaEvents>\n <event>\n <assetID>a401eaf3-6087-4dd2-822c-635a7ae45e74</assetID>\n <eventID>1614834</eventID>\n <eventName>Rock 'n' Roll Half Marathon - San Jose</eventName>\n <eventDate>2009-10-04T08:00:00-07:00</eventDate>\n <eventDetailsPageUrl>http://www.active.com/page/Event_Details.htm?event_id=1614834</eventDetailsPageUrl>\n </event>\n </metaEvents>\n <channels>\n <channel>\n <channelName>Running</channelName>\n <primaryChannel>true</primaryChannel>\n </channel>\n </channels>\n <eventCategories/>\n <eventDetails>\n <eventDetail>\n <eventDetailsName>Online Registration Closes</eventDetailsName>\n <eventDetailsOrder>1</eventDetailsOrder>\n <eventDetailsValue>Sunday, September 26, 2010</eventDetailsValue>\n </eventDetail>\n </eventDetails>\n <eventDonationLinks/>\n <eventSanctions/>\n <eventUrl>http://san-jose.competitor.com</eventUrl>\n <resultsUrl>http://results.active.com/pages/page.jsp?pubID=3&amp;eventID=1802851</resultsUrl>\n <eventDetailsPageUrl>http://www.active.com/page/Event_Details.htm?event_id=1802851</eventDetailsPageUrl>\n <eventContactUrl>http://www.active.com/event_contact.cfm?event_id=1802851</eventContactUrl>\n <eventImageUrl>http://www.active.com/images/upimages/1802851.jpg</eventImageUrl>\n</event>\n"))
136
+ r.event_url.should eql("http://san-jose.competitor.com")
137
+ end
138
+
139
+ it "should have a valid content" do
140
+ r = RegCenter.new(Hash.from_xml('<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <event> <assetID>5c6fa2f2-0434-4d6c-953d-cab9bade4f64</assetID> <eventID>1877942</eventID> <eventName>Realistic Drawing (6-12 Yrs.)</eventName> <eventDate>2010-09-16T15:30:00-07:00</eventDate> <eventTime>3:30 PM</eventTime> <eventLocation>Arts &amp; Crafts Room - Nick Rodriguez Community Center</eventLocation> <eventAddress>213 "F" Street</eventAddress> <eventCity>Antioch</eventCity> <eventState>California</eventState> <eventZip>94509</eventZip> <eventCountry>USA</eventCountry> <eventDescription>Do you love to draw?Learn how to make your drawings more realistic with projects that focus on observation,proportion,perspective,composition,light and shadow and texture.Media will include pencil,pen,charcoal,and pastel.A &amp;10 materials fee is payable to the instuctor at the first class.</eventDescription> <usatSanctioned>false</usatSanctioned> <regOnline>true</regOnline> <eventCloseDate>2010-09-16T00:00:00-07:00</eventCloseDate> <currencyCode>USD</currencyCode> <eventTypeID>1</eventTypeID> <eventType>Recware Activities</eventType> <hasEventResults>false</hasEventResults> <hasMetaResults>false</hasMetaResults> <showMap>true</showMap> <longitude>-121.8058</longitude> <latitude>38.00492</latitude> <eventContactEmail>dadams@ci.antioch.ca.us</eventContactEmail> <eventContactPhone>925-779-7070</eventContactPhone> <displayCloseDate>true</displayCloseDate> <excludedFromEmailing>false</excludedFromEmailing> <category>Activities</category> <mediaTypes> <mediaType>Recware Activities</mediaType> </mediaTypes> <channels> <channel> <primaryChannel>false</primaryChannel> </channel> </channels> <eventCategories/> <eventDetails> <eventDetail> <eventDetailsName>Ages</eventDetailsName> <eventDetailsOrder>1</eventDetailsOrder> <eventDetailsValue>6 years - 12 years 11months</eventDetailsValue> </eventDetail> <eventDetail> <eventDetailsName>Instructor</eventDetailsName> <eventDetailsOrder>2</eventDetailsOrder> <eventDetailsValue>Nancy Roberts</eventDetailsValue> </eventDetail> <eventDetail> <eventDetailsName>Code</eventDetailsName> <eventDetailsOrder>3</eventDetailsOrder> <eventDetailsValue>1447.401</eventDetailsValue> </eventDetail> <eventDetail> <eventDetailsName>Classification</eventDetailsName> <eventDetailsOrder>4</eventDetailsOrder> <eventDetailsValue>Art</eventDetailsValue> </eventDetail> <eventDetail> <eventDetailsName>Schedule</eventDetailsName> <eventDetailsOrder>5</eventDetailsOrder> <eventDetailsValue>Occurs every week on Thursday effective 9/16/10 until 10/21/10 from 3:30 PM to 4:30 PM</eventDetailsValue> </eventDetail> </eventDetails> <eventDonationLinks/> <eventSanctions/> <eventDetailsPageUrl>http://www.active.com/page/Event_Details.htm?event_id=1877942</eventDetailsPageUrl> <eventContactUrl>http://www.active.com/event_contact.cfm?event_id=1877942</eventContactUrl> </event>'))
141
+ r.content.should be_an_instance_of(Array)
142
+ r.content[0][:title].should eql("Ages")
143
+ r.content[1][:title].should eql("Instructor")
144
+ r.content[2][:title].should eql("Code")
145
+ r.content[3][:title].should eql("Classification")
146
+ r.content[4][:title].should eql("Schedule")
147
+
148
+ r.content[0][:content].should eql("6 years - 12 years 11months")
149
+ r.content[1][:content].should eql("Nancy Roberts")
150
+ r.content[2][:content].should eql("1447.401")
151
+ r.content[3][:content].should eql("Art")
152
+ r.content[4][:content].should eql("Occurs every week on Thursday effective 9/16/10 until 10/21/10 from 3:30 PM to 4:30 PM")
153
+ end
154
+
155
+ it "should handle not having extra content" do
156
+ r = RegCenter.new(Hash.from_xml('<?xml version="1.0" encoding="UTF-8" standalone="yes"?><event> <assetID>396e12ba-d496-4d3c-ad76-4ac581ac7628</assetID> <eventID>1893115</eventID> <eventName>San Francisco Halloween Run &amp; Walk for Schools</eventName> <eventDate>2010-10-31T08:30:00-07:00</eventDate> <eventTime>Mile starts 8:30 AM, 5K starts 9 AM</eventTime> <eventLocation>John F. Kennedy Drive at Middle Drive in Golden Gate Park.</eventLocation> <eventCity>San Francisco</eventCity> <eventState>California</eventState> <eventZip>94117</eventZip> <eventCountry>USA</eventCountry> <briefDescription>Both the 5K and mile are USATF Certified distances that visit some of Golden Gate Park’s best views. &lt;b&gt;The Jefferson Mile is the 2010 RRCA California State Championship Mile. It Starts 8:30 AM&lt;/b&gt;. &lt;b&gt;The 5K is flat and fast with a couple of easy hills and Starts 9 AM on JFK, East of the Conservatory of Flowers. Certified Maps at PeopleEvents.org&lt;/b&gt;</briefDescription> <eventDescription>Awards 3 deep in all divisions 8 &amp; under to 80+ Prizes for winners, top pledge collector and random drawing. We feature online Finish Videos and post downloadable Finish Line Photos.</eventDescription> <usatSanctioned>false</usatSanctioned> <regOnline>true</regOnline> <eventCloseDate>2010-10-30T11:59:00-07:00</eventCloseDate> <eventFees>5K or Mile: $25 includes T-shirt until 10/19, $30 after&lt;p&gt;Combo (Mile &amp; 5K): $30 until 10/19, $35 after&lt;p&gt;Kids 12 &amp; under w/t-shirt: $15 until 10/19</eventFees> <currencyCode>USD</currencyCode> <eventTypeID>7</eventTypeID> <eventType>Event, Race</eventType> <hasEventResults>false</hasEventResults> <hasMetaResults>false</hasMetaResults> <showMap>false</showMap> <longitude>-122.4438929</longitude> <latitude>37.7717185</latitude> <eventContactEmail>Bill_Dake@peopleevents.org</eventContactEmail> <eventContactPhone>650 291-8531</eventContactPhone> <displayCloseDate>true</displayCloseDate> <excludedFromEmailing>false</excludedFromEmailing> <category>Activities</category> <mediaTypes> <mediaType>Event</mediaType> <mediaType>Event\1 mile</mediaType> <mediaType>Event\5K</mediaType> </mediaTypes> <channels> <channel> <channelName>Running</channelName> <primaryChannel>true</primaryChannel> </channel> </channels> <eventCategories/> <eventDetails> <eventDetail> <eventDetailsName>Event Flyer</eventDetailsName> <eventDetailsOrder>1</eventDetailsOrder> <eventDetailsValue>&lt;a href=http://www.eteamz.com/activeactive1/files/0913halloweenentryv5-new.pdf&gt; Click Here to View Event Flyer&lt;/a&gt;</eventDetailsValue> </eventDetail> </eventDetails> <eventDonationLinks> <eventDonationLink> <eventDonationLinkID>158285</eventDonationLinkID> <eventDonationLinkTitle>SF Halloween Run &amp; Walk for Schools</eventDonationLinkTitle> <eventDonationLinkUrl>http://www.active.com/donate/sfrunwalkforschools</eventDonationLinkUrl> </eventDonationLink> </eventDonationLinks> <eventSanctions/> <eventUrl>http://www.PeopleEvents.org</eventUrl> <eventDetailsPageUrl>http://www.active.com/page/Event_Details.htm?event_id=1893115</eventDetailsPageUrl> <eventContactUrl>http://www.active.com/event_contact.cfm?event_id=1893115</eventContactUrl> <eventImageUrl>http://www.active.com/images/upimages/halloween10_blk.jpg</eventImageUrl></event>'))
157
+ r.content.should be_an_instance_of(Array)
158
+ r.content[0][:title].should eql("Event Flyer")
159
+ r.content[0][:content].should eql("<a href=http://www.eteamz.com/activeactive1/files/0913halloweenentryv5-new.pdf> Click Here to View Event Flyer</a>")
160
+ end
161
+
162
+
163
+
164
+
134
165
 
135
166
  end
data/version.txt CHANGED
@@ -1 +1 @@
1
- 0.0.27
1
+ 0.0.28
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 0
8
- - 27
9
- version: 0.0.27
8
+ - 28
9
+ version: 0.0.28
10
10
  platform: ruby
11
11
  authors:
12
12
  - Jonathan Spooner, Brian Levine
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-10-29 00:00:00 -07:00
17
+ date: 2010-11-02 00:00:00 -07:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency