mymedia 0.3.0 → 0.5.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (6) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +1 -2
  3. data/lib/mymedia.rb +66 -27
  4. data.tar.gz.sig +0 -0
  5. metadata +11 -52
  6. metadata.gz.sig +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6fc78e7e213ed935fdffc733862d520abb3b0c7d1dc3afde43905372e8bfd427
4
- data.tar.gz: fdae3bd4aeeb04d230dbe95b67700b68fe2ec92a09292124e912bc66285a1937
3
+ metadata.gz: 788b610f7561b603c218b18e55045766e787fef8f6065471fc5faccfa2e3f6d0
4
+ data.tar.gz: 3f16cb556b14e811bee09bb267dc2d7b4007bad0d358d1aa4b6755c198d14e22
5
5
  SHA512:
6
- metadata.gz: ee00e96ba62317e509b44024544885deae61cebbc973fd62417106bd56f6c025eba8aac5c6baa658ad965bff9be1d37501a8a8be2716e5d36f37b21d4cf88692
7
- data.tar.gz: 0a4ed8e0eb86dccf1e6603d9f6a0b7bc78acbb3e864706c2e61724d46d1a925e520e84d94dfb111f4193b46615af9cc5132868f93f2c9d79c0c47272e0edd44b
6
+ metadata.gz: 54085653a1f9707f565070f00faa8eb31a81aa3452b124f3c6dd8f7c95879880348206ac5c372b65713c473846139d588f7f3751091e5e316bba5704c2283d31
7
+ data.tar.gz: 68922f33adc6cb6d1008d22bc76243a8a48a90f91644cf4a32121d8fb9ac6f3d80a0fca7ae5503ccdc7d445cd5aaa530a0d28ab76b5906f9dae29d2703718b04
checksums.yaml.gz.sig CHANGED
@@ -1,2 +1 @@
1
- mبB��d!�׻�%�l����+����1�/�D�i��ހq��A��/�V��mZR�;�!
2
- �uu��S��W����Q�_�6?�}�D@ҵ{����궠�:D������6)K�[ʀ����1
1
+ ;�R�O(x5�}RcC�j ����6Q����<p�|IP:�S'�
data/lib/mymedia.rb CHANGED
@@ -3,7 +3,6 @@
3
3
  # file: mymedia.rb
4
4
 
5
5
  require 'time'
6
- require 'fileutils'
7
6
  require 'logger'
8
7
  require 'dynarex'
9
8
  require 'sps-pub'
@@ -11,6 +10,7 @@ require 'dir-to-xml'
11
10
  require 'dataisland'
12
11
  require 'increment'
13
12
  require 'simple-config'
13
+ require 'rxfileio'
14
14
 
15
15
 
16
16
  module MyMedia
@@ -20,6 +20,7 @@ module MyMedia
20
20
 
21
21
 
22
22
  class Publisher
23
+ include RXFReadWriteModule
23
24
 
24
25
  def initialize(opts={})
25
26
  @index_page = true
@@ -33,7 +34,7 @@ module MyMedia
33
34
 
34
35
  opt = {id: nil, rss: false}.merge(options)
35
36
 
36
- dynarex = if File.exists? dynarex_filepath then
37
+ dynarex = if FileX.exists? dynarex_filepath then
37
38
  Dynarex.new(dynarex_filepath)
38
39
  else
39
40
  Dynarex.new(@schema)
@@ -48,7 +49,7 @@ module MyMedia
48
49
 
49
50
  dynarex.xslt_schema = dynarex.summary[:xslt_schema]
50
51
  rss_filepath = dynarex_filepath.sub(/\.xml$/,'_rss.xml')
51
- File.open(rss_filepath, 'w'){|f| f.write dynarex.to_rss }
52
+ FileX.write rss_filepath, dynarex.to_rss
52
53
  end
53
54
 
54
55
  end
@@ -61,7 +62,7 @@ module MyMedia
61
62
  return unless @index_page == true
62
63
  raise MyMediaPublisherException, \
63
64
  "template path: #{template_path} not found" unless \
64
- File.exists?(template_path)
65
+ FileX.exists?(template_path)
65
66
  =begin jr 040916
66
67
  dataisland = DataIsland.new(template_path, @opts)
67
68
 
@@ -71,7 +72,7 @@ module MyMedia
71
72
 
72
73
  def publish_dxlite(dynarex_filepath='', record={title: '',url: ''})
73
74
 
74
- dynarex = if File.exists? dynarex_filepath then
75
+ dynarex = if FileX.exists? dynarex_filepath then
75
76
  DxLite.new(dynarex_filepath)
76
77
  else
77
78
  DxLite.new(@schema)
@@ -92,12 +93,13 @@ module MyMedia
92
93
  end
93
94
 
94
95
  module IndexReader
96
+ include RXFRead
95
97
 
96
98
  def browse()
97
99
 
98
100
  json_filepath = "%s/%s/dynarex.json" % [@home, @public_type]
99
101
 
100
- if File.exists? json_filepath then
102
+ if FileX.exists? json_filepath then
101
103
 
102
104
  dx = DxLite.new(json_filepath)
103
105
  return dx.all
@@ -110,7 +112,7 @@ module MyMedia
110
112
 
111
113
  json_filepath = "%s/%s/dynarex.json" % [@home, @public_type]
112
114
 
113
- if File.exists? json_filepath then
115
+ if FileX.exists? json_filepath then
114
116
 
115
117
  dx = DxLite.new(json_filepath)
116
118
  return dx.all.select {|x| x.title =~ /#{keyword}/i}
@@ -124,10 +126,11 @@ module MyMedia
124
126
  end
125
127
 
126
128
  class Base < Publisher
129
+ include RXFileIOModule
127
130
 
128
131
  attr_reader :to_s
129
132
 
130
- def initialize(media_type: 'blog', public_type: 'blog',
133
+ def initialize(media_type: 'blog', public_type: media_type,
131
134
  ext: 'txt', config: nil, log: nil, debug: false)
132
135
 
133
136
  super()
@@ -139,6 +142,7 @@ module MyMedia
139
142
  c = SimpleConfig.new(config).to_h
140
143
 
141
144
  @home = c[:home]
145
+ puts '@home: ' + @home.inspect if @debug
142
146
  @media_src = "%s/media/%s" % [@home, media_type]
143
147
  @website = c[:website]
144
148
 
@@ -160,7 +164,7 @@ module MyMedia
160
164
  @rss = false
161
165
  @debug = debug
162
166
 
163
- Dir.chdir @home
167
+ DirX.chdir @home
164
168
 
165
169
  end
166
170
 
@@ -180,26 +184,31 @@ module MyMedia
180
184
 
181
185
  @log.info 'Base inside auto_copy_publish' if @log
182
186
  puts '@media_src: ' + @media_src.inspect if @debug
183
- #exit
184
- dir = DirToXML.new(@media_src, recursive: true, debug: false)
185
- puts 'before dir.last_modified' if @debug
186
- r = dir.last_modified
187
- puts 'r: ' + r.inspect if @debug
188
187
 
189
- filename = r.is_a?(Hash) ? r[:name] : File.join(r.map {|x| x[:name]})
188
+ # fetch the most recent file
189
+ filename = FileX.ru_r @media_src
190
190
 
191
- copy_publish( filename ,raw_msg, &blk)
191
+ if filename then
192
+
193
+ puts 'filename: ' + filename.inspect if @debug
194
+
195
+ copy_publish( filename ,raw_msg, &blk)
196
+
197
+ end
192
198
 
193
199
  end
194
200
 
195
- def basename(s1, s2)
201
+ def basename(raw_s1, raw_s2)
202
+
203
+ s1 = raw_s1.sub(/dfs:\/\/[^\/]+/,'')
204
+ s2 = raw_s2.sub(/dfs:\/\/[^\/]+/,'')
196
205
 
197
206
  (s2.split('/') - s1.split('/')).join('/')
198
207
 
199
208
  end
200
209
 
201
210
  def copy_publish(filename, raw_msg='', &blk)
202
- file_publish(File.join(@media_src,filename), raw_msg)
211
+ file_publish(filename, raw_msg)
203
212
  end
204
213
 
205
214
 
@@ -217,18 +226,23 @@ module MyMedia
217
226
 
218
227
  public_path2 = "%s/%s/%shrs%s%s" % [@public_type, \
219
228
  Time.now.strftime('%Y/%b/%d').downcase, Time.now.strftime('%H%M'),
220
- Time.now.strftime('%S%2N'), @target_ext]
229
+ Time.now.strftime('%S%2N'), @target_ext]
221
230
 
222
231
  raw_destination = "%s/%s/%s" % [@home, 'r', public_path]
223
232
 
224
- if File.exists? raw_destination then
233
+ if FileX.exists? raw_destination then
225
234
  raw_destination = "%s/%s/%s" % [@home, 'r', public_path2]
226
235
  public_path = public_path2
227
236
  end
228
237
 
229
238
  destination = File.join(@home, public_path)
230
- FileUtils.mkdir_p File.dirname(raw_destination)
231
- FileUtils.mkdir_p File.dirname(destination)
239
+ FileX.mkdir_p File.dirname(raw_destination)
240
+ FileX.mkdir_p File.dirname(destination)
241
+
242
+ if @debug then
243
+ puts "file_publish() #50 mkdir_p %s" % [File.dirname(raw_destination)]
244
+ puts "file_publish() #70 mkdir_p %s" % [File.dirname(destination)]
245
+ end
232
246
 
233
247
  raw_msg = raw_msg.join ' ' if raw_msg.is_a? Array
234
248
 
@@ -239,8 +253,21 @@ module MyMedia
239
253
  raw_msg, target_url = yield(destination, raw_destination)
240
254
  static_url = target_url
241
255
  else
242
- FileUtils.cp src_path, destination
243
- FileUtils.cp src_path, raw_destination
256
+
257
+ if @debug then
258
+ puts "file_publish() #80 cp %s to %s" % [src_path, destination]
259
+ puts "file_publish() #90 cp %s to %s" % [src_path, destination]
260
+ end
261
+
262
+ FileX.cp src_path, destination
263
+ FileX.cp src_path, raw_destination
264
+
265
+ if @debug then
266
+ puts "file_publish() #100 copied %s to %s" % [src_path, destination]
267
+ puts "file_publish() #200 copied %s to %s" % \
268
+ [src_path, raw_destination]
269
+ end
270
+
244
271
  end
245
272
 
246
273
  raw_msg = raw_msg.join if raw_msg.is_a? Array
@@ -261,7 +288,13 @@ module MyMedia
261
288
  static_destination = "%s/%s" % [@home, static_path]
262
289
 
263
290
  #FileUtils.mkdir_p File.dirname(static_destination)
264
- FileUtils.cp destination, static_destination
291
+
292
+ if @debug then
293
+ puts "file_publish() #300 copy %s to %s" % [destination,
294
+ static_destination]
295
+ end
296
+
297
+ FileX.cp destination, static_destination
265
298
 
266
299
  #jr010817 FileUtils.cp raw_destination, raw_static_destination
267
300
 
@@ -270,8 +303,14 @@ module MyMedia
270
303
 
271
304
  xmlfilepath = destination.sub('.html','.xml')
272
305
 
273
- if File.exists?(xmlfilepath) then
274
- FileUtils.cp xmlfilepath, static_destination.sub('.html','.xml')
306
+ if FileX.exists?(xmlfilepath) then
307
+
308
+ FileX.cp xmlfilepath, static_destination.sub('.html','.xml')
309
+
310
+ if @debug then
311
+ puts "file_publish() #400 copied %s to %s" % [xmlfilepath, static_destination.sub('.html','.xml')]
312
+ end
313
+
275
314
  end
276
315
 
277
316
  end
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mymedia
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Robertson
@@ -35,88 +35,48 @@ cert_chain:
35
35
  bL55NDdi8BFHkNVohRBak7aqxsw41LJKy3UTP+4TzU5vyluDJMiscK6JJFaM4JiS
36
36
  xtlAM0O5ZFe9QflatP+P8JnB
37
37
  -----END CERTIFICATE-----
38
- date: 2022-02-03 00:00:00.000000000 Z
38
+ date: 2022-03-06 00:00:00.000000000 Z
39
39
  dependencies:
40
40
  - !ruby/object:Gem::Dependency
41
- name: dynarex
42
- requirement: !ruby/object:Gem::Requirement
43
- requirements:
44
- - - "~>"
45
- - !ruby/object:Gem::Version
46
- version: '1.9'
47
- - - ">="
48
- - !ruby/object:Gem::Version
49
- version: 1.9.2
50
- type: :runtime
51
- prerelease: false
52
- version_requirements: !ruby/object:Gem::Requirement
53
- requirements:
54
- - - "~>"
55
- - !ruby/object:Gem::Version
56
- version: '1.9'
57
- - - ">="
58
- - !ruby/object:Gem::Version
59
- version: 1.9.2
60
- - !ruby/object:Gem::Dependency
61
- name: sps-pub
41
+ name: dir-to-xml
62
42
  requirement: !ruby/object:Gem::Requirement
63
43
  requirements:
64
44
  - - "~>"
65
45
  - !ruby/object:Gem::Version
66
- version: '0.5'
46
+ version: '1.2'
67
47
  - - ">="
68
48
  - !ruby/object:Gem::Version
69
- version: 0.5.5
49
+ version: 1.2.2
70
50
  type: :runtime
71
51
  prerelease: false
72
52
  version_requirements: !ruby/object:Gem::Requirement
73
53
  requirements:
74
54
  - - "~>"
75
55
  - !ruby/object:Gem::Version
76
- version: '0.5'
56
+ version: '1.2'
77
57
  - - ">="
78
58
  - !ruby/object:Gem::Version
79
- version: 0.5.5
59
+ version: 1.2.2
80
60
  - !ruby/object:Gem::Dependency
81
- name: dir-to-xml
61
+ name: dataisland
82
62
  requirement: !ruby/object:Gem::Requirement
83
63
  requirements:
84
64
  - - "~>"
85
65
  - !ruby/object:Gem::Version
86
- version: '1.0'
66
+ version: '0.3'
87
67
  - - ">="
88
68
  - !ruby/object:Gem::Version
89
- version: 1.0.8
69
+ version: 0.3.0
90
70
  type: :runtime
91
71
  prerelease: false
92
72
  version_requirements: !ruby/object:Gem::Requirement
93
73
  requirements:
94
- - - "~>"
95
- - !ruby/object:Gem::Version
96
- version: '1.0'
97
- - - ">="
98
- - !ruby/object:Gem::Version
99
- version: 1.0.8
100
- - !ruby/object:Gem::Dependency
101
- name: dataisland
102
- requirement: !ruby/object:Gem::Requirement
103
- requirements:
104
- - - ">="
105
- - !ruby/object:Gem::Version
106
- version: 0.3.0
107
74
  - - "~>"
108
75
  - !ruby/object:Gem::Version
109
76
  version: '0.3'
110
- type: :runtime
111
- prerelease: false
112
- version_requirements: !ruby/object:Gem::Requirement
113
- requirements:
114
77
  - - ">="
115
78
  - !ruby/object:Gem::Version
116
79
  version: 0.3.0
117
- - - "~>"
118
- - !ruby/object:Gem::Version
119
- version: '0.3'
120
80
  - !ruby/object:Gem::Dependency
121
81
  name: increment
122
82
  requirement: !ruby/object:Gem::Requirement
@@ -183,8 +143,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
183
143
  - !ruby/object:Gem::Version
184
144
  version: '0'
185
145
  requirements: []
186
- rubyforge_project:
187
- rubygems_version: 2.7.10
146
+ rubygems_version: 3.2.22
188
147
  signing_key:
189
148
  specification_version: 4
190
149
  summary: Makes publishing to the web easier
metadata.gz.sig CHANGED
Binary file