nom 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/README.md +8 -3
- data/bin/nom +11 -1
- data/lib/nom/nom.plt.erb +1 -1
- data/lib/nom/nom.rb +21 -14
- data/lib/nom/weight_database.rb +1 -1
- metadata +8 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 9552983cfcde8485668665b06976e054a7221c131d0dc134c9aa0cb435818f2b
|
4
|
+
data.tar.gz: 81568f52af092e92e20c4252b1073b0b8e5ac06c3629e63a50714d06744c89e2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f96691c27e135e7399e5e2b2df338a0a6b89f70e98e5d0470b31aeff066719f77a0728bc112027ca450411d2e9fef9b70d41bad2eb3cc3deddf5e28c8fd6f8d7
|
7
|
+
data.tar.gz: 9350d1aedf1cbeeaee8f99f47aee4026dd2bf0e4ec0619c315d99ba76f2e1fdd64cd4b67ad02ba7f235d7b167dee18a8d5e7f284aa9df0f727d0cf6971bda3c8
|
data/README.md
CHANGED
@@ -59,7 +59,7 @@ And get nice graphs. The upper graph shows weight over time, with a weighted (no
|
|
59
59
|
|
60
60
|
$ nom plot
|
61
61
|
|
62
|
-
![Graphs of weight and input over time](http://files.
|
62
|
+
![Graphs of weight and input over time](http://files.blinry.org/nom-0.1.0.svg)
|
63
63
|
|
64
64
|
Enter `nom help` if you're lost:
|
65
65
|
|
@@ -91,9 +91,14 @@ Enter `nom help` if you're lost:
|
|
91
91
|
|
92
92
|
## Conventions
|
93
93
|
|
94
|
-
*nom*
|
94
|
+
*nom* looks for its configuration directory in `${XDG_DATA_HOME}/nom`, `~/.local/share/nom`, or `~/.nom/` (in that order),
|
95
|
+
and operates on three files in that configuration directory:
|
96
|
+
* `config` contains configuration settings
|
97
|
+
* `input` contains stuff you ate
|
98
|
+
* `weight` contains weight measurements.
|
99
|
+
The files are plain text, you can edit them by hand.
|
95
100
|
|
96
|
-
By default, energy quantities will have the unit "kcal". You can change this by adding a line like `unit: 0.239` to your
|
101
|
+
By default, energy quantities will have the unit "kcal". You can change this by adding a line like `unit: 0.239` to your `config`, which means you want to use the unit "0.239 kcal" (= "1 kJ"). Energy quantities are displayed in parentheses: `(42)`
|
97
102
|
|
98
103
|
Weight quantities are displayed as "kg", but you can use arbitrary units, like pounds.
|
99
104
|
|
data/bin/nom
CHANGED
@@ -19,9 +19,19 @@ commands = [
|
|
19
19
|
[ "help", nil, nil, "Print this help" ],
|
20
20
|
]
|
21
21
|
|
22
|
+
aliases = {
|
23
|
+
"--help": "help",
|
24
|
+
"-h": "help",
|
25
|
+
}
|
26
|
+
|
22
27
|
nom = Nom::Nom.new
|
23
28
|
|
24
|
-
cmd_name = ARGV.shift or "status"
|
29
|
+
cmd_name = (ARGV.shift or "status")
|
30
|
+
|
31
|
+
if aliases.include? cmd_name.to_sym
|
32
|
+
cmd_name = aliases[cmd_name.to_sym]
|
33
|
+
end
|
34
|
+
|
25
35
|
command = commands.find{|c| c[0] == cmd_name or c[1] == cmd_name}
|
26
36
|
|
27
37
|
if command.nil?
|
data/lib/nom/nom.plt.erb
CHANGED
data/lib/nom/nom.rb
CHANGED
@@ -13,8 +13,16 @@ require "nom/helpers"
|
|
13
13
|
module Nom
|
14
14
|
class Nom
|
15
15
|
def initialize
|
16
|
-
|
17
|
-
|
16
|
+
xdg_data = (ENV["XDG_DATA_HOME"] or File.join(Dir.home, ".local", "share"))
|
17
|
+
preferred_config_location = File.join(xdg_data, "nom")
|
18
|
+
[ preferred_config_location, File.join(Dir.home,".nom") ].each do |dir|
|
19
|
+
if Dir.exists? dir
|
20
|
+
@nom_dir = dir
|
21
|
+
break
|
22
|
+
end
|
23
|
+
end
|
24
|
+
if not @nom_dir or not Dir.exists? @nom_dir
|
25
|
+
@nom_dir = preferred_config_location
|
18
26
|
puts "Creating #{@nom_dir}"
|
19
27
|
Dir.mkdir(@nom_dir)
|
20
28
|
end
|
@@ -34,9 +42,9 @@ module Nom
|
|
34
42
|
end
|
35
43
|
|
36
44
|
@weights.interpolate_gaps!
|
37
|
-
@weights.precompute_moving_average!(0.
|
45
|
+
@weights.precompute_moving_average!(0.05, 0.05, goal, rate)
|
38
46
|
@weights.predict_weights!(rate, goal, 30)
|
39
|
-
@weights.precompute_moving_average!(0.
|
47
|
+
@weights.precompute_moving_average!(0.05, 0.05, goal, rate)
|
40
48
|
|
41
49
|
precompute_inputs_at
|
42
50
|
precompute_base_rate_at
|
@@ -106,13 +114,13 @@ module Nom
|
|
106
114
|
term = args.join(" ")
|
107
115
|
puts
|
108
116
|
term = term.encode("ISO-8859-1")
|
109
|
-
url = "
|
117
|
+
url = "https://fddb.info/db/de/suche/?udd=0&cat=site-de&search=#{CGI.escape(term)}"
|
110
118
|
|
111
|
-
page = Nokogiri::HTML(open(url))
|
119
|
+
page = Nokogiri::HTML(URI.open(url))
|
112
120
|
results = page.css(".standardcontent a").map{|a| a["href"]}.select{|href| href.include? "lebensmittel"}
|
113
121
|
|
114
122
|
results[0..4].each do |result|
|
115
|
-
page = Nokogiri::HTML(open(result))
|
123
|
+
page = Nokogiri::HTML(URI.open("https://fddb.info"+result))
|
116
124
|
title = page.css(".breadcrumb a").last.text
|
117
125
|
brand = page.css(".standardcontent p a").select{|a| a["href"].include? "hersteller"}.first.text
|
118
126
|
puts "#{title} (#{brand})"
|
@@ -121,7 +129,7 @@ module Nom
|
|
121
129
|
size = serving.css("a.servb").text
|
122
130
|
kcal = serving.css("div")[5].css("div")[1].text.to_i
|
123
131
|
#kj = serving.css("div")[2].css("div")[1].text.to_i
|
124
|
-
puts " (#{quantize(kcal)}) #{size}"
|
132
|
+
puts " (#{quantize(kcal,1)}) #{size}"
|
125
133
|
end
|
126
134
|
end
|
127
135
|
end
|
@@ -306,8 +314,8 @@ module Nom
|
|
306
314
|
end
|
307
315
|
end
|
308
316
|
|
309
|
-
def quantize kcal
|
310
|
-
(1.0*kcal/@config.get("unit")).round
|
317
|
+
def quantize kcal, decimal_places=0
|
318
|
+
(1.0*kcal/@config.get("unit")).round(decimal_places)
|
311
319
|
end
|
312
320
|
|
313
321
|
def dequantize number
|
@@ -349,17 +357,16 @@ module Nom
|
|
349
357
|
def log_since start
|
350
358
|
remaining = 0
|
351
359
|
start.upto(Date.today) do |date|
|
352
|
-
remaining += allowed_kcal(date)
|
353
360
|
puts
|
354
361
|
puts "#{format_date(date)}: (#{quantize(allowed_kcal(date))})"
|
355
362
|
puts
|
356
|
-
remaining = allowed_kcal(date)
|
363
|
+
remaining = quantize(allowed_kcal(date))
|
357
364
|
inputs_at(date).each do |i|
|
358
365
|
entry(quantize(i.kcal), i.description)
|
359
|
-
remaining -= i.kcal
|
366
|
+
remaining -= quantize(i.kcal)
|
360
367
|
end
|
361
368
|
separator
|
362
|
-
entry(
|
369
|
+
entry(remaining, "remaining (#{(100-100.0*remaining/quantize(allowed_kcal(date))).round}% used)")
|
363
370
|
end
|
364
371
|
if kcal_balance > 0 and @config.has("balance_start")
|
365
372
|
cost = if @config.has("balance_factor")
|
data/lib/nom/weight_database.rb
CHANGED
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.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
-
|
8
|
-
autorequire:
|
7
|
+
- blinry
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-09-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|
@@ -29,7 +29,7 @@ description: |-
|
|
29
29
|
tracking your energy intake and creating a negative feedback loop.
|
30
30
|
It's inspired by John Walker's "The Hacker's Diet" and tries to
|
31
31
|
automate things as much as possible.
|
32
|
-
email:
|
32
|
+
email: mail@blinry.org
|
33
33
|
executables:
|
34
34
|
- nom
|
35
35
|
extensions: []
|
@@ -47,7 +47,7 @@ homepage: https://github.com/blinry/nom
|
|
47
47
|
licenses:
|
48
48
|
- GPL-2.0+
|
49
49
|
metadata: {}
|
50
|
-
post_install_message:
|
50
|
+
post_install_message:
|
51
51
|
rdoc_options: []
|
52
52
|
require_paths:
|
53
53
|
- lib
|
@@ -63,9 +63,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
63
63
|
version: '0'
|
64
64
|
requirements:
|
65
65
|
- gnuplot
|
66
|
-
|
67
|
-
|
68
|
-
signing_key:
|
66
|
+
rubygems_version: 3.3.21
|
67
|
+
signing_key:
|
69
68
|
specification_version: 4
|
70
69
|
summary: Lose weight and hair through stress and poor nutrition
|
71
70
|
test_files: []
|