butterfly 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.autotest +6 -0
- data/.gitignore +4 -0
- data/.rspec +2 -0
- data/Gemfile +3 -0
- data/Rakefile +9 -0
- data/butterfly.gemspec +29 -0
- data/lib/butterfly/like.rb +27 -0
- data/lib/butterfly/provider/base.rb +11 -0
- data/lib/butterfly/provider/dribbble.rb +45 -0
- data/lib/butterfly/provider/flickr.rb +47 -0
- data/lib/butterfly/provider/tumblr.rb +83 -0
- data/lib/butterfly/provider/twitter.rb +45 -0
- data/lib/butterfly/user.rb +19 -0
- data/lib/butterfly/version.rb +3 -0
- data/lib/butterfly.rb +13 -0
- data/spec/provider/dribbble_spec.rb +35 -0
- data/spec/provider/flickr_spec.rb +35 -0
- data/spec/provider/tumblr_spec.rb +70 -0
- data/spec/provider/twitter_spec.rb +35 -0
- data/spec/spec_helper.rb +10 -0
- data/spec/support/fakeweb.rb +3 -0
- data/spec/support/responses/dribbble.json +1 -0
- data/spec/support/responses/flickr.json +1 -0
- data/spec/support/responses/tumblr.xml +3 -0
- data/spec/support/responses/twitter.json +1 -0
- metadata +155 -0
data/.autotest
ADDED
data/.gitignore
ADDED
data/.rspec
ADDED
data/Gemfile
ADDED
data/Rakefile
ADDED
data/butterfly.gemspec
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "butterfly/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "butterfly"
|
7
|
+
s.version = Butterfly::VERSION
|
8
|
+
s.platform = Gem::Platform::RUBY
|
9
|
+
s.authors = ["Steve Hoeksema"]
|
10
|
+
s.email = ["steve@seven.net.nz"]
|
11
|
+
s.homepage = ""
|
12
|
+
s.summary = "Social media aggregator"
|
13
|
+
s.description = "Retrieves \"likes\" from various social media sites and presents them in a common format"
|
14
|
+
|
15
|
+
s.rubyforge_project = "butterfly"
|
16
|
+
|
17
|
+
s.files = `git ls-files`.split("\n")
|
18
|
+
s.test_files = `git ls-files -- {spec,features}/*`.split("\n")
|
19
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
20
|
+
s.require_paths = ["lib"]
|
21
|
+
|
22
|
+
s.add_dependency "activesupport", ["~> 3"]
|
23
|
+
s.add_dependency "httparty", ["~> 0"]
|
24
|
+
|
25
|
+
s.add_development_dependency "rspec", ["~> 2"]
|
26
|
+
s.add_development_dependency "autotest"
|
27
|
+
s.add_development_dependency "autotest-fsevent" if RUBY_PLATFORM =~ /darwin/i
|
28
|
+
s.add_development_dependency "fakeweb"
|
29
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module Butterfly
|
2
|
+
class Like
|
3
|
+
|
4
|
+
attr_accessor :service,
|
5
|
+
:id,
|
6
|
+
:title,
|
7
|
+
:description,
|
8
|
+
:created_at,
|
9
|
+
:liked_at,
|
10
|
+
:tags,
|
11
|
+
:photo_url,
|
12
|
+
:url,
|
13
|
+
:type,
|
14
|
+
:user
|
15
|
+
|
16
|
+
def initialize(attributes = {})
|
17
|
+
attributes.each_pair do |key, value|
|
18
|
+
self.send("#{key}=", value)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def as_json(options = {})
|
23
|
+
instance_values.merge("user" => user.as_json)
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
module Butterfly
|
2
|
+
module Provider
|
3
|
+
class Dribbble < Base
|
4
|
+
|
5
|
+
base_uri "http://api.dribbble.com"
|
6
|
+
|
7
|
+
attr_reader :username
|
8
|
+
|
9
|
+
def initialize(username)
|
10
|
+
@username = username
|
11
|
+
end
|
12
|
+
|
13
|
+
def raw
|
14
|
+
@raw ||= self.class.get("/players/#{username}/shots/likes", :format => :json)
|
15
|
+
end
|
16
|
+
|
17
|
+
def likes
|
18
|
+
@likes ||= raw["shots"].collect do |raw_like|
|
19
|
+
Butterfly::Like.new({
|
20
|
+
:service => "dribbble",
|
21
|
+
:id => raw_like["id"],
|
22
|
+
:title => raw_like["title"],
|
23
|
+
:description => raw_like["title"],
|
24
|
+
:created_at => DateTime.parse(raw_like["created_at"]),
|
25
|
+
:liked_at => nil,
|
26
|
+
:tags => [],
|
27
|
+
:photo_url => raw_like["image_url"],
|
28
|
+
:url => raw_like["url"],
|
29
|
+
:type => "photo",
|
30
|
+
:user => Butterfly::User.new({
|
31
|
+
:id => raw_like["player"]["id"],
|
32
|
+
:username => raw_like["player"]["username"],
|
33
|
+
:name => raw_like["player"]["name"],
|
34
|
+
:service_url => raw_like["player"]["url"],
|
35
|
+
:photo_url => raw_like["player"]["avatar_url"],
|
36
|
+
:website_url => raw_like["player"]["website_url"],
|
37
|
+
:location => raw_like["player"]["location"],
|
38
|
+
})
|
39
|
+
})
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
module Butterfly
|
2
|
+
module Provider
|
3
|
+
class Flickr < Base
|
4
|
+
|
5
|
+
EXTRAS = %w(description license date_upload date_taken owner_name icon_server original_format last_update geo tags machine_tags o_dims views media path_alias url_sq url_t url_s url_m url_z url_l url_o)
|
6
|
+
|
7
|
+
base_uri "http://api.flickr.com/services/rest"
|
8
|
+
|
9
|
+
attr_reader :user_id, :api_key
|
10
|
+
|
11
|
+
def initialize(user_id, api_key)
|
12
|
+
@user_id, @api_key = user_id, api_key
|
13
|
+
end
|
14
|
+
|
15
|
+
def raw
|
16
|
+
@raw ||= self.class.get("/", :format => :json, :query => { :method => "flickr.favorites.getPublicList", :api_key => api_key, :user_id => user_id, :format => "json", :nojsoncallback => "1", :extras => EXTRAS.join(",") })
|
17
|
+
end
|
18
|
+
|
19
|
+
def likes
|
20
|
+
@likes ||= raw["photos"]["photo"].collect do |raw_like|
|
21
|
+
Butterfly::Like.new({
|
22
|
+
:service => "flickr",
|
23
|
+
:id => raw_like["id"],
|
24
|
+
:title => raw_like["title"],
|
25
|
+
:description => raw_like["description"]["_content"],
|
26
|
+
:created_at => Time.at(raw_like["dateupload"].to_i),
|
27
|
+
:liked_at => Time.at(raw_like["date_faved"].to_i),
|
28
|
+
:tags => raw_like["tags"].split(" "),
|
29
|
+
:photo_url => raw_like["url_sq"],
|
30
|
+
:url => "http://www.flickr.com/photos/#{raw_like["pathalias"]}/#{raw_like["id"]}/",
|
31
|
+
:type => "photo",
|
32
|
+
:user => Butterfly::User.new({
|
33
|
+
:id => raw_like["owner"],
|
34
|
+
:username => raw_like["ownername"],
|
35
|
+
:name => raw_like["ownername"],
|
36
|
+
:service_url => "http://www.flickr.com/photos/#{raw_like["pathalias"]}/",
|
37
|
+
:photo_url => nil,
|
38
|
+
:website_url => nil,
|
39
|
+
:location => nil,
|
40
|
+
})
|
41
|
+
})
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,83 @@
|
|
1
|
+
module Butterfly
|
2
|
+
module Provider
|
3
|
+
class Tumblr < Base
|
4
|
+
|
5
|
+
base_uri "http://www.tumblr.com/api"
|
6
|
+
|
7
|
+
attr_reader :email, :password
|
8
|
+
|
9
|
+
def initialize(email, password)
|
10
|
+
@email, @password = email, password
|
11
|
+
end
|
12
|
+
|
13
|
+
def raw
|
14
|
+
@raw ||= self.class.get("/likes", :format => :xml, :query => { :email => email, :password => password })
|
15
|
+
end
|
16
|
+
|
17
|
+
# TODO - could do some better handling of some forms
|
18
|
+
def likes
|
19
|
+
@likes ||= raw["tumblr"]["posts"]["post"].collect do |raw_like|
|
20
|
+
if raw_like["type"] == "regular"
|
21
|
+
title = raw_like["regular_title"]
|
22
|
+
body = raw_like["regular_body"]
|
23
|
+
type = "text"
|
24
|
+
photo_url = nil
|
25
|
+
elsif raw_like["type"] == "quote"
|
26
|
+
title = raw_like["quote_text"]
|
27
|
+
body = raw_like["quote_source"]
|
28
|
+
type = "text"
|
29
|
+
photo_url = nil
|
30
|
+
elsif raw_like["type"] == "photo"
|
31
|
+
title = raw_like["photo_caption"]
|
32
|
+
body = raw_like["photo_caption"]
|
33
|
+
type = "photo"
|
34
|
+
photo_url = raw_like["photo_url"].last
|
35
|
+
elsif raw_like["type"] == "link"
|
36
|
+
title = raw_like["link_text"]
|
37
|
+
body = raw_like["link_description"]
|
38
|
+
type = "text"
|
39
|
+
photo_url = nil
|
40
|
+
elsif raw_like["type"] == "conversation"
|
41
|
+
title = raw_like["conversation_title"]
|
42
|
+
body = raw_like["conversation_text"]
|
43
|
+
type = "text"
|
44
|
+
photo_url = nil
|
45
|
+
elsif raw_like["type"] == "video"
|
46
|
+
title = raw_like["video_caption"]
|
47
|
+
body = raw_like["video_player"]
|
48
|
+
type = "video"
|
49
|
+
photo_url = nil
|
50
|
+
elsif raw_like["type"] == "audio"
|
51
|
+
title = raw_like["audio_caption"]
|
52
|
+
body = raw_like["audio_player"]
|
53
|
+
type = "audio"
|
54
|
+
photo_url = nil
|
55
|
+
end
|
56
|
+
|
57
|
+
Butterfly::Like.new({
|
58
|
+
:service => "tumblr",
|
59
|
+
:id => raw_like["id"],
|
60
|
+
:title => title,
|
61
|
+
:description => body,
|
62
|
+
:created_at => Time.at(raw_like["unix_timestamp"].to_i),
|
63
|
+
:liked_at => nil,
|
64
|
+
:tags => raw_like["tag"],
|
65
|
+
:photo_url => photo_url,
|
66
|
+
:url => raw_like["url_with_slug"],
|
67
|
+
:type => type,
|
68
|
+
:user => Butterfly::User.new({
|
69
|
+
:id => raw_like["tumblelog"],
|
70
|
+
:username => raw_like["tumblelog"],
|
71
|
+
:name => raw_like["tumblelog"],
|
72
|
+
:service_url => "#{raw_like["tumblelog"]}.tumblr.com",
|
73
|
+
:photo_url => nil,
|
74
|
+
:website_url => nil,
|
75
|
+
:location => nil,
|
76
|
+
})
|
77
|
+
})
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
module Butterfly
|
2
|
+
module Provider
|
3
|
+
class Twitter < Base
|
4
|
+
|
5
|
+
base_uri "http://api.twitter.com/1"
|
6
|
+
|
7
|
+
attr_reader :username
|
8
|
+
|
9
|
+
def initialize(username)
|
10
|
+
@username = username
|
11
|
+
end
|
12
|
+
|
13
|
+
def raw
|
14
|
+
@raw ||= self.class.get("/favorites/#{username}.json", :format => :json, :query => { :include_entities => 1 })
|
15
|
+
end
|
16
|
+
|
17
|
+
def likes
|
18
|
+
@likes ||= raw.collect do |raw_like|
|
19
|
+
Butterfly::Like.new({
|
20
|
+
:service => "twitter",
|
21
|
+
:id => raw_like["id"],
|
22
|
+
:title => raw_like["text"],
|
23
|
+
:description => raw_like["text"],
|
24
|
+
:created_at => Time.parse(raw_like["created_at"]),
|
25
|
+
:liked_at => nil,
|
26
|
+
:tags => [],
|
27
|
+
:photo_url => nil,
|
28
|
+
:url => "http://twitter.com/#{raw_like["user"]["screen_name"]}/status/#{raw_like["id"]}",
|
29
|
+
:type => "text",
|
30
|
+
:user => Butterfly::User.new({
|
31
|
+
:id => raw_like["user"]["id"],
|
32
|
+
:username => raw_like["user"]["screen_name"],
|
33
|
+
:name => raw_like["user"]["name"],
|
34
|
+
:service_url => "http://twitter.com/#{raw_like["user"]["screen_name"]}",
|
35
|
+
:photo_url => raw_like["user"]["profile_image_url"],
|
36
|
+
:website_url => raw_like["user"]["url"],
|
37
|
+
:location => raw_like["user"]["location"],
|
38
|
+
})
|
39
|
+
})
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Butterfly
|
2
|
+
class User
|
3
|
+
|
4
|
+
attr_accessor :id,
|
5
|
+
:username,
|
6
|
+
:name,
|
7
|
+
:service_url,
|
8
|
+
:photo_url,
|
9
|
+
:website_url,
|
10
|
+
:location
|
11
|
+
|
12
|
+
def initialize(attributes = {})
|
13
|
+
attributes.each_pair do |key, value|
|
14
|
+
self.send("#{key}=", value)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
end
|
data/lib/butterfly.rb
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
module Butterfly
|
2
|
+
end
|
3
|
+
|
4
|
+
require "active_support/json"
|
5
|
+
|
6
|
+
require "butterfly/like"
|
7
|
+
require "butterfly/user"
|
8
|
+
|
9
|
+
require "butterfly/provider/base"
|
10
|
+
require "butterfly/provider/dribbble"
|
11
|
+
require "butterfly/provider/flickr"
|
12
|
+
require "butterfly/provider/tumblr"
|
13
|
+
require "butterfly/provider/twitter"
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Butterfly::Provider::Dribbble do
|
4
|
+
|
5
|
+
let(:valid_response) { File.read(File.join(RSPEC_ROOT, "support/responses/dribbble.json")) }
|
6
|
+
|
7
|
+
it "should retrieve dribbble likes" do
|
8
|
+
FakeWeb.register_uri(:get, "http://api.dribbble.com/players/testusername/shots/likes", :body => valid_response)
|
9
|
+
|
10
|
+
dribbble = Butterfly::Provider::Dribbble.new("testusername")
|
11
|
+
|
12
|
+
dribbble.likes.first.as_json.should == {
|
13
|
+
"service" => "dribbble",
|
14
|
+
"id" => 123746,
|
15
|
+
"title" => "Cross Stitch",
|
16
|
+
"description" => "Cross Stitch",
|
17
|
+
"created_at" => Time.new(2011, 3, 4, 11, 21, 46, "-05:00"),
|
18
|
+
"liked_at" => nil,
|
19
|
+
"tags" => [],
|
20
|
+
"photo_url" => "http://dribbble.com/system/users/1396/screenshots/123746/shot_1299255706.jpg?1299580058",
|
21
|
+
"url" => "http://dribbble.com/shots/123746-Cross-Stitch",
|
22
|
+
"type" => "photo",
|
23
|
+
"user" => {
|
24
|
+
"id" => 1396,
|
25
|
+
"username" => "chloe_eardley",
|
26
|
+
"name" => "Chloe Angharad Eardley",
|
27
|
+
"service_url" => "http://dribbble.com/chloe_eardley",
|
28
|
+
"photo_url" => "http://dribbble.com/system/users/1396/avatars/original/me.jpg?1299772963",
|
29
|
+
"website_url" => nil,
|
30
|
+
"location" => "Bristol, UK",
|
31
|
+
}
|
32
|
+
}
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Butterfly::Provider::Flickr do
|
4
|
+
|
5
|
+
let(:valid_response) { File.read(File.join(RSPEC_ROOT, "support/responses/flickr.json")) }
|
6
|
+
|
7
|
+
it "should retrieve flickr likes" do
|
8
|
+
FakeWeb.register_uri(:get, "http://api.flickr.com/services/rest/?method=flickr.favorites.getPublicList&api_key=testapikey&user_id=testuserid&format=json&nojsoncallback=1&extras=description%2Clicense%2Cdate_upload%2Cdate_taken%2Cowner_name%2Cicon_server%2Coriginal_format%2Clast_update%2Cgeo%2Ctags%2Cmachine_tags%2Co_dims%2Cviews%2Cmedia%2Cpath_alias%2Curl_sq%2Curl_t%2Curl_s%2Curl_m%2Curl_z%2Curl_l%2Curl_o", :body => valid_response)
|
9
|
+
|
10
|
+
flickr = Butterfly::Provider::Flickr.new("testuserid", "testapikey")
|
11
|
+
|
12
|
+
flickr.likes.first.as_json.should == {
|
13
|
+
"service" => "flickr",
|
14
|
+
"id" => "5508838592",
|
15
|
+
"title" => "i am thinking it's a sign that the freckles in our eyes are mirror images",
|
16
|
+
"description" => "",
|
17
|
+
"created_at" => Time.new(2011, 3, 8, 21, 13, 44, "+13:00"),
|
18
|
+
"liked_at" => Time.new(2011, 3, 9, 13, 22, 55, "+13:00"),
|
19
|
+
"tags" => ["graffiti", "auckland", "inatree2010"],
|
20
|
+
"photo_url" => "http://farm6.static.flickr.com/5055/5508838592_9fc5e8a643_s.jpg",
|
21
|
+
"url" => "http://www.flickr.com/photos/explode/5508838592/",
|
22
|
+
"type" => "photo",
|
23
|
+
"user" => {
|
24
|
+
"id" => "37996619930@N01",
|
25
|
+
"username" => "mandamonium",
|
26
|
+
"name" => "mandamonium",
|
27
|
+
"service_url" => "http://www.flickr.com/photos/explode/",
|
28
|
+
"photo_url" => nil,
|
29
|
+
"website_url" => nil,
|
30
|
+
"location" => nil
|
31
|
+
}
|
32
|
+
}
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
@@ -0,0 +1,70 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Butterfly::Provider::Tumblr do
|
4
|
+
|
5
|
+
let(:valid_response) { File.read(File.join(RSPEC_ROOT, "support/responses/tumblr.xml")) }
|
6
|
+
|
7
|
+
it "should retrieve tumblr likes" do
|
8
|
+
FakeWeb.register_uri(:get, "http://www.tumblr.com/api/likes?email=testemail&password=testpassword", :body => valid_response)
|
9
|
+
|
10
|
+
tumblr = Butterfly::Provider::Tumblr.new("testemail", "testpassword")
|
11
|
+
|
12
|
+
tumblr.likes.first.as_json.should == {
|
13
|
+
"service" => "tumblr",
|
14
|
+
"id" => "3851619268",
|
15
|
+
"title" => "Text title",
|
16
|
+
"description" => "<p>Test post with some <strong>HTMLs</strong></p>",
|
17
|
+
"created_at" => Time.new(2011, 3, 14, 21, 1, 39, "+13:00"),
|
18
|
+
"liked_at" => nil,
|
19
|
+
"tags" => nil,
|
20
|
+
"photo_url" => nil,
|
21
|
+
"url" => "http://butterflyapitest.tumblr.com/post/3851619268/text-title",
|
22
|
+
"type" => "text",
|
23
|
+
"user" => {
|
24
|
+
"id" => "butterflyapitest",
|
25
|
+
"username" => "butterflyapitest",
|
26
|
+
"name" => "butterflyapitest",
|
27
|
+
"service_url" => "butterflyapitest.tumblr.com",
|
28
|
+
"photo_url" => nil,
|
29
|
+
"website_url" => nil,
|
30
|
+
"location" => nil
|
31
|
+
}
|
32
|
+
}
|
33
|
+
|
34
|
+
tumblr.likes[0].type.should == "text"
|
35
|
+
tumblr.likes[0].title.should == "Text title"
|
36
|
+
tumblr.likes[0].description.should == "<p>Test post with some <strong>HTMLs</strong></p>"
|
37
|
+
tumblr.likes[0].photo_url.should be_nil
|
38
|
+
|
39
|
+
tumblr.likes[1].type.should == "text"
|
40
|
+
tumblr.likes[1].title.should == "I am a quote"
|
41
|
+
tumblr.likes[1].description.should == "John <strong>Smith</strong>"
|
42
|
+
tumblr.likes[1].photo_url.should be_nil
|
43
|
+
|
44
|
+
tumblr.likes[2].type.should == "photo"
|
45
|
+
tumblr.likes[2].title.should == "<p>Caption with <strong>HTML</strong></p>"
|
46
|
+
tumblr.likes[2].description.should == "<p>Caption with <strong>HTML</strong></p>"
|
47
|
+
tumblr.likes[2].photo_url.should == "http://28.media.tumblr.com/tumblr_li1fnzjnOO1qi2hiqo1_75sq.jpg"
|
48
|
+
|
49
|
+
tumblr.likes[3].type.should == "text"
|
50
|
+
tumblr.likes[3].title.should == "Linky link link"
|
51
|
+
tumblr.likes[3].description.should == "<p>Cabbages and <strong>HTML</strong></p>"
|
52
|
+
tumblr.likes[3].photo_url.should be_nil
|
53
|
+
|
54
|
+
tumblr.likes[4].type.should == "text"
|
55
|
+
tumblr.likes[4].title.should == "I like camels"
|
56
|
+
tumblr.likes[4].description.should == "Tourist: Could you give us directions to Olive Garden?\r\nNew Yorker: No, but I could give you directions to an actual Italian restaurant."
|
57
|
+
tumblr.likes[4].photo_url.should be_nil
|
58
|
+
|
59
|
+
tumblr.likes[5].type.should == "video"
|
60
|
+
tumblr.likes[5].title.should == "<p>Caption with <strong>HTML</strong></p>"
|
61
|
+
tumblr.likes[5].description.should == "<object width=\"400\" height=\"325\"><param name=\"movie\" value=\"http://www.youtube.com/v/JZOxqVl5oP4&rel=0&egm=0&showinfo=0&fs=1\"></param><param name=\"wmode\" value=\"transparent\"></param><param name=\"allowFullScreen\" value=\"true\"></param><embed src=\"http://www.youtube.com/v/JZOxqVl5oP4&rel=0&egm=0&showinfo=0&fs=1\" type=\"application/x-shockwave-flash\" width=\"400\" height=\"325\" allowFullScreen=\"true\" wmode=\"transparent\"></embed></object>"
|
62
|
+
tumblr.likes[5].photo_url.should be_nil
|
63
|
+
|
64
|
+
tumblr.likes[6].type.should == "audio"
|
65
|
+
tumblr.likes[6].title.should == "<p>I am a test <strong>audio </strong>upload</p>"
|
66
|
+
tumblr.likes[6].description.should == "<embed type=\"application/x-shockwave-flash\" src=\"http://assets.tumblr.com/swf/audio_player.swf?audio_file=http://www.tumblr.com/audio_file/3851665622/tumblr_li1fvesD151qi2hiq&color=FFFFFF\" height=\"27\" width=\"207\" quality=\"best\"></embed>"
|
67
|
+
tumblr.likes[6].photo_url.should be_nil
|
68
|
+
end
|
69
|
+
|
70
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Butterfly::Provider::Twitter do
|
4
|
+
|
5
|
+
let(:valid_response) { File.read(File.join(RSPEC_ROOT, "support/responses/twitter.json")) }
|
6
|
+
|
7
|
+
it "should retrieve twitter likes" do
|
8
|
+
FakeWeb.register_uri(:get, "http://api.twitter.com/1/favorites/testusername.json?include_entities=1", :body => valid_response)
|
9
|
+
|
10
|
+
twitter = Butterfly::Provider::Twitter.new("testusername")
|
11
|
+
|
12
|
+
twitter.likes.first.as_json.should == {
|
13
|
+
"service" => "twitter",
|
14
|
+
"id" => 45864664919318529,
|
15
|
+
"title" => "Post-it wars in Clerkenwell: @UMLondon started with http://twitpic.com/485g82 so @wearesocial have replied http://twitpic.com/485fs1",
|
16
|
+
"description" => "Post-it wars in Clerkenwell: @UMLondon started with http://twitpic.com/485g82 so @wearesocial have replied http://twitpic.com/485fs1",
|
17
|
+
"created_at" => Time.new(2011, 3, 11, 4, 12, 42, "+13:00"),
|
18
|
+
"liked_at" => nil,
|
19
|
+
"tags" => [],
|
20
|
+
"photo_url" => nil,
|
21
|
+
"url" => "http://twitter.com/qwghlm/status/45864664919318529",
|
22
|
+
"type" => "text",
|
23
|
+
"user" => {
|
24
|
+
"id" => 80363,
|
25
|
+
"username" => "qwghlm",
|
26
|
+
"name" => "Chris Applegate",
|
27
|
+
"service_url" => "http://twitter.com/qwghlm",
|
28
|
+
"photo_url" => "http://a2.twimg.com/profile_images/1234065174/Photo_on_2011-02-03_at_22.18_normal.jpg",
|
29
|
+
"website_url" => "http://qwghlm.co.uk/",
|
30
|
+
"location" => "London, UK"
|
31
|
+
}
|
32
|
+
}
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
{"total":32,"shots":[{"player":{"shots_count":32,"twitter_screen_name":"chloeeee","avatar_url":"http://dribbble.com/system/users/1396/avatars/original/me.jpg?1299772963","likes_received_count":165,"name":"Chloe Angharad Eardley","created_at":"2010/03/19 04:49:27 -0400","location":"Bristol, UK","following_count":113,"likes_count":178,"website_url":null,"username":"chloe_eardley","url":"http://dribbble.com/chloe_eardley","rebounds_count":2,"draftees_count":3,"id":1396,"drafted_by_player_id":968,"followers_count":67,"comments_received_count":79,"comments_count":37,"rebounds_received_count":1},"short_url":"http://drbl.in/123746","created_at":"2011/03/04 11:21:46 -0500","image_url":"http://dribbble.com/system/users/1396/screenshots/123746/shot_1299255706.jpg?1299580058","title":"Cross Stitch","likes_count":16,"rebound_source_id":null,"url":"http://dribbble.com/shots/123746-Cross-Stitch","rebounds_count":0,"id":123746,"image_teaser_url":"http://dribbble.com/system/users/1396/screenshots/123746/shot_1299255706_teaser.jpg?1299580058","height":300,"views_count":102,"comments_count":7,"width":400},{"player":{"shots_count":56,"twitter_screen_name":"rockatee","avatar_url":"http://dribbble.com/system/users/4082/avatars/original/rockatee.avatar2.png?1281638825","likes_received_count":1117,"name":"Maleika","created_at":"2010/08/11 17:43:37 -0400","location":"Germany","following_count":693,"likes_count":3964,"website_url":"http://rockatee.com/","username":"rockatee","url":"http://dribbble.com/rockatee","rebounds_count":9,"draftees_count":2,"id":4082,"drafted_by_player_id":1148,"followers_count":635,"comments_received_count":276,"comments_count":710,"rebounds_received_count":10},"short_url":"http://drbl.in/114823","created_at":"2011/02/14 08:35:01 -0500","image_url":"http://dribbble.com/system/users/4082/screenshots/114823/shot_1297690501.png?1299534490","title":"Latest News","likes_count":111,"rebound_source_id":null,"url":"http://dribbble.com/shots/114823-Latest-News","rebounds_count":0,"id":114823,"image_teaser_url":"http://dribbble.com/system/users/4082/screenshots/114823/shot_1297690501_teaser.png?1299534490","height":300,"views_count":912,"comments_count":14,"width":400},{"player":{"shots_count":37,"twitter_screen_name":"JulienRenvoye","avatar_url":"http://dribbble.com/system/users/2559/avatars/original/logo-new.png?1280333725","likes_received_count":2121,"name":"Julien Renvoye","created_at":"2010/06/03 11:13:06 -0400","location":"San Diego","following_count":189,"likes_count":214,"website_url":"http://www.justalab.com","username":"Jrenvoye","url":"http://dribbble.com/Jrenvoye","rebounds_count":2,"draftees_count":2,"id":2559,"drafted_by_player_id":635,"followers_count":792,"comments_received_count":268,"comments_count":178,"rebounds_received_count":2},"short_url":"http://drbl.in/120088","created_at":"2011/02/24 18:33:36 -0500","image_url":"http://dribbble.com/system/users/2559/screenshots/120088/shot_1298590416.jpg?1299631575","title":"Gmail Pokki Final Ui","likes_count":366,"rebound_source_id":113836,"url":"http://dribbble.com/shots/120088-Gmail-Pokki-Final-Ui","rebounds_count":0,"id":120088,"image_teaser_url":"http://dribbble.com/system/users/2559/screenshots/120088/shot_1298590416_teaser.jpg?1299631575","height":300,"views_count":5888,"comments_count":22,"width":400},{"player":{"shots_count":22,"twitter_screen_name":"@foundationsix","avatar_url":"http://dribbble.com/system/users/771/avatars/original/IMG_5472.jpg?1288135528","likes_received_count":2755,"name":"Dave Ruiz","created_at":"2010/01/22 11:55:53 -0500","location":"Hamilton, ON Canada ","following_count":106,"likes_count":1084,"website_url":"http://www.foundationsix.com","username":"foundationsix","url":"http://dribbble.com/foundationsix","rebounds_count":0,"draftees_count":3,"id":771,"drafted_by_player_id":49,"followers_count":1087,"comments_received_count":398,"comments_count":205,"rebounds_received_count":1},"short_url":"http://drbl.in/119787","created_at":"2011/02/24 11:15:28 -0500","image_url":"http://dribbble.com/system/users/771/screenshots/119787/shot_1298564128.jpg?1299864380","title":"Steelfish Exploration","likes_count":188,"rebound_source_id":null,"url":"http://dribbble.com/shots/119787-Steelfish-Exploration","rebounds_count":0,"id":119787,"image_teaser_url":"http://dribbble.com/system/users/771/screenshots/119787/shot_1298564128_teaser.jpg?1299864380","height":300,"views_count":1821,"comments_count":21,"width":400},{"player":{"shots_count":108,"twitter_screen_name":"RypeArts","avatar_url":"http://dribbble.com/system/users/3460/avatars/original/Avatar.jpg?1279284541","likes_received_count":8312,"name":"Ryan Putnam","created_at":"2010/07/16 08:48:16 -0400","location":"Colorado Springs, CO","following_count":174,"likes_count":2483,"website_url":"http://rypearts.com","username":"RypeArts","url":"http://dribbble.com/RypeArts","rebounds_count":37,"draftees_count":3,"id":3460,"drafted_by_player_id":431,"followers_count":1890,"comments_received_count":1241,"comments_count":233,"rebounds_received_count":44},"short_url":"http://drbl.in/120275","created_at":"2011/02/25 08:53:06 -0500","image_url":"http://dribbble.com/system/users/3460/screenshots/120275/shot_1298641986.png?1299759378","title":"WeeCons","likes_count":151,"rebound_source_id":null,"url":"http://dribbble.com/shots/120275-WeeCons","rebounds_count":0,"id":120275,"image_teaser_url":"http://dribbble.com/system/users/3460/screenshots/120275/shot_1298641986_teaser.png?1299759378","height":300,"views_count":2421,"comments_count":13,"width":400},{"player":{"shots_count":56,"twitter_screen_name":"rockatee","avatar_url":"http://dribbble.com/system/users/4082/avatars/original/rockatee.avatar2.png?1281638825","likes_received_count":1117,"name":"Maleika","created_at":"2010/08/11 17:43:37 -0400","location":"Germany","following_count":693,"likes_count":3964,"website_url":"http://rockatee.com/","username":"rockatee","url":"http://dribbble.com/rockatee","rebounds_count":9,"draftees_count":2,"id":4082,"drafted_by_player_id":1148,"followers_count":635,"comments_received_count":276,"comments_count":710,"rebounds_received_count":10},"short_url":"http://drbl.in/106532","created_at":"2011/01/27 23:10:33 -0500","image_url":"http://dribbble.com/system/users/4082/screenshots/106532/shot_1296187833.png?1299211539","title":"Roads Without Path","likes_count":39,"rebound_source_id":null,"url":"http://dribbble.com/shots/106532-Roads-Without-Path","rebounds_count":0,"id":106532,"image_teaser_url":"http://dribbble.com/system/users/4082/screenshots/106532/shot_1296187833_teaser.png?1299211539","height":300,"views_count":310,"comments_count":8,"width":400},{"player":{"shots_count":56,"twitter_screen_name":"rockatee","avatar_url":"http://dribbble.com/system/users/4082/avatars/original/rockatee.avatar2.png?1281638825","likes_received_count":1117,"name":"Maleika","created_at":"2010/08/11 17:43:37 -0400","location":"Germany","following_count":693,"likes_count":3964,"website_url":"http://rockatee.com/","username":"rockatee","url":"http://dribbble.com/rockatee","rebounds_count":9,"draftees_count":2,"id":4082,"drafted_by_player_id":1148,"followers_count":635,"comments_received_count":276,"comments_count":710,"rebounds_received_count":10},"short_url":"http://drbl.in/111841","created_at":"2011/02/07 22:39:38 -0500","image_url":"http://dribbble.com/system/users/4082/screenshots/111841/shot_1297136378.png?1299541743","title":"Helvetica \u201cAlpha\u201d Ornament","likes_count":20,"rebound_source_id":null,"url":"http://dribbble.com/shots/111841-Helvetica-Alpha-Ornament","rebounds_count":0,"id":111841,"image_teaser_url":"http://dribbble.com/system/users/4082/screenshots/111841/shot_1297136378_teaser.png?1299541743","height":300,"views_count":127,"comments_count":2,"width":400},{"player":{"shots_count":56,"twitter_screen_name":"rockatee","avatar_url":"http://dribbble.com/system/users/4082/avatars/original/rockatee.avatar2.png?1281638825","likes_received_count":1117,"name":"Maleika","created_at":"2010/08/11 17:43:37 -0400","location":"Germany","following_count":693,"likes_count":3964,"website_url":"http://rockatee.com/","username":"rockatee","url":"http://dribbble.com/rockatee","rebounds_count":9,"draftees_count":2,"id":4082,"drafted_by_player_id":1148,"followers_count":635,"comments_received_count":276,"comments_count":710,"rebounds_received_count":10},"short_url":"http://drbl.in/111918","created_at":"2011/02/08 03:01:34 -0500","image_url":"http://dribbble.com/system/users/4082/screenshots/111918/shot_1297152094.png?1299700809","title":"Helvetica Alphamate Planes","likes_count":39,"rebound_source_id":null,"url":"http://dribbble.com/shots/111918-Helvetica-Alphamate-Planes","rebounds_count":0,"id":111918,"image_teaser_url":"http://dribbble.com/system/users/4082/screenshots/111918/shot_1297152094_teaser.png?1299700809","height":300,"views_count":275,"comments_count":6,"width":400},{"player":{"shots_count":4,"twitter_screen_name":"eklosterman","avatar_url":"http://dribbble.com/system/users/6135/avatars/original/twitter_normal.jpg?1292720571","likes_received_count":30,"name":"Erica Klosterman","created_at":"2010/12/18 20:02:51 -0500","location":"Orlando, FL","following_count":4,"likes_count":7,"website_url":null,"username":"ericaklosterman","url":"http://dribbble.com/ericaklosterman","rebounds_count":0,"draftees_count":0,"id":6135,"drafted_by_player_id":1329,"followers_count":23,"comments_received_count":5,"comments_count":2,"rebounds_received_count":0},"short_url":"http://drbl.in/111232","created_at":"2011/02/06 21:22:17 -0500","image_url":"http://dribbble.com/system/users/6135/screenshots/111232/shot_1297045337.jpg?1297153455","title":"Badge","likes_count":10,"rebound_source_id":null,"url":"http://dribbble.com/shots/111232-Badge","rebounds_count":0,"id":111232,"image_teaser_url":"http://dribbble.com/system/users/6135/screenshots/111232/shot_1297045337_teaser.jpg?1297153455","height":300,"views_count":134,"comments_count":0,"width":400},{"player":{"shots_count":24,"twitter_screen_name":"jpwain","avatar_url":"http://dribbble.com/system/users/2971/avatars/original/boat.png?1276183769","likes_received_count":348,"name":"Joseph Wain","created_at":"2010/06/10 11:28:14 -0400","location":"NYC","following_count":51,"likes_count":78,"website_url":"http://penandthink.com","username":"jpwain","url":"http://dribbble.com/jpwain","rebounds_count":3,"draftees_count":1,"id":2971,"drafted_by_player_id":718,"followers_count":155,"comments_received_count":100,"comments_count":40,"rebounds_received_count":3},"short_url":"http://drbl.in/66883","created_at":"2010/10/16 12:11:56 -0400","image_url":"http://dribbble.com/system/users/2971/screenshots/66883/shot_1287245516.png?1298210218","title":"Conspiracy","likes_count":30,"rebound_source_id":null,"url":"http://dribbble.com/shots/66883-Conspiracy","rebounds_count":2,"id":66883,"image_teaser_url":"http://dribbble.com/system/users/2971/screenshots/66883/shot_1287245516_teaser.png?1298210218","height":300,"views_count":3779,"comments_count":14,"width":400},{"player":{"shots_count":22,"twitter_screen_name":"jarred","avatar_url":"http://dribbble.com/system/users/488/avatars/original/faceScan.jpg?1263922444","likes_received_count":118,"name":"Jarred Bishop","created_at":"2010/01/19 00:55:31 -0500","location":"Wellington NZ","following_count":92,"likes_count":55,"website_url":"http://jarredbishop.info","username":"jarred","url":"http://dribbble.com/jarred","rebounds_count":0,"draftees_count":3,"id":488,"drafted_by_player_id":444,"followers_count":89,"comments_received_count":30,"comments_count":5,"rebounds_received_count":0},"short_url":"http://drbl.in/60985","created_at":"2010/10/03 00:55:28 -0400","image_url":"http://dribbble.com/system/users/488/screenshots/60985/shot_1286081728.png?1286081741","title":"internal dashboard.","likes_count":9,"rebound_source_id":null,"url":"http://dribbble.com/shots/60985-internal-dashboard-","rebounds_count":0,"id":60985,"image_teaser_url":"http://dribbble.com/system/users/488/screenshots/60985/shot_1286081728_teaser.png?1286081741","height":300,"views_count":457,"comments_count":1,"width":400},{"player":{"shots_count":26,"twitter_screen_name":"mrb","avatar_url":"http://dribbble.com/system/users/444/avatars/original/matt-2011.jpg?1292924199","likes_received_count":257,"name":"Matthew Buchanan","created_at":"2010/01/11 14:09:08 -0500","location":"Auckland, New Zealand","following_count":264,"likes_count":951,"website_url":"http://matthewbuchanan.name","username":"matthewbuchanan","url":"http://dribbble.com/matthewbuchanan","rebounds_count":3,"draftees_count":10,"id":444,"drafted_by_player_id":127,"followers_count":232,"comments_received_count":83,"comments_count":38,"rebounds_received_count":3},"short_url":"http://drbl.in/56766","created_at":"2010/09/20 19:36:33 -0400","image_url":"http://dribbble.com/system/users/444/screenshots/56766/shot_1285025793.png?1285894880","title":"Product","likes_count":18,"rebound_source_id":null,"url":"http://dribbble.com/shots/56766-Product","rebounds_count":0,"id":56766,"image_teaser_url":"http://dribbble.com/system/users/444/screenshots/56766/shot_1285025793_teaser.png?1285894880","height":300,"views_count":386,"comments_count":7,"width":400},{"player":{"shots_count":75,"twitter_screen_name":"cameronmoll","avatar_url":"http://dribbble.com/system/users/11/avatars/original/cm141.jpg?1256606522","likes_received_count":2548,"name":"Cameron Moll","created_at":"2009/08/06 22:25:36 -0400","location":"Sarasota, Florida","following_count":159,"likes_count":527,"website_url":"http://cameronmoll.com/","username":"cameronmoll","url":"http://dribbble.com/cameronmoll","rebounds_count":16,"draftees_count":13,"id":11,"drafted_by_player_id":1,"followers_count":3998,"comments_received_count":806,"comments_count":388,"rebounds_received_count":63},"short_url":"http://drbl.in/50785","created_at":"2010/08/31 10:22:43 -0400","image_url":"http://dribbble.com/system/users/11/screenshots/50785/shot_1283264563.png?1297368851","title":"Five","likes_count":158,"rebound_source_id":null,"url":"http://dribbble.com/shots/50785-Five","rebounds_count":1,"id":50785,"image_teaser_url":"http://dribbble.com/system/users/11/screenshots/50785/shot_1283264563_teaser.png?1297368851","height":300,"views_count":3578,"comments_count":29,"width":400},{"player":{"shots_count":22,"twitter_screen_name":"jarred","avatar_url":"http://dribbble.com/system/users/488/avatars/original/faceScan.jpg?1263922444","likes_received_count":118,"name":"Jarred Bishop","created_at":"2010/01/19 00:55:31 -0500","location":"Wellington NZ","following_count":92,"likes_count":55,"website_url":"http://jarredbishop.info","username":"jarred","url":"http://dribbble.com/jarred","rebounds_count":0,"draftees_count":3,"id":488,"drafted_by_player_id":444,"followers_count":89,"comments_received_count":30,"comments_count":5,"rebounds_received_count":0},"short_url":"http://drbl.in/44978","created_at":"2010/08/12 23:58:40 -0400","image_url":"http://dribbble.com/system/users/488/screenshots/44978/shot_1281671920.jpg?1281671971","title":"41\u00b0\u00d7174\u00b0","likes_count":13,"rebound_source_id":null,"url":"http://dribbble.com/shots/44978-41-174-","rebounds_count":0,"id":44978,"image_teaser_url":"http://dribbble.com/system/users/488/screenshots/44978/shot_1281671920_teaser.jpg?1281671971","height":220,"views_count":421,"comments_count":2,"width":400},{"player":{"shots_count":46,"twitter_screen_name":"mrgan","avatar_url":"http://dribbble.com/system/users/1425/avatars/original/Derek-avatar.png?1269003782","likes_received_count":1080,"name":"Neven Mrgan","created_at":"2010/03/19 08:23:14 -0400","location":"Portland, OR","following_count":32,"likes_count":20,"website_url":"Http://mrgan.com","username":"neven","url":"http://dribbble.com/neven","rebounds_count":3,"draftees_count":5,"id":1425,"drafted_by_player_id":215,"followers_count":832,"comments_received_count":298,"comments_count":74,"rebounds_received_count":8},"short_url":"http://drbl.in/44530","created_at":"2010/08/11 23:56:47 -0400","image_url":"http://dribbble.com/system/users/1425/screenshots/44530/shot_1281585407.png?1294979746","title":"Grubeway","likes_count":59,"rebound_source_id":null,"url":"http://dribbble.com/shots/44530-Grubeway","rebounds_count":1,"id":44530,"image_teaser_url":"http://dribbble.com/system/users/1425/screenshots/44530/shot_1281585407_teaser.png?1294979746","height":300,"views_count":3210,"comments_count":15,"width":400}],"pages":3,"page":1,"per_page":15}
|