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 CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- MmMxNTZhYWFkN2E4N2JjN2NkNjRlMmFlMjU3YWYxMDJlOWVmNzBhMw==
4
+ NTMzZGRhYzQxZTMxNTI4YzI3NDExMWY3NmVkZDBjZmU2Yzg3YWYyYw==
5
5
  data.tar.gz: !binary |-
6
- MDMwOWQ2NWYyYmUxMGExOWI0MzM5YjA2ZTkwZTNlY2ViZmVlOGFhYQ==
6
+ Y2RmZDhmMDllZDBmNmEwNWFjZjQ3NDA0ZjBkYzZmNmU5YzQ1NzcxNg==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- YmM4MDg1ZTFlZTJlZGJiZTYxMzc2MWI5N2FkYjkxMDc4NmEzNjdmYjVjMDJj
10
- ZDQxMTc5YTY3ZjY3MzY5MWRjNjk4ODFmYWJjNTE4ZmQwMGI2YTI2ZjhiMjU3
11
- ZGFhMzNlNzcwNjIzZWFhYTNkYWQ3NWY5OTU1M2Q0NDM0ZjQxYzU=
9
+ NWIxNDBkMzE4YmQ3NzZmYzQ3YzZhZDVkNjQ3NWMxOGI2YjQwNDFkMTQ0OTZj
10
+ YzYxM2MzYzcwOWE3YTY0NzJkZTc0NzA5M2FhNzY0NmY2MDc1ZjY4YmE0MzIz
11
+ MDM4YWY5OTMzY2I5Zjk0ZDBkNWJjNjEyNTZlZDEyN2M3NGUzZDA=
12
12
  data.tar.gz: !binary |-
13
- MDRlNWY3MGQ1ZWI4MTYyNzY0ZmY0MGIxY2U2NDA5NTg4Zjc2MGI5NDgxNzBl
14
- MzRiOTUwNmVlMTdjZmFiMGFkZThmODFkYjllN2QxMWZlOTI5NWM1MzNmMDA1
15
- MmU5YjcxYWY3Y2RjZGE5ZjJmNDU5NjBkMzc1MjNiODA5YjIxMGI=
13
+ NjEzM2M4NDhjZmVmMGViMjRmY2VjZjc1ZmRlM2UxZTM5ZWI1NjU5OTIyYjhj
14
+ YjMzMThlNDJiMDY1OTE2MWExMTBkMzU2OTA3NWFjMmI0N2UwNGIxYTk3ODRj
15
+ NjgwNzZkMmZlN2RmMjZmZDc5Nzg2ZmY0NjA3OTQ0ZjQ5M2VhYzI=
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ # 2.2.1
2
+
3
+ - Fix issue when computing link density ratio
4
+
1
5
  # 2.2.0
2
6
 
3
7
  - Add support for `og:video`
@@ -14,7 +14,7 @@ module LinkThumbnailer
14
14
  end
15
15
 
16
16
  def call(current_score)
17
- raise 'must implement'
17
+ fail NotImplementedError
18
18
  end
19
19
 
20
20
  private
@@ -3,7 +3,8 @@ module LinkThumbnailer
3
3
  class LinkDensity < ::LinkThumbnailer::Graders::Base
4
4
 
5
5
  def call(current_score)
6
- current_score *= (1 - density)
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
@@ -9,7 +9,7 @@ module LinkThumbnailer
9
9
  end
10
10
 
11
11
  def call
12
- raise 'you must implement this method'
12
+ fail NotImplementedError
13
13
  end
14
14
 
15
15
  end
@@ -1,9 +1,4 @@
1
1
  module LinkThumbnailer
2
2
  class Railtie < ::Rails::Railtie
3
-
4
- initializer 'link_thumbnailer.routes' do
5
- LinkThumbnailer::Rails::Routes.install!
6
- end
7
-
8
3
  end
9
4
  end
@@ -1,3 +1,3 @@
1
1
  module LinkThumbnailer
2
- VERSION = '2.2.0'
2
+ VERSION = '2.2.1'
3
3
  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
- before do
15
- instance.stub(:density).and_return(density)
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
- it { expect(action).to eq(-9) }
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.0
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-06-17 00:00:00.000000000 Z
11
+ date: 2014-07-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport