Class: ActivityMapper::DeliciousServiceModule

Inherits:
ServiceModule show all
Defined in:
lib/activity_mapper/service_modules/delicious.rb

Constant Summary collapse

ACTIVITY_MAP =
{
  nil => {
    'activity.occurred_at'          => 'dt',
    'activity.caption'              => 'd',
    'activity_object.title'         => 'd',
    'activity_object.body'          => 'd',
    'activity_object.tag_list'      => 't',
    'activity_object.url'           => 'u',
    'activity.url'                  => 'u'
  }
}
ACCEPTED_HOSTS =
[/delicious\.com/, /del\.icio\.us/]

Constants inherited from ServiceModule

ServiceModule::COMMON_DIRECTIVES

Instance Method Summary collapse

Methods inherited from ServiceModule

accepts?, all_accepted_hosts, #deep_analysis_on, detect_username, #initialize, klass_for, #shallow_analysis_on, subclasses

Constructor Details

This class inherits a constructor from ActivityMapper::ServiceModule

Instance Method Details

#aggregate_activity!(options = {}) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/activity_mapper/service_modules/delicious.rb', line 22

def aggregate_activity!(options = {})
  mapper = ActivityDataMapper.new(ACTIVITY_MAP)

  mapper.fetch!(
    "http://feeds.delicious.com/v2/json/#{@profile.username}?count=20",
    :format => :json
  )
  mapper.map!
  mapper.entries.sort! { |e2,e1|
    e1['activity.occurred_at'] <=> e2['activity.occurred_at']
  }
  mapper.entries.each do |entry|
    break if Activity.exists?(@profile.user_id, entry)
    create_activity(entry, ActivityObjectType::BOOKMARK, ActivityVerb::POST)
  end
end

#create_or_update_summary!(options = {}) ⇒ Object



18
19
20
# File 'lib/activity_mapper/service_modules/delicious.rb', line 18

def create_or_update_summary!(options = {})
  @profile.update_attributes(:username => self.class.username_from_url(@profile.url))
end