thornbed 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.md +1 -1
- data/lib/thornbed/providers/memecrunch.rb +33 -0
- data/lib/thornbed/version.rb +1 -1
- data/spec/providers/memecrunch_spec.rb +46 -0
- metadata +7 -4
data/README.md
CHANGED
@@ -0,0 +1,33 @@
|
|
1
|
+
require "uri"
|
2
|
+
require "thornbed"
|
3
|
+
|
4
|
+
module Thornbed::Providers
|
5
|
+
class Memecrunch < Thornbed::Providers::Provider
|
6
|
+
attr_accessor :pattern
|
7
|
+
|
8
|
+
def initialize
|
9
|
+
self.pattern = /^http(s)?:\/\/memecrunch.com\/meme\/\w+\/[\w-]+(\/image.png)?(\?w=\d+)?$/
|
10
|
+
end
|
11
|
+
|
12
|
+
def get(url)
|
13
|
+
raise Thornbed::NotValid, url if !valid?(url)
|
14
|
+
url = URI.parse(url)
|
15
|
+
|
16
|
+
res = /([A-Z]{4,})\/([\w-]+)/.match(url.path)
|
17
|
+
pic_id = res[1]
|
18
|
+
slug = res[2]
|
19
|
+
|
20
|
+
{
|
21
|
+
url: "http://memecrunch.com/meme/#{pic_id}/#{slug}/image.png",
|
22
|
+
type: "photo",
|
23
|
+
provider_name: provider_name,
|
24
|
+
provider_url: "http://memecrunch.com",
|
25
|
+
thumbnail_url: "http://memecrunch.com/meme/#{pic_id}/#{slug}/image.png?w=75",
|
26
|
+
version: "1.0",
|
27
|
+
page: "http://memecrunch.com/meme/#{pic_id}/#{slug}/",
|
28
|
+
width: nil,
|
29
|
+
height: nil
|
30
|
+
}
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
data/lib/thornbed/version.rb
CHANGED
@@ -0,0 +1,46 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe "Memecrunch" do
|
4
|
+
it "should have Memecrunch as a provider" do
|
5
|
+
Thornbed::Providers.constants.should include(:Memecrunch)
|
6
|
+
end
|
7
|
+
|
8
|
+
it "should accept different Memecrunch urls" do
|
9
|
+
memecrunch = Thornbed::Providers::Memecrunch.new
|
10
|
+
memecrunch.valid?("http://memecrunch.com/meme/CHDE/when-browsing-r-new").should be_true
|
11
|
+
memecrunch.valid?("http://memecrunch.com/meme/CHDE/when-browsing-r-new/image.png").should be_true
|
12
|
+
memecrunch.valid?("http://memecrunch.com/meme/CHDE/when-browsing-r-new/image.png?w=75").should be_true
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should return OEmbed hash for Memecrunch urls" do
|
16
|
+
memecrunch = Thornbed::Providers::Memecrunch.new
|
17
|
+
res = memecrunch.get("http://memecrunch.com/meme/CHDE/when-browsing-r-new")
|
18
|
+
res.should include(url: "http://memecrunch.com/meme/CHDE/when-browsing-r-new/image.png")
|
19
|
+
|
20
|
+
res = memecrunch.get("http://memecrunch.com/meme/CHDE/when-browsing-r-new/image.png")
|
21
|
+
res.should include(url: "http://memecrunch.com/meme/CHDE/when-browsing-r-new/image.png")
|
22
|
+
|
23
|
+
res = memecrunch.get("http://memecrunch.com/meme/CHDE/when-browsing-r-new/image.png?w=75")
|
24
|
+
res.should include(url: "http://memecrunch.com/meme/CHDE/when-browsing-r-new/image.png")
|
25
|
+
end
|
26
|
+
|
27
|
+
it "should discover Memecrunch provider" do
|
28
|
+
res = Thornbed.get("http://memecrunch.com/meme/CHDE/when-browsing-r-new")
|
29
|
+
res.should include(url: "http://memecrunch.com/meme/CHDE/when-browsing-r-new/image.png")
|
30
|
+
res.should include(thumbnail_url: "http://memecrunch.com/meme/CHDE/when-browsing-r-new/image.png?w=75")
|
31
|
+
res.should include(page: "http://memecrunch.com/meme/CHDE/when-browsing-r-new/")
|
32
|
+
res.should include(provider_name: "Memecrunch")
|
33
|
+
|
34
|
+
res = Thornbed.get("http://memecrunch.com/meme/CHDE/when-browsing-r-new/image.png")
|
35
|
+
res.should include(url: "http://memecrunch.com/meme/CHDE/when-browsing-r-new/image.png")
|
36
|
+
res.should include(thumbnail_url: "http://memecrunch.com/meme/CHDE/when-browsing-r-new/image.png?w=75")
|
37
|
+
res.should include(page: "http://memecrunch.com/meme/CHDE/when-browsing-r-new/")
|
38
|
+
res.should include(provider_name: "Memecrunch")
|
39
|
+
|
40
|
+
res = Thornbed.get("http://memecrunch.com/meme/CHDE/when-browsing-r-new/image.png?w=75")
|
41
|
+
res.should include(url: "http://memecrunch.com/meme/CHDE/when-browsing-r-new/image.png")
|
42
|
+
res.should include(thumbnail_url: "http://memecrunch.com/meme/CHDE/when-browsing-r-new/image.png?w=75")
|
43
|
+
res.should include(page: "http://memecrunch.com/meme/CHDE/when-browsing-r-new/")
|
44
|
+
res.should include(provider_name: "Memecrunch")
|
45
|
+
end
|
46
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: thornbed
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-12-03 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: ruby-oembed
|
@@ -143,12 +143,14 @@ files:
|
|
143
143
|
- lib/thornbed/providers.rb
|
144
144
|
- lib/thornbed/providers/9gag.rb
|
145
145
|
- lib/thornbed/providers/imgur.rb
|
146
|
+
- lib/thornbed/providers/memecrunch.rb
|
146
147
|
- lib/thornbed/providers/memegenerator.rb
|
147
148
|
- lib/thornbed/providers/quickmeme.rb
|
148
149
|
- lib/thornbed/version.rb
|
149
150
|
- spec/provider_spec.rb
|
150
151
|
- spec/providers/9gag_spec.rb
|
151
152
|
- spec/providers/imgur_spec.rb
|
153
|
+
- spec/providers/memecrunch_spec.rb
|
152
154
|
- spec/providers/memegenerator_spec.rb
|
153
155
|
- spec/providers/quickmeme_spec.rb
|
154
156
|
- spec/spec_helper.rb
|
@@ -168,7 +170,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
168
170
|
version: '0'
|
169
171
|
segments:
|
170
172
|
- 0
|
171
|
-
hash:
|
173
|
+
hash: 1111310976437943127
|
172
174
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
173
175
|
none: false
|
174
176
|
requirements:
|
@@ -177,7 +179,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
177
179
|
version: '0'
|
178
180
|
segments:
|
179
181
|
- 0
|
180
|
-
hash:
|
182
|
+
hash: 1111310976437943127
|
181
183
|
requirements: []
|
182
184
|
rubyforge_project:
|
183
185
|
rubygems_version: 1.8.24
|
@@ -189,6 +191,7 @@ test_files:
|
|
189
191
|
- spec/provider_spec.rb
|
190
192
|
- spec/providers/9gag_spec.rb
|
191
193
|
- spec/providers/imgur_spec.rb
|
194
|
+
- spec/providers/memecrunch_spec.rb
|
192
195
|
- spec/providers/memegenerator_spec.rb
|
193
196
|
- spec/providers/quickmeme_spec.rb
|
194
197
|
- spec/spec_helper.rb
|