daily_planner 0.1.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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 58fac8df0728281c5c090e5c9708c5ff93e88596
4
+ data.tar.gz: 49e16b68d676cc2899bf49badc9472956b160b98
5
+ SHA512:
6
+ metadata.gz: e5c99f5ec3ac4eac4db66f02e4e2dc937d2499a8c46d403bb4176a62f49c61c738f833aa185e0ef32395763ad307d2eee3e830cbb429b3faa5117688d5a77f33
7
+ data.tar.gz: 8d8d3c63ba04442b739ee6a64fe78db5cb98c7c438f7d2f404065c498c32b16cc74096efdaa6ecba8f69c592254db6325f53d3824ae0339550e19d28e10c980c
checksums.yaml.gz.sig ADDED
Binary file
data.tar.gz.sig ADDED
@@ -0,0 +1,2 @@
1
+ ʈ3B�34���8I�� k���DF���Y
2
+ ��O�%�O����M�lWv~.LJ�%e���HnG�,�g[�f��:?�U���~�<�G�p%����&�tJd��K�n9KMδŇ�ں��1_�-s�:��g������}�m`��K��� FW���^�x�Y%l)��pk�)�����f>uA�%�w�
@@ -0,0 +1,99 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # file: daily_planner.rb
4
+
5
+ require 'date'
6
+ require 'recordx'
7
+ require 'fileutils'
8
+
9
+
10
+ class DailyPlanner
11
+
12
+ attr_reader :to_s
13
+
14
+ def initialize(filename='daily-planner.txt', path: '.')
15
+
16
+ @filename, @path = filename, path
17
+
18
+ fpath = File.join(path, filename)
19
+
20
+ if File.exists?(fpath) then
21
+ @rx = import_to_rx(File.read(fpath))
22
+ else
23
+ @rx = new_rx
24
+ end
25
+
26
+ end
27
+
28
+ def rx()
29
+ @rx
30
+ end
31
+
32
+ def save(filename=@filename)
33
+
34
+ s = File.basename(filename) + "\n" + rx_to_s(@rx).lines[1..-1].join
35
+ File.write File.join(@path, filename), s
36
+
37
+ end
38
+
39
+ def to_s()
40
+ rx_to_s @rx
41
+ end
42
+
43
+ private
44
+
45
+
46
+ def import_to_rx(s)
47
+
48
+ rx = new_rx()
49
+
50
+ rows = s.split(/.*(?=^[\w, ]+\n\-+)/)
51
+
52
+ rx.date = Date.parse(rows[1].lines.first.chomp)
53
+ rx.today = rows[1].lines[2..-1].join.strip
54
+ rx.tomorrow = rows[2].lines[2..-1].join.strip
55
+
56
+ return rx
57
+
58
+ end
59
+
60
+ def rx_to_s(rx)
61
+
62
+ def format_row(heading, s)
63
+
64
+ content = s.clone
65
+ content.prepend "\n\n" unless content.empty?
66
+ "%s\n%s%s" % [heading, '-' * heading.length, content]
67
+
68
+ end
69
+
70
+ def ordinal(n)
71
+ n.to_s + ( (10...20).include?(n) ? 'th' : \
72
+ %w{ th st nd rd th th th th th th }[n % 10] )
73
+ end
74
+
75
+ d = Date.parse(rx.date)
76
+
77
+ heading = "%s, %s %s" % [Date::DAYNAMES[d.wday], ordinal(d.day),
78
+ Date::ABBR_MONTHNAMES[d.month]]
79
+ rows = [format_row(heading, rx.today)]
80
+ rows << format_row('Tomorrow', rx.tomorrow)
81
+
82
+ title = File.basename(@filename)
83
+ title + "\n" + "=" * title.length + "\n\n%s\n\n" % [rows.join("\n\n")]
84
+
85
+ end
86
+
87
+ def new_rx()
88
+
89
+ title = "Daily Planner"
90
+ date = DateTime.now
91
+ rx = RecordX.new({title: title, date: date, today: '', tomorrow: ''})
92
+
93
+ return rx
94
+ end
95
+
96
+ def refresh(rxfilepath, latest_rx)
97
+ end
98
+
99
+ end
metadata ADDED
@@ -0,0 +1,87 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: daily_planner
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - James Robertson
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain:
11
+ - |
12
+ -----BEGIN CERTIFICATE-----
13
+ MIIDljCCAn6gAwIBAgIBATANBgkqhkiG9w0BAQUFADBIMRIwEAYDVQQD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/wWrHEjpz1Qr/qOi65COA4884eHDmayZViDakJlujztLEhbYI9PSRt2A5Io
30
+ SuEwRui2OJig9gyiU8G3ugQSn6ZU7gMFuoyXAVdZkZ43Y7/5c/3CY93ccO0Zv06L
31
+ 52/Qhn5QdVacSO+YlHFgL6wMk/FAnJzGgADFpvq/QgXbDkH5G2eRKpvJP9J1E34V
32
+ iT9ytBP7h9+uFg==
33
+ -----END CERTIFICATE-----
34
+ date: 2015-12-11 00:00:00.000000000 Z
35
+ dependencies:
36
+ - !ruby/object:Gem::Dependency
37
+ name: recordx
38
+ requirement: !ruby/object:Gem::Requirement
39
+ requirements:
40
+ - - "~>"
41
+ - !ruby/object:Gem::Version
42
+ version: '0.2'
43
+ - - ">="
44
+ - !ruby/object:Gem::Version
45
+ version: 0.2.4
46
+ type: :runtime
47
+ prerelease: false
48
+ version_requirements: !ruby/object:Gem::Requirement
49
+ requirements:
50
+ - - "~>"
51
+ - !ruby/object:Gem::Version
52
+ version: '0.2'
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ version: 0.2.4
56
+ description:
57
+ email: james@r0bertson.co.uk
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - lib/daily_planner.rb
63
+ homepage: https://github.com/jrobertson/daily_planner
64
+ licenses:
65
+ - MIT
66
+ metadata: {}
67
+ post_install_message:
68
+ rdoc_options: []
69
+ require_paths:
70
+ - lib
71
+ required_ruby_version: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ required_rubygems_version: !ruby/object:Gem::Requirement
77
+ requirements:
78
+ - - ">="
79
+ - !ruby/object:Gem::Version
80
+ version: '0'
81
+ requirements: []
82
+ rubyforge_project:
83
+ rubygems_version: 2.4.8
84
+ signing_key:
85
+ specification_version: 4
86
+ summary: Creates a daily-planner.txt template file
87
+ test_files: []
metadata.gz.sig ADDED
Binary file