weneedfeed 0.19.3 → 0.21.0

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,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 000a213e575858330b55a18d94739be1c2a541eb6066c498513d79d8ced83be1
4
- data.tar.gz: 524ecd8eb36bfcfbae378cc4aa784c46b404d5c2a60c96c67d357d349e9a850b
3
+ metadata.gz: e0a5be92085f05d5e0ea6adcfbe1c96362032309c75ade79295eb96e8927c761
4
+ data.tar.gz: d03d6ef5342fc5112eb5d7e2216cfcbb2958b0890e94f5d57a1b91bf89d208f8
5
5
  SHA512:
6
- metadata.gz: b1d7dd8cbe3b566056848cdcaaee638b5d592255d62b7e71437bd0ca67ec07b4eafbfbf3ab1c23886a75ef263b1c42b3bb17f2c7bd0a0f160cc499cdd96993cf
7
- data.tar.gz: 39edaa98fc6c8bf80c8177256e70163a6ea84ad0ff347d9531536334daa636dfce4daca0beda6498200bd4deb9531f40b343ef2ac2f2a0171c511b3a4f54aff2
6
+ metadata.gz: 37582af6c0f94dabe6520f55f3c5a600e94ec00aa1fd5ed599d205b235c6b9d128222b239561b58ab3690a9b101ed0285fda56487fa558b1ed9b1be1f0609523
7
+ data.tar.gz: 2e36c65a2fc9e61a62e9060de9662a5afe8892ee8b98919b23247efba3dba9213951399b76421b74e9d5c73f9262c050774d9fe045108aaea4f5d87b476f2a03
@@ -0,0 +1,23 @@
1
+ changelog:
2
+ categories:
3
+ - title: Added
4
+ labels:
5
+ - add
6
+ - title: Changed
7
+ labels:
8
+ - change
9
+ - title: Deprecated
10
+ labels:
11
+ - deprecate
12
+ - title: Fixed
13
+ labels:
14
+ - fix
15
+ - title: Removed
16
+ labels:
17
+ - remove
18
+ - title: Security
19
+ labels:
20
+ - security
21
+ - title: Others
22
+ labels:
23
+ - "*"
@@ -0,0 +1,63 @@
1
+ # This file is machine-generated by `gh actions-lock`.
2
+ # Do not edit by hand; run `gh actions-lock` to update.
3
+ # Docs: https://gh.io/actions-lockfile
4
+ version: 'v0.0.3'
5
+ workflows:
6
+ '.github/workflows/bump-request.yml':
7
+ - 'actions/checkout@v7.0.1'
8
+ - 'r7kamura/bump-request@v0.7.1'
9
+ - 'ruby/setup-ruby@v1.336.0'
10
+ '.github/workflows/github-label-sync.yml':
11
+ - 'r7kamura/github-label-sync-action@v0.1.0'
12
+ '.github/workflows/release.yml': []
13
+ '.github/workflows/test.yml':
14
+ - 'actions/checkout@v7.0.1'
15
+ - 'r7kamura/rubocop-problem-matchers-action@v1.2.2'
16
+ - 'ruby/setup-ruby@v1.336.0'
17
+ dependencies:
18
+ 'actions/checkout@v3':
19
+ ref: 'v3'
20
+ commit: 'sha1-a37ce9120846195fa4ece8f58b268e6043cb2f26'
21
+ owner_id: 44036562
22
+ repo_id: 197814629
23
+ 'actions/checkout@v7.0.1':
24
+ ref: 'v7.0.1'
25
+ commit: 'sha1-3d3c42e5aac5ba805825da76410c181273ba90b1'
26
+ owner_id: 44036562
27
+ repo_id: 197814629
28
+ 'actions/setup-node@v3':
29
+ ref: 'v3'
30
+ commit: 'sha1-3235b876344d2a9aa001b8d1453c930bba69e610'
31
+ owner_id: 44036562
32
+ repo_id: 189476904
33
+ 'actions/setup-node@v7.1.0':
34
+ ref: 'v7.1.0'
35
+ commit: 'sha1-949feb2413d6458794dcd2491c4babbbce0c15c1'
36
+ owner_id: 44036562
37
+ repo_id: 189476904
38
+ 'r7kamura/bump-request@v0.7.1':
39
+ ref: 'v0.7.1'
40
+ commit: 'sha1-b27937188d404bc0c2fd442403e6de1d20f9b349'
41
+ owner_id: 111689
42
+ repo_id: 533135195
43
+ uses:
44
+ - 'actions/checkout@v7.0.1'
45
+ - 'actions/setup-node@v7.1.0'
46
+ 'r7kamura/github-label-sync-action@v0.1.0':
47
+ ref: 'v0.1.0'
48
+ commit: 'sha1-061649dd3b80eb5bafad0316466f72962e62c300'
49
+ owner_id: 111689
50
+ repo_id: 514711932
51
+ uses:
52
+ - 'actions/checkout@v3'
53
+ - 'actions/setup-node@v3'
54
+ 'r7kamura/rubocop-problem-matchers-action@v1.2.2':
55
+ ref: 'v1.2.2'
56
+ commit: 'sha1-59f1a0759f50cc2649849fd850b8487594bb5a81'
57
+ owner_id: 111689
58
+ repo_id: 311386667
59
+ 'ruby/setup-ruby@v1.336.0':
60
+ ref: 'v1.336.0'
61
+ commit: 'sha1-de492cf36cbab201753d720ce4f4e336cd688c94'
62
+ owner_id: 210414
63
+ repo_id: 231208785
@@ -0,0 +1,26 @@
1
+ name: bump-request
2
+
3
+ on:
4
+ workflow_dispatch:
5
+ inputs:
6
+ version:
7
+ description: Version to change to.
8
+ required: true
9
+ type: string
10
+
11
+ jobs:
12
+ run:
13
+ runs-on: ubuntu-latest
14
+ steps:
15
+ - uses: actions/checkout@v7.0.1
16
+ - name: Set up Ruby
17
+ uses: ruby/setup-ruby@v1.336.0
18
+ with:
19
+ ruby-version: '3.3'
20
+ bundler-cache: true
21
+ - uses: r7kamura/bump-request@v0.7.1
22
+ with:
23
+ command: |
24
+ sed -i -r 's/([0-9]+\.[0-9]+\.[0-9]+)/${{ inputs.version }}/' lib/*/version.rb
25
+ bundle install
26
+ version: ${{ inputs.version }}
@@ -0,0 +1,18 @@
1
+ name: github-label-sync
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - main
7
+ paths:
8
+ - .github/workflows/github-label-sync.yml
9
+ workflow_dispatch:
10
+
11
+ jobs:
12
+ build:
13
+ runs-on: ubuntu-latest
14
+ steps:
15
+ - uses: r7kamura/github-label-sync-action@v0.1.0
16
+ with:
17
+ source_path: labels-keepachangelog.yml
18
+ source_repository: r7kamura/github-label-presets
@@ -0,0 +1,11 @@
1
+ name: release
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - main
7
+
8
+ jobs:
9
+ release:
10
+ uses: r7kamura/workflows/.github/workflows/gem-release.yml@main
11
+ if: github.repository_owner == 'r7kamura'
@@ -12,25 +12,26 @@ jobs:
12
12
  fail-fast: false
13
13
  matrix:
14
14
  ruby:
15
- - 2.7.2
16
- - 3.0.2
17
- runs-on: ubuntu-20.04
15
+ - '3.3'
16
+ - '3.4'
17
+ - '4.0'
18
+ runs-on: ubuntu-latest
18
19
  steps:
19
- - uses: actions/checkout@v2
20
- - uses: ruby/setup-ruby@v1
20
+ - uses: actions/checkout@v7.0.1
21
+ - uses: ruby/setup-ruby@v1.336.0
21
22
  with:
22
23
  bundler-cache: true
23
24
  ruby-version: ${{ matrix.ruby }}
24
25
  - run: bundle exec rspec --force-color
25
26
  rubocop:
26
- runs-on: ubuntu-20.04
27
+ runs-on: ubuntu-latest
27
28
  steps:
28
- - uses: actions/checkout@v2
29
+ - uses: actions/checkout@v7.0.1
29
30
  with:
30
31
  ref: ${{ github.event.pull_request.head.sha }}
31
- - uses: ruby/setup-ruby@v1
32
+ - uses: ruby/setup-ruby@v1.336.0
32
33
  with:
33
34
  bundler-cache: true
34
- ruby-version: 2.7.2
35
- - uses: r7kamura/rubocop-problem-matchers-action@v1
35
+ ruby-version: '3.3'
36
+ - uses: r7kamura/rubocop-problem-matchers-action@v1.2.2
36
37
  - run: bundle exec rubocop --parallel
data/.rubocop.yml CHANGED
@@ -4,7 +4,10 @@ require:
4
4
 
5
5
  AllCops:
6
6
  NewCops: enable
7
- TargetRubyVersion: 2.5
7
+ TargetRubyVersion: 3.3
8
+
9
+ Gemspec/RequireMFA:
10
+ Enabled: false
8
11
 
9
12
  Lint/SuppressedException:
10
13
  Enabled: false
data/Gemfile CHANGED
@@ -5,6 +5,7 @@ source 'https://rubygems.org'
5
5
  # Specify your gem's dependencies in weneedfeed.gemspec
6
6
  gemspec
7
7
 
8
+ gem 'ostruct'
8
9
  gem 'rack-test'
9
10
  gem 'rake', '~> 12.0'
10
11
  gem 'rspec'
data/Gemfile.lock CHANGED
@@ -1,36 +1,51 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- weneedfeed (0.19.3)
4
+ weneedfeed (0.21.0)
5
5
  activesupport
6
6
  addressable
7
7
  builder
8
8
  faraday
9
9
  faraday_middleware
10
- hibana (>= 0.2.1)
11
10
  marcel
12
11
  nokogiri
13
12
  psych (>= 4)
13
+ rack
14
14
  rack-capture (>= 0.4.0)
15
15
  thor
16
+ tilt
16
17
 
17
18
  GEM
18
19
  remote: https://rubygems.org/
19
20
  specs:
20
- activesupport (7.0.3.1)
21
- concurrent-ruby (~> 1.0, >= 1.0.2)
21
+ activesupport (8.1.4)
22
+ base64
23
+ bigdecimal
24
+ concurrent-ruby (~> 1.0, >= 1.3.1)
25
+ connection_pool (>= 2.2.5)
26
+ drb
22
27
  i18n (>= 1.6, < 2)
28
+ json
29
+ logger (>= 1.4.2)
23
30
  minitest (>= 5.1)
24
- tzinfo (~> 2.0)
25
- addressable (2.8.0)
26
- public_suffix (>= 2.0.2, < 5.0)
27
- ast (2.4.2)
28
- builder (3.2.4)
29
- concurrent-ruby (1.1.10)
30
- crack (0.4.5)
31
+ securerandom (>= 0.3)
32
+ tzinfo (~> 2.0, >= 2.0.5)
33
+ uri (>= 0.13.1)
34
+ addressable (2.9.1)
35
+ public_suffix (>= 2.0.2, < 8.0)
36
+ ast (2.4.3)
37
+ base64 (0.3.0)
38
+ bigdecimal (4.1.3)
39
+ builder (3.3.0)
40
+ concurrent-ruby (1.3.8)
41
+ connection_pool (3.0.2)
42
+ crack (1.0.1)
43
+ bigdecimal
31
44
  rexml
32
- diff-lcs (1.5.0)
33
- faraday (1.10.0)
45
+ date (3.6.0)
46
+ diff-lcs (1.6.2)
47
+ drb (2.2.3)
48
+ faraday (1.10.6)
34
49
  faraday-em_http (~> 1.0)
35
50
  faraday-em_synchrony (~> 1.0)
36
51
  faraday-excon (~> 1.1)
@@ -43,95 +58,101 @@ GEM
43
58
  faraday-retry (~> 1.0)
44
59
  ruby2_keywords (>= 0.0.4)
45
60
  faraday-em_http (1.0.0)
46
- faraday-em_synchrony (1.0.0)
61
+ faraday-em_synchrony (1.0.1)
47
62
  faraday-excon (1.1.0)
48
63
  faraday-httpclient (1.0.1)
49
- faraday-multipart (1.0.4)
50
- multipart-post (~> 2)
51
- faraday-net_http (1.0.1)
64
+ faraday-multipart (1.2.0)
65
+ multipart-post (~> 2.0)
66
+ faraday-net_http (1.0.2)
52
67
  faraday-net_http_persistent (1.2.0)
53
68
  faraday-patron (1.0.0)
54
69
  faraday-rack (1.0.0)
55
- faraday-retry (1.0.3)
56
- faraday_middleware (1.2.0)
70
+ faraday-retry (1.0.4)
71
+ faraday_middleware (1.2.1)
57
72
  faraday (~> 1.0)
58
- hanami-router (2.0.0.alpha3)
59
- mustermann (~> 1.0)
60
- mustermann-contrib (~> 1.0)
61
- rack (~> 2.0)
62
- hansi (0.2.1)
63
- hashdiff (1.0.1)
64
- hibana (0.2.1)
65
- hanami-router (= 2.0.0.alpha3)
66
- rack
67
- tilt
68
- i18n (1.12.0)
73
+ hashdiff (1.2.1)
74
+ i18n (1.15.2)
69
75
  concurrent-ruby (~> 1.0)
70
- marcel (1.0.2)
71
- mini_portile2 (2.8.0)
72
- minitest (5.16.2)
73
- multipart-post (2.2.3)
74
- mustermann (1.1.2)
75
- ruby2_keywords (~> 0.0.1)
76
- mustermann-contrib (1.1.2)
77
- hansi (~> 0.2.0)
78
- mustermann (= 1.1.2)
79
- nokogiri (1.13.8)
80
- mini_portile2 (~> 2.8.0)
76
+ json (3.1.0)
77
+ language_server-protocol (3.17.0.6)
78
+ lint_roller (1.1.0)
79
+ logger (1.7.0)
80
+ marcel (2.1.0)
81
+ mini_portile2 (2.8.9)
82
+ minitest (6.0.6)
83
+ drb (~> 2.0)
84
+ prism (~> 1.5)
85
+ multipart-post (2.4.1)
86
+ nokogiri (1.19.4)
87
+ mini_portile2 (~> 2.8.2)
81
88
  racc (~> 1.4)
82
- parallel (1.22.1)
83
- parser (3.1.2.0)
89
+ ostruct (0.6.3)
90
+ parallel (2.3.0)
91
+ parser (3.3.13.0)
84
92
  ast (~> 2.4.1)
85
- psych (4.0.4)
93
+ racc
94
+ prism (1.9.0)
95
+ psych (5.5.0)
96
+ date
86
97
  stringio
87
- public_suffix (4.0.7)
88
- racc (1.6.0)
89
- rack (2.2.3)
98
+ public_suffix (7.0.5)
99
+ racc (1.8.1)
100
+ rack (2.2.25)
90
101
  rack-capture (0.4.0)
91
102
  rack
92
- rack-test (1.1.0)
93
- rack (>= 1.0, < 3)
103
+ rack-test (2.3.0)
104
+ rack (>= 1.3)
94
105
  rainbow (3.1.1)
95
106
  rake (12.3.3)
96
- regexp_parser (2.3.0)
97
- rexml (3.2.5)
98
- rspec (3.11.0)
99
- rspec-core (~> 3.11.0)
100
- rspec-expectations (~> 3.11.0)
101
- rspec-mocks (~> 3.11.0)
102
- rspec-core (3.11.0)
103
- rspec-support (~> 3.11.0)
104
- rspec-expectations (3.11.0)
107
+ regexp_parser (2.13.1)
108
+ rexml (3.4.4)
109
+ rspec (3.13.2)
110
+ rspec-core (~> 3.13.0)
111
+ rspec-expectations (~> 3.13.0)
112
+ rspec-mocks (~> 3.13.0)
113
+ rspec-core (3.13.6)
114
+ rspec-support (~> 3.13.0)
115
+ rspec-expectations (3.13.5)
105
116
  diff-lcs (>= 1.2.0, < 2.0)
106
- rspec-support (~> 3.11.0)
107
- rspec-mocks (3.11.1)
117
+ rspec-support (~> 3.13.0)
118
+ rspec-mocks (3.13.8)
108
119
  diff-lcs (>= 1.2.0, < 2.0)
109
- rspec-support (~> 3.11.0)
110
- rspec-support (3.11.0)
111
- rubocop (1.27.0)
112
- parallel (~> 1.10)
113
- parser (>= 3.1.0.0)
120
+ rspec-support (~> 3.13.0)
121
+ rspec-support (3.13.7)
122
+ rubocop (1.92.2)
123
+ json (>= 2.3)
124
+ language_server-protocol (~> 3.17.0.2)
125
+ lint_roller (~> 1.1.0)
126
+ parallel (>= 1.10)
127
+ parser (>= 3.3.0.2)
114
128
  rainbow (>= 2.2.2, < 4.0)
115
- regexp_parser (>= 1.8, < 3.0)
116
- rexml
117
- rubocop-ast (>= 1.16.0, < 2.0)
129
+ regexp_parser (>= 2.11.3, < 3.0)
130
+ rubocop-ast (>= 1.49.0, < 2.0)
118
131
  ruby-progressbar (~> 1.7)
119
- unicode-display_width (>= 1.4.0, < 3.0)
120
- rubocop-ast (1.17.0)
121
- parser (>= 3.1.1.0)
122
- rubocop-rake (0.6.0)
123
- rubocop (~> 1.0)
124
- rubocop-rspec (2.9.0)
125
- rubocop (~> 1.19)
126
- ruby-progressbar (1.11.0)
132
+ unicode-display_width (>= 2.4.0, < 4.0)
133
+ rubocop-ast (1.50.0)
134
+ parser (>= 3.3.7.2)
135
+ prism (~> 1.7)
136
+ rubocop-rake (0.7.1)
137
+ lint_roller (~> 1.1)
138
+ rubocop (>= 1.72.1)
139
+ rubocop-rspec (3.10.2)
140
+ lint_roller (~> 1.1)
141
+ regexp_parser (>= 2.0)
142
+ rubocop (~> 1.86, >= 1.86.2)
143
+ ruby-progressbar (1.13.0)
127
144
  ruby2_keywords (0.0.5)
128
- stringio (3.0.2)
129
- thor (1.2.1)
130
- tilt (2.0.11)
131
- tzinfo (2.0.5)
145
+ securerandom (0.4.1)
146
+ stringio (3.2.0)
147
+ thor (1.5.0)
148
+ tilt (2.9.0)
149
+ tzinfo (2.0.6)
132
150
  concurrent-ruby (~> 1.0)
133
- unicode-display_width (2.1.0)
134
- webmock (3.14.0)
151
+ unicode-display_width (3.3.0)
152
+ unicode-emoji (~> 4.3)
153
+ unicode-emoji (4.3.0)
154
+ uri (1.1.2)
155
+ webmock (3.34.0)
135
156
  addressable (>= 2.8.0)
136
157
  crack (>= 0.3.2)
137
158
  hashdiff (>= 0.4.0, < 2.0.0)
@@ -140,6 +161,7 @@ PLATFORMS
140
161
  ruby
141
162
 
142
163
  DEPENDENCIES
164
+ ostruct
143
165
  rack-test
144
166
  rake (~> 12.0)
145
167
  rspec
@@ -150,4 +172,4 @@ DEPENDENCIES
150
172
  weneedfeed!
151
173
 
152
174
  BUNDLED WITH
153
- 2.2.29
175
+ 4.0.20
data/README.md CHANGED
@@ -1,8 +1,5 @@
1
1
  # Weneedfeed
2
2
 
3
- [![](https://badge.fury.io/rb/weneedfeed.svg)](https://rubygems.org/gems/weneedfeed)
4
- [![](https://github.com/r7kamura/weneedfeed/workflows/test/badge.svg)](https://github.com/r7kamura/weneedfeed/actions?query=workflow%3Atest)
5
-
6
3
  Generate feeds from URL and selectors.
7
4
 
8
5
  ## Installation
@@ -171,24 +168,8 @@ Run HTTP server.
171
168
 
172
169
  Use [weneedfeed-action](https://github.com/r7kamura/weneedfeed-action) for invoking weneedfeed on GitHub Actions.
173
170
 
174
- ## Development
175
-
176
- ### Setup
177
-
178
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
179
-
180
- ### Local installation
181
-
182
- To install this gem onto your local machine, run `bundle exec rake install`.
183
-
184
- ### Release
185
-
186
- To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
187
-
188
- ## Contributing
189
-
190
- Bug reports and pull requests are welcome on GitHub at https://github.com/r7kamura/weneedfeed.
191
-
192
- ## License
171
+ ### Examples
193
172
 
194
- The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
173
+ - https://github.com/r7kamura/weneedfeed-comic-newtype
174
+ - https://github.com/r7kamura/weneedfeed-mangacross
175
+ - https://github.com/r7kamura/weneedfeed-webace
@@ -1,25 +1,27 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'hibana'
4
-
5
3
  module Weneedfeed
6
- class Application < ::Hibana::Application
7
- route do
8
- get '/', to: ::Weneedfeed::Controllers::ShowTopPage, as: :top_page
9
- get '/feeds/:page_id.xml', to: ::Weneedfeed::Controllers::ShowFeed, as: :feed
10
- get '/opml.xml', to: ::Weneedfeed::Controllers::ShowOpml, as: :opml
4
+ class Application
5
+ class << self
6
+ # @return [Weneedfeed::Router]
7
+ def router
8
+ @router ||= ::Weneedfeed::Router.new.tap do |router|
9
+ router.get '/', to: ::Weneedfeed::Controllers::ShowTopPage, as: :top_page
10
+ router.get '/feeds/:page_id.xml', to: ::Weneedfeed::Controllers::ShowFeed, as: :feed
11
+ router.get '/opml.xml', to: ::Weneedfeed::Controllers::ShowOpml, as: :opml
12
+ end
13
+ end
11
14
  end
12
15
 
13
16
  # @param [String] schema_path
14
17
  def initialize(schema_path:)
15
18
  @schema = ::Weneedfeed::Schema.load_file(schema_path)
16
- super()
17
19
  end
18
20
 
19
21
  # @param [Hash] env
20
22
  def call(env)
21
23
  env['weneedfeed.schema'] = @schema
22
- super
24
+ self.class.router.call(env)
23
25
  end
24
26
 
25
27
  # @return [Array<String>]
@@ -1,12 +1,42 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'rack'
4
+
3
5
  module Weneedfeed
4
6
  module Controllers
5
- class Base < ::Hibana::Controller
7
+ class Base
6
8
  include ::Weneedfeed::Helpers::Parameters
7
9
 
10
+ class << self
11
+ # @param [Hash] env
12
+ # @return [Array]
13
+ def call(env)
14
+ controller = new(env: env)
15
+ controller.call
16
+ controller.response.finish
17
+ end
18
+ end
19
+
20
+ # @return [Rack::Response]
21
+ attr_reader :response
22
+
23
+ # @param [Hash] env
24
+ def initialize(env:)
25
+ @env = env
26
+ @response = ::Rack::Response.new
27
+ end
28
+
29
+ def call
30
+ raise ::NotImplementedError
31
+ end
32
+
8
33
  private
9
34
 
35
+ # @return [Rack::Request]
36
+ def request
37
+ @request ||= ::Rack::Request.new(@env)
38
+ end
39
+
10
40
  # @return [Weneedfeed::Schema]
11
41
  def schema
12
42
  request.env['weneedfeed.schema']
@@ -0,0 +1,79 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'rack'
4
+
5
+ module Weneedfeed
6
+ class Router
7
+ Route = ::Struct.new(
8
+ :controller,
9
+ :name,
10
+ :path,
11
+ :regexp,
12
+ keyword_init: true
13
+ )
14
+
15
+ def initialize
16
+ @routes = []
17
+ end
18
+
19
+ # @param [String] path
20
+ # @param [#call] to
21
+ # @param [Symbol] as
22
+ def get(
23
+ path,
24
+ as:,
25
+ to:
26
+ )
27
+ @routes << Route.new(
28
+ controller: to,
29
+ name: as,
30
+ path: path,
31
+ regexp: to_regexp(path)
32
+ )
33
+ end
34
+
35
+ # @param [Hash] env
36
+ # @return [Array]
37
+ def call(env)
38
+ if %w[GET HEAD].include?(env['REQUEST_METHOD'])
39
+ @routes.each do |route|
40
+ match_data = route.regexp.match(env['PATH_INFO'])
41
+ next unless match_data
42
+
43
+ env['router.params'] = match_data.named_captures.to_h do |key, value|
44
+ [key.to_sym, ::Rack::Utils.unescape_path(value)]
45
+ end
46
+ return route.controller.call(env)
47
+ end
48
+ end
49
+
50
+ [404, { 'content-type' => 'text/plain' }, ['Not Found']]
51
+ end
52
+
53
+ # @param [Symbol] name
54
+ # @param [Hash{Symbol => String}] parameters
55
+ # @return [String]
56
+ def path(
57
+ name,
58
+ **parameters
59
+ )
60
+ route = @routes.find { |element| element.name == name }
61
+ raise ::ArgumentError, "Unknown route: #{name}" unless route
62
+
63
+ route.path.gsub(/:(\w+)/) do
64
+ ::Rack::Utils.escape_path(parameters.fetch(::Regexp.last_match(1).to_sym).to_s)
65
+ end
66
+ end
67
+
68
+ private
69
+
70
+ # @param [String] path
71
+ # @return [Regexp]
72
+ def to_regexp(path)
73
+ pattern = ::Regexp.escape(path).gsub(/:(\w+)/) do
74
+ "(?<#{::Regexp.last_match(1)}>[^/]+?)"
75
+ end
76
+ /\A#{pattern}\z/
77
+ end
78
+ end
79
+ end
@@ -5,10 +5,14 @@ require 'nokogiri'
5
5
 
6
6
  module Weneedfeed
7
7
  class Scraping
8
+ DEFAULT_HEADERS = {
9
+ 'User-Agent' => 'Weneedfeed'
10
+ }.freeze
11
+
8
12
  class << self
9
13
  # @return [Faraday::Connection]
10
14
  def faraday_connection
11
- @faraday_connection ||= ::Faraday.new do |connection|
15
+ @faraday_connection ||= ::Faraday.new(headers: DEFAULT_HEADERS) do |connection|
12
16
  connection.use ::Weneedfeed::FaradayResponseMiddleware
13
17
  end
14
18
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Weneedfeed
4
- VERSION = '0.19.3'
4
+ VERSION = '0.21.0'
5
5
  end
@@ -1,11 +1,31 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'tilt'
4
+
3
5
  module Weneedfeed
4
6
  module Views
5
- class Base < ::Hibana::View
7
+ class Base
8
+ # @param [String] partial_template_path
9
+ # @param [Rack::Request] request
10
+ def initialize(
11
+ partial_template_path:,
12
+ request:
13
+ )
14
+ @partial_template_path = partial_template_path
15
+ @request = request
16
+ end
17
+
18
+ # @return [String]
19
+ def to_s
20
+ ::Tilt.new(@partial_template_path).render(self)
21
+ end
22
+
6
23
  private
7
24
 
8
- # @return [Hanami::Router]
25
+ # @return [Rack::Request]
26
+ attr_reader :request
27
+
28
+ # @return [Weneedfeed::Router]
9
29
  def router
10
30
  ::Weneedfeed::Application.router
11
31
  end
@@ -31,11 +31,6 @@ module Weneedfeed
31
31
  def page_schemata
32
32
  @schema.page_schemata.sort_by(&:title)
33
33
  end
34
-
35
- # @return [Hanami::Router]
36
- def router
37
- ::Weneedfeed::Application.router
38
- end
39
34
  end
40
35
  end
41
36
  end
data/lib/weneedfeed.rb CHANGED
@@ -13,6 +13,7 @@ module Weneedfeed
13
13
  autoload :Page, 'weneedfeed/page'
14
14
  autoload :PageSchema, 'weneedfeed/page_schema'
15
15
  autoload :Schema, 'weneedfeed/schema'
16
+ autoload :Router, 'weneedfeed/router'
16
17
  autoload :Scraping, 'weneedfeed/scraping'
17
18
  autoload :Views, 'weneedfeed/views'
18
19
  end
data/weneedfeed.gemspec CHANGED
@@ -11,12 +11,11 @@ Gem::Specification.new do |spec|
11
11
  spec.summary = 'Generate feeds from URL and selectors.'
12
12
  spec.homepage = 'https://github.com/r7kamura/weneedfeed'
13
13
  spec.license = 'MIT'
14
- spec.required_ruby_version = Gem::Requirement.new('>= 2.5.0')
14
+ spec.required_ruby_version = Gem::Requirement.new('>= 3.3')
15
15
 
16
16
  spec.metadata['homepage_uri'] = spec.homepage
17
17
  spec.metadata['source_code_uri'] = spec.homepage
18
-
19
- spec.metadata['rubygems_mfa_required'] = 'true'
18
+ spec.metadata['changelog_uri'] = "#{spec.homepage}/releases"
20
19
 
21
20
  # Specify which files should be added to the gem when it is released.
22
21
  # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
@@ -27,15 +26,16 @@ Gem::Specification.new do |spec|
27
26
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
28
27
  spec.require_paths = ['lib']
29
28
 
30
- spec.add_runtime_dependency 'activesupport'
31
- spec.add_runtime_dependency 'addressable'
32
- spec.add_runtime_dependency 'builder'
33
- spec.add_runtime_dependency 'faraday'
34
- spec.add_runtime_dependency 'faraday_middleware'
35
- spec.add_runtime_dependency 'hibana', '>= 0.2.1'
36
- spec.add_runtime_dependency 'marcel'
37
- spec.add_runtime_dependency 'nokogiri'
38
- spec.add_runtime_dependency 'psych', '>= 4'
39
- spec.add_runtime_dependency 'rack-capture', '>= 0.4.0'
40
- spec.add_runtime_dependency 'thor'
29
+ spec.add_dependency 'activesupport'
30
+ spec.add_dependency 'addressable'
31
+ spec.add_dependency 'builder'
32
+ spec.add_dependency 'faraday'
33
+ spec.add_dependency 'faraday_middleware'
34
+ spec.add_dependency 'marcel'
35
+ spec.add_dependency 'nokogiri'
36
+ spec.add_dependency 'psych', '>= 4'
37
+ spec.add_dependency 'rack'
38
+ spec.add_dependency 'rack-capture', '>= 0.4.0'
39
+ spec.add_dependency 'thor'
40
+ spec.add_dependency 'tilt'
41
41
  end
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: weneedfeed
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.19.3
4
+ version: 0.21.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryo Nakamura
8
- autorequire:
9
8
  bindir: exe
10
9
  cert_chain: []
11
- date: 2022-08-01 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: activesupport
@@ -81,21 +80,21 @@ dependencies:
81
80
  - !ruby/object:Gem::Version
82
81
  version: '0'
83
82
  - !ruby/object:Gem::Dependency
84
- name: hibana
83
+ name: marcel
85
84
  requirement: !ruby/object:Gem::Requirement
86
85
  requirements:
87
86
  - - ">="
88
87
  - !ruby/object:Gem::Version
89
- version: 0.2.1
88
+ version: '0'
90
89
  type: :runtime
91
90
  prerelease: false
92
91
  version_requirements: !ruby/object:Gem::Requirement
93
92
  requirements:
94
93
  - - ">="
95
94
  - !ruby/object:Gem::Version
96
- version: 0.2.1
95
+ version: '0'
97
96
  - !ruby/object:Gem::Dependency
98
- name: marcel
97
+ name: nokogiri
99
98
  requirement: !ruby/object:Gem::Requirement
100
99
  requirements:
101
100
  - - ">="
@@ -109,33 +108,33 @@ dependencies:
109
108
  - !ruby/object:Gem::Version
110
109
  version: '0'
111
110
  - !ruby/object:Gem::Dependency
112
- name: nokogiri
111
+ name: psych
113
112
  requirement: !ruby/object:Gem::Requirement
114
113
  requirements:
115
114
  - - ">="
116
115
  - !ruby/object:Gem::Version
117
- version: '0'
116
+ version: '4'
118
117
  type: :runtime
119
118
  prerelease: false
120
119
  version_requirements: !ruby/object:Gem::Requirement
121
120
  requirements:
122
121
  - - ">="
123
122
  - !ruby/object:Gem::Version
124
- version: '0'
123
+ version: '4'
125
124
  - !ruby/object:Gem::Dependency
126
- name: psych
125
+ name: rack
127
126
  requirement: !ruby/object:Gem::Requirement
128
127
  requirements:
129
128
  - - ">="
130
129
  - !ruby/object:Gem::Version
131
- version: '4'
130
+ version: '0'
132
131
  type: :runtime
133
132
  prerelease: false
134
133
  version_requirements: !ruby/object:Gem::Requirement
135
134
  requirements:
136
135
  - - ">="
137
136
  - !ruby/object:Gem::Version
138
- version: '4'
137
+ version: '0'
139
138
  - !ruby/object:Gem::Dependency
140
139
  name: rack-capture
141
140
  requirement: !ruby/object:Gem::Requirement
@@ -164,7 +163,20 @@ dependencies:
164
163
  - - ">="
165
164
  - !ruby/object:Gem::Version
166
165
  version: '0'
167
- description:
166
+ - !ruby/object:Gem::Dependency
167
+ name: tilt
168
+ requirement: !ruby/object:Gem::Requirement
169
+ requirements:
170
+ - - ">="
171
+ - !ruby/object:Gem::Version
172
+ version: '0'
173
+ type: :runtime
174
+ prerelease: false
175
+ version_requirements: !ruby/object:Gem::Requirement
176
+ requirements:
177
+ - - ">="
178
+ - !ruby/object:Gem::Version
179
+ version: '0'
168
180
  email:
169
181
  - r7kamura@gmail.com
170
182
  executables:
@@ -172,11 +184,15 @@ executables:
172
184
  extensions: []
173
185
  extra_rdoc_files: []
174
186
  files:
187
+ - ".github/release.yml"
188
+ - ".github/workflows/actions.lock"
189
+ - ".github/workflows/bump-request.yml"
190
+ - ".github/workflows/github-label-sync.yml"
191
+ - ".github/workflows/release.yml"
175
192
  - ".github/workflows/test.yml"
176
193
  - ".gitignore"
177
194
  - ".rspec"
178
195
  - ".rubocop.yml"
179
- - CHANGELOG.md
180
196
  - Gemfile
181
197
  - Gemfile.lock
182
198
  - LICENSE.txt
@@ -200,6 +216,7 @@ files:
200
216
  - lib/weneedfeed/item.rb
201
217
  - lib/weneedfeed/page.rb
202
218
  - lib/weneedfeed/page_schema.rb
219
+ - lib/weneedfeed/router.rb
203
220
  - lib/weneedfeed/schema.rb
204
221
  - lib/weneedfeed/scraping.rb
205
222
  - lib/weneedfeed/version.rb
@@ -218,8 +235,7 @@ licenses:
218
235
  metadata:
219
236
  homepage_uri: https://github.com/r7kamura/weneedfeed
220
237
  source_code_uri: https://github.com/r7kamura/weneedfeed
221
- rubygems_mfa_required: 'true'
222
- post_install_message:
238
+ changelog_uri: https://github.com/r7kamura/weneedfeed/releases
223
239
  rdoc_options: []
224
240
  require_paths:
225
241
  - lib
@@ -227,15 +243,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
227
243
  requirements:
228
244
  - - ">="
229
245
  - !ruby/object:Gem::Version
230
- version: 2.5.0
246
+ version: '3.3'
231
247
  required_rubygems_version: !ruby/object:Gem::Requirement
232
248
  requirements:
233
249
  - - ">="
234
250
  - !ruby/object:Gem::Version
235
251
  version: '0'
236
252
  requirements: []
237
- rubygems_version: 3.3.7
238
- signing_key:
253
+ rubygems_version: 4.0.20
239
254
  specification_version: 4
240
255
  summary: Generate feeds from URL and selectors.
241
256
  test_files: []
data/CHANGELOG.md DELETED
@@ -1,233 +0,0 @@
1
- # Changelog
2
-
3
- All notable changes to this project will be documented in this file.
4
-
5
- The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
- and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
-
8
- ## Unreleased
9
-
10
- ## 0.19.3 - 2022-08-02
11
-
12
- ### Fixed
13
-
14
- - Change hibana version requirement.
15
-
16
- ## 0.19.2 - 2022-08-01
17
-
18
- ### Fixed
19
-
20
- - Fix XML excape on OPML.
21
-
22
- ## 0.19.1 - 2022-08-01
23
-
24
- ### Fixed
25
-
26
- - Fix bug when time item includes white spaces.
27
-
28
- ## 0.19.0 - 2022-08-01
29
-
30
- ### Added
31
-
32
- - Support %m月%d日配信 date format
33
-
34
- ## 0.18.0 - 2022-04-17
35
-
36
- ### Added
37
-
38
- - Support configurable feeds title.
39
- - Add --port= option to server command.
40
-
41
- ## 0.17.0 - 2022-04-15
42
-
43
- ### Changed
44
-
45
- - Change outline title on OPML.
46
-
47
- ## 0.16.1 - 2022-04-15
48
-
49
- ### Fixed
50
-
51
- - Fix bug that opml.xml is not built.
52
-
53
- ## 0.16.0 - 2022-04-15
54
-
55
- ### Added
56
-
57
- - Add OPML page.
58
-
59
- ## 0.15.0 - 2022-04-14
60
-
61
- ### Changed
62
-
63
- - Use hashed title and content as guid fallback.
64
-
65
- ## 0.14.0 - 2022-04-14
66
-
67
- ### Added
68
-
69
- - Support YAML aliases (on psych 4.x).
70
-
71
- ## 0.13.0 - 2022-04-14
72
-
73
- ### Changed
74
-
75
- - Normalize item URLs.
76
-
77
- ## 0.12.0 - 2022-04-14
78
-
79
- ### Fixed
80
-
81
- - Handle incorrect URLs a little better.
82
-
83
- ## 0.11.0 - 2022-04-13
84
-
85
- ### Changed
86
-
87
- - Support invalid link URL and image URL.
88
-
89
- ## 0.10.0 - 2022-04-13
90
-
91
- ### Changed
92
-
93
- - Replace mimemagic with marcel.
94
-
95
- ### Fixed
96
-
97
- - Fix error on activesupport 7.
98
-
99
- ## 0.9.2 - 2020-12-03
100
-
101
- ### Fixed
102
-
103
- - Fix item image URL on JSON source.
104
- - Fix item image MIME type detection.
105
-
106
- ## 0.9.1 - 2020-12-03
107
-
108
- ### Fixed
109
-
110
- - Fix escape bug in escaping HTML and generating XML.
111
-
112
- ## 0.9.0 - 2020-12-03
113
-
114
- ### Added
115
-
116
- - Add item_image_selector.
117
-
118
- ## 0.8.0 - 2020-11-25
119
-
120
- ### Added
121
-
122
- - Add page description for writing channel description.
123
-
124
- ### Changed
125
-
126
- - Change channel link content from feeds index URL to page URL.
127
-
128
- ## 0.7.2 - 2020-11-25
129
-
130
- ### Fixed
131
-
132
- - Fix time parse error by HTML entities handling.
133
-
134
- ## 0.7.1 - 2020-11-25
135
-
136
- ### Fixed
137
-
138
- - Fix error when no title element found.
139
-
140
- ## 0.7.0 - 2020-11-23
141
-
142
- ### Added
143
-
144
- - Convert JSON response into XML.
145
-
146
- ### Fixed
147
-
148
- - Fix bug that item_description_selector is not used.
149
-
150
- ## 0.6.1 - 2020-11-15
151
-
152
- ### Changed
153
-
154
- - Require hibana 0.2 or later.
155
-
156
- ### Fixed
157
-
158
- - Fix installation error caused by hanami-router version restriction.
159
-
160
- ### Removed
161
-
162
- - Remove direct dependency on hanami-router.
163
-
164
- ## 0.6.0 - 2020-11-15
165
-
166
- ### Changed
167
-
168
- - Change pages schema from Hash to Array.
169
- - Require hanami-router 2.0.0.alpha3 or later versions.
170
- - Ignore pubDate when item.time is not found.
171
- - Make some item_description_selector and item_time_selector optional.
172
-
173
- ## 0.5.0 - 2020-11-14
174
-
175
- ### Added
176
-
177
- - Add datetime attribute support on time element.
178
-
179
- ### Changed
180
-
181
- - Change schema format about selectors.
182
-
183
- ## 0.4.1 - 2020-11-08
184
-
185
- ### Fixed
186
-
187
- - Fix error when item description is not found.
188
-
189
- ## 0.4.0 - 2020-11-08
190
-
191
- ### Added
192
-
193
- - Add CSS selector support.
194
-
195
- ### Changed
196
-
197
- - Change schema key from `xpath` to `selectors`.
198
- - Change item_link_selector target from href attribute to a element.
199
- - Change some argument names from `_xpath` to `_selector`.
200
- - Change `weneedfeed build` description.
201
- - Change `weneedfeed server` description.
202
- - Change channel link from feed URL to top page URL.
203
- - Sort top page feeds by its title.
204
-
205
- ## 0.3.0 - 2020-11-08
206
-
207
- ### Added
208
-
209
- - Add channel description.
210
- - Add item description.
211
- - Add `weneedfeed build` command.
212
- - Add `weneedfeed server` command.
213
-
214
- ### Changed
215
-
216
- - Surround channel title by CDATA.
217
- - Change channel children order.
218
-
219
- ## 0.2.0 - 2020-11-07
220
-
221
- ### Changed
222
-
223
- - Change required ruby version from 2.4.0 to 2.5.0.
224
-
225
- ### Fixed
226
-
227
- - Fix feed URL when SCRIPT_NAME is used.
228
-
229
- ## 0.1.0 - 2020-10-29
230
-
231
- ### Added
232
-
233
- - 1st release.