rss_creator 0.4.2 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +2 -3
- data/lib/rss_creator.rb +49 -46
- data.tar.gz.sig +0 -0
- metadata +13 -14
- 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: f63f706ec5787caf10560fc4613d9e5d39b250a509d405d0e01ecadb6e929136
|
4
|
+
data.tar.gz: 837e62756235a56f0cfd03f395fcc99b88860cad04f7b5598a58ea9c4a561233
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 96e3a748827858a09f27d3cd949b6b5852512b98c1449bd72ae9ba7e3f90cf4bc3a411c14ba83ffae405d8e8de7251a1eed6d891d278e736e8947e236cca69b9
|
7
|
+
data.tar.gz: fd03f1600aeb8ea4933d5b3bd9ef7e257a035434c69ba25bf0365c30599fddadb72d4a5eb8143e238897e92dec998e4ee63af99b71ec877b8bc27362bcb20518
|
checksums.yaml.gz.sig
CHANGED
@@ -1,3 +1,2 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
3���[��tZ�\ZQ2V�PfE���q.�l2��� �VKs�wo��,�P���\I3Q�v0�O�'�SPS䎴5"���&/�Ҍe��q��{�g-;���P�QEě�ޮLH)[ei�O�ߘ��-�F��)B1
|
1
|
+
H}�"L�7�T��
|
2
|
+
��GX#X*�'�a���X��7B_�����
|
data/lib/rss_creator.rb
CHANGED
@@ -7,52 +7,53 @@ require 'rss_to_dynarex'
|
|
7
7
|
|
8
8
|
|
9
9
|
class RSScreator
|
10
|
+
include RXFReadWriteModule
|
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
|
-
custom_fields: [], limit: 10, debug: false)
|
15
|
+
def initialize(filepath='rss.xml', dx_xslt: nil, dx_filename: 'feed.xml',
|
16
|
+
custom_fields: [], limit: 10, log: nil, debug: false)
|
16
17
|
|
17
18
|
|
18
|
-
@filepath, @debug = filepath, debug
|
19
|
+
@filepath, @log, @debug = filepath, log, debug
|
19
20
|
|
20
21
|
dxfilepath = File.join(File.dirname(filepath), dx_filename)
|
21
|
-
|
22
|
-
if filepath and
|
22
|
+
|
23
|
+
if filepath and FileX.exists? dxfilepath then
|
23
24
|
|
24
25
|
@dx = Dynarex.new dxfilepath
|
25
26
|
@title, @description, @link = @dx.title, @dx.description, @dx.link
|
26
27
|
@image_url = @dx.image
|
27
28
|
|
28
29
|
else
|
29
|
-
if filepath and
|
30
|
-
|
30
|
+
if filepath and FileX.exists? filepath
|
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,33 @@ class RSScreator
|
|
65
66
|
|
66
67
|
end
|
67
68
|
|
68
|
-
def add(
|
69
|
+
def add(itemx={title: '', link: '', description: ''}, item: itemx, id: nil)
|
70
|
+
|
71
|
+
@log.debug 'RssCreator#add item: ' + item.inspect if @log
|
69
72
|
|
70
73
|
unless item[:title] and item[:link] then
|
71
|
-
raise 'RSScreator: title or link can\'t be blank'
|
74
|
+
raise 'RSScreator: title or link can\'t be blank'
|
72
75
|
end
|
73
|
-
|
76
|
+
|
74
77
|
record = {date: Time.now.strftime("%a, %d %b %Y %H:%M:%S %z")}.merge(item)
|
75
78
|
@dx.create(record, id: id)
|
76
|
-
|
79
|
+
|
77
80
|
@dirty = true
|
78
|
-
|
81
|
+
|
79
82
|
end
|
80
83
|
|
81
84
|
def save(new_filepath=nil)
|
82
85
|
|
83
86
|
filepath = new_filepath ? new_filepath : @filepath
|
84
|
-
|
87
|
+
FileX.write filepath, print_rss
|
85
88
|
@dx.save File.join(File.dirname(filepath), @dxfilename) if @dxfilename
|
86
89
|
end
|
87
|
-
|
90
|
+
|
88
91
|
def description=(val)
|
89
92
|
@description = val
|
90
93
|
@dirty = true
|
91
94
|
end
|
92
|
-
|
95
|
+
|
93
96
|
def delete(id)
|
94
97
|
@dx.delete id.to_s
|
95
98
|
end
|
@@ -100,24 +103,24 @@ class RSScreator
|
|
100
103
|
def dynarex()
|
101
104
|
@dx
|
102
105
|
end
|
103
|
-
|
106
|
+
|
104
107
|
def image_url=(val)
|
105
108
|
@image_url = val
|
106
109
|
@dirty = true
|
107
110
|
end
|
108
|
-
|
111
|
+
|
109
112
|
alias image= image_url=
|
110
|
-
|
113
|
+
|
111
114
|
def image_target_url=(val)
|
112
115
|
@image_target_url = val
|
113
116
|
@dirty = true
|
114
|
-
end
|
117
|
+
end
|
115
118
|
|
116
119
|
def link=(val)
|
117
120
|
@link = val
|
118
121
|
@dirty = true
|
119
|
-
end
|
120
|
-
|
122
|
+
end
|
123
|
+
|
121
124
|
def title=(val)
|
122
125
|
@title = val
|
123
126
|
@dirty = true
|
@@ -130,43 +133,43 @@ class RSScreator
|
|
130
133
|
private
|
131
134
|
|
132
135
|
def print_rss()
|
133
|
-
|
136
|
+
|
134
137
|
return @rss unless @dirty
|
135
138
|
|
136
139
|
if @title.nil? or @description.nil? then
|
137
|
-
raise 'RSScreator: title or description can\'t be blank'
|
140
|
+
raise 'RSScreator: title or description can\'t be blank'
|
138
141
|
end
|
139
142
|
|
140
143
|
@dx.title, @dx.description, @dx.link = @title, @description, @link || ''
|
141
144
|
@dx.image = @image_url if @dx.respond_to? :image
|
142
|
-
|
145
|
+
|
143
146
|
@rss = if @xslt then
|
144
|
-
|
147
|
+
|
145
148
|
@dx.to_rss({limit: @limit}) do |doc|
|
146
|
-
|
149
|
+
|
147
150
|
doc.instructions << ['xml-stylesheet',\
|
148
151
|
"title='XSL_formatting' type='text/xsl' href='#{@xslt}'"]
|
149
|
-
|
150
|
-
end
|
151
|
-
|
152
|
+
|
153
|
+
end
|
154
|
+
|
152
155
|
else
|
153
|
-
|
156
|
+
|
154
157
|
@dx.to_rss({limit: @limit}) do |doc|
|
155
|
-
|
158
|
+
|
156
159
|
if @image_url then
|
157
|
-
|
160
|
+
|
158
161
|
img = Rexle::Element.new('image')
|
159
162
|
img.add Rexle::Element.new('url').add_text @image_url
|
160
163
|
img.add Rexle::Element.new('link').add_text @image_target_url
|
161
|
-
|
164
|
+
|
162
165
|
doc.root.element('channel/item').insert_before img
|
163
|
-
|
164
|
-
end
|
165
|
-
|
166
|
+
|
167
|
+
end
|
168
|
+
|
166
169
|
end
|
167
|
-
|
170
|
+
|
168
171
|
end
|
169
|
-
|
172
|
+
|
170
173
|
@dirty = false
|
171
174
|
@rss
|
172
175
|
|
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.6.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-02-22 00:00:00.000000000 Z
|
39
39
|
dependencies:
|
40
40
|
- !ruby/object:Gem::Dependency
|
41
41
|
name: rss_to_dynarex
|
@@ -43,40 +43,40 @@ dependencies:
|
|
43
43
|
requirements:
|
44
44
|
- - "~>"
|
45
45
|
- !ruby/object:Gem::Version
|
46
|
-
version: '0.
|
46
|
+
version: '0.2'
|
47
47
|
- - ">="
|
48
48
|
- !ruby/object:Gem::Version
|
49
|
-
version: 0.
|
49
|
+
version: 0.2.0
|
50
50
|
type: :runtime
|
51
51
|
prerelease: false
|
52
52
|
version_requirements: !ruby/object:Gem::Requirement
|
53
53
|
requirements:
|
54
54
|
- - "~>"
|
55
55
|
- !ruby/object:Gem::Version
|
56
|
-
version: '0.
|
56
|
+
version: '0.2'
|
57
57
|
- - ">="
|
58
58
|
- !ruby/object:Gem::Version
|
59
|
-
version: 0.
|
59
|
+
version: 0.2.0
|
60
60
|
- !ruby/object:Gem::Dependency
|
61
61
|
name: rss_sliml
|
62
62
|
requirement: !ruby/object:Gem::Requirement
|
63
63
|
requirements:
|
64
|
-
- - ">="
|
65
|
-
- !ruby/object:Gem::Version
|
66
|
-
version: 0.2.0
|
67
64
|
- - "~>"
|
68
65
|
- !ruby/object:Gem::Version
|
69
66
|
version: '0.2'
|
67
|
+
- - ">="
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: 0.2.0
|
70
70
|
type: :runtime
|
71
71
|
prerelease: false
|
72
72
|
version_requirements: !ruby/object:Gem::Requirement
|
73
73
|
requirements:
|
74
|
-
- - ">="
|
75
|
-
- !ruby/object:Gem::Version
|
76
|
-
version: 0.2.0
|
77
74
|
- - "~>"
|
78
75
|
- !ruby/object:Gem::Version
|
79
76
|
version: '0.2'
|
77
|
+
- - ">="
|
78
|
+
- !ruby/object:Gem::Version
|
79
|
+
version: 0.2.0
|
80
80
|
description:
|
81
81
|
email: digital.robertson@gmail.com
|
82
82
|
executables: []
|
@@ -103,8 +103,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
103
103
|
- !ruby/object:Gem::Version
|
104
104
|
version: '0'
|
105
105
|
requirements: []
|
106
|
-
|
107
|
-
rubygems_version: 2.7.10
|
106
|
+
rubygems_version: 3.2.22
|
108
107
|
signing_key:
|
109
108
|
specification_version: 4
|
110
109
|
summary: A gem for creating RSS feeds
|
metadata.gz.sig
CHANGED
Binary file
|