link_thumbnailer 3.0.3 → 3.1.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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +12 -0
- data/README.md +1 -1
- data/lib/generators/templates/initializer.rb +1 -1
- data/lib/link_thumbnailer/configuration.rb +1 -1
- data/lib/link_thumbnailer/grader.rb +1 -1
- data/lib/link_thumbnailer/graders/base.rb +7 -2
- data/lib/link_thumbnailer/image_comparators/size.rb +1 -1
- data/lib/link_thumbnailer/version.rb +1 -1
- data/spec/grader_spec.rb +3 -2
- data/spec/image_comparators/size_spec.rb +17 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f47134a149128a2df4c2a4e91fb3857b2f38d4be
|
4
|
+
data.tar.gz: 4dfb35562b6ecc861c2948cfc7e2bfb41c1b3705
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dde01e9975a4da2c2044b5d6f203fbca53b04ce018dd1c5f70096fec040902a6fcd972d1fb054869572a37b74d6cdbc2281f6d93bb6f66328cb2388f6131df42
|
7
|
+
data.tar.gz: 03af8d1474d4443646a458902c9114677a71c5cfac8ef3b6e0c01964b474b3e4780001460a22b88050395a0019b818a8afbe2cefc42a39ad2edef2cf0a2a6931
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,15 @@
|
|
1
|
+
# 3.1.0
|
2
|
+
|
3
|
+
- Fix an issue when image sizes could not be retrieved.
|
4
|
+
- Grapers now accepts an optional parameter to customize the weigth of the grader in the probablity computation.
|
5
|
+
|
6
|
+
```ruby
|
7
|
+
LinkThumbnailer::Graders::Position.new(description, weigth: 3)
|
8
|
+
```
|
9
|
+
|
10
|
+
Will give a 3 times more weigth to the `Position` grader compare to other graders.
|
11
|
+
By default all graders have a weigth of `1`.
|
12
|
+
|
1
13
|
# 3.0.3
|
2
14
|
|
3
15
|
- Fix an issue when dealing with absolute urls. https://github.com/gottfrois/link_thumbnailer/issues/68
|
data/README.md
CHANGED
@@ -129,7 +129,7 @@ LinkThumbnailer.configure do |config|
|
|
129
129
|
# ->(description) { ::LinkThumbnailer::Graders::Length.new(description) },
|
130
130
|
# ->(description) { ::LinkThumbnailer::Graders::HtmlAttribute.new(description, :class) },
|
131
131
|
# ->(description) { ::LinkThumbnailer::Graders::HtmlAttribute.new(description, :id) },
|
132
|
-
# ->(description) { ::LinkThumbnailer::Graders::Position.new(description) },
|
132
|
+
# ->(description) { ::LinkThumbnailer::Graders::Position.new(description, weight: 3) },
|
133
133
|
# ->(description) { ::LinkThumbnailer::Graders::LinkDensity.new(description) }
|
134
134
|
# ]
|
135
135
|
|
@@ -40,7 +40,7 @@ LinkThumbnailer.configure do |config|
|
|
40
40
|
# ->(description) { ::LinkThumbnailer::Graders::Length.new(description) },
|
41
41
|
# ->(description) { ::LinkThumbnailer::Graders::HtmlAttribute.new(description, :class) },
|
42
42
|
# ->(description) { ::LinkThumbnailer::Graders::HtmlAttribute.new(description, :id) },
|
43
|
-
# ->(description) { ::LinkThumbnailer::Graders::Position.new(description) },
|
43
|
+
# ->(description) { ::LinkThumbnailer::Graders::Position.new(description, weight: 3) },
|
44
44
|
# ->(description) { ::LinkThumbnailer::Graders::LinkDensity.new(description) }
|
45
45
|
# ]
|
46
46
|
|
@@ -50,7 +50,7 @@ module LinkThumbnailer
|
|
50
50
|
->(description) { ::LinkThumbnailer::Graders::Length.new(description) },
|
51
51
|
->(description) { ::LinkThumbnailer::Graders::HtmlAttribute.new(description, :class) },
|
52
52
|
->(description) { ::LinkThumbnailer::Graders::HtmlAttribute.new(description, :id) },
|
53
|
-
->(description) { ::LinkThumbnailer::Graders::Position.new(description) },
|
53
|
+
->(description) { ::LinkThumbnailer::Graders::Position.new(description, weigth: 3) },
|
54
54
|
->(description) { ::LinkThumbnailer::Graders::LinkDensity.new(description) },
|
55
55
|
]
|
56
56
|
@description_min_length = 50
|
@@ -4,11 +4,12 @@ module LinkThumbnailer
|
|
4
4
|
module Graders
|
5
5
|
class Base < ::SimpleDelegator
|
6
6
|
|
7
|
-
attr_reader :config, :description
|
7
|
+
attr_reader :config, :description, :options
|
8
8
|
|
9
|
-
def initialize(description)
|
9
|
+
def initialize(description, options = {})
|
10
10
|
@config = ::LinkThumbnailer.page.config
|
11
11
|
@description = description
|
12
|
+
@options = options
|
12
13
|
|
13
14
|
super(config)
|
14
15
|
end
|
@@ -17,6 +18,10 @@ module LinkThumbnailer
|
|
17
18
|
fail NotImplementedError
|
18
19
|
end
|
19
20
|
|
21
|
+
def weight
|
22
|
+
options.fetch(:weigth, 1)
|
23
|
+
end
|
24
|
+
|
20
25
|
private
|
21
26
|
|
22
27
|
def node
|
data/spec/grader_spec.rb
CHANGED
@@ -8,7 +8,8 @@ describe LinkThumbnailer::Grader do
|
|
8
8
|
describe '#call' do
|
9
9
|
|
10
10
|
let(:probability) { 0.5 }
|
11
|
-
let(:
|
11
|
+
let(:weight) { 2 }
|
12
|
+
let(:grader) { double('grader', call: probability, weight: weight) }
|
12
13
|
let(:lambda) { ->(_) { grader } }
|
13
14
|
let(:graders) { [lambda, lambda] }
|
14
15
|
let(:action) { instance.call }
|
@@ -17,7 +18,7 @@ describe LinkThumbnailer::Grader do
|
|
17
18
|
instance.stub(:graders).and_return(graders)
|
18
19
|
end
|
19
20
|
|
20
|
-
it { expect(action).to eq(0.5 * 0.5) }
|
21
|
+
it { expect(action).to eq((0.5 * 0.5) ** weight) }
|
21
22
|
|
22
23
|
end
|
23
24
|
|
@@ -34,6 +34,23 @@ describe LinkThumbnailer::ImageComparators::Size do
|
|
34
34
|
|
35
35
|
end
|
36
36
|
|
37
|
+
context 'when other image size could not be computed' do
|
38
|
+
|
39
|
+
let(:other_size) { [] }
|
40
|
+
|
41
|
+
it { expect(action).to eq(-1) }
|
42
|
+
|
43
|
+
end
|
44
|
+
|
45
|
+
context 'when self image size could not be computed' do
|
46
|
+
|
47
|
+
let(:image) { double(size: []) }
|
48
|
+
let(:other_size) { [10, 10] }
|
49
|
+
|
50
|
+
it { expect(action).to eq(1) }
|
51
|
+
|
52
|
+
end
|
53
|
+
|
37
54
|
end
|
38
55
|
|
39
56
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: link_thumbnailer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.0
|
4
|
+
version: 3.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pierre-Louis Gottfrois
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-09-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|