-
Notifications
You must be signed in to change notification settings - Fork 106
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add image limit config ; add fallback mechanism. Fixes #15
- Loading branch information
Showing
11 changed files
with
187 additions
and
90 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,6 +20,10 @@ def call(website, attribute_name) | |
website | ||
end | ||
|
||
def applicable? | ||
true | ||
end | ||
|
||
private | ||
|
||
def value | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
require 'pry' | ||
require 'link_thumbnailer/scrapers/opengraph/base' | ||
|
||
module LinkThumbnailer | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
require 'spec_helper' | ||
|
||
describe LinkThumbnailer::Scrapers::Opengraph::Base do | ||
|
||
let(:node) { double('node') } | ||
let(:document) { double('document') } | ||
let(:instance) { described_class.new(document) } | ||
|
||
describe '#applicable?' do | ||
|
||
let(:meta) { [node, node] } | ||
let(:action) { instance.applicable? } | ||
|
||
before do | ||
instance.stub(:meta).and_return(meta) | ||
end | ||
|
||
context 'when all node is an opengraph' do | ||
|
||
before do | ||
instance.stub(:opengraph_node?).and_return(true, true) | ||
end | ||
|
||
it { expect(action).to be_true } | ||
|
||
end | ||
|
||
context 'when any node is an opengraph' do | ||
|
||
before do | ||
instance.stub(:opengraph_node?).and_return(true, false) | ||
end | ||
|
||
it { expect(action).to be_true } | ||
|
||
end | ||
|
||
context 'when no node is an opengraph' do | ||
|
||
before do | ||
instance.stub(:opengraph_node?).and_return(false, false) | ||
end | ||
|
||
it { expect(action).to be_false } | ||
|
||
end | ||
|
||
end | ||
|
||
describe '#opengraph_node?' do | ||
|
||
let(:action) { instance.send(:opengraph_node?, node) } | ||
|
||
before do | ||
node.stub(:attribute).with('name').and_return(attribute_from_name) | ||
end | ||
|
||
context 'with attribute from name valid' do | ||
|
||
let(:attribute_from_name) { 'og:foo' } | ||
|
||
it { expect(action).to be_true } | ||
|
||
end | ||
|
||
context 'with attribute from name not valid' do | ||
|
||
let(:attribute_from_name) { 'foo' } | ||
|
||
before do | ||
node.stub(:attribute).with('property').and_return(attribute_from_property) | ||
end | ||
|
||
context 'and attribute from property valid' do | ||
|
||
let(:attribute_from_property) { 'og:bar' } | ||
|
||
it { expect(action).to be_true } | ||
|
||
end | ||
|
||
context 'and attribute from property not valid' do | ||
|
||
let(:attribute_from_property) { 'bar' } | ||
|
||
it { expect(action).to be_false } | ||
|
||
end | ||
|
||
end | ||
|
||
end | ||
|
||
end |