rss_creator 0.3.7 → 0.4.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 +5 -5
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/lib/rss_creator.rb +62 -25
- metadata +36 -32
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 647757a294410e98e341314c9f85c097059161320456321ff8472deb90c363d6
|
4
|
+
data.tar.gz: 396951cc15ffcd5ae92790392a4ad139310acd35cdd2d7b1f59d0e15696a6bd2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 465c8405ef8d2f6ff853f418d35eaf4eb6d07f301f02664d31a59b41357a27486a49d5b159e8b941c69697b1464ec623dab641dcbcfd77612e704e9861565abd
|
7
|
+
data.tar.gz: 2308016cbad0de11a04ccfdbb2bfa2e345ac440700fedb7cea0c1f9aeac1164fc152fd0569fa8f55a69db3e82c32ac3695be5e0f003cc867a56bb54422263ef2
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/lib/rss_creator.rb
CHANGED
@@ -8,53 +8,62 @@ require 'rss_to_dynarex'
|
|
8
8
|
|
9
9
|
class RSScreator
|
10
10
|
|
11
|
-
attr_accessor :title, :description, :link, :limit, :xslt
|
11
|
+
attr_accessor :title, :description, :link, :limit, :xslt, :image_url,
|
12
|
+
:image_target_url
|
12
13
|
|
13
|
-
def initialize(filepath='rss.xml', dx_xslt: nil,
|
14
|
-
|
14
|
+
def initialize(filepath='rss.xml', dx_xslt: nil, dx_filename: 'feed.xml',
|
15
|
+
custom_fields: [], limit: 10, debug: false)
|
15
16
|
|
16
17
|
|
17
|
-
@filepath = filepath
|
18
|
+
@filepath, @debug = filepath, debug
|
18
19
|
|
19
20
|
dxfilepath = File.join(File.dirname(filepath), dx_filename)
|
20
21
|
|
21
22
|
if filepath and File.exists? dxfilepath then
|
22
|
-
|
23
|
+
|
23
24
|
@dx = Dynarex.new dxfilepath
|
24
25
|
@title, @description, @link = @dx.title, @dx.description, @dx.link
|
26
|
+
|
27
|
+
else
|
28
|
+
if filepath and File.exists? filepath
|
25
29
|
|
26
|
-
|
27
|
-
|
28
|
-
rtd = RSStoDynarex.new filepath
|
29
|
-
@dx = rtd.to_dynarex
|
30
|
+
rtd = RSStoDynarex.new filepath
|
31
|
+
@dx = rtd.to_dynarex
|
30
32
|
|
31
|
-
|
33
|
+
@title, @description, @link = @dx.title, @dx.description, @dx.link
|
32
34
|
|
33
|
-
|
35
|
+
else
|
36
|
+
|
34
37
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
38
|
+
schema = 'channel[title, description, link]/' + \
|
39
|
+
'item(title, link, description, date'
|
40
|
+
schema += ', ' + custom_fields.join(', ') if custom_fields.any?
|
41
|
+
schema += ')'
|
42
|
+
|
43
|
+
@dx = Dynarex.new schema
|
44
|
+
end
|
45
|
+
|
46
|
+
@dx.order = 'descending'
|
47
|
+
@dx.default_key = 'uid'
|
48
|
+
@dx.xslt = dx_xslt if dx_xslt
|
49
|
+
|
39
50
|
|
40
|
-
@dx = Dynarex.new schema
|
41
51
|
end
|
42
|
-
|
43
|
-
@dx.order = 'descending'
|
44
|
-
@dx.default_key = 'uid'
|
45
|
-
@dx.xslt = dx_xslt if dx_xslt
|
52
|
+
|
46
53
|
@dx.xslt_schema = 'channel[title:title,description:description,' + \
|
47
54
|
'link:link]/item(title:title,description:description,' + \
|
48
55
|
'link:link,pubDate:date)'
|
49
56
|
# maxium number of items saved in the RSS feed
|
50
|
-
@dx.limit = @limit =
|
57
|
+
@dx.limit = @limit = limit
|
58
|
+
|
59
|
+
|
51
60
|
@dirty = true
|
52
61
|
@dxfilename = dx_filename
|
53
62
|
|
54
63
|
end
|
55
64
|
|
56
|
-
def add(item
|
57
|
-
|
65
|
+
def add(item: {title: '', link: '', description: ''}, id: nil)
|
66
|
+
|
58
67
|
unless item[:title] and item[:link] then
|
59
68
|
raise 'RSScreator: title or link can\'t be blank'
|
60
69
|
end
|
@@ -77,6 +86,10 @@ class RSScreator
|
|
77
86
|
@description = val
|
78
87
|
@dirty = true
|
79
88
|
end
|
89
|
+
|
90
|
+
def delete(id)
|
91
|
+
@dx.delete id.to_s
|
92
|
+
end
|
80
93
|
|
81
94
|
alias desc= description=
|
82
95
|
alias desc description
|
@@ -84,6 +97,18 @@ class RSScreator
|
|
84
97
|
def dynarex()
|
85
98
|
@dx
|
86
99
|
end
|
100
|
+
|
101
|
+
def image_url=(val)
|
102
|
+
@image_url = val
|
103
|
+
@dirty = true
|
104
|
+
end
|
105
|
+
|
106
|
+
alias image= image_url=
|
107
|
+
|
108
|
+
def image_target_url=(val)
|
109
|
+
@image_target_url = val
|
110
|
+
@dirty = true
|
111
|
+
end
|
87
112
|
|
88
113
|
def link=(val)
|
89
114
|
@link = val
|
@@ -122,7 +147,19 @@ class RSScreator
|
|
122
147
|
|
123
148
|
else
|
124
149
|
|
125
|
-
@dx.to_rss({limit: @limit})
|
150
|
+
@dx.to_rss({limit: @limit}) do |doc|
|
151
|
+
|
152
|
+
if @image_url then
|
153
|
+
|
154
|
+
img = Rexle::Element.new('image')
|
155
|
+
img.add Rexle::Element.new('url').add_text @image_url
|
156
|
+
img.add Rexle::Element.new('link').add_text @image_target_url
|
157
|
+
|
158
|
+
doc.root.element('channel/item').insert_before img
|
159
|
+
|
160
|
+
end
|
161
|
+
|
162
|
+
end
|
126
163
|
|
127
164
|
end
|
128
165
|
|
@@ -131,4 +168,4 @@ class RSScreator
|
|
131
168
|
|
132
169
|
end
|
133
170
|
|
134
|
-
end
|
171
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rss_creator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Robertson
|
@@ -10,28 +10,32 @@ bindir: bin
|
|
10
10
|
cert_chain:
|
11
11
|
- |
|
12
12
|
-----BEGIN CERTIFICATE-----
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
13
|
+
MIIEXjCCAsagAwIBAgIBATANBgkqhkiG9w0BAQsFADAsMSowKAYDVQQDDCFnZW1t
|
14
|
+
YXN0ZXIvREM9amFtZXNyb2JlcnRzb24vREM9ZXUwHhcNMjEwMjI0MTEzNTE4WhcN
|
15
|
+
MjIwMjI0MTEzNTE4WjAsMSowKAYDVQQDDCFnZW1tYXN0ZXIvREM9amFtZXNyb2Jl
|
16
|
+
cnRzb24vREM9ZXUwggGiMA0GCSqGSIb3DQEBAQUAA4IBjwAwggGKAoIBgQC/EdPv
|
17
|
+
Z9PmSgZQ31H8hgTyVkC5Ww2VyrxJbX9LA2xX++xTEMm2LvLs4G9vGeNWiUpLdSZt
|
18
|
+
EkPMLX58IhDJoETYMF4UpAw/tOPMlvzrmM9vFTdsZXKXwTwS3blbWahUgRAlXWpV
|
19
|
+
pbNj+SQlnIZklZ8FR/rvXE98wAFO4IIldQcyuUi9ehrYfazpS6fOg3f3Yg6ffPMs
|
20
|
+
xWUmhF4zQs+J6utjoJeWyVHWwHFpcmzMIEcLbnGOsn6JHdPmDaCTyAWjbrTsbMRn
|
21
|
+
o4BHS81Mn9ao3FDOR+Rj/zxZJNwEoEdWtQXCqCRFtBNehODqjSGNEBlYQmG0gQJ1
|
22
|
+
2PiXAf8lcqVo2KJPMVPjMSwKDQKdf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|
+
date: 2021-02-24 00:00:00.000000000 Z
|
35
39
|
dependencies:
|
36
40
|
- !ruby/object:Gem::Dependency
|
37
41
|
name: rss_to_dynarex
|
@@ -57,24 +61,24 @@ dependencies:
|
|
57
61
|
name: rss_sliml
|
58
62
|
requirement: !ruby/object:Gem::Requirement
|
59
63
|
requirements:
|
60
|
-
- - "~>"
|
61
|
-
- !ruby/object:Gem::Version
|
62
|
-
version: '0.1'
|
63
64
|
- - ">="
|
64
65
|
- !ruby/object:Gem::Version
|
65
|
-
version: 0.
|
66
|
+
version: 0.2.0
|
67
|
+
- - "~>"
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0.2'
|
66
70
|
type: :runtime
|
67
71
|
prerelease: false
|
68
72
|
version_requirements: !ruby/object:Gem::Requirement
|
69
73
|
requirements:
|
70
|
-
- - "~>"
|
71
|
-
- !ruby/object:Gem::Version
|
72
|
-
version: '0.1'
|
73
74
|
- - ">="
|
74
75
|
- !ruby/object:Gem::Version
|
75
|
-
version: 0.
|
76
|
+
version: 0.2.0
|
77
|
+
- - "~>"
|
78
|
+
- !ruby/object:Gem::Version
|
79
|
+
version: '0.2'
|
76
80
|
description:
|
77
|
-
email:
|
81
|
+
email: digital.robertson@gmail.com
|
78
82
|
executables: []
|
79
83
|
extensions: []
|
80
84
|
extra_rdoc_files: []
|
@@ -100,7 +104,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
100
104
|
version: '0'
|
101
105
|
requirements: []
|
102
106
|
rubyforge_project:
|
103
|
-
rubygems_version: 2.
|
107
|
+
rubygems_version: 2.7.10
|
104
108
|
signing_key:
|
105
109
|
specification_version: 4
|
106
110
|
summary: A gem for creating RSS feeds
|
metadata.gz.sig
CHANGED
Binary file
|