weneedfeed 0.12.0 → 0.15.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +18 -0
- data/Gemfile.lock +5 -1
- data/lib/weneedfeed/application.rb +3 -3
- data/lib/weneedfeed/capture.rb +1 -7
- data/lib/weneedfeed/command.rb +1 -3
- data/lib/weneedfeed/item.rb +16 -3
- data/lib/weneedfeed/schema.rb +11 -0
- data/lib/weneedfeed/version.rb +1 -1
- data/templates/show_feed.xml.erb +1 -1
- data/weneedfeed.gemspec +1 -0
- metadata +19 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 819bba3695f6ec96a66d4a2eca1521ffd70362061267ae43278bc9e2a50263f7
|
4
|
+
data.tar.gz: bfe94358ddedce6a9d2fc029c1cef72b7672e6dd29c1a0de7c7ad9535f9b4d74
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f6cf9a9347388458458b433b0397f942b1a1db30712d5cc35155b90ef5ccda42e23eb2dcf5e264b8440fb2cec1b74ba14886718da840824da012f043a5f899fe
|
7
|
+
data.tar.gz: 978321586272751213ac40ad55fb4907c868e9e893985b3464be7d8d6e0f8af28242d341f35af9b4bba50708208a0fdc20904c4e00821ab10ad045b8735525f9
|
data/CHANGELOG.md
CHANGED
@@ -7,6 +7,24 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
7
7
|
|
8
8
|
## Unreleased
|
9
9
|
|
10
|
+
## 0.15.0 - 2022-04-14
|
11
|
+
|
12
|
+
### Changed
|
13
|
+
|
14
|
+
- Use hashed title and content as guid fallback.
|
15
|
+
|
16
|
+
## 0.14.0 - 2022-04-14
|
17
|
+
|
18
|
+
### Added
|
19
|
+
|
20
|
+
- Support YAML aliases (on psych 4.x).
|
21
|
+
|
22
|
+
## 0.13.0 - 2022-04-14
|
23
|
+
|
24
|
+
### Changed
|
25
|
+
|
26
|
+
- Normalize item URLs.
|
27
|
+
|
10
28
|
## 0.12.0 - 2022-04-14
|
11
29
|
|
12
30
|
### Fixed
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
weneedfeed (0.
|
4
|
+
weneedfeed (0.15.0)
|
5
5
|
activesupport
|
6
6
|
addressable
|
7
7
|
builder
|
@@ -10,6 +10,7 @@ PATH
|
|
10
10
|
hibana (>= 0.2)
|
11
11
|
marcel
|
12
12
|
nokogiri
|
13
|
+
psych (>= 4)
|
13
14
|
rack-capture (>= 0.4.0)
|
14
15
|
thor
|
15
16
|
|
@@ -81,6 +82,8 @@ GEM
|
|
81
82
|
parallel (1.22.1)
|
82
83
|
parser (3.1.2.0)
|
83
84
|
ast (~> 2.4.1)
|
85
|
+
psych (4.0.3)
|
86
|
+
stringio
|
84
87
|
public_suffix (4.0.7)
|
85
88
|
racc (1.6.0)
|
86
89
|
rack (2.2.3)
|
@@ -122,6 +125,7 @@ GEM
|
|
122
125
|
rubocop (~> 1.19)
|
123
126
|
ruby-progressbar (1.11.0)
|
124
127
|
ruby2_keywords (0.0.5)
|
128
|
+
stringio (3.0.1)
|
125
129
|
thor (1.2.1)
|
126
130
|
tilt (2.0.10)
|
127
131
|
tzinfo (2.0.4)
|
@@ -9,9 +9,9 @@ module Weneedfeed
|
|
9
9
|
get '/feeds/:page_id.xml', to: ::Weneedfeed::Controllers::ShowFeed, as: :feed
|
10
10
|
end
|
11
11
|
|
12
|
-
# @param [
|
13
|
-
def initialize(
|
14
|
-
@schema = ::Weneedfeed::Schema.
|
12
|
+
# @param [String] schema_path
|
13
|
+
def initialize(schema_path:)
|
14
|
+
@schema = ::Weneedfeed::Schema.load_file(schema_path)
|
15
15
|
super()
|
16
16
|
end
|
17
17
|
|
data/lib/weneedfeed/capture.rb
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'rack/capture'
|
4
|
-
require 'yaml'
|
5
4
|
|
6
5
|
module Weneedfeed
|
7
6
|
class Capture
|
@@ -44,7 +43,7 @@ module Weneedfeed
|
|
44
43
|
# @return [Weneedfeed::Application]
|
45
44
|
def app
|
46
45
|
@app ||= ::Weneedfeed::Application.new(
|
47
|
-
|
46
|
+
schema_path: @schema_path
|
48
47
|
)
|
49
48
|
end
|
50
49
|
|
@@ -53,11 +52,6 @@ module Weneedfeed
|
|
53
52
|
@base_uri ||= ::URI.parse(@base_url)
|
54
53
|
end
|
55
54
|
|
56
|
-
# @return [Hash]
|
57
|
-
def schema
|
58
|
-
::YAML.load_file(@schema_path)
|
59
|
-
end
|
60
|
-
|
61
55
|
# @return [String]
|
62
56
|
def script_name
|
63
57
|
case base_uri.path
|
data/lib/weneedfeed/command.rb
CHANGED
@@ -2,7 +2,6 @@
|
|
2
2
|
|
3
3
|
require 'rack'
|
4
4
|
require 'thor'
|
5
|
-
require 'yaml'
|
6
5
|
|
7
6
|
module Weneedfeed
|
8
7
|
class Command < ::Thor
|
@@ -55,8 +54,7 @@ module Weneedfeed
|
|
55
54
|
)
|
56
55
|
|
57
56
|
def server
|
58
|
-
|
59
|
-
application = Weneedfeed::Application.new(schema: schema)
|
57
|
+
application = Weneedfeed::Application.new(schema_path: options[:schema_path])
|
60
58
|
::Rack::Handler.default.run(application)
|
61
59
|
end
|
62
60
|
end
|
data/lib/weneedfeed/item.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'addressable'
|
4
|
+
require 'digest/sha1'
|
4
5
|
require 'marcel'
|
5
6
|
|
6
7
|
module Weneedfeed
|
@@ -50,6 +51,11 @@ module Weneedfeed
|
|
50
51
|
@node.at(@description_selector)&.inner_html
|
51
52
|
end
|
52
53
|
|
54
|
+
# @return [String]
|
55
|
+
def guid
|
56
|
+
link || hashed_title_and_description
|
57
|
+
end
|
58
|
+
|
53
59
|
# @return [String, nil]
|
54
60
|
def image_mime_type
|
55
61
|
return unless image_url
|
@@ -77,17 +83,17 @@ module Weneedfeed
|
|
77
83
|
::Addressable::URI.join(
|
78
84
|
@url,
|
79
85
|
image_path_or_url
|
80
|
-
).to_s
|
86
|
+
).normalize.to_s
|
81
87
|
end
|
82
88
|
|
83
|
-
# @return [String]
|
89
|
+
# @return [String, nil]
|
84
90
|
def link
|
85
91
|
return unless link_path_or_url
|
86
92
|
|
87
93
|
::Addressable::URI.join(
|
88
94
|
@url,
|
89
95
|
link_path_or_url
|
90
|
-
).to_s
|
96
|
+
).normalize.to_s
|
91
97
|
end
|
92
98
|
|
93
99
|
# @return [Nokogiri::Node, nil]
|
@@ -120,6 +126,13 @@ module Weneedfeed
|
|
120
126
|
|
121
127
|
private
|
122
128
|
|
129
|
+
# @return [String]
|
130
|
+
def hashed_title_and_description
|
131
|
+
source = [title, description].join(':')
|
132
|
+
sha1 = ::Digest::SHA1.hexdigest(source)
|
133
|
+
"urn:sha1:#{sha1}"
|
134
|
+
end
|
135
|
+
|
123
136
|
# @return [Nokogiri::Node, nil]
|
124
137
|
def time_node
|
125
138
|
@node.at(@time_selector)
|
data/lib/weneedfeed/schema.rb
CHANGED
@@ -1,7 +1,18 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require 'yaml'
|
4
|
+
|
3
5
|
module Weneedfeed
|
4
6
|
class Schema
|
7
|
+
class << self
|
8
|
+
# @param [String] schema_path
|
9
|
+
# @return [Weneedfeed::Schema]
|
10
|
+
def load_file(schema_path)
|
11
|
+
raw = ::YAML.load_file(schema_path, aliases: true)
|
12
|
+
new(raw)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
5
16
|
# @param [Hash] raw
|
6
17
|
def initialize(raw)
|
7
18
|
@raw = raw
|
data/lib/weneedfeed/version.rb
CHANGED
data/templates/show_feed.xml.erb
CHANGED
@@ -17,7 +17,7 @@
|
|
17
17
|
<% end %>
|
18
18
|
<description><![CDATA[<%= item.description %>]]></description>
|
19
19
|
<content:encoded><![CDATA[<%= item.description %>]]></content:encoded>
|
20
|
-
<guid isPermaLink="true"><%= item.
|
20
|
+
<guid isPermaLink="true"><%= item.guid %></guid>
|
21
21
|
<% if item.image_url %>
|
22
22
|
<enclosure url=<%= item.image_url.encode(xml: :attr) %> length="0" type="<%= item.image_mime_type %>"/>
|
23
23
|
<% end %>
|
data/weneedfeed.gemspec
CHANGED
@@ -35,6 +35,7 @@ Gem::Specification.new do |spec|
|
|
35
35
|
spec.add_runtime_dependency 'hibana', '>= 0.2'
|
36
36
|
spec.add_runtime_dependency 'marcel'
|
37
37
|
spec.add_runtime_dependency 'nokogiri'
|
38
|
+
spec.add_runtime_dependency 'psych', '>= 4'
|
38
39
|
spec.add_runtime_dependency 'rack-capture', '>= 0.4.0'
|
39
40
|
spec.add_runtime_dependency 'thor'
|
40
41
|
end
|
metadata
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: weneedfeed
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.15.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryo Nakamura
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
11
|
date: 2022-04-14 00:00:00.000000000 Z
|
@@ -122,6 +122,20 @@ dependencies:
|
|
122
122
|
- - ">="
|
123
123
|
- !ruby/object:Gem::Version
|
124
124
|
version: '0'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: psych
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - ">="
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '4'
|
132
|
+
type: :runtime
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - ">="
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '4'
|
125
139
|
- !ruby/object:Gem::Dependency
|
126
140
|
name: rack-capture
|
127
141
|
requirement: !ruby/object:Gem::Requirement
|
@@ -150,7 +164,7 @@ dependencies:
|
|
150
164
|
- - ">="
|
151
165
|
- !ruby/object:Gem::Version
|
152
166
|
version: '0'
|
153
|
-
description:
|
167
|
+
description:
|
154
168
|
email:
|
155
169
|
- r7kamura@gmail.com
|
156
170
|
executables:
|
@@ -201,7 +215,7 @@ metadata:
|
|
201
215
|
homepage_uri: https://github.com/r7kamura/weneedfeed
|
202
216
|
source_code_uri: https://github.com/r7kamura/weneedfeed
|
203
217
|
rubygems_mfa_required: 'true'
|
204
|
-
post_install_message:
|
218
|
+
post_install_message:
|
205
219
|
rdoc_options: []
|
206
220
|
require_paths:
|
207
221
|
- lib
|
@@ -217,7 +231,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
217
231
|
version: '0'
|
218
232
|
requirements: []
|
219
233
|
rubygems_version: 3.1.4
|
220
|
-
signing_key:
|
234
|
+
signing_key:
|
221
235
|
specification_version: 4
|
222
236
|
summary: Generate feeds from URL and selectors.
|
223
237
|
test_files: []
|