rss_creator 0.4.2 → 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 +4 -4
- checksums.yaml.gz.sig +0 -0
- data/lib/rss_creator.rb +43 -42
- data.tar.gz.sig +0 -0
- metadata +2 -2
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
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,18 +7,19 @@ 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, :image_url,
|
|
12
|
+
attr_accessor :title, :description, :link, :limit, :xslt, :image_url,
|
|
12
13
|
:image_target_url
|
|
13
14
|
|
|
14
|
-
def initialize(filepath='rss.xml', dx_xslt: nil, dx_filename: 'feed.xml',
|
|
15
|
+
def initialize(filepath='rss.xml', dx_xslt: nil, dx_filename: 'feed.xml',
|
|
15
16
|
custom_fields: [], limit: 10, debug: false)
|
|
16
17
|
|
|
17
18
|
|
|
18
19
|
@filepath, @debug = filepath, debug
|
|
19
20
|
|
|
20
21
|
dxfilepath = File.join(File.dirname(filepath), dx_filename)
|
|
21
|
-
|
|
22
|
+
|
|
22
23
|
if filepath and File.exists? dxfilepath then
|
|
23
24
|
|
|
24
25
|
@dx = Dynarex.new dxfilepath
|
|
@@ -27,32 +28,32 @@ class RSScreator
|
|
|
27
28
|
|
|
28
29
|
else
|
|
29
30
|
if filepath and File.exists? filepath
|
|
30
|
-
|
|
31
|
+
|
|
31
32
|
rtd = RSStoDynarex.new filepath
|
|
32
33
|
@dx = rtd.to_dynarex
|
|
33
34
|
|
|
34
35
|
@title, @description, @link = @dx.title, @dx.description, @dx.link
|
|
35
36
|
@image_url = @dx.image if @dx.image and @dx.image.length > 1
|
|
36
37
|
@image_target_url = @link if @link and @link.length > 1
|
|
37
|
-
|
|
38
|
+
|
|
38
39
|
else
|
|
39
40
|
|
|
40
|
-
|
|
41
|
+
|
|
41
42
|
schema = 'channel[title, description, link, image]/' + \
|
|
42
43
|
'item(title, link, description, date'
|
|
43
44
|
schema += ', ' + custom_fields.join(', ') if custom_fields.any?
|
|
44
45
|
schema += ')'
|
|
45
|
-
|
|
46
|
+
|
|
46
47
|
@dx = Dynarex.new schema
|
|
47
48
|
end
|
|
48
49
|
|
|
49
|
-
@dx.order = 'descending'
|
|
50
|
+
@dx.order = 'descending'
|
|
50
51
|
@dx.default_key = 'uid'
|
|
51
|
-
@dx.xslt = dx_xslt if dx_xslt
|
|
52
|
+
@dx.xslt = dx_xslt if dx_xslt
|
|
53
|
+
|
|
52
54
|
|
|
53
|
-
|
|
54
55
|
end
|
|
55
|
-
|
|
56
|
+
|
|
56
57
|
@dx.xslt_schema = 'channel[title:title,description:description,' + \
|
|
57
58
|
'link:link]/item(title:title,description:description,' + \
|
|
58
59
|
'link:link,pubDate:date)'
|
|
@@ -65,31 +66,31 @@ class RSScreator
|
|
|
65
66
|
|
|
66
67
|
end
|
|
67
68
|
|
|
68
|
-
def add(
|
|
69
|
+
def add(itemx={title: '', link: '', description: ''}, item: itemx, id: nil)
|
|
69
70
|
|
|
70
71
|
unless item[:title] and item[:link] then
|
|
71
|
-
raise 'RSScreator: title or link can\'t be blank'
|
|
72
|
+
raise 'RSScreator: title or link can\'t be blank'
|
|
72
73
|
end
|
|
73
|
-
|
|
74
|
+
|
|
74
75
|
record = {date: Time.now.strftime("%a, %d %b %Y %H:%M:%S %z")}.merge(item)
|
|
75
76
|
@dx.create(record, id: id)
|
|
76
|
-
|
|
77
|
+
|
|
77
78
|
@dirty = true
|
|
78
|
-
|
|
79
|
+
|
|
79
80
|
end
|
|
80
81
|
|
|
81
82
|
def save(new_filepath=nil)
|
|
82
83
|
|
|
83
84
|
filepath = new_filepath ? new_filepath : @filepath
|
|
84
|
-
|
|
85
|
+
FileX.write filepath, print_rss
|
|
85
86
|
@dx.save File.join(File.dirname(filepath), @dxfilename) if @dxfilename
|
|
86
87
|
end
|
|
87
|
-
|
|
88
|
+
|
|
88
89
|
def description=(val)
|
|
89
90
|
@description = val
|
|
90
91
|
@dirty = true
|
|
91
92
|
end
|
|
92
|
-
|
|
93
|
+
|
|
93
94
|
def delete(id)
|
|
94
95
|
@dx.delete id.to_s
|
|
95
96
|
end
|
|
@@ -100,24 +101,24 @@ class RSScreator
|
|
|
100
101
|
def dynarex()
|
|
101
102
|
@dx
|
|
102
103
|
end
|
|
103
|
-
|
|
104
|
+
|
|
104
105
|
def image_url=(val)
|
|
105
106
|
@image_url = val
|
|
106
107
|
@dirty = true
|
|
107
108
|
end
|
|
108
|
-
|
|
109
|
+
|
|
109
110
|
alias image= image_url=
|
|
110
|
-
|
|
111
|
+
|
|
111
112
|
def image_target_url=(val)
|
|
112
113
|
@image_target_url = val
|
|
113
114
|
@dirty = true
|
|
114
|
-
end
|
|
115
|
+
end
|
|
115
116
|
|
|
116
117
|
def link=(val)
|
|
117
118
|
@link = val
|
|
118
119
|
@dirty = true
|
|
119
|
-
end
|
|
120
|
-
|
|
120
|
+
end
|
|
121
|
+
|
|
121
122
|
def title=(val)
|
|
122
123
|
@title = val
|
|
123
124
|
@dirty = true
|
|
@@ -130,43 +131,43 @@ class RSScreator
|
|
|
130
131
|
private
|
|
131
132
|
|
|
132
133
|
def print_rss()
|
|
133
|
-
|
|
134
|
+
|
|
134
135
|
return @rss unless @dirty
|
|
135
136
|
|
|
136
137
|
if @title.nil? or @description.nil? then
|
|
137
|
-
raise 'RSScreator: title or description can\'t be blank'
|
|
138
|
+
raise 'RSScreator: title or description can\'t be blank'
|
|
138
139
|
end
|
|
139
140
|
|
|
140
141
|
@dx.title, @dx.description, @dx.link = @title, @description, @link || ''
|
|
141
142
|
@dx.image = @image_url if @dx.respond_to? :image
|
|
142
|
-
|
|
143
|
+
|
|
143
144
|
@rss = if @xslt then
|
|
144
|
-
|
|
145
|
+
|
|
145
146
|
@dx.to_rss({limit: @limit}) do |doc|
|
|
146
|
-
|
|
147
|
+
|
|
147
148
|
doc.instructions << ['xml-stylesheet',\
|
|
148
149
|
"title='XSL_formatting' type='text/xsl' href='#{@xslt}'"]
|
|
149
|
-
|
|
150
|
-
end
|
|
151
|
-
|
|
150
|
+
|
|
151
|
+
end
|
|
152
|
+
|
|
152
153
|
else
|
|
153
|
-
|
|
154
|
+
|
|
154
155
|
@dx.to_rss({limit: @limit}) do |doc|
|
|
155
|
-
|
|
156
|
+
|
|
156
157
|
if @image_url then
|
|
157
|
-
|
|
158
|
+
|
|
158
159
|
img = Rexle::Element.new('image')
|
|
159
160
|
img.add Rexle::Element.new('url').add_text @image_url
|
|
160
161
|
img.add Rexle::Element.new('link').add_text @image_target_url
|
|
161
|
-
|
|
162
|
+
|
|
162
163
|
doc.root.element('channel/item').insert_before img
|
|
163
|
-
|
|
164
|
-
end
|
|
165
|
-
|
|
164
|
+
|
|
165
|
+
end
|
|
166
|
+
|
|
166
167
|
end
|
|
167
|
-
|
|
168
|
+
|
|
168
169
|
end
|
|
169
|
-
|
|
170
|
+
|
|
170
171
|
@dirty = false
|
|
171
172
|
@rss
|
|
172
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
|
|
@@ -35,7 +35,7 @@ cert_chain:
|
|
|
35
35
|
CmoNNvIZ3zS4vUkMoFR7S0bXN/xdxzLVn5uGLJ8FwP76BqKlR2+xV5Bj+40hyMDP
|
|
36
36
|
s+qwrtoA3kBtGhpVjCn/TE5q
|
|
37
37
|
-----END CERTIFICATE-----
|
|
38
|
-
date:
|
|
38
|
+
date: 2022-01-17 00:00:00.000000000 Z
|
|
39
39
|
dependencies:
|
|
40
40
|
- !ruby/object:Gem::Dependency
|
|
41
41
|
name: rss_to_dynarex
|
metadata.gz.sig
CHANGED
|
Binary file
|