weekly_planner 0.1.1 → 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 +4 -4
- checksums.yaml.gz.sig +0 -0
- data/lib/weekly_planner.rb +44 -1
- data.tar.gz.sig +0 -0
- metadata +4 -4
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dcc9be272018ca4c1ed5f7acf006c877c1dbf9c4
|
4
|
+
data.tar.gz: e5805310a96ba8611a520bed7ca8cf20014b13ac
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: abafb6f96d7d4f0f927cb82a9f1324e925fbc61b9e41da49083e3b578b31acee67a5c7a464544d4378f51bf06e703b5455b88c3f66ffbca81393b04fa6abaf02
|
7
|
+
data.tar.gz: b1590914a4e1d687bddfeb94d8e1f5abfc7ef0162dab1745de1d9b91765dcfb37eefa316b5ff1372b0282a0a22b23d9a0a94fc44d4ffa56234572310d7529fa0
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/lib/weekly_planner.rb
CHANGED
@@ -4,6 +4,7 @@
|
|
4
4
|
|
5
5
|
require 'date'
|
6
6
|
require 'dynarex'
|
7
|
+
require 'fileutils'
|
7
8
|
|
8
9
|
|
9
10
|
class WeeklyPlanner
|
@@ -25,8 +26,50 @@ class WeeklyPlanner
|
|
25
26
|
end
|
26
27
|
|
27
28
|
def save(filename=@filename)
|
29
|
+
|
28
30
|
s = File.basename(filename) + "\n" + @s.lines[1..-1].join
|
29
31
|
File.write File.join(@path, filename), s
|
32
|
+
|
33
|
+
# archive the weekly planner
|
34
|
+
# e.g. weeklyplanner/2015/wp50.xml
|
35
|
+
d = Date.strptime(@dx.all.first.id, "%Y%m%d")
|
36
|
+
archive_path = File.join(@path, d.year.to_s)
|
37
|
+
FileUtils.mkdir_p archive_path
|
38
|
+
|
39
|
+
a = @dx.all.partition {|x| Date.strptime(x.id, "%Y%m%d").cweek == d.cweek }
|
40
|
+
|
41
|
+
a.each do |rows|
|
42
|
+
|
43
|
+
filename = "wp%s.xml" % Date.strptime(rows.first.id, "%Y%m%d").cweek
|
44
|
+
filepath = File.join(archive_path, filename)
|
45
|
+
|
46
|
+
if File.exists? filepath then
|
47
|
+
|
48
|
+
dx = Dynarex.new filepath
|
49
|
+
|
50
|
+
rows.each do |row|
|
51
|
+
|
52
|
+
record = dx.find_by_id row.id
|
53
|
+
|
54
|
+
if record then
|
55
|
+
record.x = row.x unless record.x == row.x
|
56
|
+
else
|
57
|
+
dx.create row
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
dx.save filepath
|
62
|
+
|
63
|
+
else
|
64
|
+
|
65
|
+
dx = Dynarex.new 'sections[title]/section(x)'
|
66
|
+
rows.each {|row| dx.create row }
|
67
|
+
dx.save filepath
|
68
|
+
|
69
|
+
end
|
70
|
+
|
71
|
+
end
|
72
|
+
|
30
73
|
end
|
31
74
|
|
32
75
|
def to_s()
|
@@ -71,7 +114,7 @@ class WeeklyPlanner
|
|
71
114
|
heading = "# %s\n" % (d + i).strftime("%d-%b-%Y")
|
72
115
|
|
73
116
|
a.shift # removes the dashed line
|
74
|
-
content = a.join
|
117
|
+
content = a.join.rstrip
|
75
118
|
dx.create({x: heading + content}, id: (d + i).strftime("%Y%m%d"))
|
76
119
|
|
77
120
|
end
|
data.tar.gz.sig
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: weekly_planner
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Robertson
|
@@ -31,7 +31,7 @@ cert_chain:
|
|
31
31
|
z7gNRJqGU+m6WOC+EaEcNkm4WwRqy2Il3J8DydaFl+h20aqjFe1k7KgLU8qy8jyU
|
32
32
|
FlTqE0DQzwY5Dg==
|
33
33
|
-----END CERTIFICATE-----
|
34
|
-
date: 2015-12-
|
34
|
+
date: 2015-12-08 00:00:00.000000000 Z
|
35
35
|
dependencies:
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: dynarex
|
@@ -42,7 +42,7 @@ dependencies:
|
|
42
42
|
version: '1.5'
|
43
43
|
- - ">="
|
44
44
|
- !ruby/object:Gem::Version
|
45
|
-
version: 1.5.
|
45
|
+
version: 1.5.44
|
46
46
|
type: :runtime
|
47
47
|
prerelease: false
|
48
48
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -52,7 +52,7 @@ dependencies:
|
|
52
52
|
version: '1.5'
|
53
53
|
- - ">="
|
54
54
|
- !ruby/object:Gem::Version
|
55
|
-
version: 1.5.
|
55
|
+
version: 1.5.44
|
56
56
|
description:
|
57
57
|
email: james@r0bertson.co.uk
|
58
58
|
executables: []
|
metadata.gz.sig
CHANGED
Binary file
|