ldgr 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1cdd71b68327e76f3c01194a9a24e5e2c053b310
4
- data.tar.gz: 55fb61cbb6400393d965e131165934c015d64d10
3
+ metadata.gz: 2cf0af91bbd0fc24c82ffcba64fe56010760d6a5
4
+ data.tar.gz: 25e3a3306bd5b3d53345fa057684b002d7063640
5
5
  SHA512:
6
- metadata.gz: 2ca3cc59260eb2b85bf97a9a14a9213320c3f66994fb64b1e8b486f264dd9e616d190e2b7827f1ea124c9dac88ccce5215dbe4d0754a2011dce52a51ea2cd570
7
- data.tar.gz: e646c0f9cdc2505bd5300b0eccbc4fdc835e83291caa6a04dd897d289a6e196be715315bc5c779614f8ca17f605a4bb6f84188894646defd4aa47d1da4a0b2e2
6
+ metadata.gz: 51e1bb6a8c4510c348590dc2491585780402cfee9ace93a5b7c12c13d0ec4a39a1b08429d757dfe909dc9923e2741d8fa90b0315485d5781277fb405659fb00f
7
+ data.tar.gz: 10dac09da6a9406235535eba7b4b114c5d59711ac4e9ce1006b407eb18bf3cbb35c4fc610d033b737278bdec47836c4c291ca47ed71ebee636369f9db2850d93
data/.gitignore CHANGED
@@ -7,3 +7,4 @@
7
7
  /pkg/
8
8
  /spec/reports/
9
9
  /tmp/
10
+ config.rb
data/README.md CHANGED
@@ -1,6 +1,21 @@
1
1
  # Ldgr
2
2
 
3
- Ldgr is a command-line tool for adding, sorting and tagging transactions in your Ledger file.
3
+ Ldgr is a command-line tool for adding, sorting and tagging transactions in your Ledger file. It's rather opinionated in that it requires you to break down your Ledger file into multiple files.
4
+
5
+ ~~~
6
+ ~/.config/ledger/
7
+ -> ledger.dat
8
+ -> setup.dat
9
+ -> transactions.dat
10
+ -> accounts.dat
11
+ -> commodities.dat
12
+ -> budgets.dat
13
+ -> aliases.dat
14
+ ~~~
15
+
16
+ ldgr can't handle all the text manipulation of transactions unless it can expect the text in the file to be just transaction data. This may be addressed in the future, but for now, please ahere to this file structure. I think you'll find it works well. You can use the **include** directive in Ledger files to add everything into the **ledger.dat** file.
17
+
18
+ For maximum compatibility, `alias ledger="ledger --init-file ~/.config/ledger/ledgerrc"`, where the RC file contains frequently used command-line options.
4
19
 
5
20
  ## Installation
6
21
 
@@ -40,15 +55,17 @@ ldgr sort
40
55
  ~~~ruby
41
56
  transaction = Ldgr::Transaction.new do |t|
42
57
  t.payee = 'Brandon'
43
- t.amount = 1000
58
+ t.amount = '1000'
44
59
  t.account = 'Something'
45
- t.equity = 'Cash
46
- t.date = Date.today + 1'
47
- t.effective = Date.today + 10'
60
+ t.equity = 'Cash'
61
+ t.date = Date.today + 1
62
+ t.effective = Date.today + 10
48
63
  t.cleared = true
49
64
  end
50
65
  ~~~
51
66
 
67
+ Ledger works with plain text files, so **yes**, the amount attribute should be a string.
68
+
52
69
  ## TODO
53
70
 
54
71
  Currently, the Ledger file is a constant set to `~/.config/ledger/transactions.dat`. This should probably be customizable, possibly with a `.ldgrrc` in the future. Also, the default currency is Japanese Yen. You can change this the `--currency $` flag on the command line or setting it in the `Transaction.new` block. In the future, this should be set in an rc file.
data/bin/ldgr CHANGED
File without changes
data/ldgr.gemspec CHANGED
@@ -35,6 +35,7 @@ Gem::Specification.new do |spec|
35
35
  spec.add_development_dependency "bundler", "~> 1.14"
36
36
  spec.add_development_dependency "rake", "~> 10.0"
37
37
  spec.add_development_dependency "minitest", "~> 5.0"
38
+ spec.add_development_dependency "minitest-reporters"
38
39
 
39
40
  spec.executables << 'ldgr'
40
41
  end
data/lib/ldgr/parser.rb CHANGED
@@ -5,6 +5,7 @@ require 'optparse'
5
5
  require 'optparse/date'
6
6
  require 'pathname'
7
7
  require 'strscan'
8
+ require 'fileutils'
8
9
 
9
10
  module Ldgr
10
11
  class Parser
@@ -133,5 +134,20 @@ module Ldgr
133
134
 
134
135
  open_file(ARGV[1])
135
136
  end
137
+
138
+ def self.setup
139
+ unless config_exist?
140
+ %w(transactions.dat accounts.dat budgets.dat aliases.dat commodities.dat setup.dat ledger.dat).each do |file|
141
+ FileUtils.touch("#{FILEBASE}#{file}")
142
+ end
143
+ end
144
+ end
145
+
146
+ def self.config_exist?
147
+ return false unless Pathname(FILEBASE).exist?
148
+ true
149
+ end
150
+
151
+ setup
136
152
  end
137
153
  end
@@ -12,7 +12,7 @@ module Ldgr
12
12
  #
13
13
  # Returns a transaction.
14
14
  class Transaction
15
- attr_accessor :payee, :amount, :account, :equity, :date, :currency, :cleared
15
+ attr_accessor :payee, :amount, :account, :equity, :date, :effective, :currency, :cleared
16
16
 
17
17
  def initialize(&block)
18
18
  yield self if block_given?
@@ -21,9 +21,16 @@ module Ldgr
21
21
  def to_s
22
22
  <<~HERE
23
23
  #{date} #{cleared}#{payee}
24
- #{account} #{currency}#{amount}
25
- #{equity}
24
+ #{account} #{currency}#{amount}
25
+ #{equity}
26
26
  HERE
27
27
  end
28
+
29
+ def valid?
30
+ return false if String(payee).empty?
31
+ return false if String(amount).empty?
32
+ return false if String(account).empty?
33
+ true
34
+ end
28
35
  end
29
36
  end
data/lib/ldgr/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Ldgr
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ldgr
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brandon Pittman
@@ -66,6 +66,20 @@ dependencies:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
68
  version: '5.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: minitest-reporters
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
69
83
  description: A command-line tool for managing Ledger transactions.
70
84
  email:
71
85
  - ldgr@brandonpittman.net