daily_notices 0.1.0 → 0.2.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 828b51f0aab79eab086616ca1f189ca783d6cd41
4
- data.tar.gz: f59664078dea26d08b978bbc33597bb04d0048f7
3
+ metadata.gz: 60ad8102a04b345aa184b5ae1107aed37a68cbbc
4
+ data.tar.gz: 2248a86c6b39297e379377be6b6769194ae202ee
5
5
  SHA512:
6
- metadata.gz: 4dae0a488847e6f0d6caa9b396ca875121ea979108bf25a3e85f8ce08d16d1074ebfb4564cb0846e7e7e32932f505b50ca0972c5b62b8fcdb617c986c6e02f06
7
- data.tar.gz: d2442e759b8c1b6d6fa4fb531c71efe4e63678096c21413dfd2c372a45357899bbe2616269dccf9b3be08a0ae66cc34050f0fe10ca013302723a93fdbffe3bd8
6
+ metadata.gz: 247a9cd2f677ff3510447566b72889e360bd7dba16c5d2e5c631429a2f42ce7160787feb8b344449b34ce161d79ef828059329923ed24e53d23e055701e040dc
7
+ data.tar.gz: a07871d6701ee5d3785b48404d5c7dccf0bb08356d89abd3a0c1949e8b82ad97c6e4fa61bc7e55998d9ab05fbc9c1478b56f188dec9824399297a6a662fd6d47
checksums.yaml.gz.sig CHANGED
Binary file
data.tar.gz.sig CHANGED
Binary file
data/lib/daily_notices.rb CHANGED
@@ -2,12 +2,69 @@
2
2
 
3
3
  # file: daily_notices.rb
4
4
 
5
- require 'activity-logger'
6
5
 
7
- class DailyNotices < ActivityLogger
6
+ require 'rss_creator'
7
+ require 'fileutils'
8
+
9
+
10
+ class DailyNotices
11
+
12
+ attr_accessor :title, :description, :link, :dx_xslt, :rss_xslt
13
+
14
+ def initialize(filepath='', url_base: 'http:/127.0.0.1/', \
15
+ dx_xslt: '', rss_xslt: '')
16
+
17
+ @filepath, @url_base, @dx_xslt, @rss_xslt = filepath, \
18
+ url_base, dx_xslt, rss_xslt
19
+
20
+ @archive_path = Time.now.strftime("%Y/%b/%d").downcase
21
+
22
+ # If the file doesn't already exist in the
23
+ # archive directory then symlink it
24
+ @indexpath = File.join(@filepath, @archive_path, 'index.xml')
25
+ FileUtils.mkdir_p File.dirname(@indexpath)
26
+
27
+ if File.exists? @indexpath then
28
+ @dx = Dynarex.new @indexpath
29
+ else
30
+ @dx = Dynarex.new 'items/item(description, time)'
31
+ @dx.order = 'descending'
32
+ @dx.default_key = 'uid'
33
+ @dx.xslt = @dx_xslt
34
+ end
35
+
36
+ # open the Dynarex file or create a new Dynarex file
37
+
38
+ @rssfile = File.join(@filepath, 'rss.xml')
39
+
40
+ if File.exists? @rssfile then
41
+ @rss = RSScreator.new @rssfile
42
+ else
43
+ @rss = RSScreator.new
44
+ @rss.xslt = @rss_xslt
45
+ @rss.title = 'Daily notices'
46
+ @rss.description = 'Generated using the daily_notices gem'
47
+ @rss.link = @url_base
48
+ end
49
+ end
50
+
51
+ def create(description, time=Time.now, title: nil, \
52
+ id: Time.now.strftime('%H%M%S'))
53
+
54
+ @dx.create description: description, time: time, id: id
55
+ @dx.save @indexpath
56
+ File.write File.join(@filepath, @archive_path, 'index.html'), \
57
+ @dx.to_html(domain: @url_base)
58
+
59
+ # Add it to the RSS document
60
+ title ||= description.split(/\n/,2).first[0..140]
61
+ link = File.join(@url_base, @archive_path, '#' + id)
62
+ @rss.add title: title, link: link, description: description
63
+ @rss.save @rssfile
64
+
8
65
 
9
- def initialize(dir: nil, options: {})
10
- super(dir: dir, options: options)
11
66
  end
67
+
68
+ alias add create
12
69
 
13
70
  end
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.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Robertson
@@ -31,28 +31,28 @@ cert_chain:
31
31
  6KZopP6uiDZcPfIWtD5QSbhxe2cyGqlu4Xnb4imiAb9DWj8g5YP45vWTp1a71ytC
32
32
  TGdJpNvN31W5+w==
33
33
  -----END CERTIFICATE-----
34
- date: 2015-05-24 00:00:00.000000000 Z
34
+ date: 2015-10-27 00:00:00.000000000 Z
35
35
  dependencies:
36
36
  - !ruby/object:Gem::Dependency
37
- name: activity-logger
37
+ name: rss_creator
38
38
  requirement: !ruby/object:Gem::Requirement
39
39
  requirements:
40
40
  - - "~>"
41
41
  - !ruby/object:Gem::Version
42
- version: '0.3'
42
+ version: '0.2'
43
43
  - - ">="
44
44
  - !ruby/object:Gem::Version
45
- version: 0.3.2
45
+ version: 0.2.7
46
46
  type: :runtime
47
47
  prerelease: false
48
48
  version_requirements: !ruby/object:Gem::Requirement
49
49
  requirements:
50
50
  - - "~>"
51
51
  - !ruby/object:Gem::Version
52
- version: '0.3'
52
+ version: '0.2'
53
53
  - - ">="
54
54
  - !ruby/object:Gem::Version
55
- version: 0.3.2
55
+ version: 0.2.7
56
56
  description:
57
57
  email: james@r0bertson.co.uk
58
58
  executables: []
@@ -80,8 +80,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
80
80
  version: '0'
81
81
  requirements: []
82
82
  rubyforge_project:
83
- rubygems_version: 2.4.6
83
+ rubygems_version: 2.4.8
84
84
  signing_key:
85
85
  specification_version: 4
86
- summary: daily_notices
86
+ summary: A public facing noticeboard which is centered around an RSS feed.
87
87
  test_files: []
metadata.gz.sig CHANGED
Binary file