rss_creator 0.6.0 → 0.6.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f63f706ec5787caf10560fc4613d9e5d39b250a509d405d0e01ecadb6e929136
4
- data.tar.gz: 837e62756235a56f0cfd03f395fcc99b88860cad04f7b5598a58ea9c4a561233
3
+ metadata.gz: 6d8273cee98cf1c57f43cca58ce9d2742f8c30abe5ae21c32ecc439dcccbb305
4
+ data.tar.gz: 03ba208ffbba59b52e6d505a23bc080cf3ccdb69f61b58e02c97788a12103592
5
5
  SHA512:
6
- metadata.gz: 96e3a748827858a09f27d3cd949b6b5852512b98c1449bd72ae9ba7e3f90cf4bc3a411c14ba83ffae405d8e8de7251a1eed6d891d278e736e8947e236cca69b9
7
- data.tar.gz: fd03f1600aeb8ea4933d5b3bd9ef7e257a035434c69ba25bf0365c30599fddadb72d4a5eb8143e238897e92dec998e4ee63af99b71ec877b8bc27362bcb20518
6
+ metadata.gz: bc13a9d7c9190002a9df32c8121afb26bf48a3fa7c5afddea9cb64afd52b50e9fd4878fe798a0068e4532429763f71c352ff39e1b201a22126d08d7d307672d0
7
+ data.tar.gz: 472941429205c0a266f530b1f0e97186a119f7ef3c834a88e003a36575093f970e123351b6e80224f7e34799013076ad334806c54a250eb72787d45d05b2d4a1
checksums.yaml.gz.sig CHANGED
Binary file
data/lib/rss_creator.rb CHANGED
@@ -9,51 +9,51 @@ require 'rss_to_dynarex'
9
9
  class RSScreator
10
10
  include RXFReadWriteModule
11
11
 
12
- attr_accessor :title, :description, :link, :limit, :xslt, :image_url,
12
+ attr_accessor :title, :description, :link, :limit, :xslt, :image_url,
13
13
  :image_target_url
14
14
 
15
- def initialize(filepath='rss.xml', dx_xslt: nil, dx_filename: 'feed.xml',
15
+ def initialize(filepath='rss.xml', dx_xslt: nil, dx_filename: 'list.xml',
16
16
  custom_fields: [], limit: 10, log: nil, debug: false)
17
17
 
18
18
 
19
19
  @filepath, @log, @debug = filepath, log, debug
20
20
 
21
21
  dxfilepath = File.join(File.dirname(filepath), dx_filename)
22
-
22
+
23
23
  if filepath and FileX.exists? dxfilepath then
24
24
 
25
- @dx = Dynarex.new dxfilepath
25
+ @dx = Dynarex.new dxfilepath, debug: debug
26
26
  @title, @description, @link = @dx.title, @dx.description, @dx.link
27
27
  @image_url = @dx.image
28
28
 
29
29
  else
30
30
  if filepath and FileX.exists? filepath
31
-
31
+
32
32
  rtd = RSStoDynarex.new filepath
33
33
  @dx = rtd.to_dynarex
34
34
 
35
35
  @title, @description, @link = @dx.title, @dx.description, @dx.link
36
36
  @image_url = @dx.image if @dx.image and @dx.image.length > 1
37
37
  @image_target_url = @link if @link and @link.length > 1
38
-
38
+
39
39
  else
40
40
 
41
-
41
+
42
42
  schema = 'channel[title, description, link, image]/' + \
43
43
  'item(title, link, description, date'
44
44
  schema += ', ' + custom_fields.join(', ') if custom_fields.any?
45
45
  schema += ')'
46
-
46
+
47
47
  @dx = Dynarex.new schema
48
48
  end
49
49
 
50
- @dx.order = 'descending'
50
+ @dx.order = 'descending'
51
51
  @dx.default_key = 'uid'
52
- @dx.xslt = dx_xslt if dx_xslt
53
-
52
+ @dx.xslt = dx_xslt if dx_xslt
54
53
 
54
+
55
55
  end
56
-
56
+
57
57
  @dx.xslt_schema = 'channel[title:title,description:description,' + \
58
58
  'link:link]/item(title:title,description:description,' + \
59
59
  'link:link,pubDate:date)'
@@ -71,28 +71,35 @@ class RSScreator
71
71
  @log.debug 'RssCreator#add item: ' + item.inspect if @log
72
72
 
73
73
  unless item[:title] and item[:link] then
74
- raise 'RSScreator: title or link can\'t be blank'
74
+ raise 'RSScreator: title or link can\'t be blank'
75
75
  end
76
-
76
+
77
77
  record = {date: Time.now.strftime("%a, %d %b %Y %H:%M:%S %z")}.merge(item)
78
78
  @dx.create(record, id: id)
79
-
79
+ @log&.debug 'RssCreator#add item; after @dx.create'
80
+
80
81
  @dirty = true
81
-
82
+
82
83
  end
83
84
 
84
85
  def save(new_filepath=nil)
85
86
 
86
87
  filepath = new_filepath ? new_filepath : @filepath
88
+ puts 'save() before FileX.write' if @debug
89
+ puts 'filepath: ' + filepath.inspect if @debug
90
+ puts 'print_rss: ' + print_rss.inspect if @debug
87
91
  FileX.write filepath, print_rss
92
+
93
+ puts 'save() after FileX.write' if @debug
94
+
88
95
  @dx.save File.join(File.dirname(filepath), @dxfilename) if @dxfilename
89
96
  end
90
-
97
+
91
98
  def description=(val)
92
99
  @description = val
93
100
  @dirty = true
94
101
  end
95
-
102
+
96
103
  def delete(id)
97
104
  @dx.delete id.to_s
98
105
  end
@@ -103,24 +110,24 @@ class RSScreator
103
110
  def dynarex()
104
111
  @dx
105
112
  end
106
-
113
+
107
114
  def image_url=(val)
108
115
  @image_url = val
109
116
  @dirty = true
110
117
  end
111
-
118
+
112
119
  alias image= image_url=
113
-
120
+
114
121
  def image_target_url=(val)
115
122
  @image_target_url = val
116
123
  @dirty = true
117
- end
124
+ end
118
125
 
119
126
  def link=(val)
120
127
  @link = val
121
128
  @dirty = true
122
- end
123
-
129
+ end
130
+
124
131
  def title=(val)
125
132
  @title = val
126
133
  @dirty = true
@@ -133,43 +140,45 @@ class RSScreator
133
140
  private
134
141
 
135
142
  def print_rss()
136
-
143
+
137
144
  return @rss unless @dirty
138
145
 
139
146
  if @title.nil? or @description.nil? then
140
- raise 'RSScreator: title or description can\'t be blank'
147
+ raise 'RSScreator: title or description can\'t be blank'
141
148
  end
142
149
 
143
150
  @dx.title, @dx.description, @dx.link = @title, @description, @link || ''
144
151
  @dx.image = @image_url if @dx.respond_to? :image
145
-
152
+
146
153
  @rss = if @xslt then
147
-
154
+
148
155
  @dx.to_rss({limit: @limit}) do |doc|
149
-
156
+
150
157
  doc.instructions << ['xml-stylesheet',\
151
158
  "title='XSL_formatting' type='text/xsl' href='#{@xslt}'"]
152
-
153
- end
154
-
159
+
160
+ end
161
+
155
162
  else
156
163
 
157
- @dx.to_rss({limit: @limit}) do |doc|
164
+ puts 'before @dx.to_rss' if @debug
158
165
 
166
+ @dx.to_rss({limit: @limit}) do |doc|
167
+
159
168
  if @image_url then
160
-
169
+
161
170
  img = Rexle::Element.new('image')
162
171
  img.add Rexle::Element.new('url').add_text @image_url
163
172
  img.add Rexle::Element.new('link').add_text @image_target_url
164
-
173
+
165
174
  doc.root.element('channel/item').insert_before img
166
-
167
- end
168
-
175
+
176
+ end
177
+
169
178
  end
170
-
179
+
171
180
  end
172
-
181
+
173
182
  @dirty = false
174
183
  @rss
175
184
 
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.6.0
4
+ version: 0.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Robertson
@@ -10,32 +10,33 @@ bindir: bin
10
10
  cert_chain:
11
11
  - |
12
12
  -----BEGIN CERTIFICATE-----
13
- MIIEXjCCAsagAwIBAgIBATANBgkqhkiG9w0BAQsFADAsMSowKAYDVQQDDCFnZW1t
14
- YXN0ZXIvREM9amFtZXNyb2JlcnRzb24vREM9ZXUwHhcNMjEwMjI0MTEzNTE4WhcN
15
- MjIwMjI0MTEzNTE4WjAsMSowKAYDVQQDDCFnZW1tYXN0ZXIvREM9amFtZXNyb2Jl
16
- cnRzb24vREM9ZXUwggGiMA0GCSqGSIb3DQEBAQUAA4IBjwAwggGKAoIBgQC/EdPv
17
- Z9PmSgZQ31H8hgTyVkC5Ww2VyrxJbX9LA2xX++xTEMm2LvLs4G9vGeNWiUpLdSZt
18
- EkPMLX58IhDJoETYMF4UpAw/tOPMlvzrmM9vFTdsZXKXwTwS3blbWahUgRAlXWpV
19
- pbNj+SQlnIZklZ8FR/rvXE98wAFO4IIldQcyuUi9ehrYfazpS6fOg3f3Yg6ffPMs
20
- xWUmhF4zQs+J6utjoJeWyVHWwHFpcmzMIEcLbnGOsn6JHdPmDaCTyAWjbrTsbMRn
21
-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bZ2VtbWFzdGVyQGphbWVzcm9iZXJ0
29
+ c29uLmV1MA0GCSqGSIb3DQEBCwUAA4IBgQCUdxLq/mWu5T9k6vko7AqfClaINL6h
30
+ JTQ9tr9Yz7qjlyCDwr98JzlGowpSJ+nBHq0YJc4vrFVPfHCeSPVscmehnO9OUdqT
31
+ m2po4qj37bBvJUGOYrmQuIWfFRGZeNletKYaKIglVFKg6U3w+JRpvQyorklS49Rf
32
+ cTXM6eEwAb9ohZ1Mg+Z6gM+ZvgB7GKYUhGITcec7JBpgabPMa92oCk7AbYaco+Gm
33
+ W0MzPUrw76BsCiyrwNMWwvCyuzruC8wQB5jfUp1rlVInizESnvWHjsJcdJw0XqgK
34
+ C4c3H208VnkvfxsMIf5a7y9rj1SO3KZSExoW+sPefm1hFioN3Sa6MLyCFrxXO8Rt
35
+ UjpVoogNCe056wHoaox6Qx2MQg8TDqFqWIiJXLAGtNGP+3vV4VHPY4efYvnfLmN0
36
+ cvt0iXma+gx/Ov53QNTxxB3QbNEEFdeEjg0+lO4JPFlhgtITILe804ZJCWi+hgxp
37
+ gIx/INLAIB0o7xvs4rvitJ+wC8T5u20Ubss=
37
38
  -----END CERTIFICATE-----
38
- date: 2022-02-22 00:00:00.000000000 Z
39
+ date: 2023-03-02 00:00:00.000000000 Z
39
40
  dependencies:
40
41
  - !ruby/object:Gem::Dependency
41
42
  name: rss_to_dynarex
@@ -46,7 +47,7 @@ dependencies:
46
47
  version: '0.2'
47
48
  - - ">="
48
49
  - !ruby/object:Gem::Version
49
- version: 0.2.0
50
+ version: 0.2.1
50
51
  type: :runtime
51
52
  prerelease: false
52
53
  version_requirements: !ruby/object:Gem::Requirement
@@ -56,7 +57,7 @@ dependencies:
56
57
  version: '0.2'
57
58
  - - ">="
58
59
  - !ruby/object:Gem::Version
59
- version: 0.2.0
60
+ version: 0.2.1
60
61
  - !ruby/object:Gem::Dependency
61
62
  name: rss_sliml
62
63
  requirement: !ruby/object:Gem::Requirement
@@ -103,7 +104,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
103
104
  - !ruby/object:Gem::Version
104
105
  version: '0'
105
106
  requirements: []
106
- rubygems_version: 3.2.22
107
+ rubygems_version: 3.4.4
107
108
  signing_key:
108
109
  specification_version: 4
109
110
  summary: A gem for creating RSS feeds
metadata.gz.sig CHANGED
Binary file