thornbed 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +26 -0
- data/Gemfile +4 -0
- data/Guardfile +10 -0
- data/LICENSE.txt +22 -0
- data/README.md +52 -0
- data/Rakefile +1 -0
- data/lib/thornbed/errors.rb +16 -0
- data/lib/thornbed/provider.rb +32 -0
- data/lib/thornbed/providers/imgur.rb +49 -0
- data/lib/thornbed/providers/quickmeme.rb +40 -0
- data/lib/thornbed/providers.rb +6 -0
- data/lib/thornbed/version.rb +3 -0
- data/lib/thornbed.rb +20 -0
- data/spec/providers/imgur_spec.rb +69 -0
- data/spec/providers/quickmeme_spec.rb +69 -0
- data/spec/spec_helper.rb +21 -0
- data/spec/thornbed_spec.rb +42 -0
- data/thornbed.gemspec +25 -0
- metadata +164 -0
data/.gitignore
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
.bundle
|
4
|
+
.config
|
5
|
+
.yardoc
|
6
|
+
Gemfile.lock
|
7
|
+
InstalledFiles
|
8
|
+
_yardoc
|
9
|
+
coverage
|
10
|
+
doc/
|
11
|
+
lib/bundler/man
|
12
|
+
pkg
|
13
|
+
rdoc
|
14
|
+
spec/reports
|
15
|
+
test/tmp
|
16
|
+
test/version_tmp
|
17
|
+
tmp
|
18
|
+
.gs
|
19
|
+
.codeintel/
|
20
|
+
.gemtags
|
21
|
+
.rbenv-version
|
22
|
+
.rspec
|
23
|
+
.rvmrc
|
24
|
+
.tags*
|
25
|
+
bin/
|
26
|
+
build_gemtags.rb
|
data/Gemfile
ADDED
data/Guardfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2012 Esteban (Eka) Feldman
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
# Thornbed
|
2
|
+
|
3
|
+
Thornbed provides a single interface to get embeddable content from many sites, even sites with no OEmbed support.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'thornbed'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install thornbed
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
>> require "thornbed"
|
22
|
+
=> true
|
23
|
+
>> Thornbed.get("http://instagram.com/p/SOlosmBgoZ/")
|
24
|
+
=> {"provider_url"=>"http://instagram.com/",
|
25
|
+
"media_id"=>"328365347227175449_43815385",
|
26
|
+
"title"=>"Smile",
|
27
|
+
"url"=>
|
28
|
+
"http://distilleryimage1.instagram.com/b43af7ce329811e281d822000a1f9682_7.jpg",
|
29
|
+
"author_name"=>"esteban108",
|
30
|
+
"height"=>612,
|
31
|
+
"width"=>612,
|
32
|
+
"version"=>"1.0",
|
33
|
+
"author_url"=>"http://instagram.com/",
|
34
|
+
"author_id"=>43815385,
|
35
|
+
"type"=>"photo",
|
36
|
+
"provider_name"=>"Instagram"}
|
37
|
+
|
38
|
+
## Adding new providers
|
39
|
+
|
40
|
+
See ruby-oembed on this. Don't forget to call `OEmbed::Providers.register_all`
|
41
|
+
|
42
|
+
## Creating your custom providers
|
43
|
+
|
44
|
+
You should inherit from `Thornbed::Providers::Provider`. See imgur.rb for an example.
|
45
|
+
|
46
|
+
## Contributing
|
47
|
+
|
48
|
+
1. Fork it
|
49
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
50
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
51
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
52
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Thornbed
|
2
|
+
class Error < StandardError
|
3
|
+
end
|
4
|
+
|
5
|
+
class NotFound < Thornbed::Error
|
6
|
+
def to_s
|
7
|
+
"No embeddable content at '#{super}'"
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
class NotValid < Thornbed::Error
|
12
|
+
def to_s
|
13
|
+
"Not valid url for this provider"
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require "thornbed/errors"
|
2
|
+
|
3
|
+
module Thornbed
|
4
|
+
module Providers
|
5
|
+
class Provider
|
6
|
+
@providers = []
|
7
|
+
|
8
|
+
class << self
|
9
|
+
attr_reader :providers
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.inherited(subclass)
|
13
|
+
@providers << subclass
|
14
|
+
end
|
15
|
+
|
16
|
+
def valid?(url)
|
17
|
+
!!@pattern.match(url)
|
18
|
+
end
|
19
|
+
|
20
|
+
def provider_name
|
21
|
+
self.class.to_s.split('::')[-1]
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def self.get(url)
|
26
|
+
providers = Thornbed::Providers::Provider.providers
|
27
|
+
provider = providers.detect { |p| p.new.valid?(url) }
|
28
|
+
raise Thornbed::NotFound, url if provider.nil?
|
29
|
+
provider.new.get(url)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
require "uri"
|
2
|
+
require "thornbed"
|
3
|
+
|
4
|
+
|
5
|
+
module Thornbed::Providers
|
6
|
+
class Imgur < Thornbed::Providers::Provider
|
7
|
+
|
8
|
+
def initialize
|
9
|
+
@pattern = /^http(s)?:\/\/((i\.)|(www\.))?imgur.com\/(gallery\/)?(\w){5}(s|l|b|m|t)?(\.gif|\.jpg|.jpeg|\.png)?(\?full)?$/
|
10
|
+
@type = "photo"
|
11
|
+
@provider_url = "http://imgur.com"
|
12
|
+
end
|
13
|
+
|
14
|
+
def get(url)
|
15
|
+
raise Thornbed::NotValid, url if !self.valid?(url)
|
16
|
+
url = URI.parse(url)
|
17
|
+
gallery = /gallery/ =~ url.path
|
18
|
+
direct = /\/(\w){5}(\.gif|\.jpg|\.jpeg|\.png)$/.match(url.path)
|
19
|
+
thumb = /\/(\w){5}(s|l|b|m|t)(\.gif|\.jpg|\.jpeg|\.png)$/.match(url.path)
|
20
|
+
page = /\/(\w){5}$/ =~ url.path
|
21
|
+
ptype = "jpg"
|
22
|
+
|
23
|
+
if page || gallery
|
24
|
+
pic_id = /(\/gallery\/)?\/(\w)*$/.match(url.path)[0][1..-1]
|
25
|
+
elsif thumb
|
26
|
+
pic_id = thumb[0][1..5]
|
27
|
+
elsif direct
|
28
|
+
pic_id = direct[0][1..5]
|
29
|
+
ptype = /(\.gif|\.jpg|\.jpeg|\.png)$/.match(url.path)[0][1..-1]
|
30
|
+
else
|
31
|
+
raise Thornbed::NotValid, url
|
32
|
+
end
|
33
|
+
|
34
|
+
{
|
35
|
+
url: "http://i.imgur.com/#{pic_id}.#{ptype}",
|
36
|
+
type: "#{@type}",
|
37
|
+
provider_name: self.provider_name,
|
38
|
+
provider_url: @provider_url,
|
39
|
+
thumbnail_url: "http://i.imgur.com/#{pic_id}s.#{ptype}",
|
40
|
+
version: "1.0",
|
41
|
+
page: "http://imgur.com/#{pic_id}",
|
42
|
+
width: nil,
|
43
|
+
height: nil
|
44
|
+
}
|
45
|
+
end
|
46
|
+
|
47
|
+
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require "uri"
|
2
|
+
require "thornbed"
|
3
|
+
|
4
|
+
|
5
|
+
module Thornbed::Providers
|
6
|
+
class QuickMeme < Thornbed::Providers::Provider
|
7
|
+
def initialize
|
8
|
+
@pattern = /http(s)?:\/\/(i|t)?(\.)?(www\.)?(quickmeme.com|qkme.me)\/(meme\/)?(\w){6}(\/)?(.jpg)?((\?|#).*)?$/
|
9
|
+
@type = "photo"
|
10
|
+
@provider_url = "http://quickmeme.com"
|
11
|
+
end
|
12
|
+
|
13
|
+
def get(url)
|
14
|
+
raise Thornbed::NotValid, url if !self.valid?(url)
|
15
|
+
url = URI.parse(url)
|
16
|
+
normal = /quickmeme.com/ =~ url.to_s
|
17
|
+
direct = /qkme.me/ =~ url.to_s
|
18
|
+
ptype = "jpg"
|
19
|
+
if normal
|
20
|
+
pic_id = /(\w){6}/.match(url.path)
|
21
|
+
elsif direct
|
22
|
+
pic_id = url.path[/(\w){6}(.jpg)?/ =~ url.path..6]
|
23
|
+
else
|
24
|
+
raise Thornbed::NotValid, url
|
25
|
+
end
|
26
|
+
|
27
|
+
{
|
28
|
+
url: "http://i.qkme.me/#{pic_id}.#{ptype}",
|
29
|
+
type: "#{@type}",
|
30
|
+
provider_name: self.provider_name,
|
31
|
+
provider_url: @provider_url,
|
32
|
+
thumbnail_url: "http://t.qkme.me/#{pic_id}.#{ptype}",
|
33
|
+
version: "1.0",
|
34
|
+
page: "http://quickmeme.com/#{pic_id}/",
|
35
|
+
width: nil,
|
36
|
+
height: nil
|
37
|
+
}
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
data/lib/thornbed.rb
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
require "oembed"
|
2
|
+
require "thornbed/version"
|
3
|
+
require "thornbed/provider"
|
4
|
+
require "thornbed/providers"
|
5
|
+
require "thornbed/errors"
|
6
|
+
|
7
|
+
|
8
|
+
OEmbed::Providers.register_all
|
9
|
+
|
10
|
+
module Thornbed
|
11
|
+
def self.get(url)
|
12
|
+
begin
|
13
|
+
res = OEmbed::Providers.get(url)
|
14
|
+
res.fields
|
15
|
+
rescue OEmbed::NotFound
|
16
|
+
res = Thornbed::Providers.get(url)
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,69 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
require "fakeweb"
|
3
|
+
require "thornbed"
|
4
|
+
|
5
|
+
describe "Imgur" do
|
6
|
+
it "should have Imgur as a provider" do
|
7
|
+
Thornbed::Providers.constants.include?(:Imgur).should_not be_false
|
8
|
+
end
|
9
|
+
|
10
|
+
it "should accept different imgur urls" do
|
11
|
+
imgur = Thornbed::Providers::Imgur.new
|
12
|
+
imgur.valid?('http://imgur.com/gallery/A0TP9').should be_true
|
13
|
+
imgur.valid?('http://i.imgur.com/A0TP9.png').should be_true
|
14
|
+
imgur.valid?('http://i.imgur.com/A0TP9.gif').should be_true
|
15
|
+
imgur.valid?('http://i.imgur.com/A0TP9.jpg').should be_true
|
16
|
+
imgur.valid?('http://i.imgur.com/PFaps.jpg').should be_true
|
17
|
+
imgur.valid?('http://imgur.com/SruWT?full').should be_true
|
18
|
+
imgur.valid?('http://i.imgur.com/DE7Rbl.jpg').should be_true
|
19
|
+
imgur.valid?('http://i.imgur.com/N2IDN.gif').should be_true
|
20
|
+
imgur.valid?('http://i.imgur.com/A0TP9s.jpg').should be_true
|
21
|
+
imgur.valid?('http://www.imgur.com/RUUuR.jpeg').should be_true
|
22
|
+
imgur.valid?('http://imgur.com/none').should be_false
|
23
|
+
imgur.valid?('http://imgur.com/none.jpg').should be_false
|
24
|
+
imgur.valid?('http://imgur.com/a/pq0N2').should be_false
|
25
|
+
end
|
26
|
+
|
27
|
+
it "should return OEmbed hash for imgur urls" do
|
28
|
+
imgur = Thornbed::Providers::Imgur.new
|
29
|
+
res = imgur.get('http://imgur.com/gallery/A0TP9')
|
30
|
+
res.should include(url: 'http://i.imgur.com/A0TP9.jpg')
|
31
|
+
|
32
|
+
res = imgur.get('http://i.imgur.com/A0TP9.png')
|
33
|
+
res.should include(url: 'http://i.imgur.com/A0TP9.png')
|
34
|
+
|
35
|
+
res = imgur.get('http://i.imgur.com/A0TP9.gif')
|
36
|
+
res.should include(url: 'http://i.imgur.com/A0TP9.gif')
|
37
|
+
|
38
|
+
res = imgur.get('http://i.imgur.com/A0TP9.jpg')
|
39
|
+
res.should include(url: 'http://i.imgur.com/A0TP9.jpg')
|
40
|
+
|
41
|
+
res = imgur.get('http://i.imgur.com/PFaps.jpg')
|
42
|
+
res.should include(url: 'http://i.imgur.com/PFaps.jpg')
|
43
|
+
|
44
|
+
res = imgur.get('http://imgur.com/SruWT?full')
|
45
|
+
res.should include(url: 'http://i.imgur.com/SruWT.jpg')
|
46
|
+
|
47
|
+
res = imgur.get('http://i.imgur.com/DE7Rbl.jpg')
|
48
|
+
res.should include(url: 'http://i.imgur.com/DE7Rb.jpg')
|
49
|
+
|
50
|
+
res = imgur.get('http://i.imgur.com/N2IDN.gif')
|
51
|
+
res.should include(url: 'http://i.imgur.com/N2IDN.gif')
|
52
|
+
|
53
|
+
res = imgur.get('http://i.imgur.com/A0TP9s.jpg')
|
54
|
+
res.should include(url: 'http://i.imgur.com/A0TP9.jpg')
|
55
|
+
|
56
|
+
res = imgur.get('http://www.imgur.com/RUUuR.jpeg')
|
57
|
+
res.should include(url: 'http://i.imgur.com/RUUuR.jpeg')
|
58
|
+
|
59
|
+
lambda { imgur.get('http://imgur.com/none') }.should raise_error(Thornbed::NotValid)
|
60
|
+
lambda { imgur.get('http://imgur.com/none.jpg') }.should raise_error(Thornbed::NotValid)
|
61
|
+
lambda { imgur.get('http://imgur.com/a/pq0N2') }.should raise_error(Thornbed::NotValid)
|
62
|
+
end
|
63
|
+
|
64
|
+
it "should discover Imgur provider" do
|
65
|
+
res = Thornbed.get('http://imgur.com/N2IDN')
|
66
|
+
res.should include(url: 'http://i.imgur.com/N2IDN.jpg')
|
67
|
+
res.should include(provider_name: "Imgur")
|
68
|
+
end
|
69
|
+
end
|
@@ -0,0 +1,69 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
require "fakeweb"
|
3
|
+
require "thornbed"
|
4
|
+
|
5
|
+
describe "QuickMeme" do
|
6
|
+
it "should have QuickMeme as a provider" do
|
7
|
+
Thornbed::Providers.constants.include?(:QuickMeme).should_not be_false
|
8
|
+
end
|
9
|
+
|
10
|
+
it "should accept different quickmeme urls" do
|
11
|
+
quickmeme = Thornbed::Providers::QuickMeme.new
|
12
|
+
quickmeme.valid?('http://i.qkme.me/353dum.jpg').should be_true
|
13
|
+
quickmeme.valid?('http://t.qkme.me/353dum.jpg').should be_true
|
14
|
+
quickmeme.valid?('http://www.quickmeme.com/meme/353dum/').should be_true
|
15
|
+
quickmeme.valid?('http://qkme.me/353i1m?id=189959962').should be_true
|
16
|
+
quickmeme.valid?('http://www.quickmeme.com/meme/3rt124/#by=ad').should be_true
|
17
|
+
quickmeme.valid?('http://www.quickmeme.com/meme/3rtne7/').should be_true
|
18
|
+
quickmeme.valid?('http://qkme.me/353i1ma').should be_false
|
19
|
+
quickmeme.valid?('http://www.quickmeme.com/meme/353duma/').should be_false
|
20
|
+
quickmeme.valid?('http://i.qkme.me/353duma.jpg').should be_false
|
21
|
+
end
|
22
|
+
|
23
|
+
it "should return OEmbed hash for quickmeme urls" do
|
24
|
+
quickmeme = Thornbed::Providers::QuickMeme.new
|
25
|
+
res = quickmeme.get('http://i.qkme.me/353dum.jpg')
|
26
|
+
res.should include(url: 'http://i.qkme.me/353dum.jpg')
|
27
|
+
|
28
|
+
res = quickmeme.get('http://t.qkme.me/353dum.jpg')
|
29
|
+
res.should include(url: 'http://i.qkme.me/353dum.jpg')
|
30
|
+
|
31
|
+
res = quickmeme.get('http://www.quickmeme.com/meme/353dum/')
|
32
|
+
res.should include(url: 'http://i.qkme.me/353dum.jpg')
|
33
|
+
|
34
|
+
res = quickmeme.get('http://qkme.me/353i1m?id=189959962')
|
35
|
+
res.should include(url: 'http://i.qkme.me/353i1m.jpg')
|
36
|
+
|
37
|
+
res = quickmeme.get('http://qkme.me/353dum')
|
38
|
+
res.should include(url: 'http://i.qkme.me/353dum.jpg')
|
39
|
+
|
40
|
+
res = quickmeme.get('http://www.quickmeme.com/meme/3rtne7/')
|
41
|
+
res.should include(url: 'http://i.qkme.me/3rtne7.jpg')
|
42
|
+
|
43
|
+
lambda { quickmeme.get('http://qkme.me/353i1ma') }.should raise_error(Thornbed::NotValid)
|
44
|
+
lambda { quickmeme.get('http://www.quickmeme.com/meme/353duma/') }.should raise_error(Thornbed::NotValid)
|
45
|
+
lambda { quickmeme.get('http://i.qkme.me/353duma.jpg') }.should raise_error(Thornbed::NotValid)
|
46
|
+
end
|
47
|
+
|
48
|
+
it "should discover Imgur provider" do
|
49
|
+
res = Thornbed.get('http://qkme.me/353dum')
|
50
|
+
res.should include(url: 'http://i.qkme.me/353dum.jpg')
|
51
|
+
res.should include(provider_name: "QuickMeme")
|
52
|
+
|
53
|
+
res = Thornbed.get('http://www.quickmeme.com/meme/353dum/')
|
54
|
+
res.should include(url: 'http://i.qkme.me/353dum.jpg')
|
55
|
+
res.should include(provider_name: "QuickMeme")
|
56
|
+
|
57
|
+
res = Thornbed.get('http://t.qkme.me/353dum.jpg')
|
58
|
+
res.should include(url: 'http://i.qkme.me/353dum.jpg')
|
59
|
+
res.should include(provider_name: "QuickMeme")
|
60
|
+
|
61
|
+
res = Thornbed.get('http://qkme.me/353i1m?id=189959962')
|
62
|
+
res.should include(url: 'http://i.qkme.me/353i1m.jpg')
|
63
|
+
res.should include(provider_name: "QuickMeme")
|
64
|
+
|
65
|
+
res = Thornbed.get('http://qkme.me/353dum')
|
66
|
+
res.should include(url: 'http://i.qkme.me/353dum.jpg')
|
67
|
+
res.should include(provider_name: "QuickMeme")
|
68
|
+
end
|
69
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
# This file was generated by the `rspec --init` command. Conventionally, all
|
2
|
+
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
|
3
|
+
# Require this file using `require "spec_helper"` to ensure that it is only
|
4
|
+
# loaded once.
|
5
|
+
#
|
6
|
+
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
7
|
+
require "bundler/setup"
|
8
|
+
require "thornbed"
|
9
|
+
|
10
|
+
|
11
|
+
RSpec.configure do |config|
|
12
|
+
config.treat_symbols_as_metadata_keys_with_true_values = true
|
13
|
+
config.run_all_when_everything_filtered = true
|
14
|
+
config.filter_run :focus
|
15
|
+
|
16
|
+
# Run specs in random order to surface order dependencies. If you find an
|
17
|
+
# order dependency and want to debug it, you can fix the order by providing
|
18
|
+
# the seed, which is printed after each run.
|
19
|
+
# --seed 1234
|
20
|
+
config.order = 'random'
|
21
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
require "fakeweb"
|
3
|
+
require "thornbed"
|
4
|
+
|
5
|
+
describe Thornbed do
|
6
|
+
|
7
|
+
it "should have a VERSION constant" do
|
8
|
+
subject.const_get('VERSION').should_not be_empty
|
9
|
+
end
|
10
|
+
|
11
|
+
it "should rely on ruby-oembed when querying for a oembed provider" do
|
12
|
+
good_response = {
|
13
|
+
"provider_url"=>"http://www.youtube.com/",
|
14
|
+
"thumbnail_url"=>"http://i1.ytimg.com/vi/xJbJayhYxG4/hqdefault.jpg",
|
15
|
+
"title"=>"How can I know if God Exists?",
|
16
|
+
"html"=>
|
17
|
+
"<iframe width=\"459\" height=\"344\" src=\"http://www.youtube.com/embed/xJbJayhYxG4?fs=1&feature=oembed\" frameborder=\"0\" allowfullscreen></iframe>",
|
18
|
+
"author_name"=>"radhanathswamionline",
|
19
|
+
"height"=>344,
|
20
|
+
"thumbnail_width"=>480,
|
21
|
+
"width"=>459,
|
22
|
+
"version"=>"1.0",
|
23
|
+
"author_url"=>"http://www.youtube.com/user/radhanathswamionline",
|
24
|
+
"provider_name"=>"YouTube",
|
25
|
+
"type"=>"video",
|
26
|
+
"thumbnail_height"=>360
|
27
|
+
}
|
28
|
+
FakeWeb.register_uri(:get, /http(s)?:\/\/*(\.)?google\.com\/*/, body: good_response)
|
29
|
+
url = "http://www.youtube.com/watch?v=xJbJayhYxG4&feature=g-vrec"
|
30
|
+
res = Thornbed.get(url)
|
31
|
+
|
32
|
+
res.should == good_response
|
33
|
+
end
|
34
|
+
|
35
|
+
it "should raise an error when calling get on a bad url" do
|
36
|
+
imgur = Thornbed::Providers::Imgur.new
|
37
|
+
lambda { imgur.get('http://imgur.com/none.jpg') }.should raise_error(Thornbed::NotValid)
|
38
|
+
end
|
39
|
+
|
40
|
+
|
41
|
+
|
42
|
+
end
|
data/thornbed.gemspec
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'thornbed/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |gem|
|
7
|
+
gem.name = "thornbed"
|
8
|
+
gem.version = Thornbed::VERSION
|
9
|
+
gem.authors = ["Esteban (Eka) Feldman"]
|
10
|
+
gem.email = ["esteban.feldman@gmail.com"]
|
11
|
+
gem.description = %q{Thin OEmbed wrapper}
|
12
|
+
gem.summary = %q{Thornbed provides a single interface to get embeddable content from many sites, even sites with no OEmbed support.}
|
13
|
+
gem.homepage = "https://github.com/eka/thornbed/"
|
14
|
+
|
15
|
+
gem.files = `git ls-files`.split($/)
|
16
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
17
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
18
|
+
gem.require_paths = ["lib"]
|
19
|
+
gem.add_runtime_dependency "ruby-oembed", "~> 0.8.7"
|
20
|
+
gem.add_development_dependency "rspec", "~> 2.12.0"
|
21
|
+
gem.add_development_dependency "guard-rspec", "~> 2.1.1"
|
22
|
+
gem.add_development_dependency "rb-fsevent", "~> 0.9.2"
|
23
|
+
gem.add_development_dependency "terminal-notifier-guard", "~> 1.5.3"
|
24
|
+
gem.add_development_dependency "fakeweb", "~> 1.3.0"
|
25
|
+
end
|
metadata
ADDED
@@ -0,0 +1,164 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: thornbed
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Esteban (Eka) Feldman
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-11-20 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: ruby-oembed
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 0.8.7
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 0.8.7
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: rspec
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ~>
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: 2.12.0
|
38
|
+
type: :development
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ~>
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: 2.12.0
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: guard-rspec
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ~>
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: 2.1.1
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 2.1.1
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: rb-fsevent
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ~>
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: 0.9.2
|
70
|
+
type: :development
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ~>
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: 0.9.2
|
78
|
+
- !ruby/object:Gem::Dependency
|
79
|
+
name: terminal-notifier-guard
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ~>
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: 1.5.3
|
86
|
+
type: :development
|
87
|
+
prerelease: false
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ~>
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: 1.5.3
|
94
|
+
- !ruby/object:Gem::Dependency
|
95
|
+
name: fakeweb
|
96
|
+
requirement: !ruby/object:Gem::Requirement
|
97
|
+
none: false
|
98
|
+
requirements:
|
99
|
+
- - ~>
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: 1.3.0
|
102
|
+
type: :development
|
103
|
+
prerelease: false
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
106
|
+
requirements:
|
107
|
+
- - ~>
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: 1.3.0
|
110
|
+
description: Thin OEmbed wrapper
|
111
|
+
email:
|
112
|
+
- esteban.feldman@gmail.com
|
113
|
+
executables: []
|
114
|
+
extensions: []
|
115
|
+
extra_rdoc_files: []
|
116
|
+
files:
|
117
|
+
- .gitignore
|
118
|
+
- Gemfile
|
119
|
+
- Guardfile
|
120
|
+
- LICENSE.txt
|
121
|
+
- README.md
|
122
|
+
- Rakefile
|
123
|
+
- lib/thornbed.rb
|
124
|
+
- lib/thornbed/errors.rb
|
125
|
+
- lib/thornbed/provider.rb
|
126
|
+
- lib/thornbed/providers.rb
|
127
|
+
- lib/thornbed/providers/imgur.rb
|
128
|
+
- lib/thornbed/providers/quickmeme.rb
|
129
|
+
- lib/thornbed/version.rb
|
130
|
+
- spec/providers/imgur_spec.rb
|
131
|
+
- spec/providers/quickmeme_spec.rb
|
132
|
+
- spec/spec_helper.rb
|
133
|
+
- spec/thornbed_spec.rb
|
134
|
+
- thornbed.gemspec
|
135
|
+
homepage: https://github.com/eka/thornbed/
|
136
|
+
licenses: []
|
137
|
+
post_install_message:
|
138
|
+
rdoc_options: []
|
139
|
+
require_paths:
|
140
|
+
- lib
|
141
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
142
|
+
none: false
|
143
|
+
requirements:
|
144
|
+
- - ! '>='
|
145
|
+
- !ruby/object:Gem::Version
|
146
|
+
version: '0'
|
147
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
148
|
+
none: false
|
149
|
+
requirements:
|
150
|
+
- - ! '>='
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: '0'
|
153
|
+
requirements: []
|
154
|
+
rubyforge_project:
|
155
|
+
rubygems_version: 1.8.24
|
156
|
+
signing_key:
|
157
|
+
specification_version: 3
|
158
|
+
summary: Thornbed provides a single interface to get embeddable content from many
|
159
|
+
sites, even sites with no OEmbed support.
|
160
|
+
test_files:
|
161
|
+
- spec/providers/imgur_spec.rb
|
162
|
+
- spec/providers/quickmeme_spec.rb
|
163
|
+
- spec/spec_helper.rb
|
164
|
+
- spec/thornbed_spec.rb
|