meme 0.1.1
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.
- data/.document +5 -0
- data/.gitignore +21 -0
- data/LICENSE +20 -0
- data/README.rdoc +62 -0
- data/Rakefile +45 -0
- data/VERSION +1 -0
- data/init.rb +3 -0
- data/lib/meme.rb +60 -0
- data/spec/fixtures/meme_info.json +21 -0
- data/spec/fixtures/meme_info_not_found.json +10 -0
- data/spec/fixtures/meme_search.json +122 -0
- data/spec/fixtures/meme_search_type_audio.json +10 -0
- data/spec/fixtures/meme_search_type_photo.json +45 -0
- data/spec/fixtures/meme_search_type_video.json +34 -0
- data/spec/meme_spec.rb +140 -0
- data/spec/spec.opts +2 -0
- data/spec/spec_helper.rb +13 -0
- metadata +82 -0
data/.document
ADDED
data/.gitignore
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2009 Jésus Lopes
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,62 @@
|
|
1
|
+
= meme
|
2
|
+
|
3
|
+
Yahoo! Meme API wrapper library in Ruby
|
4
|
+
|
5
|
+
This project was made during {Yahoo! Open Hack Day Brasil 2010}[http://openhackbrazil.pbworks.com/]. Event that happened in São Paulo 20, 21 of March 2010.
|
6
|
+
|
7
|
+
Meme uses {YQL}[http://developer.yahoo.com/yql/] to get API of {Yahoo! Meme}[http://meme.yahoo.com/] and is based on {meme-py}[http://github.com/guilhermechapiewski/meme-py] API created by {Guilherme Chapiewski}[http://twitter.com/gchapiewski]
|
8
|
+
|
9
|
+
== Usage
|
10
|
+
|
11
|
+
=== Find a user by name
|
12
|
+
|
13
|
+
user = Meme::Info.find('jtadeulopes')
|
14
|
+
|
15
|
+
user.name
|
16
|
+
=> "jtadeulopes"
|
17
|
+
|
18
|
+
user.description
|
19
|
+
=> "software developer"
|
20
|
+
|
21
|
+
user.guid
|
22
|
+
=> "EMREXCV4R5OTM3CZW3HBD5QAGY"
|
23
|
+
|
24
|
+
user.avatar_url
|
25
|
+
=> "http://d.yimg.com/gg/jtadeulopes/avatars/44251e70378d4d225f8cda09a6c3aec87301833a.jpeg"
|
26
|
+
|
27
|
+
=== Find posts
|
28
|
+
|
29
|
+
posts = Meme::Post.find('brhackday')
|
30
|
+
|
31
|
+
posts.first.category
|
32
|
+
=> "text"
|
33
|
+
|
34
|
+
post.first.content
|
35
|
+
=> "RT @codepo8: And I am off - plane leaves BR for London. Thanks to everybody I met at #brhackday. I have not a single bad memory to speak of."
|
36
|
+
|
37
|
+
Find by type:
|
38
|
+
|
39
|
+
posts = Meme::Post.find('meme rocks', :type => :photo)
|
40
|
+
|
41
|
+
posts.first.type
|
42
|
+
=> "photo"
|
43
|
+
|
44
|
+
For more information, please refer the {project wiki}[http://wiki.github.com/jtadeulopes/meme/]
|
45
|
+
|
46
|
+
== TODO
|
47
|
+
|
48
|
+
Much remains to be done! Please refer the {project wiki}[http://wiki.github.com/jtadeulopes/meme/]
|
49
|
+
|
50
|
+
== Note on Patches/Pull Requests
|
51
|
+
|
52
|
+
* Fork the project.
|
53
|
+
* Make your feature addition or bug fix.
|
54
|
+
* Add tests for it. This is important so I don't break it in a
|
55
|
+
future version unintentionally.
|
56
|
+
* Commit, do not mess with rakefile, version, or history.
|
57
|
+
(if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
|
58
|
+
* Send me a pull request. Bonus points for topic branches.
|
59
|
+
|
60
|
+
== Copyright
|
61
|
+
|
62
|
+
Copyright (c) 2010 Jésus Lopes. See LICENSE for details.
|
data/Rakefile
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'jeweler'
|
6
|
+
Jeweler::Tasks.new do |gem|
|
7
|
+
gem.name = "meme"
|
8
|
+
gem.summary = %Q{Ruby Yahoo! Meme API}
|
9
|
+
gem.description = %Q{Yahoo! Meme API wrapper library in Ruby}
|
10
|
+
gem.email = "jlopes@zigotto.com.br"
|
11
|
+
gem.homepage = "http://github.com/jtadeulopes/meme"
|
12
|
+
gem.authors = ["Jésus Lopes"]
|
13
|
+
gem.add_development_dependency "rspec", ">= 1.2.9"
|
14
|
+
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
15
|
+
end
|
16
|
+
Jeweler::GemcutterTasks.new
|
17
|
+
rescue LoadError
|
18
|
+
puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
|
19
|
+
end
|
20
|
+
|
21
|
+
require 'spec/rake/spectask'
|
22
|
+
Spec::Rake::SpecTask.new(:spec) do |spec|
|
23
|
+
spec.libs << 'lib' << 'spec'
|
24
|
+
spec.spec_files = FileList['spec/**/*_spec.rb']
|
25
|
+
end
|
26
|
+
|
27
|
+
Spec::Rake::SpecTask.new(:rcov) do |spec|
|
28
|
+
spec.libs << 'lib' << 'spec'
|
29
|
+
spec.pattern = 'spec/**/*_spec.rb'
|
30
|
+
spec.rcov = true
|
31
|
+
end
|
32
|
+
|
33
|
+
task :spec => :check_dependencies
|
34
|
+
|
35
|
+
task :default => :spec
|
36
|
+
|
37
|
+
require 'rake/rdoctask'
|
38
|
+
Rake::RDocTask.new do |rdoc|
|
39
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
40
|
+
|
41
|
+
rdoc.rdoc_dir = 'rdoc'
|
42
|
+
rdoc.title = "meme #{version}"
|
43
|
+
rdoc.rdoc_files.include('README*')
|
44
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
45
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.1.1
|
data/init.rb
ADDED
data/lib/meme.rb
ADDED
@@ -0,0 +1,60 @@
|
|
1
|
+
class Meme
|
2
|
+
|
3
|
+
class Info
|
4
|
+
|
5
|
+
VARS = ["avatar_url", "name", "title", "guid", "followers", "language", "url", "description"]
|
6
|
+
|
7
|
+
attr_accessor *VARS
|
8
|
+
|
9
|
+
def initialize(data)
|
10
|
+
unless data.nil?
|
11
|
+
VARS.each do |var|
|
12
|
+
self.instance_variable_set("@#{var}", data[var])
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.find(name)
|
18
|
+
url = URI.escape("https://query.yahooapis.com/v1/public/yql?q=SELECT * FROM meme.info WHERE name='#{name}'&format=json")
|
19
|
+
buffer = open(url).read
|
20
|
+
parse = JSON.parse(buffer)
|
21
|
+
if parse
|
22
|
+
results = parse['query']['results']
|
23
|
+
results.nil? ? nil : Info.new(results['meme'])
|
24
|
+
else
|
25
|
+
parse.error!
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
30
|
+
|
31
|
+
class Post
|
32
|
+
|
33
|
+
VARS = ["category", "timestamp", "guid", "pubid", "url", "repost_count", "caption", "type", "content"]
|
34
|
+
|
35
|
+
attr_accessor *VARS
|
36
|
+
|
37
|
+
def initialize(data)
|
38
|
+
unless data.nil?
|
39
|
+
VARS.each do |var|
|
40
|
+
self.instance_variable_set("@#{var}", data[var])
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def self.find(query, options = {})
|
46
|
+
type = " and type='#{options.delete(:type).to_s}'" if options.has_key?(:type)
|
47
|
+
url = URI.escape("https://query.yahooapis.com/v1/public/yql?q=SELECT * FROM meme.search WHERE query='#{query}'#{type}&format=json")
|
48
|
+
buffer = open(url).read
|
49
|
+
parse = JSON.parse(buffer)
|
50
|
+
if parse
|
51
|
+
results = parse['query']['results']
|
52
|
+
results.nil? ? nil : results['post'].map {|m| Post.new(m)}
|
53
|
+
else
|
54
|
+
parse.error!
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
end
|
59
|
+
|
60
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
{
|
2
|
+
"query":{
|
3
|
+
"count":"1",
|
4
|
+
"created":"2010-03-14T11:56:39Z",
|
5
|
+
"lang":"en-US",
|
6
|
+
"updated":"2010-03-14T11:56:39Z",
|
7
|
+
"uri":"https://query.yahooapis.com/v1/yql?q=SELECT+*+FROM+meme.info+WHERE+owner_guid%3D%27EMREXCV4R5OTM3CZW3HBD5QAGY%27",
|
8
|
+
"results":{
|
9
|
+
"meme":{
|
10
|
+
"guid":"EMREXCV4R5OTM3CZW3HBD5QAGY",
|
11
|
+
"name":"jtadeulopes",
|
12
|
+
"title":"Jésus Lopes",
|
13
|
+
"description":"software developer",
|
14
|
+
"url":"http://meme.yahoo.com/jtadeulopes/",
|
15
|
+
"avatar_url":"http://d.yimg.com/gg/jtadeulopes/avatars/44251e70378d4d225f8cda09a6c3aec87301833a.jpeg",
|
16
|
+
"language":"pt",
|
17
|
+
"followers":"34"
|
18
|
+
}
|
19
|
+
}
|
20
|
+
}
|
21
|
+
}
|
@@ -0,0 +1,122 @@
|
|
1
|
+
{
|
2
|
+
"query":{
|
3
|
+
"count":"10",
|
4
|
+
"created":"2010-03-17T02:48:58Z",
|
5
|
+
"lang":"en-US",
|
6
|
+
"updated":"2010-03-17T02:48:58Z",
|
7
|
+
"uri":"https://query.yahooapis.com/v1/yql?q=SELECT+*+FROM+meme.search+WHERE+query%3D%22meme+rocks%22%3B",
|
8
|
+
"results":{
|
9
|
+
"post":[{
|
10
|
+
"pubid":"yC8nqOd",
|
11
|
+
"guid":"7Z7XFAPD5FLXFKJVT4NG6XTTA4",
|
12
|
+
"url":"http://meme.yahoo.com/celizelove/p/yC8nqOd/",
|
13
|
+
"timestamp":"1268410909000",
|
14
|
+
"category":"text",
|
15
|
+
"type":"text",
|
16
|
+
"content":"okay...it's meme in english...starting meme ^.<) rock!!",
|
17
|
+
"repost_count":"0",
|
18
|
+
"caption":""
|
19
|
+
},
|
20
|
+
{
|
21
|
+
"pubid":"a7DxqA3",
|
22
|
+
"guid":"RZ662DMAG7SS3ULUEGSSWCTIN4",
|
23
|
+
"url":"http://meme.yahoo.com/james_sa/p/a7DxqA3/",
|
24
|
+
"timestamp":"1268226995000",
|
25
|
+
"category":"photo",
|
26
|
+
"type":"photo",
|
27
|
+
"content":"http://d.yimg.com/gg/u/7531e1387997debf4b436c21104221527e1884e7.jpeg",
|
28
|
+
"repost_count":"0",
|
29
|
+
"caption":"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!"
|
30
|
+
},
|
31
|
+
{
|
32
|
+
"pubid":"Qu0qzpw",
|
33
|
+
"guid":"RZ662DMAG7SS3ULUEGSSWCTIN4",
|
34
|
+
"url":"http://meme.yahoo.com/james_sa/p/Qu0qzpw/",
|
35
|
+
"timestamp":"1268185814000",
|
36
|
+
"category":"text",
|
37
|
+
"type":"text",
|
38
|
+
"content":"Anonymous asked: ‘How do you maintain focus (on work, dreams, goals, life)?’\u000a \u000a You do one thing at a time.",
|
39
|
+
"repost_count":"0",
|
40
|
+
"caption":""
|
41
|
+
},
|
42
|
+
{
|
43
|
+
"pubid":"FYG6jj6",
|
44
|
+
"guid":"JIW3KPQK3Z6Q6RCHPK77GRRQUQ",
|
45
|
+
"url":"http://meme.yahoo.com/ahnyenye/p/FYG6jj6/",
|
46
|
+
"timestamp":"1268780547000",
|
47
|
+
"category":"text",
|
48
|
+
"type":"text",
|
49
|
+
"content":"rock you...^_^",
|
50
|
+
"repost_count":"0",
|
51
|
+
"caption":""
|
52
|
+
},
|
53
|
+
{
|
54
|
+
"pubid":"w-WRsfU",
|
55
|
+
"guid":"FREBGIQRAVGTJTK5MO2SZRJJ7Y",
|
56
|
+
"url":"http://meme.yahoo.com/bandit_/p/w-WRsfU/",
|
57
|
+
"timestamp":"1268739146000",
|
58
|
+
"category":"photo",
|
59
|
+
"type":"photo",
|
60
|
+
"content":"http://d.yimg.com/gg/u/2441eceb4b334c6fc29c9bd306fe1957693d605e.jpeg",
|
61
|
+
"repost_count":"0",
|
62
|
+
"caption":"Alodia Rocks!!!"
|
63
|
+
},
|
64
|
+
{
|
65
|
+
"pubid":"xLWxaiC",
|
66
|
+
"guid":"FLNH2DLQBKGR3NHRGPCCE2WYME",
|
67
|
+
"url":"http://meme.yahoo.com/sergioruiz/p/xLWxaiC/",
|
68
|
+
"timestamp":"1268776544000",
|
69
|
+
"category":"text",
|
70
|
+
"type":"text",
|
71
|
+
"content":"@RicGrajeda Rock it men!",
|
72
|
+
"repost_count":"0",
|
73
|
+
"caption":""
|
74
|
+
},
|
75
|
+
{
|
76
|
+
"pubid":"sTtco-b",
|
77
|
+
"guid":"L2UB3RTLRKYN5NFGBAQCUQ42RM",
|
78
|
+
"url":"http://meme.yahoo.com/thumpergooga1/p/sTtco-b/",
|
79
|
+
"timestamp":"1268775387000",
|
80
|
+
"category":"text",
|
81
|
+
"type":"text",
|
82
|
+
"content":"Bio-Rock Pemuteran Bali Indonesia - GeorgeM3 >> http://is.gd/aL0IP",
|
83
|
+
"repost_count":"0",
|
84
|
+
"caption":""
|
85
|
+
},
|
86
|
+
{
|
87
|
+
"pubid":"BxvLPH7",
|
88
|
+
"guid":"Y7HTBSODNETNT53GC6NEYGTKYQ",
|
89
|
+
"url":"http://meme.yahoo.com/celebboardnet/p/BxvLPH7/",
|
90
|
+
"timestamp":"1268784114000",
|
91
|
+
"category":"photo",
|
92
|
+
"type":"photo",
|
93
|
+
"content":"http://d.yimg.com/gg/u/14df7a560e4601c2771bdb81582d40a85da716ce.jpeg",
|
94
|
+
"repost_count":"0",
|
95
|
+
"caption":"Faith Hill - 25th Annual Rock And Roll Hall of Fame Induction Ceremony at the Waldorf-Astoria, NY 15.03.2010\u000a \u000a <--More on www.celebboard.net"
|
96
|
+
},
|
97
|
+
{
|
98
|
+
"pubid":"F5lR99K",
|
99
|
+
"guid":"HWSI5H2NOLUCJB4BAT4L3KM54M",
|
100
|
+
"url":"http://meme.yahoo.com/new_york_recruiters_-_jobs_-_careers/p/F5lR99K/",
|
101
|
+
"timestamp":"1268793501000",
|
102
|
+
"category":"text",
|
103
|
+
"type":"text",
|
104
|
+
"content":"Mega64 pokes fun at The Beatles: Rock Band with a little help from a friend: \u000a Mega64 gets .. http://bit.ly/cKDl6C\u000a miamirecruiters.biz",
|
105
|
+
"repost_count":"0",
|
106
|
+
"caption":""
|
107
|
+
},
|
108
|
+
{
|
109
|
+
"pubid":"WWbjTrB",
|
110
|
+
"guid":"HWSI5H2NOLUCJB4BAT4L3KM54M",
|
111
|
+
"url":"http://meme.yahoo.com/new_york_recruiters_-_jobs_-_careers/p/WWbjTrB/",
|
112
|
+
"timestamp":"1268793482000",
|
113
|
+
"category":"text",
|
114
|
+
"type":"text",
|
115
|
+
"content":"Mega64 pokes fun at The Beatles: Rock Band with a little help from a friend: \u000a Mega64 gets .. http://bit.ly/cKDl6C\u000a miamirecruiters.biz",
|
116
|
+
"repost_count":"0",
|
117
|
+
"caption":""
|
118
|
+
}
|
119
|
+
]
|
120
|
+
}
|
121
|
+
}
|
122
|
+
}
|
@@ -0,0 +1,10 @@
|
|
1
|
+
{
|
2
|
+
"query":{
|
3
|
+
"count":"0",
|
4
|
+
"created":"2010-03-23T10:36:30Z",
|
5
|
+
"lang":"en-US",
|
6
|
+
"updated":"2010-03-23T10:36:30Z",
|
7
|
+
"uri":"https://query.yahooapis.com/v1/yql?q=SELECT+*+FROM+meme.search+WHERE+query%3D%27brhackday%27+and+type%3D%27audio%27%3B",
|
8
|
+
"results":null
|
9
|
+
}
|
10
|
+
}
|
@@ -0,0 +1,45 @@
|
|
1
|
+
{
|
2
|
+
"query":{
|
3
|
+
"count":"3",
|
4
|
+
"created":"2010-03-16T04:10:22Z",
|
5
|
+
"lang":"en-US",
|
6
|
+
"updated":"2010-03-16T04:10:22Z",
|
7
|
+
"uri":"https://query.yahooapis.com/v1/yql?q=SELECT+*+FROM+meme.search+WHERE+query%3D%22cat%22+and+type%3D%27photo%27%3B",
|
8
|
+
"results":{
|
9
|
+
"post":[{
|
10
|
+
"pubid":"rAH9Buw",
|
11
|
+
"guid":"7WSQE47HTRJV4SH6L22FA3SE3A",
|
12
|
+
"url":"http://meme.yahoo.com/sarchi1/p/rAH9Buw/",
|
13
|
+
"timestamp":"1268188001000",
|
14
|
+
"category":"photo",
|
15
|
+
"type":"photo",
|
16
|
+
"content":"http://d.yimg.com/gg/u/94909e01ff2130c7b6c733d255ff11193c9a8df9.jpeg",
|
17
|
+
"repost_count":"0",
|
18
|
+
"caption":"CAT !"
|
19
|
+
},
|
20
|
+
{
|
21
|
+
"pubid":"A2j6WMA",
|
22
|
+
"guid":"U6P7AFQCVBYRVMXEBUYR7XOR3U",
|
23
|
+
"url":"http://meme.yahoo.com/bevero/p/A2j6WMA/",
|
24
|
+
"timestamp":"1268405155000",
|
25
|
+
"category":"photo",
|
26
|
+
"type":"photo",
|
27
|
+
"content":"http://d.yimg.com/gg/u/8e53cd3849898454f7e9a885c30d45b37781ed05.gifa",
|
28
|
+
"repost_count":"0",
|
29
|
+
"caption":"Cat-astrophe"
|
30
|
+
},
|
31
|
+
{
|
32
|
+
"pubid":"HDSXglJ",
|
33
|
+
"guid":"SOAFYSYHEYJWJ3O4P7GAE7GUP4",
|
34
|
+
"url":"http://meme.yahoo.com/kimisykes/p/HDSXglJ/",
|
35
|
+
"timestamp":"1268568490000",
|
36
|
+
"category":"photo",
|
37
|
+
"type":"photo",
|
38
|
+
"content":"http://d.yimg.com/gg/u/924cfa94811b7435082adcd06a32dfdf7038d67b.jpeg",
|
39
|
+
"repost_count":"1",
|
40
|
+
"caption":"my little cat :)"
|
41
|
+
}
|
42
|
+
]
|
43
|
+
}
|
44
|
+
}
|
45
|
+
}
|
@@ -0,0 +1,34 @@
|
|
1
|
+
{
|
2
|
+
"query":{
|
3
|
+
"count":"2",
|
4
|
+
"created":"2010-03-21T01:49:03Z",
|
5
|
+
"lang":"en-US",
|
6
|
+
"updated":"2010-03-21T01:49:03Z",
|
7
|
+
"uri":"https://query.yahooapis.com/v1/yql?q=SELECT+*+FROM+meme.search+WHERE+query%3D%22keyboard+cat%22+and+type%3D%27video%27%3B",
|
8
|
+
"results":{
|
9
|
+
"post":[{
|
10
|
+
"pubid":"6KCkGnw",
|
11
|
+
"guid":"SD4QBFS6YGJYQODE74V5CBYOAM",
|
12
|
+
"url":"http://meme.yahoo.com/diegocosta/p/6KCkGnw/",
|
13
|
+
"timestamp":"1268757628000",
|
14
|
+
"category":"video",
|
15
|
+
"type":"video",
|
16
|
+
"content":"http://youtube.com/v/xSE9Qk9wkig",
|
17
|
+
"repost_count":"1",
|
18
|
+
"caption":"Keyboard cat v2.0"
|
19
|
+
},
|
20
|
+
{
|
21
|
+
"pubid":"aHY4rbw",
|
22
|
+
"guid":"KLKFHSHPT6APXZACURLC4AWNAU",
|
23
|
+
"url":"http://meme.yahoo.com/bambii/p/aHY4rbw/",
|
24
|
+
"timestamp":"1268712800000",
|
25
|
+
"category":"video",
|
26
|
+
"type":"video",
|
27
|
+
"content":"http://youtube.com/v/xSE9Qk9wkig",
|
28
|
+
"repost_count":"0",
|
29
|
+
"caption":"I favorited a YouTube video -- Charlie Schmidt's Keyboard Cat REINCARNATED! http://youtu.be/xSE9Qk9wkig?a"
|
30
|
+
}
|
31
|
+
]
|
32
|
+
}
|
33
|
+
}
|
34
|
+
}
|
data/spec/meme_spec.rb
ADDED
@@ -0,0 +1,140 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
+
|
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
|
+
end
|
data/spec/spec.opts
ADDED
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
2
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
3
|
+
require 'rubygems'
|
4
|
+
require 'meme'
|
5
|
+
require 'spec'
|
6
|
+
require 'spec/autorun'
|
7
|
+
require 'open-uri'
|
8
|
+
require 'json'
|
9
|
+
require 'fakeweb'
|
10
|
+
|
11
|
+
Spec::Runner.configure do |config|
|
12
|
+
|
13
|
+
end
|
metadata
ADDED
@@ -0,0 +1,82 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: meme
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- "J\xC3\xA9sus Lopes"
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2010-03-23 00:00:00 -03:00
|
13
|
+
default_executable:
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: rspec
|
17
|
+
type: :development
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 1.2.9
|
24
|
+
version:
|
25
|
+
description: Yahoo! Meme API wrapper library in Ruby
|
26
|
+
email: jlopes@zigotto.com.br
|
27
|
+
executables: []
|
28
|
+
|
29
|
+
extensions: []
|
30
|
+
|
31
|
+
extra_rdoc_files:
|
32
|
+
- LICENSE
|
33
|
+
- README.rdoc
|
34
|
+
files:
|
35
|
+
- .document
|
36
|
+
- .gitignore
|
37
|
+
- LICENSE
|
38
|
+
- README.rdoc
|
39
|
+
- Rakefile
|
40
|
+
- VERSION
|
41
|
+
- init.rb
|
42
|
+
- lib/meme.rb
|
43
|
+
- spec/fixtures/meme_info.json
|
44
|
+
- spec/fixtures/meme_info_not_found.json
|
45
|
+
- spec/fixtures/meme_search.json
|
46
|
+
- spec/fixtures/meme_search_type_audio.json
|
47
|
+
- spec/fixtures/meme_search_type_photo.json
|
48
|
+
- spec/fixtures/meme_search_type_video.json
|
49
|
+
- spec/meme_spec.rb
|
50
|
+
- spec/spec.opts
|
51
|
+
- spec/spec_helper.rb
|
52
|
+
has_rdoc: true
|
53
|
+
homepage: http://github.com/jtadeulopes/meme
|
54
|
+
licenses: []
|
55
|
+
|
56
|
+
post_install_message:
|
57
|
+
rdoc_options:
|
58
|
+
- --charset=UTF-8
|
59
|
+
require_paths:
|
60
|
+
- lib
|
61
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
62
|
+
requirements:
|
63
|
+
- - ">="
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: "0"
|
66
|
+
version:
|
67
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
68
|
+
requirements:
|
69
|
+
- - ">="
|
70
|
+
- !ruby/object:Gem::Version
|
71
|
+
version: "0"
|
72
|
+
version:
|
73
|
+
requirements: []
|
74
|
+
|
75
|
+
rubyforge_project:
|
76
|
+
rubygems_version: 1.3.5
|
77
|
+
signing_key:
|
78
|
+
specification_version: 3
|
79
|
+
summary: Ruby Yahoo! Meme API
|
80
|
+
test_files:
|
81
|
+
- spec/meme_spec.rb
|
82
|
+
- spec/spec_helper.rb
|