nom 0.1.2.2 → 0.1.3
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
- data/lib/nom/config.rb +1 -0
- data/lib/nom/nom.plt.erb +1 -1
- data/lib/nom/nom.rb +18 -7
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7631851ac3b0706686593b269cf49b21d8de8599
|
4
|
+
data.tar.gz: 98c3d3b7f73cb9ee660c33d3e8f60385e6049183
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8d485c873e3f738c69be2d4ffa997677062a43c0c083346c5a4ba2655a4230ec2b5524d27f301d0e160add5b18865ea454924b7bb258c41ab6a78fa5e8bd4493
|
7
|
+
data.tar.gz: fb82204147412eace494619adf76e7d447af500baf9567b9182656ac16ddfc5f8590580f4ca94b07bbb2215d4cdc8c3a67966732414c683bda4775b0c882b8e5
|
data/lib/nom/config.rb
CHANGED
@@ -18,6 +18,7 @@ module Nom
|
|
18
18
|
"unit" => [ "your desired base unit in kcal", 1, Float ],
|
19
19
|
"start_date" => [ "the first day that should be considered by nom [yyyy-mm-dd]", nil, Date ],
|
20
20
|
"balance_start" => [ "the day from which on nom should keep track of a energy balance [yyyy-mm-dd]", nil, Date ],
|
21
|
+
"balance_factor" => [ "how many money units you'll have to pay per energy unit", 0.01, Float ],
|
21
22
|
}
|
22
23
|
end
|
23
24
|
|
data/lib/nom/nom.plt.erb
CHANGED
@@ -31,7 +31,7 @@ plot <%= goal %> t "Goal" lc rgb "forest-green" lw 2, \
|
|
31
31
|
unset obj 1
|
32
32
|
|
33
33
|
set yrange [ 0 : <%= quantize((@weights.first..@weights.last).map{|d| [consumed_at(d), allowed_kcal(d, 0), allowed_kcal(d, rate)]}.flatten.max) %> ]
|
34
|
-
set ytics 200 nomirror
|
34
|
+
set ytics <%= quantize(200) %> nomirror
|
35
35
|
set key right bottom
|
36
36
|
|
37
37
|
plot "<%= input_dat.path %>" using 1:2:(0):($4-$2) w vectors nohead lc rgb "navy" notitle, \
|
data/lib/nom/nom.rb
CHANGED
@@ -201,11 +201,13 @@ module Nom
|
|
201
201
|
|
202
202
|
def nom_entry args, date
|
203
203
|
summands = args.pop.split("+")
|
204
|
-
|
204
|
+
number = summands.inject(0) do |sum, summand|
|
205
205
|
factors = summand.split("x")
|
206
206
|
sum + factors.map{ |f| f.to_f }.inject(1){ |p,f| p*f }
|
207
207
|
end
|
208
208
|
|
209
|
+
kcal = dequantize(number)
|
210
|
+
|
209
211
|
if kcal == 0
|
210
212
|
raise "energy term cannot be zero"
|
211
213
|
end
|
@@ -233,8 +235,8 @@ module Nom
|
|
233
235
|
if r.nil?
|
234
236
|
r = @weights.rate_at(date, goal, rate)
|
235
237
|
end
|
236
|
-
if date > @weights.
|
237
|
-
date = @weights.
|
238
|
+
if date > @weights.last_real
|
239
|
+
date = @weights.last_real
|
238
240
|
end
|
239
241
|
@base_rate_at[date] + r*1000
|
240
242
|
end
|
@@ -305,7 +307,11 @@ module Nom
|
|
305
307
|
end
|
306
308
|
|
307
309
|
def quantize kcal
|
308
|
-
|
310
|
+
(1.0*kcal/@config.get("unit")).round
|
311
|
+
end
|
312
|
+
|
313
|
+
def dequantize number
|
314
|
+
(1.0*number*@config.get("unit")).round
|
309
315
|
end
|
310
316
|
|
311
317
|
def format_date date
|
@@ -353,10 +359,15 @@ module Nom
|
|
353
359
|
remaining -= i.kcal
|
354
360
|
end
|
355
361
|
separator
|
356
|
-
entry(quantize(remaining), "remaining (#{(100-100.0*remaining/allowed_kcal(date)).round}% used)")
|
362
|
+
entry(quantize(remaining), "remaining (#{(100-100.0*quantize(remaining)/quantize(allowed_kcal(date))).round}% used)")
|
357
363
|
end
|
358
|
-
if kcal_balance > 0
|
359
|
-
|
364
|
+
if kcal_balance > 0 and @config.has("balance_start")
|
365
|
+
cost = if @config.has("balance_factor")
|
366
|
+
" (cost: %.2f)" % (@config.get("balance_factor")*quantize(kcal_balance)).round(2)
|
367
|
+
else
|
368
|
+
""
|
369
|
+
end
|
370
|
+
entry(quantize(kcal_balance), "too much since #{balance_start}#{cost}")
|
360
371
|
end
|
361
372
|
end
|
362
373
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nom
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sebastian Morr
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-03-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|
@@ -64,7 +64,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
64
64
|
requirements:
|
65
65
|
- gnuplot
|
66
66
|
rubyforge_project:
|
67
|
-
rubygems_version: 2.
|
67
|
+
rubygems_version: 2.5.1
|
68
68
|
signing_key:
|
69
69
|
specification_version: 4
|
70
70
|
summary: Lose weight and hair through stress and poor nutrition
|