link_thumbnailer 3.0.0 → 3.0.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 +4 -4
- data/CHANGELOG.md +4 -0
- data/README.md +7 -2
- data/lib/generators/templates/initializer.rb +1 -2
- data/lib/link_thumbnailer/grader.rb +0 -1
- data/lib/link_thumbnailer/version.rb +1 -1
- data/spec/graders/length_spec.rb +2 -2
- metadata +1 -3
- data/spec/graders/punctuation_density_spec.rb +0 -50
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3677cdb11ee3930b3fac0464c6daf3262a8114fe
|
4
|
+
data.tar.gz: dfe19706e2e54885d2935573460de7959fe191dc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 885d0d41e9c0553885c519dc8008c8203b70e9645d6c3089398e8b2179c047feb8a22fecf478f50feb7e9949d5208e73e67ff21d9b00b1430d1292db6abe0532
|
7
|
+
data.tar.gz: 499caa974e1723f66657870cb18a32ffb950a8334308afd8f892f55a1c342a01e05882a9b58d868b7d13aefc2e269ef10d0ff613717013923bae1e3df192a561
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -124,8 +124,7 @@ LinkThumbnailer.configure do |config|
|
|
124
124
|
# config.attributes = [:title, :images, :description, :videos, :favicon]
|
125
125
|
|
126
126
|
# List of procedures used to rate the website description. Add you custom class
|
127
|
-
# here.
|
128
|
-
# on how to build your own graders.
|
127
|
+
# here. See wiki for more details on how to build your own graders.
|
129
128
|
#
|
130
129
|
# config.graders = [
|
131
130
|
# ->(description) { ::LinkThumbnailer::Graders::Length.new(description) },
|
@@ -158,6 +157,11 @@ LinkThumbnailer.configure do |config|
|
|
158
157
|
# does not have to fetch its size and type.
|
159
158
|
#
|
160
159
|
# config.image_stats = true
|
160
|
+
#
|
161
|
+
# Whether you want LinkThumbnailer to raise an exception if the Content-Type of the HTTP request
|
162
|
+
# is not an html or xml.
|
163
|
+
#
|
164
|
+
# config.raise_on_invalid_format = false
|
161
165
|
end
|
162
166
|
```
|
163
167
|
|
@@ -177,6 +181,7 @@ LinkThumbnailer defines a list of custom exceptions you may want to rescue in yo
|
|
177
181
|
|
178
182
|
* `RedirectLimit` -- raised when redirection threshold defined in config is reached
|
179
183
|
* `BadUriFormat` -- raised when url given is not a valid HTTP url
|
184
|
+
* `FormatNotSupported` -- raised when the `Content-Type` of the HTTP request is not supported (not `html`)
|
180
185
|
|
181
186
|
You can rescue from any LinkThumbnailer exceptions using the following code:
|
182
187
|
|
@@ -34,8 +34,7 @@ LinkThumbnailer.configure do |config|
|
|
34
34
|
# config.attributes = [:title, :images, :description, :videos, :favicon]
|
35
35
|
|
36
36
|
# List of procedures used to rate the website description. Add you custom class
|
37
|
-
# here.
|
38
|
-
# on how to build your own graders.
|
37
|
+
# here. See wiki for more details on how to build your own graders.
|
39
38
|
#
|
40
39
|
# config.graders = [
|
41
40
|
# ->(description) { ::LinkThumbnailer::Graders::Length.new(description) },
|
@@ -3,7 +3,6 @@ require 'link_thumbnailer/graders/base'
|
|
3
3
|
require 'link_thumbnailer/graders/length'
|
4
4
|
require 'link_thumbnailer/graders/html_attribute'
|
5
5
|
require 'link_thumbnailer/graders/link_density'
|
6
|
-
require 'link_thumbnailer/graders/punctuation_density'
|
7
6
|
require 'link_thumbnailer/graders/position'
|
8
7
|
|
9
8
|
module LinkThumbnailer
|
data/spec/graders/length_spec.rb
CHANGED
@@ -31,9 +31,9 @@ describe LinkThumbnailer::Graders::Length do
|
|
31
31
|
instance.stub(:text).and_return(text)
|
32
32
|
end
|
33
33
|
|
34
|
-
context 'when text length is
|
34
|
+
context 'when text length is 120' do
|
35
35
|
|
36
|
-
let(:text) { 'f' *
|
36
|
+
let(:text) { 'f' * 120 }
|
37
37
|
|
38
38
|
it { expect(action).to eq(1.0) }
|
39
39
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
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.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pierre-Louis Gottfrois
|
@@ -194,7 +194,6 @@ files:
|
|
194
194
|
- spec/graders/length_spec.rb
|
195
195
|
- spec/graders/link_density_spec.rb
|
196
196
|
- spec/graders/position_spec.rb
|
197
|
-
- spec/graders/punctuation_density_spec.rb
|
198
197
|
- spec/image_comparators/size_spec.rb
|
199
198
|
- spec/image_parsers/size_spec.rb
|
200
199
|
- spec/image_parsers/type_spec.rb
|
@@ -254,7 +253,6 @@ test_files:
|
|
254
253
|
- spec/graders/length_spec.rb
|
255
254
|
- spec/graders/link_density_spec.rb
|
256
255
|
- spec/graders/position_spec.rb
|
257
|
-
- spec/graders/punctuation_density_spec.rb
|
258
256
|
- spec/image_comparators/size_spec.rb
|
259
257
|
- spec/image_parsers/size_spec.rb
|
260
258
|
- spec/image_parsers/type_spec.rb
|
@@ -1,50 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe LinkThumbnailer::Graders::PunctuationDensity do
|
4
|
-
|
5
|
-
let(:description) { double('description') }
|
6
|
-
let(:instance) { described_class.new(description) }
|
7
|
-
|
8
|
-
describe '#call' do
|
9
|
-
|
10
|
-
let(:action) { instance.call }
|
11
|
-
|
12
|
-
before do
|
13
|
-
instance.stub(:text).and_return(text)
|
14
|
-
instance.stub(:punctuations).and_return(punctuations)
|
15
|
-
end
|
16
|
-
|
17
|
-
context 'when text length is 0' do
|
18
|
-
|
19
|
-
let(:text) { '' }
|
20
|
-
let(:punctuations) { [] }
|
21
|
-
|
22
|
-
it { expect(action).to eq(0.0) }
|
23
|
-
|
24
|
-
end
|
25
|
-
|
26
|
-
context 'when text length is > 0' do
|
27
|
-
|
28
|
-
let(:text) { 'foo' }
|
29
|
-
|
30
|
-
context 'and punctuations is 0' do
|
31
|
-
|
32
|
-
let(:punctuations) { [] }
|
33
|
-
|
34
|
-
it { expect(action).to eq(1.0) }
|
35
|
-
|
36
|
-
end
|
37
|
-
|
38
|
-
context 'and punctuations is > 0' do
|
39
|
-
|
40
|
-
let(:punctuations) { [1] }
|
41
|
-
|
42
|
-
it { expect(action).to be_within(0.001).of(0.666) }
|
43
|
-
|
44
|
-
end
|
45
|
-
|
46
|
-
end
|
47
|
-
|
48
|
-
end
|
49
|
-
|
50
|
-
end
|