app/models/calagator/source/parser/meetup.rb in calagator-1.0.0.rc2 vs app/models/calagator/source/parser/meetup.rb in calagator-1.0.0.rc3

- old
+ new

@@ -6,11 +6,11 @@ def to_events return fallback unless Calagator.meetup_api_key.present? return unless data = get_data event = Event.new({ - source: opts[:source], + source: source, title: data['name'], description: data['description'], url: data['event_url'], venue: to_venue(data['venue']), tag_list: "meetup:event=#{data['event_id']}, meetup:group=#{data['group']['urlname']}", @@ -30,11 +30,11 @@ lambda { |matcher| "http://www.meetup.com/#{matcher[1]}/events/#{matcher[2]}/ical" } ) end def get_data - to_events_api_helper(opts[:url], "problem") do |event_id| + to_events_api_helper(url, "problem") do |event_id| [ "https://api.meetup.com/2/event/#{event_id}", { key: Calagator.meetup_api_key, sign: 'true' @@ -44,11 +44,11 @@ end def to_venue(value) return if value.blank? venue = Venue.new({ - source: opts[:source], + source: source, title: value['name'], street_address: [value['address_1'], value['address_2'], value['address_3']].compact.join(", "), locality: value['city'], region: value['state'], postal_code: value['zip'], @@ -58,14 +58,13 @@ }) venue.geocode! venue_or_duplicate(venue) end - def to_events_wrapper(driver, source, target) - if matcher = opts[:url].try(:match, source) - url = target.call(matcher) - opts[:content] = self.class.read_url(url) - driver.new(opts).to_events + def to_events_wrapper(driver, match, template) + url.try(:match, match) do |matcher| + url = template.call(matcher) + driver.new(url, source).to_events end end end end