flavicon 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/linters.yml +25 -0
- data/.github/workflows/ruby.yml +32 -0
- data/.rubocop.yml +3 -2
- data/.ruby-version +1 -1
- data/.tool-versions +1 -0
- data/Gemfile.lock +47 -43
- data/VERSION +1 -1
- data/flavicon.gemspec +6 -3
- data/lib/flavicon/finder.rb +8 -8
- data/lib/flavicon/version.rb +1 -1
- metadata +17 -15
- data/.ruby-gemset +0 -1
- data/.travis.yml +0 -21
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7f1322382cafcb279436a2b1cb8acd95929d37f4a088033852f0c3f29bb1f0f1
|
4
|
+
data.tar.gz: 447b61454abd88505d85befda16f41593f3cfa596a984f0691577c03b3e361c4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6530105b3ee054b15ecf6b161d268107ed33d31fbc6556e7f251a9c9c745d295481321f10025b67139e53d4fe1095f23e226232c9e00145817eda1e3799b4b9d
|
7
|
+
data.tar.gz: 12b79a6b748350435e9b5f0d6d436bfce14ddeae60eb1a222a8a6a882466eb416ec14c843ea4f26be438b3245344e161e7911ae67f8319aa51d002037952e5b9
|
@@ -0,0 +1,25 @@
|
|
1
|
+
name: Linters
|
2
|
+
|
3
|
+
on: [pull_request]
|
4
|
+
|
5
|
+
jobs:
|
6
|
+
ruby:
|
7
|
+
runs-on: ubuntu-latest
|
8
|
+
steps:
|
9
|
+
- uses: actions/checkout@v2
|
10
|
+
|
11
|
+
- name: Set up Ruby
|
12
|
+
uses: ruby/setup-ruby@v1
|
13
|
+
|
14
|
+
- name: RuboCop Linter
|
15
|
+
uses: reviewdog/action-rubocop@v2.1.0
|
16
|
+
with:
|
17
|
+
rubocop_version: gemfile
|
18
|
+
rubocop_extensions: rubocop-rspec:gemfile
|
19
|
+
rubocop_flags: '--parallel --force-exclusion'
|
20
|
+
github_token: ${{ secrets.GITHUB_TOKEN }}
|
21
|
+
|
22
|
+
- name: Brakeman Linter
|
23
|
+
uses: reviewdog/action-brakeman@v1
|
24
|
+
with:
|
25
|
+
github_token: ${{ secrets.GITHUB_TOKEN }}
|
@@ -0,0 +1,32 @@
|
|
1
|
+
name: Ruby
|
2
|
+
|
3
|
+
on: [push]
|
4
|
+
|
5
|
+
jobs:
|
6
|
+
build:
|
7
|
+
|
8
|
+
runs-on: ubuntu-latest
|
9
|
+
|
10
|
+
strategy:
|
11
|
+
matrix:
|
12
|
+
ruby:
|
13
|
+
- 2.7
|
14
|
+
- 3.0
|
15
|
+
- 3.1
|
16
|
+
|
17
|
+
steps:
|
18
|
+
- uses: actions/checkout@v2
|
19
|
+
|
20
|
+
- name: Set up Ruby
|
21
|
+
uses: ruby/setup-ruby@v1
|
22
|
+
with:
|
23
|
+
ruby-version: ${{ matrix.ruby }}
|
24
|
+
bundler-cache: true
|
25
|
+
|
26
|
+
- name: Run tests with RSpec
|
27
|
+
uses: paambaati/codeclimate-action@v2.5.4
|
28
|
+
env:
|
29
|
+
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
|
30
|
+
with:
|
31
|
+
coverageCommand: bundle exec rspec
|
32
|
+
debug: false
|
data/.rubocop.yml
CHANGED
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
3.1.0
|
data/.tool-versions
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
ruby 3.1.0
|
data/Gemfile.lock
CHANGED
@@ -1,36 +1,37 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
flavicon (0.
|
4
|
+
flavicon (0.3.0)
|
5
5
|
nokogiri (~> 1.10)
|
6
6
|
|
7
7
|
GEM
|
8
8
|
remote: http://rubygems.org/
|
9
9
|
specs:
|
10
|
-
addressable (2.
|
11
|
-
public_suffix (>= 2.0.2, <
|
12
|
-
ast (2.4.
|
13
|
-
coderay (1.1.
|
14
|
-
crack (0.4.
|
15
|
-
|
10
|
+
addressable (2.8.0)
|
11
|
+
public_suffix (>= 2.0.2, < 5.0)
|
12
|
+
ast (2.4.2)
|
13
|
+
coderay (1.1.3)
|
14
|
+
crack (0.4.5)
|
15
|
+
rexml
|
16
16
|
diff-lcs (1.3)
|
17
|
-
docile (1.
|
18
|
-
hashdiff (0.
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
17
|
+
docile (1.4.0)
|
18
|
+
hashdiff (1.0.1)
|
19
|
+
method_source (1.0.0)
|
20
|
+
mini_portile2 (2.7.1)
|
21
|
+
nokogiri (1.13.1)
|
22
|
+
mini_portile2 (~> 2.7.0)
|
23
|
+
racc (~> 1.4)
|
24
|
+
parallel (1.21.0)
|
25
|
+
parser (3.1.0.0)
|
26
|
+
ast (~> 2.4.1)
|
27
|
+
pry (0.14.1)
|
28
|
+
coderay (~> 1.1)
|
29
|
+
method_source (~> 1.0)
|
30
|
+
public_suffix (4.0.6)
|
31
|
+
racc (1.6.0)
|
32
|
+
rainbow (3.1.1)
|
33
|
+
regexp_parser (2.2.0)
|
34
|
+
rexml (3.2.5)
|
34
35
|
rspec (3.8.0)
|
35
36
|
rspec-core (~> 3.8.0)
|
36
37
|
rspec-expectations (~> 3.8.0)
|
@@ -44,26 +45,29 @@ GEM
|
|
44
45
|
diff-lcs (>= 1.2.0, < 2.0)
|
45
46
|
rspec-support (~> 3.8.0)
|
46
47
|
rspec-support (3.8.0)
|
47
|
-
rubocop (
|
48
|
-
jaro_winkler (~> 1.5.1)
|
48
|
+
rubocop (1.25.0)
|
49
49
|
parallel (~> 1.10)
|
50
|
-
parser (>=
|
50
|
+
parser (>= 3.1.0.0)
|
51
51
|
rainbow (>= 2.2.2, < 4.0)
|
52
|
+
regexp_parser (>= 1.8, < 3.0)
|
53
|
+
rexml
|
54
|
+
rubocop-ast (>= 1.15.1, < 2.0)
|
52
55
|
ruby-progressbar (~> 1.7)
|
53
|
-
unicode-display_width (>= 1.4.0, <
|
54
|
-
rubocop-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
56
|
+
unicode-display_width (>= 1.4.0, < 3.0)
|
57
|
+
rubocop-ast (1.15.1)
|
58
|
+
parser (>= 3.0.1.1)
|
59
|
+
rubocop-rspec (2.7.0)
|
60
|
+
rubocop (~> 1.19)
|
61
|
+
ruby-progressbar (1.11.0)
|
62
|
+
simplecov (0.21.2)
|
59
63
|
docile (~> 1.1)
|
60
|
-
|
61
|
-
|
62
|
-
simplecov-html (0.
|
63
|
-
|
64
|
-
unicode-display_width (1.
|
65
|
-
webmock (3.
|
66
|
-
addressable (>= 2.
|
64
|
+
simplecov-html (~> 0.11)
|
65
|
+
simplecov_json_formatter (~> 0.1)
|
66
|
+
simplecov-html (0.12.3)
|
67
|
+
simplecov_json_formatter (0.1.3)
|
68
|
+
unicode-display_width (2.1.0)
|
69
|
+
webmock (3.14.0)
|
70
|
+
addressable (>= 2.8.0)
|
67
71
|
crack (>= 0.3.2)
|
68
72
|
hashdiff (>= 0.4.0, < 2.0.0)
|
69
73
|
|
@@ -75,9 +79,9 @@ DEPENDENCIES
|
|
75
79
|
flavicon!
|
76
80
|
pry (~> 0)
|
77
81
|
rspec (~> 3.8)
|
78
|
-
rubocop-rspec (~>
|
79
|
-
simplecov (~> 0.
|
82
|
+
rubocop-rspec (~> 2)
|
83
|
+
simplecov (~> 0.21)
|
80
84
|
webmock (~> 3.6)
|
81
85
|
|
82
86
|
BUNDLED WITH
|
83
|
-
2.
|
87
|
+
2.3.4
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.2.0
|
data/flavicon.gemspec
CHANGED
@@ -12,9 +12,12 @@ Gem::Specification.new do |spec|
|
|
12
12
|
|
13
13
|
spec.summary = 'fetch favicon url for provided url'
|
14
14
|
spec.description = 'fetch favicon url by parsing html and falling back on /favicon.ico as default'
|
15
|
-
spec.homepage = '
|
15
|
+
spec.homepage = 'https://github.com/hasghari/flavicon'
|
16
16
|
spec.license = 'MIT'
|
17
17
|
|
18
|
+
spec.required_ruby_version = '>= 2.7'
|
19
|
+
spec.metadata['rubygems_mfa_required'] = 'true'
|
20
|
+
|
18
21
|
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
19
22
|
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
20
23
|
end
|
@@ -25,7 +28,7 @@ Gem::Specification.new do |spec|
|
|
25
28
|
spec.add_development_dependency 'bundler', '~> 2.0'
|
26
29
|
spec.add_development_dependency 'pry', '~> 0'
|
27
30
|
spec.add_development_dependency 'rspec', '~> 3.8'
|
28
|
-
spec.add_development_dependency 'rubocop-rspec', '~>
|
29
|
-
spec.add_development_dependency 'simplecov', '~> 0.
|
31
|
+
spec.add_development_dependency 'rubocop-rspec', '~> 2'
|
32
|
+
spec.add_development_dependency 'simplecov', '~> 0.21'
|
30
33
|
spec.add_development_dependency 'webmock', '~> 3.6'
|
31
34
|
end
|
data/lib/flavicon/finder.rb
CHANGED
@@ -16,8 +16,10 @@ module Flavicon
|
|
16
16
|
|
17
17
|
def find
|
18
18
|
response, resolved = request(url)
|
19
|
-
|
20
|
-
|
19
|
+
|
20
|
+
extract_from_html(response.body, resolved)
|
21
|
+
.push(default_path(resolved))
|
22
|
+
.find { |url| verify_favicon_url(url) }
|
21
23
|
end
|
22
24
|
|
23
25
|
def verify_favicon_url(url)
|
@@ -28,18 +30,16 @@ module Flavicon
|
|
28
30
|
end
|
29
31
|
|
30
32
|
def extract_from_html(html, url)
|
31
|
-
|
32
|
-
node[:rel] =~ /\A(shortcut )?icon\z/i
|
33
|
+
Nokogiri::HTML(html).css('head link').filter_map do |node|
|
34
|
+
URI.join(url, node[:href]).to_s if node[:rel] =~ /\A(shortcut )?icon\z/i
|
33
35
|
end
|
34
|
-
|
35
|
-
URI.join(url, link[:href]).to_s if link
|
36
36
|
end
|
37
37
|
|
38
38
|
def default_path(url)
|
39
39
|
URI.join(url, '/favicon.ico').to_s
|
40
40
|
end
|
41
41
|
|
42
|
-
# rubocop:disable Metrics/AbcSize,MethodLength
|
42
|
+
# rubocop:disable Metrics/AbcSize,Metrics/MethodLength
|
43
43
|
def request(url, limit = 10)
|
44
44
|
raise TooManyRedirects if limit.negative?
|
45
45
|
|
@@ -60,7 +60,7 @@ module Flavicon
|
|
60
60
|
[response, url]
|
61
61
|
end
|
62
62
|
end
|
63
|
-
# rubocop:enable Metrics/AbcSize,MethodLength
|
63
|
+
# rubocop:enable Metrics/AbcSize,Metrics/MethodLength
|
64
64
|
|
65
65
|
# While the soon-to-be obsolete IETF standard RFC 2616 (HTTP 1.1) requires a complete absolute URI for redirection,
|
66
66
|
# the most popular web browsers tolerate the passing of a relative URL as the value for a Location header field.
|
data/lib/flavicon/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: flavicon
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Hamed Asghari
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-01-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|
@@ -72,28 +72,28 @@ dependencies:
|
|
72
72
|
requirements:
|
73
73
|
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: '
|
75
|
+
version: '2'
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: '
|
82
|
+
version: '2'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: simplecov
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
87
|
- - "~>"
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version: '0.
|
89
|
+
version: '0.21'
|
90
90
|
type: :development
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
94
|
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version: '0.
|
96
|
+
version: '0.21'
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
98
|
name: webmock
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
@@ -117,12 +117,13 @@ extensions: []
|
|
117
117
|
extra_rdoc_files: []
|
118
118
|
files:
|
119
119
|
- ".document"
|
120
|
+
- ".github/workflows/linters.yml"
|
121
|
+
- ".github/workflows/ruby.yml"
|
120
122
|
- ".gitignore"
|
121
123
|
- ".rspec"
|
122
124
|
- ".rubocop.yml"
|
123
|
-
- ".ruby-gemset"
|
124
125
|
- ".ruby-version"
|
125
|
-
- ".
|
126
|
+
- ".tool-versions"
|
126
127
|
- Gemfile
|
127
128
|
- Gemfile.lock
|
128
129
|
- LICENSE.txt
|
@@ -133,11 +134,12 @@ files:
|
|
133
134
|
- lib/flavicon.rb
|
134
135
|
- lib/flavicon/finder.rb
|
135
136
|
- lib/flavicon/version.rb
|
136
|
-
homepage:
|
137
|
+
homepage: https://github.com/hasghari/flavicon
|
137
138
|
licenses:
|
138
139
|
- MIT
|
139
|
-
metadata:
|
140
|
-
|
140
|
+
metadata:
|
141
|
+
rubygems_mfa_required: 'true'
|
142
|
+
post_install_message:
|
141
143
|
rdoc_options: []
|
142
144
|
require_paths:
|
143
145
|
- lib
|
@@ -145,15 +147,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
145
147
|
requirements:
|
146
148
|
- - ">="
|
147
149
|
- !ruby/object:Gem::Version
|
148
|
-
version: '
|
150
|
+
version: '2.7'
|
149
151
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
150
152
|
requirements:
|
151
153
|
- - ">="
|
152
154
|
- !ruby/object:Gem::Version
|
153
155
|
version: '0'
|
154
156
|
requirements: []
|
155
|
-
rubygems_version: 3.
|
156
|
-
signing_key:
|
157
|
+
rubygems_version: 3.3.3
|
158
|
+
signing_key:
|
157
159
|
specification_version: 4
|
158
160
|
summary: fetch favicon url for provided url
|
159
161
|
test_files: []
|
data/.ruby-gemset
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
flavicon
|
data/.travis.yml
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
---
|
2
|
-
sudo: false
|
3
|
-
env:
|
4
|
-
global:
|
5
|
-
- CC_TEST_REPORTER_ID=e365747cb5bcc556a4ce69b2deca895b8cc1a39601d63db9e3e82c83c9c9b39e
|
6
|
-
language: ruby
|
7
|
-
rvm:
|
8
|
-
- 2.3
|
9
|
-
- 2.4
|
10
|
-
- 2.5
|
11
|
-
- 2.6
|
12
|
-
cache: bundler
|
13
|
-
before_install: gem install bundler -v 2.0.1
|
14
|
-
before_script:
|
15
|
-
- curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
|
16
|
-
- chmod +x ./cc-test-reporter
|
17
|
-
- ./cc-test-reporter before-build
|
18
|
-
script:
|
19
|
-
- bundle exec rspec
|
20
|
-
after_script:
|
21
|
-
- ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT
|