meme 0.1.2 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +24 -2
- data/VERSION +1 -1
- data/lib/meme.rb +3 -60
- data/lib/meme/info.rb +111 -0
- data/lib/meme/request.rb +13 -0
- data/lib/meme/search.rb +47 -0
- data/meme.gemspec +16 -3
- data/spec/fixtures/meme_followers.json +112 -0
- data/spec/fixtures/meme_followers_all.json +372 -0
- data/spec/fixtures/meme_followers_count.json +62 -0
- data/spec/fixtures/meme_following.json +112 -0
- data/spec/fixtures/meme_following_all.json +402 -0
- data/spec/fixtures/meme_following_count.json +82 -0
- data/spec/info_spec.rb +87 -0
- data/spec/meme_spec.rb +0 -136
- data/spec/search_spec.rb +75 -0
- data/spec/spec_helper.rb +9 -1
- metadata +15 -2
data/spec/info_spec.rb
ADDED
@@ -0,0 +1,87 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
+
|
3
|
+
describe "Meme::Info" do
|
4
|
+
|
5
|
+
describe "#user not found" do
|
6
|
+
it "should return nil" do
|
7
|
+
query = "SELECT * FROM meme.info WHERE name='memeusernotfound'"
|
8
|
+
fake_web(query, 'meme_info_not_found.json')
|
9
|
+
Meme::Info.find('memeusernotfound').should be_nil
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
before :each do
|
14
|
+
query = "SELECT * FROM meme.info WHERE name='jtadeulopes'"
|
15
|
+
fake_web(query, 'meme_info.json')
|
16
|
+
@profile = Meme::Info.find('jtadeulopes')
|
17
|
+
end
|
18
|
+
|
19
|
+
it "should return name" do
|
20
|
+
@profile.name.should == "jtadeulopes"
|
21
|
+
end
|
22
|
+
|
23
|
+
it "should return guid" do
|
24
|
+
@profile.guid.should == "EMREXCV4R5OTM3CZW3HBD5QAGY"
|
25
|
+
end
|
26
|
+
|
27
|
+
it "should return page title" do
|
28
|
+
@profile.title.should == "Jésus Lopes"
|
29
|
+
end
|
30
|
+
|
31
|
+
it "should return description" do
|
32
|
+
@profile.description.should == "software developer"
|
33
|
+
end
|
34
|
+
|
35
|
+
it "should return url" do
|
36
|
+
@profile.url.should == "http://meme.yahoo.com/jtadeulopes/"
|
37
|
+
end
|
38
|
+
|
39
|
+
it "should return avatar" do
|
40
|
+
@profile.avatar_url.should == "http://d.yimg.com/gg/jtadeulopes/avatars/44251e70378d4d225f8cda09a6c3aec87301833a.jpeg"
|
41
|
+
end
|
42
|
+
|
43
|
+
it "should return language" do
|
44
|
+
@profile.language.should == "pt"
|
45
|
+
end
|
46
|
+
|
47
|
+
describe "#followers" do
|
48
|
+
|
49
|
+
it "should return followers" do
|
50
|
+
query = "SELECT * FROM meme.followers(10) WHERE owner_guid='EMREXCV4R5OTM3CZW3HBD5QAGY'"
|
51
|
+
fake_web(query, 'meme_followers.json')
|
52
|
+
@profile.followers.count.should == 10
|
53
|
+
end
|
54
|
+
|
55
|
+
it "should return five followers" do
|
56
|
+
query = "SELECT * FROM meme.followers(5) WHERE owner_guid='EMREXCV4R5OTM3CZW3HBD5QAGY'"
|
57
|
+
fake_web(query, 'meme_followers_count.json')
|
58
|
+
@profile.followers(5).count.should == 5
|
59
|
+
end
|
60
|
+
|
61
|
+
it "should return all followers" do
|
62
|
+
query = "SELECT * FROM meme.followers(0) WHERE owner_guid='EMREXCV4R5OTM3CZW3HBD5QAGY'"
|
63
|
+
fake_web(query, 'meme_followers_all.json')
|
64
|
+
@profile.followers(:all).count.should == 36
|
65
|
+
end
|
66
|
+
|
67
|
+
end
|
68
|
+
|
69
|
+
describe "#following" do
|
70
|
+
it "should return following" do
|
71
|
+
query = "SELECT * FROM meme.following(10) WHERE owner_guid='EMREXCV4R5OTM3CZW3HBD5QAGY'"
|
72
|
+
fake_web(query, 'meme_following.json')
|
73
|
+
@profile.following.count.should == 10
|
74
|
+
end
|
75
|
+
it "should return seven following" do
|
76
|
+
query = "SELECT * FROM meme.following(7) WHERE owner_guid='EMREXCV4R5OTM3CZW3HBD5QAGY'"
|
77
|
+
fake_web(query, 'meme_following_count.json')
|
78
|
+
@profile.following(7).count.should == 7
|
79
|
+
end
|
80
|
+
it "should return all following" do
|
81
|
+
query = "SELECT * FROM meme.following(0) WHERE owner_guid='EMREXCV4R5OTM3CZW3HBD5QAGY'"
|
82
|
+
fake_web(query, 'meme_following_all.json')
|
83
|
+
@profile.following(:all).count.should == 39
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
end
|
data/spec/meme_spec.rb
CHANGED
@@ -1,140 +1,4 @@
|
|
1
1
|
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
2
|
|
3
3
|
describe "Meme" do
|
4
|
-
|
5
|
-
describe "info" do
|
6
|
-
|
7
|
-
describe "#user not found" do
|
8
|
-
it "should return nil" do
|
9
|
-
url = URI.escape("https://query.yahooapis.com/v1/public/yql?q=SELECT * FROM meme.info WHERE name='memeusernotfound'&format=json")
|
10
|
-
FakeWeb.register_uri(:get, url, :body => load_fixture('meme_info_not_found.json'))
|
11
|
-
Meme::Info.find('memeusernotfound').should be_nil
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
before :each do
|
16
|
-
name = "jtadeulopes"
|
17
|
-
url = URI.escape("https://query.yahooapis.com/v1/public/yql?q=SELECT * FROM meme.info WHERE name='#{name}'&format=json")
|
18
|
-
FakeWeb.register_uri(:get, url, :body => load_fixture('meme_info.json'))
|
19
|
-
@profile = Meme::Info.find(name)
|
20
|
-
end
|
21
|
-
|
22
|
-
it "should return name" do
|
23
|
-
@profile.name.should == "jtadeulopes"
|
24
|
-
end
|
25
|
-
|
26
|
-
it "should return guid" do
|
27
|
-
@profile.guid.should == "EMREXCV4R5OTM3CZW3HBD5QAGY"
|
28
|
-
end
|
29
|
-
|
30
|
-
it "should return page title" do
|
31
|
-
@profile.title.should == "Jésus Lopes"
|
32
|
-
end
|
33
|
-
|
34
|
-
it "should return description" do
|
35
|
-
@profile.description.should == "software developer"
|
36
|
-
end
|
37
|
-
|
38
|
-
it "should return url" do
|
39
|
-
@profile.url.should == "http://meme.yahoo.com/jtadeulopes/"
|
40
|
-
end
|
41
|
-
|
42
|
-
it "should return avatar" do
|
43
|
-
@profile.avatar_url.should == "http://d.yimg.com/gg/jtadeulopes/avatars/44251e70378d4d225f8cda09a6c3aec87301833a.jpeg"
|
44
|
-
end
|
45
|
-
|
46
|
-
it "should return language" do
|
47
|
-
@profile.language.should == "pt"
|
48
|
-
end
|
49
|
-
|
50
|
-
it "should return followers" do
|
51
|
-
@profile.followers.should == "34"
|
52
|
-
end
|
53
|
-
|
54
|
-
end
|
55
|
-
|
56
|
-
describe "#search" do
|
57
|
-
|
58
|
-
before :each do
|
59
|
-
query = 'meme rocks'
|
60
|
-
url = URI.escape("https://query.yahooapis.com/v1/public/yql?q=SELECT * FROM meme.search WHERE query='#{query}'&format=json")
|
61
|
-
FakeWeb.register_uri(:get, url, :body => load_fixture('meme_search.json'))
|
62
|
-
@results = Meme::Post.find(query)
|
63
|
-
end
|
64
|
-
|
65
|
-
it "should return pubid" do
|
66
|
-
@results.first.pubid.should == "yC8nqOd"
|
67
|
-
end
|
68
|
-
|
69
|
-
it "should return guid" do
|
70
|
-
@results.first.guid.should == "7Z7XFAPD5FLXFKJVT4NG6XTTA4"
|
71
|
-
end
|
72
|
-
|
73
|
-
it "should return url" do
|
74
|
-
@results.first.url.should == "http://meme.yahoo.com/celizelove/p/yC8nqOd/"
|
75
|
-
end
|
76
|
-
|
77
|
-
it "should return timestamp" do
|
78
|
-
@results.first.timestamp.should == "1268410909000"
|
79
|
-
end
|
80
|
-
|
81
|
-
it "should return category" do
|
82
|
-
@results.first.category.should == "text"
|
83
|
-
end
|
84
|
-
|
85
|
-
it "should return type" do
|
86
|
-
@results.first.type.should == "text"
|
87
|
-
end
|
88
|
-
|
89
|
-
it "should return content" do
|
90
|
-
@results[4].content.should == "http://d.yimg.com/gg/u/2441eceb4b334c6fc29c9bd306fe1957693d605e.jpeg"
|
91
|
-
end
|
92
|
-
|
93
|
-
it "should return repost_count" do
|
94
|
-
@results.first.repost_count.should == "0"
|
95
|
-
end
|
96
|
-
|
97
|
-
it "should return caption" do
|
98
|
-
@results[1].caption.should == "This is good. But a lot of things happening means a high chance that I, the man who lives and breathes Panic and has a giant status board in my head, might not properly explain everything to everyone. Steve and I realized it was high time we made this Cabel Status Board public… using technology!"
|
99
|
-
end
|
100
|
-
|
101
|
-
end
|
102
|
-
|
103
|
-
describe "#search by type" do
|
104
|
-
|
105
|
-
describe "#posts not found" do
|
106
|
-
it "should return nil" do
|
107
|
-
query = 'brhackday'
|
108
|
-
fake_web(query, 'audio')
|
109
|
-
Meme::Post.find(query, :type => :audio).should be_nil
|
110
|
-
end
|
111
|
-
end
|
112
|
-
|
113
|
-
it "should search by type photo" do
|
114
|
-
query = 'meme rocks'
|
115
|
-
fake_web(query, 'photo')
|
116
|
-
@results = Meme::Post.find(query, :type => :photo)
|
117
|
-
@results.count.should == 3
|
118
|
-
@results.first.type.should == "photo"
|
119
|
-
end
|
120
|
-
it "should search by type video" do
|
121
|
-
query = 'keyboard cat'
|
122
|
-
fake_web(query, 'video')
|
123
|
-
@results = Meme::Post.find(query, :type => :video)
|
124
|
-
@results.count.should == 2
|
125
|
-
@results.first.type.should == "video"
|
126
|
-
end
|
127
|
-
|
128
|
-
def fake_web(query, type)
|
129
|
-
select = "SELECT * FROM meme.search WHERE query='#{query}' and type='#{type}'"
|
130
|
-
url = URI.escape("https://query.yahooapis.com/v1/public/yql?q=#{select}&format=json")
|
131
|
-
FakeWeb.register_uri(:get, url, :body => load_fixture("meme_search_type_#{type}.json"))
|
132
|
-
end
|
133
|
-
|
134
|
-
end
|
135
|
-
|
136
|
-
def load_fixture(name)
|
137
|
-
File.join(File.expand_path(File.dirname(__FILE__)), '/fixtures', name)
|
138
|
-
end
|
139
|
-
|
140
4
|
end
|
data/spec/search_spec.rb
ADDED
@@ -0,0 +1,75 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
+
|
3
|
+
describe "Meme::Search" do
|
4
|
+
|
5
|
+
before :each do
|
6
|
+
query = "SELECT * FROM meme.search WHERE query='meme rocks'"
|
7
|
+
fake_web(query, 'meme_search.json')
|
8
|
+
@results = Meme::Post.find('meme rocks')
|
9
|
+
end
|
10
|
+
|
11
|
+
it "should return pubid" do
|
12
|
+
@results.first.pubid.should == "yC8nqOd"
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should return guid" do
|
16
|
+
@results.first.guid.should == "7Z7XFAPD5FLXFKJVT4NG6XTTA4"
|
17
|
+
end
|
18
|
+
|
19
|
+
it "should return url" do
|
20
|
+
@results.first.url.should == "http://meme.yahoo.com/celizelove/p/yC8nqOd/"
|
21
|
+
end
|
22
|
+
|
23
|
+
it "should return timestamp" do
|
24
|
+
@results.first.timestamp.should == "1268410909000"
|
25
|
+
end
|
26
|
+
|
27
|
+
it "should return category" do
|
28
|
+
@results.first.category.should == "text"
|
29
|
+
end
|
30
|
+
|
31
|
+
it "should return type" do
|
32
|
+
@results.first.type.should == "text"
|
33
|
+
end
|
34
|
+
|
35
|
+
it "should return content" do
|
36
|
+
@results[4].content.should == "http://d.yimg.com/gg/u/2441eceb4b334c6fc29c9bd306fe1957693d605e.jpeg"
|
37
|
+
end
|
38
|
+
|
39
|
+
it "should return repost_count" do
|
40
|
+
@results.first.repost_count.should == "0"
|
41
|
+
end
|
42
|
+
|
43
|
+
it "should return caption" do
|
44
|
+
@results[1].caption.should == "This is good. But a lot of things happening means a high chance that I, the man who lives and breathes Panic and has a giant status board in my head, might not properly explain everything to everyone. Steve and I realized it was high time we made this Cabel Status Board public… using technology!"
|
45
|
+
end
|
46
|
+
|
47
|
+
describe "#search by" do
|
48
|
+
|
49
|
+
describe "#posts not found" do
|
50
|
+
it "should return nil" do
|
51
|
+
query = "SELECT * FROM meme.search WHERE query='brhackday' and type='audio'"
|
52
|
+
fake_web(query, 'meme_search_type_audio.json')
|
53
|
+
Meme::Post.find('brhackday', :type => :audio).should be_nil
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
it "type photo" do
|
58
|
+
query = "SELECT * FROM meme.search WHERE query='meme rocks' and type='photo'"
|
59
|
+
fake_web(query, 'meme_search_type_photo.json')
|
60
|
+
@results = Meme::Post.find('meme rocks', :type => :photo)
|
61
|
+
@results.count.should == 3
|
62
|
+
@results.first.type.should == "photo"
|
63
|
+
end
|
64
|
+
|
65
|
+
it "type video" do
|
66
|
+
query = "SELECT * FROM meme.search WHERE query='keyboard cat' and type='video'"
|
67
|
+
fake_web(query, 'meme_search_type_video.json')
|
68
|
+
@results = Meme::Post.find('keyboard cat', :type => :video)
|
69
|
+
@results.count.should == 2
|
70
|
+
@results.first.type.should == "video"
|
71
|
+
end
|
72
|
+
|
73
|
+
end
|
74
|
+
|
75
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -9,5 +9,13 @@ require 'json'
|
|
9
9
|
require 'fakeweb'
|
10
10
|
|
11
11
|
Spec::Runner.configure do |config|
|
12
|
-
|
12
|
+
end
|
13
|
+
|
14
|
+
def load_fixture(name)
|
15
|
+
File.join(File.expand_path(File.dirname(__FILE__)), '/fixtures', name)
|
16
|
+
end
|
17
|
+
|
18
|
+
def fake_web(query, fixture)
|
19
|
+
url = URI.escape("https://query.yahooapis.com/v1/public/yql?q=#{query}&format=json")
|
20
|
+
FakeWeb.register_uri(:get, url, :body => load_fixture(fixture))
|
13
21
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: meme
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- "J\xC3\xA9sus Lopes"
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2010-
|
12
|
+
date: 2010-04-01 00:00:00 -03:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -39,14 +39,25 @@ files:
|
|
39
39
|
- Rakefile
|
40
40
|
- VERSION
|
41
41
|
- lib/meme.rb
|
42
|
+
- lib/meme/info.rb
|
43
|
+
- lib/meme/request.rb
|
44
|
+
- lib/meme/search.rb
|
42
45
|
- meme.gemspec
|
46
|
+
- spec/fixtures/meme_followers.json
|
47
|
+
- spec/fixtures/meme_followers_all.json
|
48
|
+
- spec/fixtures/meme_followers_count.json
|
49
|
+
- spec/fixtures/meme_following.json
|
50
|
+
- spec/fixtures/meme_following_all.json
|
51
|
+
- spec/fixtures/meme_following_count.json
|
43
52
|
- spec/fixtures/meme_info.json
|
44
53
|
- spec/fixtures/meme_info_not_found.json
|
45
54
|
- spec/fixtures/meme_search.json
|
46
55
|
- spec/fixtures/meme_search_type_audio.json
|
47
56
|
- spec/fixtures/meme_search_type_photo.json
|
48
57
|
- spec/fixtures/meme_search_type_video.json
|
58
|
+
- spec/info_spec.rb
|
49
59
|
- spec/meme_spec.rb
|
60
|
+
- spec/search_spec.rb
|
50
61
|
- spec/spec.opts
|
51
62
|
- spec/spec_helper.rb
|
52
63
|
has_rdoc: true
|
@@ -79,4 +90,6 @@ specification_version: 3
|
|
79
90
|
summary: Ruby Yahoo! Meme API
|
80
91
|
test_files:
|
81
92
|
- spec/meme_spec.rb
|
93
|
+
- spec/search_spec.rb
|
82
94
|
- spec/spec_helper.rb
|
95
|
+
- spec/info_spec.rb
|