quickpep 0.2.3 → 0.3.1

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
  SHA256:
3
- metadata.gz: d2b2877222c85adc6b6af50aeb05b84da3e33f7e0826def01fb4212d443758fb
4
- data.tar.gz: 94da811b22114d193553586d60e5e810c6afdb333b7e4e7de6dbd6f4a5930a0c
3
+ metadata.gz: a11692d4544d14274014ad95d734826f40ea09fa8d1aba6327cfa310944b7dfd
4
+ data.tar.gz: 55695265b868dc5877a84f1b4dc82f650c00cac81c7a3524f3a75a3a16e86b39
5
5
  SHA512:
6
- metadata.gz: d9fc43143a9d8768ae036501406bc2668847590e9f784e08322ca952663a3e9bb203f867eca58ff1606f6737021070c45618e27a81c68979b4f5db16a62b675e
7
- data.tar.gz: c55dd271c48a2cc9e73c857cd347dea4ddc43ad3a9bee652b708602f9ebd86137b24a02df5c9184ee9d81c87a4f05cb961ddafbfccb2482335bddd0d7d4faeac
6
+ metadata.gz: ad6cc19a92376347ec2d487f7c52b6ee51b623654a45976fef503da4be7288ded73ec1e304d8fae1bc6e863003472db0889fe84ea779ea646271ccec44713a3e
7
+ data.tar.gz: ef56f151dc731176fe91354e9b68053fe758556774be0f96feb74f42d7d7d717582f84369545ce99978dab5d97249d11199fd2a1521765559322700ddc7b22e1
checksums.yaml.gz.sig CHANGED
Binary file
data/data/quickpep.txt ADDED
@@ -0,0 +1,68 @@
1
+ :html
2
+ <html>
3
+ <head>
4
+ <meta name='viewport' content='width=device-width, initial-scale=1'>
5
+ <title>#{title}</title>
6
+ <style>
7
+ table {border-collapse: collapse; width: 700px}
8
+ tr:nth-child(even) {
9
+ background-color: #aca;
10
+ }
11
+ @media print {
12
+
13
+ tr:nth-child(even) {
14
+ background-color: #ccc;
15
+ }
16
+
17
+ }
18
+ table tr td, table thead th {padding: 0.3em; margin: 0.1em}
19
+ #input table {border: 4px; background-color: #d3a;}
20
+ #input table thead {color: #131;}
21
+ #input table tr, #input table td {border: 1px solid green; padding: 3px; background-color: #dea;}
22
+ #input table tr td {
23
+ text-align: center;
24
+ }
25
+ #summary div {background-color: transparent; float: left; margin: 0.3em; padding: 1.2em; border: 1px solid #18e}
26
+
27
+ #breakdown table {background-color: transparent; width: 190px}
28
+ #breakdown table tr {background-color: transparent;}
29
+ #costsum table {background-color: transparent; width: 400px}
30
+ #costsum table tr {background-color: transparent; border-bottom: 1px solid #888;}
31
+ #costsum table tr td {background-color: transparent; padding: 1.0em 0.5em; margin: 0.4em 0.2em}
32
+ #summary div ul {list-style-type: none; background-color: transparent; padding: 0.5em; }
33
+ .break {page-break-before: always}
34
+ #input {clear: both;}
35
+ footer {font-size: 0.8em; color: #888;}
36
+ </style>
37
+
38
+ </head>
39
+ <body>
40
+ <h1>#{title}</h1>
41
+ #{html_table}
42
+ <div id='summary' class='break'>
43
+ <h2>Summary</h2>
44
+
45
+ <div id='breakdown'>
46
+ <h3>Breakdown</h3>
47
+ #{html_breakdown}
48
+ </div>
49
+
50
+ <div id='costsum'>
51
+ <h3>Expense per item</h3>
52
+ #{html_cs}
53
+ </div>
54
+ <div>
55
+ <h3>Running expense</h3>
56
+
57
+ #{html_cpi}
58
+ </div>
59
+ </div>
60
+ <div id='input' class='break'>
61
+ <h3>Input</h3>
62
+
63
+ #{html_table2}
64
+ </div>
65
+ <hr/>
66
+ <footer>Generated by QuickPEP; #{time_now}</footer>
67
+ </body>
68
+ </html>
data/lib/quickpep.rb CHANGED
@@ -4,24 +4,38 @@
4
4
 
5
5
  require 'dynarex'
6
6
  require 'event_nlp'
7
+ require 'weblet'
8
+
7
9
 
8
10
  # Quick Personal Expenses Planner - for people too lazy to use a
9
- # spreadsheet or sfinance app
11
+ # spreadsheet or finance app
10
12
  #
11
13
  class QuickPep
12
14
  using ColouredText
13
15
 
14
16
  attr_reader :to_s, :to_dx, :input
15
17
 
18
+ # end_date: should be in natural english format e.g. 2nd October
19
+ #
16
20
  def initialize(s, balance: 0, currency: '', today: Date.today,
17
- ignorewarnings: false, debug: false)
21
+ ignorewarnings: false, end_date: nil, debug: false)
18
22
 
19
23
  @balance, @currency, @debug = balance, currency, debug
20
- @today = today
24
+
25
+ @today = if today.is_a?(String) then
26
+ Chronic.parse(today).to_date
27
+ else
28
+ today
29
+ end
30
+
31
+ @end_date = end_date
21
32
  @warnings = []
22
33
  @to_s = calc_expenses(s)
23
34
 
24
35
  warnings() if @warnings.any? and not ignorewarnings
36
+
37
+ @weblet_file = weblet_file ||= File.join(File.dirname(__FILE__), '..', 'data',
38
+ 'quickpep.txt')
25
39
 
26
40
  end
27
41
 
@@ -107,73 +121,17 @@ class QuickPep
107
121
  t2.labels = %w(Title Amount: :Day: :Recurring: :Notes:)
108
122
  table2 = t2.display markdown: true
109
123
 
110
- "<html>
111
- <head>
112
- <meta name='viewport' content='width=device-width, initial-scale=1'>
113
- <title>#{title}</title>
114
- <style>
115
- table {border-collapse: collapse; width: 700px}
116
- tr:nth-child(even) {
117
- background-color: #aca;
118
- }
119
- @media print {
120
-
121
- tr:nth-child(even) {
122
- background-color: #ccc;
123
- }
124
-
125
- }
126
- table tr td, table thead th {padding: 0.3em; margin: 0.1em}
127
- #input table {border: 4px; background-color: #d3a;}
128
- #input table thead {color: #131;}
129
- #input table tr, #input table td {border: 1px solid green; padding: 3px; background-color: #dea;}
130
- #input table tr td {
131
- text-align: center;
132
- }
133
- #summary div {background-color: transparent; float: left; margin: 0.3em; padding: 1.2em; border: 1px solid #18e}
134
-
135
- #breakdown table {background-color: transparent; width: 190px}
136
- #breakdown table tr {background-color: transparent;}
137
- #costsum table {background-color: transparent; width: 400px}
138
- #costsum table tr {background-color: transparent; border-bottom: 1px solid #888;}
139
- #costsum table tr td {background-color: transparent; padding: 1.0em 0.5em; margin: 0.4em 0.2em}
140
- #summary div ul {list-style-type: none; background-color: transparent; padding: 0.5em; }
141
- .break {page-break-before: always}
142
- #input {clear: both;}
143
- footer {font-size: 0.8em; color: #888;}
144
- </style>
145
-
146
- </head>
147
- <body>
148
- <h1>#{title}</h1>
149
- #{RDiscount.new(table).to_html}
150
- <div id='summary'>
151
- <h2>Summary</h2>
152
-
153
- <div id='breakdown'>
154
- <h3>Breakdown</h3>
155
- #{RDiscount.new(breakdown().to_table()).to_html}
156
- </div>
157
-
158
- <div id='costsum'>
159
- <h3>Expense per item</h3>
160
- #{RDiscount.new(costs_summary()).to_html}
161
- </div>
162
- <div>
163
- <h3>Running expense</h3>
164
-
165
- #{RDiscount.new(costs_per_interval).to_html}
166
- </div>
167
- </div>
168
- <div id='input'>
169
- <h3>Input</h3>
170
-
171
- #{RDiscount.new(table2).to_html}
172
- </div>
173
- <hr/>
174
- <footer>Generated by QuickPEP; #{Time.now.strftime("%d %b %Y")}</footer>
175
- </body>
176
- </html>"
124
+ html_table = RDiscount.new(table).to_html
125
+ html_breakdown = RDiscount.new(breakdown().to_table()).to_html
126
+ html_cs = RDiscount.new(costs_summary()).to_html
127
+ html_cpi = RDiscount.new(costs_per_interval).to_html
128
+ html_table2 = RDiscount.new(table2).to_html
129
+ time_now = Time.now.strftime("%d %b %Y")
130
+
131
+ w = Weblet.new(@weblet_file)
132
+
133
+ w.render :html, binding
134
+
177
135
  end
178
136
 
179
137
  def total_expenses()
@@ -203,7 +161,10 @@ class QuickPep
203
161
  title = [rx.title, rx.day, recurring].join(' ')
204
162
  puts '1. title: ' + title.inspect if @debug
205
163
  e = EventNlp.new(@today.to_time)
206
- e.project(title).map {|x| [x.to_date, e.parse(title).title]}
164
+ title2 = @end_date ? (title + ' until ' + @end_date) : title
165
+ puts 'title2: ' + title2.inspect if @debug
166
+ #exit
167
+ e.project(title2).map {|x| [x.to_date, e.parse(title).title]}
207
168
 
208
169
  end.clone.sort_by(&:first)
209
170
 
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: quickpep
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Robertson
@@ -35,7 +35,7 @@ cert_chain:
35
35
  kmcJnzHNiVwSBry7rnILYU3ouLJeHEtQY1v/S4KqPXGNS1FPvas3Wb429Cui2LtB
36
36
  CkYfvLZCZS1SZGB2dGilreNS
37
37
  -----END CERTIFICATE-----
38
- date: 2022-05-21 00:00:00.000000000 Z
38
+ date: 2023-03-30 00:00:00.000000000 Z
39
39
  dependencies:
40
40
  - !ruby/object:Gem::Dependency
41
41
  name: event_nlp
@@ -43,46 +43,67 @@ dependencies:
43
43
  requirements:
44
44
  - - "~>"
45
45
  - !ruby/object:Gem::Version
46
- version: '0.6'
46
+ version: '0.8'
47
47
  - - ">="
48
48
  - !ruby/object:Gem::Version
49
- version: 0.6.8
49
+ version: 0.8.1
50
50
  type: :runtime
51
51
  prerelease: false
52
52
  version_requirements: !ruby/object:Gem::Requirement
53
53
  requirements:
54
54
  - - "~>"
55
55
  - !ruby/object:Gem::Version
56
- version: '0.6'
56
+ version: '0.8'
57
57
  - - ">="
58
58
  - !ruby/object:Gem::Version
59
- version: 0.6.8
59
+ version: 0.8.1
60
60
  - !ruby/object:Gem::Dependency
61
61
  name: dynarex
62
62
  requirement: !ruby/object:Gem::Requirement
63
63
  requirements:
64
64
  - - "~>"
65
65
  - !ruby/object:Gem::Version
66
- version: '1.9'
66
+ version: '1.10'
67
67
  - - ">="
68
68
  - !ruby/object:Gem::Version
69
- version: 1.9.10
69
+ version: 1.10.0
70
70
  type: :runtime
71
71
  prerelease: false
72
72
  version_requirements: !ruby/object:Gem::Requirement
73
73
  requirements:
74
74
  - - "~>"
75
75
  - !ruby/object:Gem::Version
76
- version: '1.9'
76
+ version: '1.10'
77
77
  - - ">="
78
78
  - !ruby/object:Gem::Version
79
- version: 1.9.10
79
+ version: 1.10.0
80
+ - !ruby/object:Gem::Dependency
81
+ name: weblet
82
+ requirement: !ruby/object:Gem::Requirement
83
+ requirements:
84
+ - - "~>"
85
+ - !ruby/object:Gem::Version
86
+ version: '0.4'
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: 0.4.1
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '0.4'
97
+ - - ">="
98
+ - !ruby/object:Gem::Version
99
+ version: 0.4.1
80
100
  description:
81
101
  email: digital.robertson@gmail.com
82
102
  executables: []
83
103
  extensions: []
84
104
  extra_rdoc_files: []
85
105
  files:
106
+ - data/quickpep.txt
86
107
  - lib/quickpep.rb
87
108
  homepage: https://github.com/jrobertson/quickpep
88
109
  licenses:
@@ -103,7 +124,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
103
124
  - !ruby/object:Gem::Version
104
125
  version: '0'
105
126
  requirements: []
106
- rubygems_version: 3.2.22
127
+ rubygems_version: 3.4.4
107
128
  signing_key:
108
129
  specification_version: 4
109
130
  summary: Quick Personal Expenses Planner - for people too lazy to use a spreadsheet
metadata.gz.sig CHANGED
Binary file