rss_creator 0.3.11 → 0.5.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/lib/rss_creator.rb +66 -36
- data.tar.gz.sig +0 -0
- metadata +36 -31
- 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: 2953523eae0c1cb5f12dc29fae51dc7447649c04e04d666b1400d2c1e6bfdc94
|
4
|
+
data.tar.gz: c13d015c8d922c498d14e398bd7910a8e8ba50d376393c5e887e638acd09e259
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3918f5754234ff6e513bcb4d0367b85a66076300ca3a6bd9986743c0f5a401944ab3fc63e06e4cf6affd1ebf70b3df2b67b83afae54b1dabb7307a4bd81fd170
|
7
|
+
data.tar.gz: 4ca1d32ee4b26e1b1e240a8b9578819f4e68034e984e3d0337a93d66c19b48a91e7dee86be0a98189c334de59c2247460a972b2b9c431a05ff17e95b2395ce9b
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/lib/rss_creator.rb
CHANGED
@@ -7,48 +7,53 @@ require 'rss_to_dynarex'
|
|
7
7
|
|
8
8
|
|
9
9
|
class RSScreator
|
10
|
+
include RXFHelperModule
|
10
11
|
|
11
|
-
attr_accessor :title, :description, :link, :limit, :xslt
|
12
|
+
attr_accessor :title, :description, :link, :limit, :xslt, :image_url,
|
13
|
+
:image_target_url
|
12
14
|
|
13
|
-
def initialize(filepath='rss.xml', dx_xslt: nil,
|
14
|
-
|
15
|
+
def initialize(filepath='rss.xml', dx_xslt: nil, dx_filename: 'feed.xml',
|
16
|
+
custom_fields: [], limit: 10, debug: false)
|
15
17
|
|
16
18
|
|
17
|
-
@filepath = filepath
|
19
|
+
@filepath, @debug = filepath, debug
|
18
20
|
|
19
21
|
dxfilepath = File.join(File.dirname(filepath), dx_filename)
|
20
|
-
|
22
|
+
|
21
23
|
if filepath and File.exists? dxfilepath then
|
22
24
|
|
23
25
|
@dx = Dynarex.new dxfilepath
|
24
26
|
@title, @description, @link = @dx.title, @dx.description, @dx.link
|
27
|
+
@image_url = @dx.image
|
25
28
|
|
26
29
|
else
|
27
30
|
if filepath and File.exists? filepath
|
28
|
-
|
31
|
+
|
29
32
|
rtd = RSStoDynarex.new filepath
|
30
33
|
@dx = rtd.to_dynarex
|
31
34
|
|
32
35
|
@title, @description, @link = @dx.title, @dx.description, @dx.link
|
33
|
-
|
36
|
+
@image_url = @dx.image if @dx.image and @dx.image.length > 1
|
37
|
+
@image_target_url = @link if @link and @link.length > 1
|
38
|
+
|
34
39
|
else
|
35
40
|
|
36
|
-
|
37
|
-
schema = 'channel[title, description, link]/' + \
|
41
|
+
|
42
|
+
schema = 'channel[title, description, link, image]/' + \
|
38
43
|
'item(title, link, description, date'
|
39
44
|
schema += ', ' + custom_fields.join(', ') if custom_fields.any?
|
40
45
|
schema += ')'
|
41
|
-
|
46
|
+
|
42
47
|
@dx = Dynarex.new schema
|
43
48
|
end
|
44
49
|
|
45
|
-
@dx.order = 'descending'
|
50
|
+
@dx.order = 'descending'
|
46
51
|
@dx.default_key = 'uid'
|
47
|
-
@dx.xslt = dx_xslt if dx_xslt
|
52
|
+
@dx.xslt = dx_xslt if dx_xslt
|
53
|
+
|
48
54
|
|
49
|
-
|
50
55
|
end
|
51
|
-
|
56
|
+
|
52
57
|
@dx.xslt_schema = 'channel[title:title,description:description,' + \
|
53
58
|
'link:link]/item(title:title,description:description,' + \
|
54
59
|
'link:link,pubDate:date)'
|
@@ -61,31 +66,31 @@ class RSScreator
|
|
61
66
|
|
62
67
|
end
|
63
68
|
|
64
|
-
def add(
|
69
|
+
def add(itemx={title: '', link: '', description: ''}, item: itemx, id: nil)
|
65
70
|
|
66
71
|
unless item[:title] and item[:link] then
|
67
|
-
raise 'RSScreator: title or link can\'t be blank'
|
72
|
+
raise 'RSScreator: title or link can\'t be blank'
|
68
73
|
end
|
69
|
-
|
74
|
+
|
70
75
|
record = {date: Time.now.strftime("%a, %d %b %Y %H:%M:%S %z")}.merge(item)
|
71
76
|
@dx.create(record, id: id)
|
72
|
-
|
77
|
+
|
73
78
|
@dirty = true
|
74
|
-
|
79
|
+
|
75
80
|
end
|
76
81
|
|
77
82
|
def save(new_filepath=nil)
|
78
83
|
|
79
84
|
filepath = new_filepath ? new_filepath : @filepath
|
80
|
-
|
85
|
+
FileX.write filepath, print_rss
|
81
86
|
@dx.save File.join(File.dirname(filepath), @dxfilename) if @dxfilename
|
82
87
|
end
|
83
|
-
|
88
|
+
|
84
89
|
def description=(val)
|
85
90
|
@description = val
|
86
91
|
@dirty = true
|
87
92
|
end
|
88
|
-
|
93
|
+
|
89
94
|
def delete(id)
|
90
95
|
@dx.delete id.to_s
|
91
96
|
end
|
@@ -97,11 +102,23 @@ class RSScreator
|
|
97
102
|
@dx
|
98
103
|
end
|
99
104
|
|
105
|
+
def image_url=(val)
|
106
|
+
@image_url = val
|
107
|
+
@dirty = true
|
108
|
+
end
|
109
|
+
|
110
|
+
alias image= image_url=
|
111
|
+
|
112
|
+
def image_target_url=(val)
|
113
|
+
@image_target_url = val
|
114
|
+
@dirty = true
|
115
|
+
end
|
116
|
+
|
100
117
|
def link=(val)
|
101
118
|
@link = val
|
102
119
|
@dirty = true
|
103
|
-
end
|
104
|
-
|
120
|
+
end
|
121
|
+
|
105
122
|
def title=(val)
|
106
123
|
@title = val
|
107
124
|
@dirty = true
|
@@ -114,30 +131,43 @@ class RSScreator
|
|
114
131
|
private
|
115
132
|
|
116
133
|
def print_rss()
|
117
|
-
|
134
|
+
|
118
135
|
return @rss unless @dirty
|
119
136
|
|
120
137
|
if @title.nil? or @description.nil? then
|
121
|
-
raise 'RSScreator: title or description can\'t be blank'
|
138
|
+
raise 'RSScreator: title or description can\'t be blank'
|
122
139
|
end
|
123
140
|
|
124
141
|
@dx.title, @dx.description, @dx.link = @title, @description, @link || ''
|
125
|
-
|
142
|
+
@dx.image = @image_url if @dx.respond_to? :image
|
143
|
+
|
126
144
|
@rss = if @xslt then
|
127
|
-
|
145
|
+
|
128
146
|
@dx.to_rss({limit: @limit}) do |doc|
|
129
|
-
|
147
|
+
|
130
148
|
doc.instructions << ['xml-stylesheet',\
|
131
149
|
"title='XSL_formatting' type='text/xsl' href='#{@xslt}'"]
|
132
|
-
|
133
|
-
end
|
134
|
-
|
150
|
+
|
151
|
+
end
|
152
|
+
|
135
153
|
else
|
136
|
-
|
137
|
-
@dx.to_rss({limit: @limit})
|
138
|
-
|
154
|
+
|
155
|
+
@dx.to_rss({limit: @limit}) do |doc|
|
156
|
+
|
157
|
+
if @image_url then
|
158
|
+
|
159
|
+
img = Rexle::Element.new('image')
|
160
|
+
img.add Rexle::Element.new('url').add_text @image_url
|
161
|
+
img.add Rexle::Element.new('link').add_text @image_target_url
|
162
|
+
|
163
|
+
doc.root.element('channel/item').insert_before img
|
164
|
+
|
165
|
+
end
|
166
|
+
|
167
|
+
end
|
168
|
+
|
139
169
|
end
|
140
|
-
|
170
|
+
|
141
171
|
@dirty = false
|
142
172
|
@rss
|
143
173
|
|
data.tar.gz.sig
CHANGED
Binary file
|
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.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Robertson
|
@@ -10,27 +10,32 @@ bindir: bin
|
|
10
10
|
cert_chain:
|
11
11
|
- |
|
12
12
|
-----BEGIN CERTIFICATE-----
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
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dMUsJgwJgYDVR0RBB8wHYEbZ2VtbWFzdGVyQGphbWVzcm9iZXJ0
|
27
|
+
c29uLmV1MCYGA1UdEgQfMB2BG2dlbW1hc3RlckBqYW1lc3JvYmVydHNvbi5ldTAN
|
28
|
+
BgkqhkiG9w0BAQsFAAOCAYEAo0n6mqehv/bgKVFYMGIfB/tq2NKDBvELxb8LRVpZ
|
29
|
+
NS4iZKtM+N5OD+zmxM8bseB08B2Yxks9y1997X5wVWWdK54oJej5qSVomfHQIqTh
|
30
|
+
Fg8+FDZk6gkDBTIia5jZOK+s9AUxoYpftcorQOio3liFq+yCqW+s6hP64RkY94sR
|
31
|
+
voFGWhBW0WG1QEGqkqUHTit2G70yBhhIp/rm7WsyG5aRuzPONcyLY8VFXhSINKmj
|
32
|
+
0Y+xZNDlcsrWogXVkGsZ0PoRNZZ4g4iyErPMwE452ObevrSVrIwbpNtsEdELB3nT
|
33
|
+
GhAiUqHiF6mNOkTz5Rj+RnhU07eAcTtHI+EesCu+U0UwvV0NAWG9/E/FkHO0a5Zj
|
34
|
+
GoDraKZUzvcj/SsP13HRpvscyV1L0cxGWubkEtJYKFGKlkjHU1WdV3xLvWLQSquN
|
35
|
+
CmoNNvIZ3zS4vUkMoFR7S0bXN/xdxzLVn5uGLJ8FwP76BqKlR2+xV5Bj+40hyMDP
|
36
|
+
s+qwrtoA3kBtGhpVjCn/TE5q
|
32
37
|
-----END CERTIFICATE-----
|
33
|
-
date:
|
38
|
+
date: 2022-01-17 00:00:00.000000000 Z
|
34
39
|
dependencies:
|
35
40
|
- !ruby/object:Gem::Dependency
|
36
41
|
name: rss_to_dynarex
|
@@ -56,24 +61,24 @@ dependencies:
|
|
56
61
|
name: rss_sliml
|
57
62
|
requirement: !ruby/object:Gem::Requirement
|
58
63
|
requirements:
|
59
|
-
- - "~>"
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '0.1'
|
62
64
|
- - ">="
|
63
65
|
- !ruby/object:Gem::Version
|
64
|
-
version: 0.
|
66
|
+
version: 0.2.0
|
67
|
+
- - "~>"
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0.2'
|
65
70
|
type: :runtime
|
66
71
|
prerelease: false
|
67
72
|
version_requirements: !ruby/object:Gem::Requirement
|
68
73
|
requirements:
|
69
|
-
- - "~>"
|
70
|
-
- !ruby/object:Gem::Version
|
71
|
-
version: '0.1'
|
72
74
|
- - ">="
|
73
75
|
- !ruby/object:Gem::Version
|
74
|
-
version: 0.
|
76
|
+
version: 0.2.0
|
77
|
+
- - "~>"
|
78
|
+
- !ruby/object:Gem::Version
|
79
|
+
version: '0.2'
|
75
80
|
description:
|
76
|
-
email:
|
81
|
+
email: digital.robertson@gmail.com
|
77
82
|
executables: []
|
78
83
|
extensions: []
|
79
84
|
extra_rdoc_files: []
|
@@ -99,7 +104,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
99
104
|
version: '0'
|
100
105
|
requirements: []
|
101
106
|
rubyforge_project:
|
102
|
-
rubygems_version: 2.
|
107
|
+
rubygems_version: 2.7.10
|
103
108
|
signing_key:
|
104
109
|
specification_version: 4
|
105
110
|
summary: A gem for creating RSS feeds
|
metadata.gz.sig
CHANGED
Binary file
|