ldgr 0.1.7 → 0.1.8
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/README.md +10 -2
- data/lib/ldgr/parser.rb +8 -7
- data/lib/ldgr/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dd1b9f7d89658b02753509fe2c2b768627ad4fa8
|
4
|
+
data.tar.gz: 5978628789242f582e8830f30f24fcca9e59d3e2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e255ab170b8b1ef33fd2ab0639befe62455ab602651b7838b9eb00fb8477343e2b04c49c677ba8693805eee80955df478f537a50b52b2abdde6b808268d8a771
|
7
|
+
data.tar.gz: 5d75bc6a48e72a46b1794034357c35e9bf01cab8f9aa5851b901f709d90c306f34938a86b1961ea86d92371e667202d4a06c34fe384023a3a48dfca68022dd7b
|
data/README.md
CHANGED
@@ -35,8 +35,16 @@ Or install it yourself as:
|
|
35
35
|
|
36
36
|
## Customization
|
37
37
|
|
38
|
-
- The CLI defaults the currency to **$**.
|
39
|
-
- The CLI defaults the equity to **Cash
|
38
|
+
- The CLI defaults the currency to **$**.
|
39
|
+
- The CLI defaults the equity to **Cash**.
|
40
|
+
|
41
|
+
~~~yaml
|
42
|
+
---
|
43
|
+
:currency: ¥
|
44
|
+
:equity: My Sweet Cash Pile
|
45
|
+
~~~
|
46
|
+
|
47
|
+
**Use symbols in YAML file.
|
40
48
|
|
41
49
|
## CLI
|
42
50
|
```
|
data/lib/ldgr/parser.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
require 'irb'
|
1
2
|
require 'csv'
|
2
3
|
require 'date'
|
3
4
|
require 'highline/import'
|
@@ -19,6 +20,7 @@ module Ldgr
|
|
19
20
|
COMMANDS = %w(add sort tag clear open)
|
20
21
|
SETUP_FILES = %w(transactions.dat accounts.dat budgets.dat aliases.dat commodities.dat setup.dat ledger.dat ldgr.yaml)
|
21
22
|
CONFIG_FILE = Pathname(FILEBASE + 'ldgr.yaml')
|
23
|
+
LDGR_DEFAULTS = { currency: '$', equity: 'Cash' }.to_h
|
22
24
|
|
23
25
|
def self.parse
|
24
26
|
cli = OptionParser.new do |o|
|
@@ -37,9 +39,9 @@ module Ldgr
|
|
37
39
|
o.define '-p', '--payee=PAYEE', String, 'the payee of the transaction'
|
38
40
|
end
|
39
41
|
|
40
|
-
config =
|
42
|
+
config = defaults
|
41
43
|
command = String(cli.parse(ARGV, into: config)[0])
|
42
|
-
|
44
|
+
binding.irb
|
43
45
|
send(command, config) if COMMANDS.include? command
|
44
46
|
end
|
45
47
|
|
@@ -138,9 +140,8 @@ module Ldgr
|
|
138
140
|
open_file(ARGV[1])
|
139
141
|
end
|
140
142
|
|
141
|
-
def self.defaults
|
142
|
-
|
143
|
-
defaults_hash.merge(YAML.load_file(CONFIG_FILE).to_h)
|
143
|
+
def self.defaults(config_file=CONFIG_FILE)
|
144
|
+
LDGR_DEFAULTS.merge(YAML.load_file(config_file).to_h)
|
144
145
|
end
|
145
146
|
|
146
147
|
def self.setup
|
@@ -152,8 +153,8 @@ module Ldgr
|
|
152
153
|
end
|
153
154
|
end
|
154
155
|
|
155
|
-
def self.config_exist?
|
156
|
-
|
156
|
+
def self.config_exist?(setup_files=SETUP_FILES)
|
157
|
+
setup_files.each do |file|
|
157
158
|
return false unless Pathname("#{FILEBASE}#{file}").exist?
|
158
159
|
end
|
159
160
|
true
|
data/lib/ldgr/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ldgr
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brandon Pittman
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-02-
|
11
|
+
date: 2017-02-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: highline
|