weneedfeed 0.9.0 → 0.10.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3b2041bae9e09565e1b72a4799f8a57034ad73c139de460dc0d187a5b94dbbe2
4
- data.tar.gz: 292b45f698fb86f8cd5632687210ab6c09cd74a6d6ad340bb6eb7b989ffc4e3a
3
+ metadata.gz: 0f0099d83b69c32c84f244925370a77c7724874e287e9d55d105af0b5ab53df8
4
+ data.tar.gz: 39646f492c8b1accb725dab3ef96a9bb5ab77291e46182789fb75f2389cc0df9
5
5
  SHA512:
6
- metadata.gz: 8dc45d743eb961d6a18983b8c20340b1e4c2085c7ed1c348332bddb51c211aa2c5067211e789f9cdd192eb3b161602d63f304adc8421ade49210ce11396a0031
7
- data.tar.gz: 60f284ba462f92130a3de4702e33ae3d73418a3057459b40656e75f0a27e8ad9bc8b67946b1137b590f38250d5dec695cdfe41cad58f96947cf0dc0885c2839b
6
+ metadata.gz: 50699fe2779917eb03e0d6845d884c26398312f7950252663dce13ac73d9f5356cbea1670ac84d39877692897711f393d1e8b55c5c3de5a9c7f8a514dd8a296c
7
+ data.tar.gz: 45cbe8c18b887791ccb7c3a83c35c841be13f95d4219bc16a31f8ae766a59880820291a091c3d0f58e97aba71e3ea766f4993948c063f6c18b812bf88560cfa9
@@ -8,13 +8,19 @@ on:
8
8
 
9
9
  jobs:
10
10
  rspec:
11
+ strategy:
12
+ fail-fast: false
13
+ matrix:
14
+ ruby:
15
+ - 2.7.2
16
+ - 3.0.2
11
17
  runs-on: ubuntu-20.04
12
18
  steps:
13
19
  - uses: actions/checkout@v2
14
20
  - uses: ruby/setup-ruby@v1
15
21
  with:
16
22
  bundler-cache: true
17
- ruby-version: 2.7.2
23
+ ruby-version: ${{ matrix.ruby }}
18
24
  - run: bundle exec rspec --force-color
19
25
  rubocop:
20
26
  runs-on: ubuntu-20.04
data/CHANGELOG.md CHANGED
@@ -7,6 +7,29 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## Unreleased
9
9
 
10
+ ## 0.10.0 - 2022-04-13
11
+
12
+ ### Changed
13
+
14
+ - Replace mimemagic with marcel.
15
+
16
+ ### Fixed
17
+
18
+ - Fix error on activesupport 7.
19
+
20
+ ## 0.9.2 - 2020-12-03
21
+
22
+ ### Fixed
23
+
24
+ - Fix item image URL on JSON source.
25
+ - Fix item image MIME type detection.
26
+
27
+ ## 0.9.1 - 2020-12-03
28
+
29
+ ### Fixed
30
+
31
+ - Fix escape bug in escaping HTML and generating XML.
32
+
10
33
  ## 0.9.0 - 2020-12-03
11
34
 
12
35
  ### Added
data/Gemfile.lock CHANGED
@@ -1,13 +1,13 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- weneedfeed (0.9.0)
4
+ weneedfeed (0.10.0)
5
5
  activesupport
6
6
  builder
7
7
  faraday
8
8
  faraday_middleware
9
9
  hibana (>= 0.2)
10
- mimemagic
10
+ marcel
11
11
  nokogiri
12
12
  rack-capture (>= 0.4.0)
13
13
  thor
@@ -15,25 +15,45 @@ PATH
15
15
  GEM
16
16
  remote: https://rubygems.org/
17
17
  specs:
18
- activesupport (6.0.3.4)
18
+ activesupport (7.0.2.3)
19
19
  concurrent-ruby (~> 1.0, >= 1.0.2)
20
- i18n (>= 0.7, < 2)
21
- minitest (~> 5.1)
22
- tzinfo (~> 1.1)
23
- zeitwerk (~> 2.2, >= 2.2.2)
24
- addressable (2.7.0)
20
+ i18n (>= 1.6, < 2)
21
+ minitest (>= 5.1)
22
+ tzinfo (~> 2.0)
23
+ addressable (2.8.0)
25
24
  public_suffix (>= 2.0.2, < 5.0)
26
- ast (2.4.1)
25
+ ast (2.4.2)
27
26
  builder (3.2.4)
28
- concurrent-ruby (1.1.7)
29
- crack (0.4.4)
30
- diff-lcs (1.4.4)
31
- faraday (1.1.0)
27
+ concurrent-ruby (1.1.10)
28
+ crack (0.4.5)
29
+ rexml
30
+ diff-lcs (1.5.0)
31
+ faraday (1.10.0)
32
+ faraday-em_http (~> 1.0)
33
+ faraday-em_synchrony (~> 1.0)
34
+ faraday-excon (~> 1.1)
35
+ faraday-httpclient (~> 1.0)
36
+ faraday-multipart (~> 1.0)
37
+ faraday-net_http (~> 1.0)
38
+ faraday-net_http_persistent (~> 1.0)
39
+ faraday-patron (~> 1.0)
40
+ faraday-rack (~> 1.0)
41
+ faraday-retry (~> 1.0)
42
+ ruby2_keywords (>= 0.0.4)
43
+ faraday-em_http (1.0.0)
44
+ faraday-em_synchrony (1.0.0)
45
+ faraday-excon (1.1.0)
46
+ faraday-httpclient (1.0.1)
47
+ faraday-multipart (1.0.3)
32
48
  multipart-post (>= 1.2, < 3)
33
- ruby2_keywords
34
- faraday_middleware (1.0.0)
49
+ faraday-net_http (1.0.1)
50
+ faraday-net_http_persistent (1.2.0)
51
+ faraday-patron (1.0.0)
52
+ faraday-rack (1.0.0)
53
+ faraday-retry (1.0.3)
54
+ faraday_middleware (1.2.0)
35
55
  faraday (~> 1.0)
36
- hanami-router (2.0.0.alpha3)
56
+ hanami-router (2.0.0.alpha5)
37
57
  mustermann (~> 1.0)
38
58
  mustermann-contrib (~> 1.0)
39
59
  rack (~> 2.0)
@@ -43,72 +63,71 @@ GEM
43
63
  hanami-router (>= 2.0.0.alpha3)
44
64
  rack
45
65
  tilt
46
- i18n (1.8.5)
66
+ i18n (1.10.0)
47
67
  concurrent-ruby (~> 1.0)
48
- mimemagic (0.3.5)
49
- mini_portile2 (2.4.0)
50
- minitest (5.14.2)
68
+ marcel (1.0.2)
69
+ mini_portile2 (2.8.0)
70
+ minitest (5.15.0)
51
71
  multipart-post (2.1.1)
52
72
  mustermann (1.1.1)
53
73
  ruby2_keywords (~> 0.0.1)
54
74
  mustermann-contrib (1.1.1)
55
75
  hansi (~> 0.2.0)
56
76
  mustermann (= 1.1.1)
57
- nokogiri (1.10.10)
58
- mini_portile2 (~> 2.4.0)
59
- parallel (1.20.1)
60
- parser (2.7.2.0)
77
+ nokogiri (1.13.4)
78
+ mini_portile2 (~> 2.8.0)
79
+ racc (~> 1.4)
80
+ parallel (1.22.1)
81
+ parser (3.1.2.0)
61
82
  ast (~> 2.4.1)
62
- public_suffix (4.0.6)
83
+ public_suffix (4.0.7)
84
+ racc (1.6.0)
63
85
  rack (2.2.3)
64
86
  rack-capture (0.4.0)
65
87
  rack
66
88
  rack-test (1.1.0)
67
89
  rack (>= 1.0, < 3)
68
- rainbow (3.0.0)
90
+ rainbow (3.1.1)
69
91
  rake (12.3.3)
70
- regexp_parser (1.8.2)
71
- rexml (3.2.4)
72
- rspec (3.9.0)
73
- rspec-core (~> 3.9.0)
74
- rspec-expectations (~> 3.9.0)
75
- rspec-mocks (~> 3.9.0)
76
- rspec-core (3.9.3)
77
- rspec-support (~> 3.9.3)
78
- rspec-expectations (3.9.3)
92
+ regexp_parser (2.3.0)
93
+ rexml (3.2.5)
94
+ rspec (3.11.0)
95
+ rspec-core (~> 3.11.0)
96
+ rspec-expectations (~> 3.11.0)
97
+ rspec-mocks (~> 3.11.0)
98
+ rspec-core (3.11.0)
99
+ rspec-support (~> 3.11.0)
100
+ rspec-expectations (3.11.0)
79
101
  diff-lcs (>= 1.2.0, < 2.0)
80
- rspec-support (~> 3.9.0)
81
- rspec-mocks (3.9.1)
102
+ rspec-support (~> 3.11.0)
103
+ rspec-mocks (3.11.1)
82
104
  diff-lcs (>= 1.2.0, < 2.0)
83
- rspec-support (~> 3.9.0)
84
- rspec-support (3.9.4)
85
- rubocop (1.4.0)
105
+ rspec-support (~> 3.11.0)
106
+ rspec-support (3.11.0)
107
+ rubocop (1.27.0)
86
108
  parallel (~> 1.10)
87
- parser (>= 2.7.1.5)
109
+ parser (>= 3.1.0.0)
88
110
  rainbow (>= 2.2.2, < 4.0)
89
- regexp_parser (>= 1.8)
111
+ regexp_parser (>= 1.8, < 3.0)
90
112
  rexml
91
- rubocop-ast (>= 1.1.1)
113
+ rubocop-ast (>= 1.16.0, < 2.0)
92
114
  ruby-progressbar (~> 1.7)
93
- unicode-display_width (>= 1.4.0, < 2.0)
94
- rubocop-ast (1.1.1)
95
- parser (>= 2.7.1.5)
96
- rubocop-rspec (2.0.0)
97
- rubocop (~> 1.0)
98
- rubocop-ast (>= 1.1.0)
99
- ruby-progressbar (1.10.1)
100
- ruby2_keywords (0.0.2)
101
- thor (1.0.1)
102
- thread_safe (0.3.6)
115
+ unicode-display_width (>= 1.4.0, < 3.0)
116
+ rubocop-ast (1.17.0)
117
+ parser (>= 3.1.1.0)
118
+ rubocop-rspec (2.9.0)
119
+ rubocop (~> 1.19)
120
+ ruby-progressbar (1.11.0)
121
+ ruby2_keywords (0.0.5)
122
+ thor (1.2.1)
103
123
  tilt (2.0.10)
104
- tzinfo (1.2.8)
105
- thread_safe (~> 0.1)
106
- unicode-display_width (1.7.0)
107
- webmock (3.9.3)
108
- addressable (>= 2.3.6)
124
+ tzinfo (2.0.4)
125
+ concurrent-ruby (~> 1.0)
126
+ unicode-display_width (2.1.0)
127
+ webmock (3.14.0)
128
+ addressable (>= 2.8.0)
109
129
  crack (>= 0.3.2)
110
130
  hashdiff (>= 0.4.0, < 2.0.0)
111
- zeitwerk (2.4.2)
112
131
 
113
132
  PLATFORMS
114
133
  ruby
@@ -123,4 +142,4 @@ DEPENDENCIES
123
142
  weneedfeed!
124
143
 
125
144
  BUNDLED WITH
126
- 2.1.4
145
+ 2.2.29
@@ -1,5 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ # For faraday_middleware/response_middleware.
4
+ # https://github.com/r7kamura/weneedfeed/issues/19
5
+ require 'active_support'
6
+ require 'active_support/isolated_execution_state' if ActiveSupport.gem_version >= Gem::Version.new('7')
7
+
3
8
  require 'active_support/core_ext/array/conversions'
4
9
  require 'active_support/core_ext/hash/conversions'
5
10
  require 'faraday'
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'mimemagic'
3
+ require 'marcel'
4
+ require 'uri'
4
5
 
5
6
  module Weneedfeed
6
7
  class Item
@@ -53,14 +54,21 @@ module Weneedfeed
53
54
  def image_mime_type
54
55
  return unless image_url
55
56
 
56
- ::MimeMagic.by_path(image_url)&.type
57
+ ::Marcel::Magic.by_path(image_url)&.type
57
58
  end
58
59
 
59
60
  # @return [String, nil]
60
61
  def image_path_or_url
61
62
  return unless @image_selector
62
63
 
63
- @node.at(@image_selector)&.[]('src')
64
+ node = @node.at(@image_selector)
65
+ return unless node
66
+
67
+ if node.name == 'img'
68
+ node['src']
69
+ else
70
+ node.content
71
+ end
64
72
  end
65
73
 
66
74
  def image_url
@@ -65,12 +65,16 @@ module Weneedfeed
65
65
 
66
66
  # @return [Nokogiri::Node]
67
67
  def parsed_body
68
- ::Nokogiri::XML.parse(response.body)
68
+ if response.headers['Content-Type']&.include?('application/json')
69
+ ::Nokogiri::XML.parse(response.body)
70
+ else
71
+ ::Nokogiri::HTML.parse(response.body)
72
+ end
69
73
  end
70
74
 
71
75
  # @return [Faraday::Response]
72
76
  def response
73
- self.class.faraday_connection.get(@url)
77
+ @response ||= self.class.faraday_connection.get(@url)
74
78
  end
75
79
  end
76
80
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Weneedfeed
4
- VERSION = '0.9.0'
4
+ VERSION = '0.10.0'
5
5
  end
@@ -19,7 +19,7 @@
19
19
  <content:encoded><![CDATA[<%= item.description %>]]></content:encoded>
20
20
  <guid isPermaLink="true"><%= item.link %></guid>
21
21
  <% if item.image_url %>
22
- <enclosure url="<%= item.image_url %>" length="0" type="<%= item.image_mime_type %>"/>
22
+ <enclosure url=<%= item.image_url.encode(xml: :attr) %> length="0" type="<%= item.image_mime_type %>"/>
23
23
  <% end %>
24
24
  </item>
25
25
  <% end %>
data/weneedfeed.gemspec CHANGED
@@ -16,6 +16,8 @@ Gem::Specification.new do |spec|
16
16
  spec.metadata['homepage_uri'] = spec.homepage
17
17
  spec.metadata['source_code_uri'] = spec.homepage
18
18
 
19
+ spec.metadata['rubygems_mfa_required'] = 'true'
20
+
19
21
  # Specify which files should be added to the gem when it is released.
20
22
  # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
21
23
  spec.files = Dir.chdir(File.expand_path(__dir__)) do
@@ -30,7 +32,7 @@ Gem::Specification.new do |spec|
30
32
  spec.add_runtime_dependency 'faraday'
31
33
  spec.add_runtime_dependency 'faraday_middleware'
32
34
  spec.add_runtime_dependency 'hibana', '>= 0.2'
33
- spec.add_runtime_dependency 'mimemagic'
35
+ spec.add_runtime_dependency 'marcel'
34
36
  spec.add_runtime_dependency 'nokogiri'
35
37
  spec.add_runtime_dependency 'rack-capture', '>= 0.4.0'
36
38
  spec.add_runtime_dependency 'thor'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: weneedfeed
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.0
4
+ version: 0.10.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryo Nakamura
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-12-02 00:00:00.000000000 Z
11
+ date: 2022-04-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -81,7 +81,7 @@ dependencies:
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0.2'
83
83
  - !ruby/object:Gem::Dependency
84
- name: mimemagic
84
+ name: marcel
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
87
  - - ">="
@@ -186,6 +186,7 @@ licenses:
186
186
  metadata:
187
187
  homepage_uri: https://github.com/r7kamura/weneedfeed
188
188
  source_code_uri: https://github.com/r7kamura/weneedfeed
189
+ rubygems_mfa_required: 'true'
189
190
  post_install_message:
190
191
  rdoc_options: []
191
192
  require_paths:
@@ -201,7 +202,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
201
202
  - !ruby/object:Gem::Version
202
203
  version: '0'
203
204
  requirements: []
204
- rubygems_version: 3.1.2
205
+ rubygems_version: 3.1.4
205
206
  signing_key:
206
207
  specification_version: 4
207
208
  summary: Generate feeds from URL and selectors.