activity_mapper 0.1.0

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.
Files changed (41) hide show
  1. data/README.textile +211 -0
  2. data/lib/activity_mapper.rb +35 -0
  3. data/lib/activity_mapper/activity_data_mapper.rb +93 -0
  4. data/lib/activity_mapper/connector.rb +71 -0
  5. data/lib/activity_mapper/lexicon.txt +92662 -0
  6. data/lib/activity_mapper/linguistics.rb +147 -0
  7. data/lib/activity_mapper/service_module.rb +194 -0
  8. data/lib/activity_mapper/service_modules.rb +4 -0
  9. data/lib/activity_mapper/service_modules/delicious.rb +41 -0
  10. data/lib/activity_mapper/service_modules/flickr.rb +59 -0
  11. data/lib/activity_mapper/service_modules/twitter.rb +57 -0
  12. data/lib/activity_mapper/service_modules/wakoopa.rb +350 -0
  13. data/lib/activity_mapper/service_modules/youtube.rb +63 -0
  14. data/lib/extensions/uri.rb +42 -0
  15. data/spec/connector_mock.rb +49 -0
  16. data/spec/data/delicious_ac8fdf9b4e304b150bf198b42a1cb1b4.json +1 -0
  17. data/spec/data/delicious_ee55656e0f69242ccf02c3eb0f97b296.json +1 -0
  18. data/spec/data/flickr_2b826afe2906894197d92f7a41c2785c. +1 -0
  19. data/spec/data/flickr_3c25cf51d174ee4bb2d8673e294ce4c0.json +196 -0
  20. data/spec/data/flickr_482967b550afd05993ec4256fa1de388.json +229 -0
  21. data/spec/data/flickr_54c4b36bea4e2b14c783e5c50cba8544.json +9 -0
  22. data/spec/data/flickr_848ea91c1a903d0347d1029bf863132a. +1 -0
  23. data/spec/data/flickr_bcb82142f3d6998cabab3c82fba15ced.json +141 -0
  24. data/spec/data/flickr_e9d78058938c7c845a8de3a2c3526c61. +1 -0
  25. data/spec/data/twitter_227e1ca72a2ba08a1b03be2cd64b681e.json +274 -0
  26. data/spec/data/twitter_5dd0884137bf193d55d446619ec65c7e.json +1 -0
  27. data/spec/data/twitter_dd694fe9ebda58a84f92a859fb1cb79c.json +1 -0
  28. data/spec/data/wakoopa_1a8b94baf4eed4fd0e7ac39dc2f53059.json +1 -0
  29. data/spec/data/youtube_050e71a038359cc8ff7e00161e687b4e.json +1 -0
  30. data/spec/data/youtube_6d895fb0245f47b9e4fcc868d1f91674.json +1 -0
  31. data/spec/data/youtube_a92042581e44f9d3da548e2c7a89849c.json +1 -0
  32. data/spec/data/youtube_bf7b648ff8720edb1db951b7b9a474c4.json +1 -0
  33. data/spec/data/zemanta_suggest_for_tweet_response.xml +405 -0
  34. data/spec/models.rb +114 -0
  35. data/spec/service_modules/delicious_spec.rb +32 -0
  36. data/spec/service_modules/flickr_spec.rb +43 -0
  37. data/spec/service_modules/twitter_spec.rb +44 -0
  38. data/spec/service_modules/wakoopa_spec.rb +35 -0
  39. data/spec/service_modules/youtube_spec.rb +47 -0
  40. data/spec/spec_helper.rb +8 -0
  41. metadata +130 -0
@@ -0,0 +1,32 @@
1
+
2
+ require File.join(File.dirname(__FILE__), '../spec_helper')
3
+
4
+ describe ActivityMapper::DeliciousServiceModule do
5
+
6
+ before(:each) do
7
+ @user = User.new(:id => 1)
8
+ end
9
+
10
+ it "should accept the proper URL's" do
11
+ ActivityMapper::DeliciousServiceModule.accepts?('http://delicious.com/dominiekth/').should be_true
12
+ ActivityMapper::DeliciousServiceModule.accepts?('http://del.icio.us/dominiekth/').should be_true
13
+ end
14
+
15
+ it "should extract the right credentials on create_or_update_summary!" do
16
+ profile = ServiceProfile.create(:url => 'http://delicious.com/dominiekth/')
17
+ profile.create_or_update_summary!
18
+ profile.username.should == 'dominiekth'
19
+ end
20
+
21
+ it "should aggregate activity" do
22
+ profile = ServiceProfile.create(:url => 'http://delicious.com/dominiekth/', :user => @user)
23
+ profile.create_or_update_summary!
24
+ profile.aggregate_activity!
25
+ profile.activities.size.should == 20
26
+ activity = profile.activities.first
27
+ activity.occurred_at.to_i.should == 1238138051
28
+ activity.object.tag_list.should include('ruby')
29
+ end
30
+
31
+ end
32
+
@@ -0,0 +1,43 @@
1
+
2
+ require File.join(File.dirname(__FILE__), '../spec_helper')
3
+
4
+ FLICKR_API_KEY = '60c760aadec73cb5f2a85d9fc12a2b81' unless defined?(FLICKR_API_KEY)
5
+
6
+ describe ActivityMapper::FlickrServiceModule do
7
+
8
+ before(:each) do
9
+ @user = User.new(:id => 1)
10
+ end
11
+
12
+ it "should extract the right credentials on create_or_update_summary!" do
13
+ user = User.new(:id => 1)
14
+ profile = ServiceProfile.new(:url => 'http://www.flickr.com/photos/dominiekterheide/', :user => @user)
15
+ profile.create_or_update_summary!
16
+ profile.username.should == 'dominiekth'
17
+ profile.native_id.should == '71386598@N00'
18
+
19
+
20
+ profile = ServiceProfile.new(:url => 'http://www.flickr.com/photos/71386598@N00/', :user => @user)
21
+ profile.create_or_update_summary!
22
+ profile.username.should == 'dominiekth'
23
+ profile.native_id.should == '71386598@N00'
24
+ end
25
+
26
+ it "should aggregate activity" do
27
+ profile = ServiceProfile.new(:url => 'http://www.flickr.com/photos/dominiekterheide/', :user => @user)
28
+ profile.create_or_update_summary!
29
+ profile.aggregate_activity!
30
+ profile.activities.size.should == 37
31
+ activity = profile.activities.first
32
+ activity.caption.should == "かに!"
33
+ activity.object.tag_list.should include('wharf')
34
+ end
35
+
36
+ it "should be able to aggregate an empty set of favorites" do
37
+ profile = ServiceProfile.new(:url => "http://www.flickr.com/photos/14594137@N04/", :user => @user)
38
+ profile.create_or_update_summary!
39
+ profile.aggregate_activity!
40
+ profile.activities.size.should == 12
41
+ end
42
+
43
+ end
@@ -0,0 +1,44 @@
1
+
2
+ require File.join(File.dirname(__FILE__), '../spec_helper')
3
+
4
+ describe ActivityMapper::TwitterServiceModule do
5
+
6
+ before(:each) do
7
+ @user = User.new(:id => 3)
8
+ end
9
+
10
+ it "should accept the proper URL's" do
11
+ ActivityMapper::TwitterServiceModule.accepts?('http://twitter.com/dominiek').should be_true
12
+ ActivityMapper::TwitterServiceModule.accepts?('http://dominiek.twitter.com').should be_true
13
+ ActivityMapper::TwitterServiceModule.accepts?('http://twieeeeeeeettr.com/dominiek').should be_false
14
+ end
15
+
16
+ it "should extract the right credentials on create_or_update_summary!" do
17
+ profile = ServiceProfile.create(:url => 'http://twitter.com/dominiek')
18
+ profile.create_or_update_summary!
19
+
20
+ profile.username.should == 'dominiek'
21
+ profile.avatar_url.should match(/amazon/)
22
+ profile.url.should == 'http://twitter.com/dominiek'
23
+ end
24
+
25
+ it "should aggregate activity" do
26
+ profile = ServiceProfile.create(:url => 'http://twitter.com/ptegelaar')
27
+ profile.create_or_update_summary!
28
+ profile.aggregate_activity!
29
+
30
+ # Assert Peter's latest tweet
31
+ tweet = profile.activities.last
32
+ tweet.native_id.should == 1100430251
33
+ tweet.url.should == "http://twitter.com/ptegelaar/status/1100430251"
34
+ tweet.occurred_at.to_i.should == 1231279375
35
+
36
+ activity_object = tweet.object
37
+ tweet_body = "Foulmouthed midgets @ Bad Santa! :D"
38
+ activity_object.title.should == tweet_body
39
+ activity_object.body.should == tweet_body
40
+ activity_object.native_id.should == tweet.native_id
41
+ activity_object.url.should == tweet.url
42
+ end
43
+
44
+ end
@@ -0,0 +1,35 @@
1
+
2
+
3
+ require File.join(File.dirname(__FILE__), '../spec_helper')
4
+
5
+ describe ActivityMapper::WakoopaServiceModule do
6
+
7
+ before(:each) do
8
+ @user = User.new(:id => 3)
9
+ end
10
+
11
+ it "should accept the proper URL's" do
12
+ ActivityMapper::WakoopaServiceModule.accepts?('http://wakoopa.com/peter').should be_true
13
+ ActivityMapper::WakoopaServiceModule.accepts?('http://wakopa.com/peter').should be_false
14
+ end
15
+
16
+ it "should extract the right credentials on create_or_update_summary!" do
17
+ profile = ServiceProfile.create(:url => 'http://wakoopa.com/peter')
18
+ profile.create_or_update_summary!
19
+ profile.username.should == 'peter'
20
+ profile.url.should == 'http://wakoopa.com/peter'
21
+ end
22
+
23
+ it "should aggregate activity" do
24
+ profile = ServiceProfile.create(:url => 'http://wakoopa.com/peter')
25
+ profile.create_or_update_summary!
26
+ profile.aggregate_activity!
27
+ profile.activities.size.should == 10
28
+
29
+ activity = profile.activities.first
30
+ activity.object.native_id.should == 9917
31
+ activity.object.url.should == "http://wakoopa.com/software/textmate"
32
+ activity.occurred_at.to_i.should == 1232460000
33
+ end
34
+
35
+ end
@@ -0,0 +1,47 @@
1
+
2
+
3
+ require File.join(File.dirname(__FILE__), '../spec_helper')
4
+
5
+ describe ActivityMapper::YoutubeServiceModule do
6
+
7
+ before(:each) do
8
+ @user = User.new(:id => 1)
9
+ end
10
+
11
+ it "should extract the right credentials on create_or_update_summary!" do
12
+ profile = ServiceProfile.create(:url => 'http://youtube.com/dominiekth', :user => @user)
13
+ profile.create_or_update_summary!
14
+ profile.username.should == 'dominiekth'
15
+ profile.url.should == 'http://youtube.com/dominiekth'
16
+
17
+ profile = ServiceProfile.create(:url => 'http://www.youtube.com/profile?user=dominiekth')
18
+ profile.create_or_update_summary!
19
+ profile.username.should == 'dominiekth'
20
+ end
21
+
22
+ it "should aggregate activity" do
23
+ profile = ServiceProfile.create(:url => 'http://youtube.com/dominiekth')
24
+ profile.create_or_update_summary!
25
+ profile.user = @user
26
+ profile.aggregate_activity!
27
+ profile.activities.size.should == 27
28
+ activity = profile.activities[2]
29
+ activity.url.should == "http://www.youtube.com/watch?v=gNWhPffhKf8"
30
+ #activity.verb.id.should == ActivityVerb::POST.id
31
+
32
+ activity_object = activity.object
33
+ activity_object.title.should == "the Hong Kong Dutchies"
34
+ activity_object.body.should match(/trip/)
35
+ #activity_object.type.id.should == ActivityObjectType::VIDEO.id
36
+
37
+ media = activity_object.media
38
+ media.duration.to_i.should == 28
39
+ media.embed_url.should match(/youtube.com\/v\//)
40
+ media.thumbnail_url.should match("i.ytimg.com")
41
+
42
+ rating_summary = activity_object.rating_summary
43
+ rating_summary.view_count.to_i.should == 35
44
+ end
45
+
46
+ end
47
+
@@ -0,0 +1,8 @@
1
+
2
+ TEST = true
3
+
4
+ require 'rubygems'
5
+ require 'spec'
6
+ require File.join(File.dirname(__FILE__), '../lib/activity_mapper')
7
+ require File.join(File.dirname(__FILE__), 'models')
8
+ require File.join(File.dirname(__FILE__), 'connector_mock')
metadata ADDED
@@ -0,0 +1,130 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: activity_mapper
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - dominiek
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2010-01-05 00:00:00 +09:00
13
+ default_executable:
14
+ dependencies: []
15
+
16
+ description: A framework for aggregating (public) social activity into a single polymorphic persistent structure.
17
+ email: info@dominiek.com
18
+ executables: []
19
+
20
+ extensions: []
21
+
22
+ extra_rdoc_files:
23
+ - README.textile
24
+ files:
25
+ - README.textile
26
+ - spec/connector_mock.rb
27
+ - spec/data/delicious_ac8fdf9b4e304b150bf198b42a1cb1b4.json
28
+ - spec/data/delicious_ee55656e0f69242ccf02c3eb0f97b296.json
29
+ - spec/data/flickr_2b826afe2906894197d92f7a41c2785c.
30
+ - spec/data/flickr_3c25cf51d174ee4bb2d8673e294ce4c0.json
31
+ - spec/data/flickr_482967b550afd05993ec4256fa1de388.json
32
+ - spec/data/flickr_54c4b36bea4e2b14c783e5c50cba8544.json
33
+ - spec/data/flickr_848ea91c1a903d0347d1029bf863132a.
34
+ - spec/data/flickr_bcb82142f3d6998cabab3c82fba15ced.json
35
+ - spec/data/flickr_e9d78058938c7c845a8de3a2c3526c61.
36
+ - spec/data/twitter_227e1ca72a2ba08a1b03be2cd64b681e.json
37
+ - spec/data/twitter_5dd0884137bf193d55d446619ec65c7e.json
38
+ - spec/data/twitter_dd694fe9ebda58a84f92a859fb1cb79c.json
39
+ - spec/data/wakoopa_1a8b94baf4eed4fd0e7ac39dc2f53059.json
40
+ - spec/data/youtube_050e71a038359cc8ff7e00161e687b4e.json
41
+ - spec/data/youtube_6d895fb0245f47b9e4fcc868d1f91674.json
42
+ - spec/data/youtube_a92042581e44f9d3da548e2c7a89849c.json
43
+ - spec/data/youtube_bf7b648ff8720edb1db951b7b9a474c4.json
44
+ - spec/data/zemanta_suggest_for_tweet_response.xml
45
+ - spec/models.rb
46
+ - spec/service_modules/delicious_spec.rb
47
+ - spec/service_modules/flickr_spec.rb
48
+ - spec/service_modules/twitter_spec.rb
49
+ - spec/service_modules/wakoopa_spec.rb
50
+ - spec/service_modules/youtube_spec.rb
51
+ - spec/spec_helper.rb
52
+ - lib/activity_mapper/activity_data_mapper.rb
53
+ - lib/activity_mapper/connector.rb
54
+ - lib/activity_mapper/lexicon.txt
55
+ - lib/activity_mapper/linguistics.rb
56
+ - lib/activity_mapper/service_module.rb
57
+ - lib/activity_mapper/service_modules/delicious.rb
58
+ - lib/activity_mapper/service_modules/flickr.rb
59
+ - lib/activity_mapper/service_modules/twitter.rb
60
+ - lib/activity_mapper/service_modules/wakoopa.rb
61
+ - lib/activity_mapper/service_modules/youtube.rb
62
+ - lib/activity_mapper/service_modules.rb
63
+ - lib/activity_mapper.rb
64
+ - lib/extensions/uri.rb
65
+ has_rdoc: true
66
+ homepage: http://github.com/dominiek/activity_mapper
67
+ licenses: []
68
+
69
+ post_install_message:
70
+ rdoc_options:
71
+ - --title
72
+ - Activity Mapper
73
+ - --charset
74
+ - utf-8
75
+ - --opname
76
+ - index.html
77
+ - --line-numbers
78
+ - --main
79
+ - README.textile
80
+ - --inline-source
81
+ - --exclude
82
+ - ^(examples)/
83
+ require_paths:
84
+ - lib
85
+ required_ruby_version: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: "0"
90
+ version:
91
+ required_rubygems_version: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - ">="
94
+ - !ruby/object:Gem::Version
95
+ version: "0"
96
+ version:
97
+ requirements: []
98
+
99
+ rubyforge_project:
100
+ rubygems_version: 1.3.5
101
+ signing_key:
102
+ specification_version: 3
103
+ summary: A framework for aggregating (public) social activity into a single polymorphic persistent structure.
104
+ test_files:
105
+ - spec/connector_mock.rb
106
+ - spec/data/delicious_ac8fdf9b4e304b150bf198b42a1cb1b4.json
107
+ - spec/data/delicious_ee55656e0f69242ccf02c3eb0f97b296.json
108
+ - spec/data/flickr_2b826afe2906894197d92f7a41c2785c.
109
+ - spec/data/flickr_3c25cf51d174ee4bb2d8673e294ce4c0.json
110
+ - spec/data/flickr_482967b550afd05993ec4256fa1de388.json
111
+ - spec/data/flickr_54c4b36bea4e2b14c783e5c50cba8544.json
112
+ - spec/data/flickr_848ea91c1a903d0347d1029bf863132a.
113
+ - spec/data/flickr_bcb82142f3d6998cabab3c82fba15ced.json
114
+ - spec/data/flickr_e9d78058938c7c845a8de3a2c3526c61.
115
+ - spec/data/twitter_227e1ca72a2ba08a1b03be2cd64b681e.json
116
+ - spec/data/twitter_5dd0884137bf193d55d446619ec65c7e.json
117
+ - spec/data/twitter_dd694fe9ebda58a84f92a859fb1cb79c.json
118
+ - spec/data/wakoopa_1a8b94baf4eed4fd0e7ac39dc2f53059.json
119
+ - spec/data/youtube_050e71a038359cc8ff7e00161e687b4e.json
120
+ - spec/data/youtube_6d895fb0245f47b9e4fcc868d1f91674.json
121
+ - spec/data/youtube_a92042581e44f9d3da548e2c7a89849c.json
122
+ - spec/data/youtube_bf7b648ff8720edb1db951b7b9a474c4.json
123
+ - spec/data/zemanta_suggest_for_tweet_response.xml
124
+ - spec/models.rb
125
+ - spec/service_modules/delicious_spec.rb
126
+ - spec/service_modules/flickr_spec.rb
127
+ - spec/service_modules/twitter_spec.rb
128
+ - spec/service_modules/wakoopa_spec.rb
129
+ - spec/service_modules/youtube_spec.rb
130
+ - spec/spec_helper.rb