link_thumbnailer 2.2.0 → 2.2.1
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 +8 -8
- data/CHANGELOG.md +4 -0
- data/lib/link_thumbnailer/graders/base.rb +1 -1
- data/lib/link_thumbnailer/graders/link_density.rb +6 -1
- data/lib/link_thumbnailer/image_comparators/base.rb +1 -1
- data/lib/link_thumbnailer/railtie.rb +0 -5
- data/lib/link_thumbnailer/version.rb +1 -1
- data/spec/graders/link_density_spec.rb +17 -4
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
NTMzZGRhYzQxZTMxNTI4YzI3NDExMWY3NmVkZDBjZmU2Yzg3YWYyYw==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
Y2RmZDhmMDllZDBmNmEwNWFjZjQ3NDA0ZjBkYzZmNmU5YzQ1NzcxNg==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
NWIxNDBkMzE4YmQ3NzZmYzQ3YzZhZDVkNjQ3NWMxOGI2YjQwNDFkMTQ0OTZj
|
10
|
+
YzYxM2MzYzcwOWE3YTY0NzJkZTc0NzA5M2FhNzY0NmY2MDc1ZjY4YmE0MzIz
|
11
|
+
MDM4YWY5OTMzY2I5Zjk0ZDBkNWJjNjEyNTZlZDEyN2M3NGUzZDA=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
NjEzM2M4NDhjZmVmMGViMjRmY2VjZjc1ZmRlM2UxZTM5ZWI1NjU5OTIyYjhj
|
14
|
+
YjMzMThlNDJiMDY1OTE2MWExMTBkMzU2OTA3NWFjMmI0N2UwNGIxYTk3ODRj
|
15
|
+
NjgwNzZkMmZlN2RmMjZmZDc5Nzg2ZmY0NjA3OTQ0ZjQ5M2VhYzI=
|
data/CHANGELOG.md
CHANGED
@@ -3,7 +3,8 @@ module LinkThumbnailer
|
|
3
3
|
class LinkDensity < ::LinkThumbnailer::Graders::Base
|
4
4
|
|
5
5
|
def call(current_score)
|
6
|
-
|
6
|
+
return 0 if density_ratio == 0
|
7
|
+
current_score *= density_ratio
|
7
8
|
end
|
8
9
|
|
9
10
|
private
|
@@ -13,6 +14,10 @@ module LinkThumbnailer
|
|
13
14
|
links.length / text.length.to_f
|
14
15
|
end
|
15
16
|
|
17
|
+
def density_ratio
|
18
|
+
1 - density
|
19
|
+
end
|
20
|
+
|
16
21
|
def links
|
17
22
|
node.css('a').map(&:text)
|
18
23
|
end
|
@@ -8,14 +8,27 @@ describe LinkThumbnailer::Graders::LinkDensity do
|
|
8
8
|
describe '#call' do
|
9
9
|
|
10
10
|
let(:previous_score) { 1 }
|
11
|
-
let(:density) { 10 }
|
12
11
|
let(:action) { instance.call(previous_score) }
|
13
12
|
|
14
|
-
|
15
|
-
|
13
|
+
context 'when density_ratio is 0' do
|
14
|
+
|
15
|
+
before do
|
16
|
+
instance.stub(:density_ratio).and_return(0)
|
17
|
+
end
|
18
|
+
|
19
|
+
it { expect(action).to eq(0) }
|
20
|
+
|
16
21
|
end
|
17
22
|
|
18
|
-
|
23
|
+
context 'when density is not 0' do
|
24
|
+
|
25
|
+
before do
|
26
|
+
instance.stub(:density_ratio).and_return(10)
|
27
|
+
end
|
28
|
+
|
29
|
+
it { expect(action).to eq(10) }
|
30
|
+
|
31
|
+
end
|
19
32
|
|
20
33
|
end
|
21
34
|
|
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: 2.2.
|
4
|
+
version: 2.2.1
|
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: 2014-
|
11
|
+
date: 2014-07-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|