meme 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Yahoo! Meme API wrapper library in Ruby
4
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.
5
+ This project was made during {Yahoo! Open Hack Day Brasil 2010}[http://openhackbrazil.pbworks.com/]. Event that happened in Sao Paulo 20, 21 of March 2010.
6
6
 
7
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
8
 
@@ -59,6 +59,18 @@ Find by type:
59
59
  posts.first.type
60
60
  => "photo"
61
61
 
62
+ === Popular
63
+
64
+ Returns the top 10 posts on that moment.
65
+
66
+ Currently, the codes are "en" for English, "es" for Spanish, "pt" for Portuguese and "id" for Bahasa Indonesia.
67
+
68
+ Meme::Post.popular
69
+
70
+ OR
71
+
72
+ Meme::Post.popular('id')
73
+
62
74
  For more information, please refer the {project wiki}[http://wiki.github.com/jtadeulopes/meme/]
63
75
 
64
76
  == Installation
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.0
1
+ 0.2.1
data/lib/meme/info.rb CHANGED
@@ -34,6 +34,23 @@ module Meme
34
34
  end
35
35
  end
36
36
 
37
+ # Find user by guid
38
+ #
39
+ # Example:
40
+ #
41
+ # user = Meme::Info.find_by_guid('EMREXCV4R5OTM3CZW3HBD5QAGY')
42
+ #
43
+ def self.find_by_guid(name)
44
+ query = "SELECT * FROM meme.info WHERE owner_guid='#{name}'"
45
+ parse = Request.parse(query)
46
+ if parse
47
+ results = parse['query']['results']
48
+ results.nil? ? nil : Info.new(results['meme'])
49
+ else
50
+ parse.error!
51
+ end
52
+ end
53
+
37
54
  # Return user followers
38
55
  #
39
56
  # Example:
data/lib/meme/search.rb CHANGED
@@ -42,6 +42,29 @@ module Meme
42
42
  end
43
43
  end
44
44
 
45
+ # Returns the top 10 posts on that moment.
46
+ # You can also set the locale that you want to retrieve:
47
+ #
48
+ # * "en" for English
49
+ # * "es" for Spanish
50
+ # * "pt" for Portuguese (Default)
51
+ # * "id" for Bahasa Indonesia
52
+ #
53
+ def self.popular(locale='pt')
54
+ query = "SELECT * FROM meme.popular WHERE locale='#{locale}'"
55
+ parse = Request.parse(query)
56
+ if parse
57
+ results = parse['query']['results']
58
+ results.nil? ? nil : results['post'].map {|m| Post.new(m)}
59
+ else
60
+ parse.error!
61
+ end
62
+ end
63
+
64
+ def user
65
+ Meme::Info.find_by_guid(self.guid)
66
+ end
67
+
45
68
  end
46
69
 
47
70
  end
data/meme.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{meme}
8
- s.version = "0.2.0"
8
+ s.version = "0.2.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["J\303\251sus Lopes"]
12
- s.date = %q{2010-04-01}
12
+ s.date = %q{2010-05-01}
13
13
  s.description = %q{Yahoo! Meme API wrapper library in Ruby}
14
14
  s.email = %q{jlopes@zigotto.com.br}
15
15
  s.extra_rdoc_files = [
@@ -35,7 +35,10 @@ Gem::Specification.new do |s|
35
35
  "spec/fixtures/meme_following_all.json",
36
36
  "spec/fixtures/meme_following_count.json",
37
37
  "spec/fixtures/meme_info.json",
38
+ "spec/fixtures/meme_info_guid.json",
38
39
  "spec/fixtures/meme_info_not_found.json",
40
+ "spec/fixtures/meme_popular_id.json",
41
+ "spec/fixtures/meme_popular_pt.json",
39
42
  "spec/fixtures/meme_search.json",
40
43
  "spec/fixtures/meme_search_type_audio.json",
41
44
  "spec/fixtures/meme_search_type_photo.json",
@@ -49,13 +52,13 @@ Gem::Specification.new do |s|
49
52
  s.homepage = %q{http://github.com/jtadeulopes/meme}
50
53
  s.rdoc_options = ["--charset=UTF-8"]
51
54
  s.require_paths = ["lib"]
52
- s.rubygems_version = %q{1.3.5}
55
+ s.rubygems_version = %q{1.3.6}
53
56
  s.summary = %q{Ruby Yahoo! Meme API}
54
57
  s.test_files = [
55
- "spec/meme_spec.rb",
58
+ "spec/info_spec.rb",
59
+ "spec/meme_spec.rb",
56
60
  "spec/search_spec.rb",
57
- "spec/spec_helper.rb",
58
- "spec/info_spec.rb"
61
+ "spec/spec_helper.rb"
59
62
  ]
60
63
 
61
64
  if s.respond_to? :specification_version then
@@ -0,0 +1,20 @@
1
+ {
2
+ "query": {
3
+ "count": "1",
4
+ "created": "2010-05-01T04:44:00Z",
5
+ "lang": "en-US",
6
+ "results": {
7
+ "meme": {
8
+ "guid": "QKSXELRVSAWRI77FVKODDYTKB4",
9
+ "name": "tempestadesilenciosa",
10
+ "title": "·ઇ\u200dઉTempestadeSilenciosa♥♥♥٠·ઇ\u200dઉ ●๋NiNA ٠",
11
+ "description": "a um passo da loucura.",
12
+ "url": "http://meme.yahoo.com/tempestadesilenciosa/",
13
+ "avatar_url": "http://d.yimg.com/gg/tempestadesilenciosa/avatars/c6ff4bd5aa79ea0ecf7c1cde3524624472d958b1.jpeg",
14
+ "language": "pt",
15
+ "following": "1000",
16
+ "followers": "1535"
17
+ }
18
+ }
19
+ }
20
+ }
@@ -0,0 +1,171 @@
1
+ {
2
+ "query": {
3
+ "count": "10",
4
+ "created": "2010-05-01T03:42:21Z",
5
+ "lang": "en-US",
6
+ "results": {
7
+ "post": [
8
+ {
9
+ "pubid": "SnGzd9k",
10
+ "guid": "PIYXX4KDAE7N73HXO2DM63CODM",
11
+ "url": "http://meme.yahoo.com/indah_puji_lestari_/p/SnGzd9k/",
12
+ "timestamp": "1272711086000",
13
+ "category": "text",
14
+ "type": "text",
15
+ "content": "Kemarin dia menawarkan cinta, hmm sayang harganya terlalu mahal jadi aku putuskan untuk tak memilikinya...",
16
+ "repost_count": "18",
17
+ "appid": null,
18
+ "comment": "",
19
+ "caption": "",
20
+ "via_guid": null,
21
+ "origin_guid": null,
22
+ "origin_pubid": null
23
+ },
24
+ {
25
+ "pubid": "FN_hLA3",
26
+ "guid": "XVLE5ZNNHUVPU3FAZCQD7PUMCM",
27
+ "url": "http://meme.yahoo.com/yurri/p/FN_hLA3/",
28
+ "timestamp": "1272687915000",
29
+ "category": "photo",
30
+ "type": "photo",
31
+ "content": "http://d.yimg.com/gg/u/b4864aa6f7af88a907ccc9627e3220ff7822a71c.jpeg",
32
+ "repost_count": "15",
33
+ "appid": null,
34
+ "comment": "",
35
+ "caption": "",
36
+ "via_guid": null,
37
+ "origin_guid": null,
38
+ "origin_pubid": null
39
+ },
40
+ {
41
+ "pubid": "wid9CsF",
42
+ "guid": "N6CDAAFMISBZFVMTPUCYVGFSQM",
43
+ "url": "http://meme.yahoo.com/harzone/p/wid9CsF/",
44
+ "timestamp": "1272688330000",
45
+ "category": "photo",
46
+ "type": "photo",
47
+ "content": "http://d.yimg.com/gg/u/fbcbe914656cc963a8d1946858275a1538ea66f9.jpeg",
48
+ "repost_count": "14",
49
+ "appid": null,
50
+ "comment": "",
51
+ "caption": "who want??",
52
+ "via_guid": null,
53
+ "origin_guid": null,
54
+ "origin_pubid": null
55
+ },
56
+ {
57
+ "pubid": "dBFjT-D",
58
+ "guid": "XVLE5ZNNHUVPU3FAZCQD7PUMCM",
59
+ "url": "http://meme.yahoo.com/yurri/p/dBFjT-D/",
60
+ "timestamp": "1272689096000",
61
+ "category": "photo",
62
+ "type": "photo",
63
+ "content": "http://d.yimg.com/gg/u/877dd096f0c3657682dae84cd2e935c3ec506390.jpeg",
64
+ "repost_count": "12",
65
+ "appid": null,
66
+ "comment": "",
67
+ "caption": "",
68
+ "via_guid": null,
69
+ "origin_guid": null,
70
+ "origin_pubid": null
71
+ },
72
+ {
73
+ "pubid": "WtpwKzy",
74
+ "guid": "XVLE5ZNNHUVPU3FAZCQD7PUMCM",
75
+ "url": "http://meme.yahoo.com/yurri/p/WtpwKzy/",
76
+ "timestamp": "1272687368000",
77
+ "category": "photo",
78
+ "type": "photo",
79
+ "content": "http://d.yimg.com/gg/u/da0a79b68df78e97737504de1618ef70b9103fc5.jpeg",
80
+ "repost_count": "10",
81
+ "appid": null,
82
+ "comment": "",
83
+ "caption": "",
84
+ "via_guid": null,
85
+ "origin_guid": null,
86
+ "origin_pubid": null
87
+ },
88
+ {
89
+ "pubid": "5YO15B0",
90
+ "guid": "PIYXX4KDAE7N73HXO2DM63CODM",
91
+ "url": "http://meme.yahoo.com/indah_puji_lestari_/p/5YO15B0/",
92
+ "timestamp": "1272709818000",
93
+ "category": "photo",
94
+ "type": "photo",
95
+ "content": "http://d.yimg.com/gg/u/c96cff7519f875931dd991110866fe5065ec208b.jpeg",
96
+ "repost_count": "10",
97
+ "appid": null,
98
+ "comment": "",
99
+ "caption": "",
100
+ "via_guid": null,
101
+ "origin_guid": null,
102
+ "origin_pubid": null
103
+ },
104
+ {
105
+ "pubid": "vSIuPtO",
106
+ "guid": "XVLE5ZNNHUVPU3FAZCQD7PUMCM",
107
+ "url": "http://meme.yahoo.com/yurri/p/vSIuPtO/",
108
+ "timestamp": "1272687481000",
109
+ "category": "photo",
110
+ "type": "photo",
111
+ "content": "http://d.yimg.com/gg/u/9259f0bc73c67131ba100704dabd7d40dc6fd3ca.jpeg",
112
+ "repost_count": "9",
113
+ "appid": null,
114
+ "comment": "",
115
+ "caption": "",
116
+ "via_guid": null,
117
+ "origin_guid": null,
118
+ "origin_pubid": null
119
+ },
120
+ {
121
+ "pubid": "4lfu0YI",
122
+ "guid": "PUW3SMKSPHHZWPQTGPILJMSXAA",
123
+ "url": "http://meme.yahoo.com/nandya/p/4lfu0YI/",
124
+ "timestamp": "1272683397000",
125
+ "category": "photo",
126
+ "type": "photo",
127
+ "content": "http://d.yimg.com/gg/u/cbcefebeaa3409942c0bd0e53be5d3e5c2db298a.jpeg",
128
+ "repost_count": "9",
129
+ "appid": null,
130
+ "comment": "",
131
+ "caption": "ini foto liburan aku ke KOTA TUA....\n KOTA TUA tempat liburan KERENNNN.....\n \n #travel_mimmingguini",
132
+ "via_guid": null,
133
+ "origin_guid": null,
134
+ "origin_pubid": null
135
+ },
136
+ {
137
+ "pubid": "JzTpzvT",
138
+ "guid": "XVLE5ZNNHUVPU3FAZCQD7PUMCM",
139
+ "url": "http://meme.yahoo.com/yurri/p/JzTpzvT/",
140
+ "timestamp": "1272687526000",
141
+ "category": "photo",
142
+ "type": "photo",
143
+ "content": "http://d.yimg.com/gg/u/b819fed6745b188114a3d57cb18e7fed8d2cfd6d.jpeg",
144
+ "repost_count": "8",
145
+ "appid": null,
146
+ "comment": "",
147
+ "caption": "",
148
+ "via_guid": null,
149
+ "origin_guid": null,
150
+ "origin_pubid": null
151
+ },
152
+ {
153
+ "pubid": "m23nTXn",
154
+ "guid": "PUW3SMKSPHHZWPQTGPILJMSXAA",
155
+ "url": "http://meme.yahoo.com/nandya/p/m23nTXn/",
156
+ "timestamp": "1272685199000",
157
+ "category": "photo",
158
+ "type": "photo",
159
+ "content": "http://d.yimg.com/gg/u/8998134faec021ce4aff7d35906181f65553a7dd.jpeg",
160
+ "repost_count": "7",
161
+ "appid": null,
162
+ "comment": "",
163
+ "caption": "kalo mau liat lagifoto liburanku ini ada yg lebih kerennn....\n #travel_mimmingguini \n http://mim.yahoo.com/nandya/p/OfGHdac/\n \n baca ceritanya ya..\n seru deh!!",
164
+ "via_guid": null,
165
+ "origin_guid": null,
166
+ "origin_pubid": null
167
+ }
168
+ ]
169
+ }
170
+ }
171
+ }
@@ -0,0 +1,171 @@
1
+ {
2
+ "query": {
3
+ "count": "10",
4
+ "created": "2010-05-01T03:26:37Z",
5
+ "lang": "en-US",
6
+ "results": {
7
+ "post": [
8
+ {
9
+ "pubid": "jCzs2y2",
10
+ "guid": "QKSXELRVSAWRI77FVKODDYTKB4",
11
+ "url": "http://meme.yahoo.com/tempestadesilenciosa/p/jCzs2y2/",
12
+ "timestamp": "1272647380000",
13
+ "category": "photo",
14
+ "type": "photo",
15
+ "content": "http://d.yimg.com/gg/u/38b15b9620e38090aa092420790d3b5a528e8e99.jpeg",
16
+ "repost_count": "155",
17
+ "appid": null,
18
+ "comment": "",
19
+ "caption": "<b>...o teu abraço é tudo que minha alma precisa.</b>\n \n Nina",
20
+ "via_guid": null,
21
+ "origin_guid": null,
22
+ "origin_pubid": null
23
+ },
24
+ {
25
+ "pubid": "eEcCtxZ",
26
+ "guid": "EZR6VL5QGZKXYLUCRLCIODT33M",
27
+ "url": "http://meme.yahoo.com/jehparra/p/eEcCtxZ/",
28
+ "timestamp": "1272644406000",
29
+ "category": "photo",
30
+ "type": "photo",
31
+ "content": "http://d.yimg.com/gg/u/aadfccc50c65ef7ab992008d7ff6302f6ef45089.jpeg",
32
+ "repost_count": "139",
33
+ "appid": null,
34
+ "comment": "",
35
+ "caption": "<i><b>“São as pequenas coisas que valem mais. \n É tão bom estarmos juntos, e tão simples...”</b> </i>",
36
+ "via_guid": null,
37
+ "origin_guid": null,
38
+ "origin_pubid": null
39
+ },
40
+ {
41
+ "pubid": "-_diulX",
42
+ "guid": "3B7ER4NMFAVG7TNRQ333GU3EXE",
43
+ "url": "http://meme.yahoo.com/blessed/p/-_diulX/",
44
+ "timestamp": "1272655458000",
45
+ "category": "photo",
46
+ "type": "photo",
47
+ "content": "http://d.yimg.com/gg/u/236bed11ce5ea25a8defe3164254b896ff4bd59c.jpeg",
48
+ "repost_count": "80",
49
+ "appid": null,
50
+ "comment": "",
51
+ "caption": "Haha duvido que não vai repostar esse sorriso mais lindo ....",
52
+ "via_guid": null,
53
+ "origin_guid": null,
54
+ "origin_pubid": null
55
+ },
56
+ {
57
+ "pubid": "okOltPI",
58
+ "guid": "QECDUBJ7SGCGGUVRGMAQPYVWKM",
59
+ "url": "http://meme.yahoo.com/debyanna/p/okOltPI/",
60
+ "timestamp": "1272656666000",
61
+ "category": "photo",
62
+ "type": "photo",
63
+ "content": "http://d.yimg.com/gg/u/2544dfc2c61a939ed7f15ef1264a4fccbea8ca15.jpeg",
64
+ "repost_count": "78",
65
+ "appid": null,
66
+ "comment": "",
67
+ "caption": "<i><b>O amor passa, a amizade volta, mesmo depois de ter adormecido um certo tempo.</b>\n \n (George Sand)</i>",
68
+ "via_guid": null,
69
+ "origin_guid": null,
70
+ "origin_pubid": null
71
+ },
72
+ {
73
+ "pubid": "D9DBJB4",
74
+ "guid": "EZR6VL5QGZKXYLUCRLCIODT33M",
75
+ "url": "http://meme.yahoo.com/jehparra/p/D9DBJB4/",
76
+ "timestamp": "1272653284000",
77
+ "category": "photo",
78
+ "type": "photo",
79
+ "content": "http://d.yimg.com/gg/u/97cb0a8634286353a7c8f5fddbd0aae2ab692a1c.jpeg",
80
+ "repost_count": "76",
81
+ "appid": null,
82
+ "comment": "",
83
+ "caption": "<i><b>O homem que não sabe o que quer não merece o que tem.</b> </i>",
84
+ "via_guid": null,
85
+ "origin_guid": null,
86
+ "origin_pubid": null
87
+ },
88
+ {
89
+ "pubid": "y-y0Czd",
90
+ "guid": "UTCBTBXKBOHENRLRHCW46HUZBE",
91
+ "url": "http://meme.yahoo.com/replicas_de_sorrisos_e_suspiros_/p/y-y0Czd/",
92
+ "timestamp": "1272642213000",
93
+ "category": "photo",
94
+ "type": "photo",
95
+ "content": "http://d.yimg.com/gg/u/91773db71850cdb65448a099538c5d57e4f5b3d7.jpeg",
96
+ "repost_count": "76",
97
+ "appid": null,
98
+ "comment": "",
99
+ "caption": "<b>&quot;A canção que toca o vento\n Faz gemer a saudade\n E quebra as cordas do coração&quot;</b>",
100
+ "via_guid": null,
101
+ "origin_guid": null,
102
+ "origin_pubid": null
103
+ },
104
+ {
105
+ "pubid": "NCMrygU",
106
+ "guid": "EZR6VL5QGZKXYLUCRLCIODT33M",
107
+ "url": "http://meme.yahoo.com/jehparra/p/NCMrygU/",
108
+ "timestamp": "1272645267000",
109
+ "category": "photo",
110
+ "type": "photo",
111
+ "content": "http://d.yimg.com/gg/u/9fbd4800d236f6253acdbc9e569e6bdd25655b49.jpeg",
112
+ "repost_count": "76",
113
+ "appid": null,
114
+ "comment": "",
115
+ "caption": "<i><b>“Não há dificuldade que o amor não vença; doença que o amor não cure; porta que o amor não abra; obstáculo que o amor não transponha.” </b> </i>\n \n Sermão da Montanha",
116
+ "via_guid": null,
117
+ "origin_guid": null,
118
+ "origin_pubid": null
119
+ },
120
+ {
121
+ "pubid": "GTuKWTP",
122
+ "guid": "QECDUBJ7SGCGGUVRGMAQPYVWKM",
123
+ "url": "http://meme.yahoo.com/debyanna/p/GTuKWTP/",
124
+ "timestamp": "1272648204000",
125
+ "category": "photo",
126
+ "type": "photo",
127
+ "content": "http://d.yimg.com/gg/u/dc72696e17ea61dd99bef10f7aac04971909222d.jpeg",
128
+ "repost_count": "75",
129
+ "appid": null,
130
+ "comment": "",
131
+ "caption": "<i><b>Os piores momentos que a vida me apresenta eu absorvo-os, filtro-os e faço deles lições de vida, lições que se forem bem aceitas, assimiladas e postas em prática, jamais me darão trabalho.</b>\n \n (Adriano Hungaro)</i>",
132
+ "via_guid": null,
133
+ "origin_guid": null,
134
+ "origin_pubid": null
135
+ },
136
+ {
137
+ "pubid": "43JSbZ5",
138
+ "guid": "QECDUBJ7SGCGGUVRGMAQPYVWKM",
139
+ "url": "http://meme.yahoo.com/debyanna/p/43JSbZ5/",
140
+ "timestamp": "1272656779000",
141
+ "category": "photo",
142
+ "type": "photo",
143
+ "content": "http://d.yimg.com/gg/u/16090d85f622797a4974b8ffc7090aa5ee36e4da.jpeg",
144
+ "repost_count": "70",
145
+ "appid": null,
146
+ "comment": "",
147
+ "caption": "<i><b>Quero e espero, espero porque quero. A anciosidade não me leva a nenhum lugar, a paciência me leva a você.</b>\n \n (Gabriel Duque)</i>",
148
+ "via_guid": null,
149
+ "origin_guid": null,
150
+ "origin_pubid": null
151
+ },
152
+ {
153
+ "pubid": "Gc3xzYb",
154
+ "guid": "Y3UXBHRS7BT36ORNVQCBOXPZMM",
155
+ "url": "http://meme.yahoo.com/angelheart/p/Gc3xzYb/",
156
+ "timestamp": "1272643017000",
157
+ "category": "photo",
158
+ "type": "photo",
159
+ "content": "http://d.yimg.com/gg/u/f14fbd92944842daf045da3f091b70f14b2d50b3.jpeg",
160
+ "repost_count": "63",
161
+ "appid": null,
162
+ "comment": "",
163
+ "caption": "&quot; Dessa vez, vamos jogar com as minhas regras...&quot;",
164
+ "via_guid": null,
165
+ "origin_guid": null,
166
+ "origin_pubid": null
167
+ }
168
+ ]
169
+ }
170
+ }
171
+ }
data/spec/info_spec.rb CHANGED
@@ -2,46 +2,66 @@ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
2
 
3
3
  describe "Meme::Info" do
4
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
5
  before :each do
14
6
  query = "SELECT * FROM meme.info WHERE name='jtadeulopes'"
15
7
  fake_web(query, 'meme_info.json')
16
8
  @profile = Meme::Info.find('jtadeulopes')
17
9
  end
18
10
 
19
- it "should return name" do
20
- @profile.name.should == "jtadeulopes"
21
- end
11
+ describe "::find" do
22
12
 
23
- it "should return guid" do
24
- @profile.guid.should == "EMREXCV4R5OTM3CZW3HBD5QAGY"
25
- end
13
+ it "if user not found, should return nil" do
14
+ query = "SELECT * FROM meme.info WHERE name='memeusernotfound'"
15
+ fake_web(query, 'meme_info_not_found.json')
16
+ Meme::Info.find('memeusernotfound').should be_nil
17
+ end
26
18
 
27
- it "should return page title" do
28
- @profile.title.should == "Jésus Lopes"
29
- end
19
+ it "should return name" do
20
+ @profile.name.should == "jtadeulopes"
21
+ end
30
22
 
31
- it "should return description" do
32
- @profile.description.should == "software developer"
33
- end
23
+ it "should return guid" do
24
+ @profile.guid.should == "EMREXCV4R5OTM3CZW3HBD5QAGY"
25
+ end
34
26
 
35
- it "should return url" do
36
- @profile.url.should == "http://meme.yahoo.com/jtadeulopes/"
37
- end
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
38
46
 
39
- it "should return avatar" do
40
- @profile.avatar_url.should == "http://d.yimg.com/gg/jtadeulopes/avatars/44251e70378d4d225f8cda09a6c3aec87301833a.jpeg"
41
47
  end
42
48
 
43
- it "should return language" do
44
- @profile.language.should == "pt"
49
+ describe "::find_by_guid" do
50
+
51
+ before :each do
52
+ query = "SELECT * FROM meme.info WHERE owner_guid='QKSXELRVSAWRI77FVKODDYTKB4'"
53
+ fake_web(query, 'meme_info_guid.json')
54
+ @profile_guid = Meme::Info.find_by_guid('QKSXELRVSAWRI77FVKODDYTKB4')
55
+ end
56
+
57
+ it "should return name" do
58
+ @profile_guid.name.should == "tempestadesilenciosa"
59
+ end
60
+
61
+ it "should return guid" do
62
+ @profile_guid.guid.should == "QKSXELRVSAWRI77FVKODDYTKB4"
63
+ end
64
+
45
65
  end
46
66
 
47
67
  describe "#followers" do
@@ -67,21 +87,25 @@ describe "Meme::Info" do
67
87
  end
68
88
 
69
89
  describe "#following" do
90
+
70
91
  it "should return following" do
71
92
  query = "SELECT * FROM meme.following(10) WHERE owner_guid='EMREXCV4R5OTM3CZW3HBD5QAGY'"
72
93
  fake_web(query, 'meme_following.json')
73
94
  @profile.following.count.should == 10
74
95
  end
96
+
75
97
  it "should return seven following" do
76
98
  query = "SELECT * FROM meme.following(7) WHERE owner_guid='EMREXCV4R5OTM3CZW3HBD5QAGY'"
77
99
  fake_web(query, 'meme_following_count.json')
78
100
  @profile.following(7).count.should == 7
79
101
  end
102
+
80
103
  it "should return all following" do
81
104
  query = "SELECT * FROM meme.following(0) WHERE owner_guid='EMREXCV4R5OTM3CZW3HBD5QAGY'"
82
105
  fake_web(query, 'meme_following_all.json')
83
106
  @profile.following(:all).count.should == 39
84
107
  end
108
+
85
109
  end
86
110
 
87
111
  end
data/spec/search_spec.rb CHANGED
@@ -1,73 +1,109 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
2
 
3
- describe "Meme::Search" do
3
+ describe "Meme::Post" do
4
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
5
+ describe "::find" do
10
6
 
11
- it "should return pubid" do
12
- @results.first.pubid.should == "yC8nqOd"
13
- end
7
+ before :each do
8
+ query = "SELECT * FROM meme.search WHERE query='meme rocks'"
9
+ fake_web(query, 'meme_search.json')
10
+ @results = Meme::Post.find('meme rocks')
11
+ end
14
12
 
15
- it "should return guid" do
16
- @results.first.guid.should == "7Z7XFAPD5FLXFKJVT4NG6XTTA4"
17
- end
13
+ it "should return pubid" do
14
+ @results.first.pubid.should == "yC8nqOd"
15
+ end
18
16
 
19
- it "should return url" do
20
- @results.first.url.should == "http://meme.yahoo.com/celizelove/p/yC8nqOd/"
21
- end
17
+ it "should return guid" do
18
+ @results.first.guid.should == "7Z7XFAPD5FLXFKJVT4NG6XTTA4"
19
+ end
22
20
 
23
- it "should return timestamp" do
24
- @results.first.timestamp.should == "1268410909000"
25
- end
21
+ it "should return url" do
22
+ @results.first.url.should == "http://meme.yahoo.com/celizelove/p/yC8nqOd/"
23
+ end
26
24
 
27
- it "should return category" do
28
- @results.first.category.should == "text"
29
- end
25
+ it "should return timestamp" do
26
+ @results.first.timestamp.should == "1268410909000"
27
+ end
30
28
 
31
- it "should return type" do
32
- @results.first.type.should == "text"
33
- end
29
+ it "should return category" do
30
+ @results.first.category.should == "text"
31
+ end
34
32
 
35
- it "should return content" do
36
- @results[4].content.should == "http://d.yimg.com/gg/u/2441eceb4b334c6fc29c9bd306fe1957693d605e.jpeg"
37
- end
33
+ it "should return type" do
34
+ @results.first.type.should == "text"
35
+ end
38
36
 
39
- it "should return repost_count" do
40
- @results.first.repost_count.should == "0"
41
- end
37
+ it "should return content" do
38
+ @results[4].content.should == "http://d.yimg.com/gg/u/2441eceb4b334c6fc29c9bd306fe1957693d605e.jpeg"
39
+ end
42
40
 
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
41
+ it "should return repost_count" do
42
+ @results.first.repost_count.should == "0"
43
+ end
46
44
 
47
- describe "#search by" do
45
+ it "should return caption" do
46
+ @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!"
47
+ end
48
+
49
+ it "if posts not found, should return nil" do
50
+ query = "SELECT * FROM meme.search WHERE query='brhackday' and type='audio'"
51
+ fake_web(query, 'meme_search_type_audio.json')
52
+ Meme::Post.find('brhackday', :type => :audio).should be_nil
53
+ end
48
54
 
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
55
+ context "using the option :type" do
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"
54
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
76
+
77
+ describe "::popular" do
78
+
79
+ before :each do
80
+ query = "SELECT * FROM meme.popular WHERE locale='pt'"
81
+ fake_web(query, 'meme_popular_pt.json')
82
+ @results = Meme::Post.popular
55
83
  end
56
84
 
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"
85
+ it { @results.count.should == 10 }
86
+
87
+ it "should return content" do
88
+ @results.first.content.should == "http://d.yimg.com/gg/u/38b15b9620e38090aa092420790d3b5a528e8e99.jpeg"
63
89
  end
64
90
 
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"
91
+ it "return the user post" do
92
+ query = "SELECT * FROM meme.info WHERE owner_guid='QKSXELRVSAWRI77FVKODDYTKB4'"
93
+ fake_web(query, 'meme_info_guid.json')
94
+ @results.first.user.guid.should == "QKSXELRVSAWRI77FVKODDYTKB4"
95
+ end
96
+
97
+ context "using the locale" do
98
+
99
+ it "locale 'id' for Bahasa Indonesia" do
100
+ query = "SELECT * FROM meme.popular WHERE locale='id'"
101
+ fake_web(query, 'meme_popular_id.json')
102
+ @results = Meme::Post.popular('id')
103
+ @results.count.should == 10
104
+ @results.first.content.should == "Kemarin dia menawarkan cinta, hmm sayang harganya terlalu mahal jadi aku putuskan untuk tak memilikinya..."
105
+ end
106
+
71
107
  end
72
108
 
73
109
  end
metadata CHANGED
@@ -1,7 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: meme
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 2
8
+ - 1
9
+ version: 0.2.1
5
10
  platform: ruby
6
11
  authors:
7
12
  - "J\xC3\xA9sus Lopes"
@@ -9,19 +14,23 @@ autorequire:
9
14
  bindir: bin
10
15
  cert_chain: []
11
16
 
12
- date: 2010-04-01 00:00:00 -03:00
17
+ date: 2010-05-01 00:00:00 -03:00
13
18
  default_executable:
14
19
  dependencies:
15
20
  - !ruby/object:Gem::Dependency
16
21
  name: rspec
17
- type: :development
18
- version_requirement:
19
- version_requirements: !ruby/object:Gem::Requirement
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
20
24
  requirements:
21
25
  - - ">="
22
26
  - !ruby/object:Gem::Version
27
+ segments:
28
+ - 1
29
+ - 2
30
+ - 9
23
31
  version: 1.2.9
24
- version:
32
+ type: :development
33
+ version_requirements: *id001
25
34
  description: Yahoo! Meme API wrapper library in Ruby
26
35
  email: jlopes@zigotto.com.br
27
36
  executables: []
@@ -50,7 +59,10 @@ files:
50
59
  - spec/fixtures/meme_following_all.json
51
60
  - spec/fixtures/meme_following_count.json
52
61
  - spec/fixtures/meme_info.json
62
+ - spec/fixtures/meme_info_guid.json
53
63
  - spec/fixtures/meme_info_not_found.json
64
+ - spec/fixtures/meme_popular_id.json
65
+ - spec/fixtures/meme_popular_pt.json
54
66
  - spec/fixtures/meme_search.json
55
67
  - spec/fixtures/meme_search_type_audio.json
56
68
  - spec/fixtures/meme_search_type_photo.json
@@ -73,23 +85,25 @@ required_ruby_version: !ruby/object:Gem::Requirement
73
85
  requirements:
74
86
  - - ">="
75
87
  - !ruby/object:Gem::Version
88
+ segments:
89
+ - 0
76
90
  version: "0"
77
- version:
78
91
  required_rubygems_version: !ruby/object:Gem::Requirement
79
92
  requirements:
80
93
  - - ">="
81
94
  - !ruby/object:Gem::Version
95
+ segments:
96
+ - 0
82
97
  version: "0"
83
- version:
84
98
  requirements: []
85
99
 
86
100
  rubyforge_project:
87
- rubygems_version: 1.3.5
101
+ rubygems_version: 1.3.6
88
102
  signing_key:
89
103
  specification_version: 3
90
104
  summary: Ruby Yahoo! Meme API
91
105
  test_files:
106
+ - spec/info_spec.rb
92
107
  - spec/meme_spec.rb
93
108
  - spec/search_spec.rb
94
109
  - spec/spec_helper.rb
95
- - spec/info_spec.rb