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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c8c6866c2d4d40abc43e7a8e8ea43c58b7c84fd6
4
- data.tar.gz: d61e4c679154b467de16b50690614bde21541a72
3
+ metadata.gz: dd1b9f7d89658b02753509fe2c2b768627ad4fa8
4
+ data.tar.gz: 5978628789242f582e8830f30f24fcca9e59d3e2
5
5
  SHA512:
6
- metadata.gz: afe0f8e4e8a9e0956e7a68e53f884ebffd33479fd2f5675729fe5df9ff88910162a61e11334c71365f0365c35888c425e47dcc11147f30c706ba179274654690
7
- data.tar.gz: e4b89b0bffdacdbcf027ac7f1e8377b4c7fb5c5e1f86cdfd579fc6707940debd334974dee9e4324bad0679d6218fb22bd747e68215dd4ec1cc41b48617a3d1ba
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 **$**. You can set a new default yourself by adding `currency: someCurrencyCharacter` to `~/.config/ledger/ldgr.yaml`.
39
- - The CLI defaults the equity to **Cash** You can set a new default yourself by adding `equity: someEquityAccount` to `~/.config/ledger/ldgr.yaml`.
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
- defaults_hash = {}
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
- SETUP_FILES.each do |file|
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
@@ -1,3 +1,3 @@
1
1
  module Ldgr
2
- VERSION = "0.1.7"
2
+ VERSION = "0.1.8"
3
3
  end
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.7
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-06 00:00:00.000000000 Z
11
+ date: 2017-02-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: highline