daily_notices 0.2.6 → 0.3.0

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
  SHA1:
3
- metadata.gz: 353e3bdad29518178624bf3ea0b24418e0d2959f
4
- data.tar.gz: 159c643c037d2e894d48fb6970df4405a9187fc6
3
+ metadata.gz: d01fea12c246c2066ece1f6d310df696fddf7ed8
4
+ data.tar.gz: 440f7c003c6be5a065097e43ddb8dc72caa64205
5
5
  SHA512:
6
- metadata.gz: 0a34945600ffb313350ccb98d473ecac2df4c47bf2dc93e095f0b70ef22eb0d7608a2e4f1bf1d0dbc1a816990e7cf2910b7a13ca772c5cf62eac10202e5296c9
7
- data.tar.gz: 8b035e7400edb371f7627bd9c56f05a95021978a9a3e7da0fa998981e6778080dff9713cd81c629ea172e1d9e569eeeb287fa736b9449c7e37ac41878c2d81f6
6
+ metadata.gz: 8e0a74aa6927357ce7c72e48abb9e612766d83b4c23ce67bfa2bfea5b1491e8fef1dae06705a2fc46913ca1efe5a9e059f615bc7a9de3c6afba68e5c2010e6c6
7
+ data.tar.gz: 0bc3dd1a61a68befcc5c058002033b2e74046decf46c708d0f1c984c02ad25164a0b3dd240b629ec3392840f3073cde924790b40b11d37e4dd73caca5dee16f4
checksums.yaml.gz.sig CHANGED
Binary file
data/lib/daily_notices.rb CHANGED
@@ -17,6 +17,10 @@ class DailyNotices
17
17
  @filepath, @url_base, @dx_xslt, @rss_xslt, @target_page, @target_xslt = \
18
18
  filepath, url_base, dx_xslt, rss_xslt, target_page, target_xslt
19
19
 
20
+
21
+ @schema ||= 'items/item(description, time)'
22
+ @default_key ||= 'uid'
23
+
20
24
  @day = Time.now.day
21
25
  new_day()
22
26
 
@@ -38,32 +42,53 @@ class DailyNotices
38
42
  @target_page = target_page
39
43
  end
40
44
 
41
- def create(description, time=Time.now, title: nil, \
42
- id: Time.now.strftime('%H%M%S'))
45
+ def create(x, time=Time.now, title: nil, \
46
+ id: Time.now.strftime('%H%M%S'), description: nil)
43
47
 
44
48
  new_day() if @day != Time.now.day
49
+
50
+ if x.is_a? String then
51
+
52
+ description = x
53
+ @dx.create({description: description, time: time}, id: id)
54
+
55
+ elsif x.is_a? Hash
56
+
57
+ @dx.create(x, id: id)
58
+
59
+ end
45
60
 
46
- @dx.create({description: description, time: time}, id: id)
47
61
  @dx.save @indexpath
48
62
 
49
63
  if @target_page == :recordset then
50
64
  File.write File.join(@filepath, @archive_path, 'index.html'), \
51
65
  @dx.to_html(domain: @url_base)
52
66
  else
53
- File.write File.join(@filepath, @archive_path, id, 'index.html'), \
54
- @dx.find(id).to_html(xslt: @target_xslt)
67
+
68
+ target_path = File.join(@filepath, @archive_path, id, 'index.html')
69
+ FileUtils.mkdir_p File.dirname(target_path)
70
+ rx = @dx.find(id)
71
+
72
+ kvx = rx.to_kvx
73
+ yield kvx if block_given?
74
+
75
+ rxdoc = Rexle.new(kvx.to_xml)
76
+ rxdoc.instructions << ['xml-stylsheet',\
77
+ "title='XSL_formatting' type='text/xsl' href='#{@target_xslt}'"]
78
+
79
+ File.write target_path.sub(/\.html$/,'.xml', ), rxdoc.xml(pretty: true)
80
+ File.write target_path, rx.to_html(xslt: @target_xslt)
55
81
  end
56
82
 
57
83
  # Add it to the RSS document
58
84
  title ||= description.split(/\n/,2).first[0..140]
59
85
  link = [File.join(@url_base, File.basename(@filepath), \
60
- @archive_path, '#' + id)].join('/')
86
+ @archive_path, id)].join('/')
61
87
  @rss.add( {title: title, link: link, description: description}, id: id)
62
88
  @rss.save @rssfile
63
89
 
64
90
  on_add(@indexpath, id)
65
91
 
66
-
67
92
  end
68
93
 
69
94
  alias add create
@@ -103,6 +128,8 @@ class DailyNotices
103
128
 
104
129
  private
105
130
 
131
+ # configures the target page (using a Dynarex document) for a new day
132
+ #
106
133
  def new_day()
107
134
 
108
135
  @archive_path = Time.now.strftime("%Y/%b/%d").downcase
@@ -110,15 +137,13 @@ class DailyNotices
110
137
  @indexpath = File.join(@filepath, @archive_path, 'index.xml')
111
138
  FileUtils.mkdir_p File.dirname(@indexpath)
112
139
 
113
- schema = 'items/item(description, time)'
114
- default_key = 'uid'
115
140
 
116
141
  if File.exists? @indexpath then
117
142
  @dx = Dynarex.new @indexpath
118
143
  else
119
- @dx = Dynarex.new schema
144
+ @dx = Dynarex.new @schema
120
145
  @dx.order = 'descending'
121
- @dx.default_key = default_key
146
+ @dx.default_key = @default_key
122
147
  @dx.xslt = @dx_xslt
123
148
  end
124
149
 
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: daily_notices
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.6
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Robertson
@@ -31,7 +31,7 @@ cert_chain:
31
31
  6KZopP6uiDZcPfIWtD5QSbhxe2cyGqlu4Xnb4imiAb9DWj8g5YP45vWTp1a71ytC
32
32
  TGdJpNvN31W5+w==
33
33
  -----END CERTIFICATE-----
34
- date: 2015-10-30 00:00:00.000000000 Z
34
+ date: 2015-11-01 00:00:00.000000000 Z
35
35
  dependencies:
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rss_creator
metadata.gz.sig CHANGED
Binary file