gnucash 1.1.0 → 1.2.0
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 +15 -0
- data/README.md +17 -1
- data/Rakefile +6 -0
- data/gnucash.gemspec +3 -0
- data/lib/gnucash.rb +6 -6
- data/lib/gnucash/account.rb +3 -1
- data/lib/gnucash/book.rb +2 -2
- data/lib/gnucash/transaction.rb +4 -2
- data/lib/gnucash/version.rb +1 -1
- data/spec/gnucash/account_spec.rb +3 -3
- data/spec/gnucash/book_spec.rb +3 -3
- data/spec/gnucash/transaction_spec.rb +5 -3
- metadata +47 -19
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
YTlmNWViYWRiZWVmNzlhYWE2NDdmODc1ZGIyYmFmZTEzNzBiOGJkYg==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
YmFmZGY1YmQ0NzkxYTRlMGEzYjBiNjVjZDE0ZTBjNDU2MGQxMGVjMQ==
|
7
|
+
SHA512:
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
NzExNTNlOTgxZjk3MjI2ZWQ4ZmFlMDIwZDEwOTQ1YzZmN2I4MmEyM2E1YTlm
|
10
|
+
MGNlMjU1NzE2MjdkZTVmZDdmZWM5YzkzNDU3YmM2MThhNzk0NzMyYzViMzBk
|
11
|
+
Y2E0MTM4ZTNmYWIzOGUzNzk1ZDkwYWJjMjU2ZGYyYzEwNzBhNmE=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
ZjY0NzY5YjZhN2Y0OWMyNTNmNzRmMjE3MTE0MjFhNjM0YWUzNTcxY2Y1ZmM1
|
14
|
+
ODg2Y2UzMzJhODJjODNiZDIxNDAwOTllMDFhOTVkNTZiYWEwYmIzZWRjYTZk
|
15
|
+
ZTQ1MTU4ODBlZDQ4ZTcxOTkxZWZhNjA5Y2M3ZGQzNGYwN2U0Mzg=
|
data/README.md
CHANGED
@@ -2,6 +2,8 @@
|
|
2
2
|
|
3
3
|
Ruby library for extracting data from GnuCash data files
|
4
4
|
|
5
|
+
[](http://badge.fury.io/rb/gnucash)
|
6
|
+
|
5
7
|
## Installation
|
6
8
|
|
7
9
|
Add this line to your application's Gemfile:
|
@@ -26,7 +28,7 @@ Or install it yourself as:
|
|
26
28
|
puts "#{account.full_name}: #{account.final_balance}"
|
27
29
|
end
|
28
30
|
|
29
|
-
act = book.find_account_by_full_name("Assets
|
31
|
+
act = book.find_account_by_full_name("Assets:Checking")
|
30
32
|
balance = Gnucash::Value.zero
|
31
33
|
act.transactions.each do |txn|
|
32
34
|
balance += txn.value
|
@@ -37,6 +39,20 @@ Or install it yourself as:
|
|
37
39
|
txn.description))
|
38
40
|
end
|
39
41
|
|
42
|
+
## Release Notes
|
43
|
+
|
44
|
+
### v1.2.0
|
45
|
+
|
46
|
+
- use Date objects instead of formatted strings for dates
|
47
|
+
- use a single colon instead of a double colon in account names
|
48
|
+
- use 'require_relative' instead of 'require'
|
49
|
+
|
50
|
+
### v1.1.0
|
51
|
+
|
52
|
+
- store and provide access to the account description
|
53
|
+
- change many attributes to read-only
|
54
|
+
- add 'placeholder' Account attribute
|
55
|
+
|
40
56
|
## Contributing
|
41
57
|
|
42
58
|
1. Fork it
|
data/Rakefile
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
require "bundler"
|
2
|
+
begin
|
3
|
+
Bundler.setup(:default, :development)
|
4
|
+
rescue Bundler::BundlerError => e
|
5
|
+
raise LoadError.new("Unable to Bundler.setup(): You probably need to run `bundle install`: #{e.message}")
|
6
|
+
end
|
1
7
|
require "bundler/gem_tasks"
|
2
8
|
require "rake/clean"
|
3
9
|
require "rspec/core/rake_task"
|
data/gnucash.gemspec
CHANGED
@@ -25,4 +25,7 @@ Gem::Specification.new do |gem|
|
|
25
25
|
gem.add_development_dependency "rspec-core"
|
26
26
|
gem.add_development_dependency "rspec-expectations"
|
27
27
|
gem.add_development_dependency "rspec-mocks"
|
28
|
+
gem.add_development_dependency "rake"
|
29
|
+
gem.add_development_dependency "rdoc"
|
30
|
+
gem.add_development_dependency "yard"
|
28
31
|
end
|
data/lib/gnucash.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
1
|
+
require_relative "gnucash/account"
|
2
|
+
require_relative "gnucash/account_transaction"
|
3
|
+
require_relative "gnucash/book"
|
4
|
+
require_relative "gnucash/transaction"
|
5
|
+
require_relative "gnucash/value"
|
6
|
+
require_relative "gnucash/version"
|
7
7
|
|
8
8
|
# Namespace module for gnucash gem functionality
|
9
9
|
module Gnucash
|
data/lib/gnucash/account.rb
CHANGED
@@ -74,7 +74,9 @@ module Gnucash
|
|
74
74
|
# Return the balance of the account as of the date given as a
|
75
75
|
# _Gnucash::Value_. Transactions that occur on the given date are included
|
76
76
|
# in the returned balance.
|
77
|
+
# date can be a _String_ ("YYYY-MM-DD") or _Date_ object.
|
77
78
|
def balance_on(date)
|
79
|
+
date = Date.parse(date) if date.is_a?(String)
|
78
80
|
return Value.new(0) unless @balances.size > 0
|
79
81
|
return Value.new(0) if @balances.first[:date] > date
|
80
82
|
return @balances.last[:value] if date >= @balances.last[:date]
|
@@ -99,7 +101,7 @@ module Gnucash
|
|
99
101
|
if @parent_id
|
100
102
|
parent = @book.find_account_by_id(@parent_id)
|
101
103
|
if parent and parent.type != 'ROOT'
|
102
|
-
prefix = parent.full_name + "
|
104
|
+
prefix = parent.full_name + ":"
|
103
105
|
end
|
104
106
|
end
|
105
107
|
prefix + name
|
data/lib/gnucash/book.rb
CHANGED
@@ -10,10 +10,10 @@ module Gnucash
|
|
10
10
|
# _Array_ of _Gnucash::Transaction_ objects in the book
|
11
11
|
attr_reader :transactions
|
12
12
|
|
13
|
-
#
|
13
|
+
# _Date_ of the first transaction in the book
|
14
14
|
attr_reader :start_date
|
15
15
|
|
16
|
-
#
|
16
|
+
# _Date_ of the last transaction in the book
|
17
17
|
attr_reader :end_date
|
18
18
|
|
19
19
|
# Construct a Book object.
|
data/lib/gnucash/transaction.rb
CHANGED
@@ -1,10 +1,12 @@
|
|
1
|
+
require "date"
|
2
|
+
|
1
3
|
module Gnucash
|
2
4
|
# Represent a GnuCash transaction.
|
3
5
|
# Transactions have multiple splits with individual values.
|
4
6
|
# Splits are created as AccountTransaction objects which are associated
|
5
7
|
# with an individual account.
|
6
8
|
class Transaction
|
7
|
-
#
|
9
|
+
# _Date_: The date of the transaction
|
8
10
|
attr_reader :date
|
9
11
|
|
10
12
|
# _String_: The GUID of the transaction
|
@@ -24,7 +26,7 @@ module Gnucash
|
|
24
26
|
@book = book
|
25
27
|
@node = node
|
26
28
|
@id = node.xpath('trn:id').text
|
27
|
-
@date = node.xpath('trn:date-posted/ts:date').text.split(' ').first
|
29
|
+
@date = Date.parse(node.xpath('trn:date-posted/ts:date').text.split(' ').first)
|
28
30
|
@description = node.xpath('trn:description').text
|
29
31
|
@splits = node.xpath('trn:splits/trn:split').map do |split_node|
|
30
32
|
value = Value.new(split_node.xpath('split:value').text)
|
data/lib/gnucash/version.rb
CHANGED
@@ -4,9 +4,9 @@ module Gnucash
|
|
4
4
|
# just read the file once
|
5
5
|
@book = Gnucash.open("spec/books/sample.gnucash")
|
6
6
|
@assets = @book.find_account_by_full_name("Assets")
|
7
|
-
@checking = @book.find_account_by_full_name("Assets
|
7
|
+
@checking = @book.find_account_by_full_name("Assets:Current Assets:Checking Account")
|
8
8
|
@income = @book.find_account_by_full_name("Income")
|
9
|
-
@salary = @book.find_account_by_full_name("Income
|
9
|
+
@salary = @book.find_account_by_full_name("Income:Salary")
|
10
10
|
end
|
11
11
|
|
12
12
|
it "gives access to the account name" do
|
@@ -18,7 +18,7 @@ module Gnucash
|
|
18
18
|
end
|
19
19
|
|
20
20
|
it "gives access to the fully-qualified account name" do
|
21
|
-
@checking.full_name.should == "Assets
|
21
|
+
@checking.full_name.should == "Assets:Current Assets:Checking Account"
|
22
22
|
end
|
23
23
|
|
24
24
|
it "gives access to the final balance" do
|
data/spec/gnucash/book_spec.rb
CHANGED
@@ -20,11 +20,11 @@ module Gnucash
|
|
20
20
|
end
|
21
21
|
|
22
22
|
it "records the date of the earliest transaction" do
|
23
|
-
@subject.start_date.should == "2007-01-01"
|
23
|
+
@subject.start_date.should == Date.parse("2007-01-01")
|
24
24
|
end
|
25
25
|
|
26
26
|
it "records the date of the last transaction" do
|
27
|
-
@subject.end_date.should == "2012-12-28"
|
27
|
+
@subject.end_date.should == Date.parse("2012-12-28")
|
28
28
|
end
|
29
29
|
|
30
30
|
it "lets you find an account by id" do
|
@@ -32,7 +32,7 @@ module Gnucash
|
|
32
32
|
end
|
33
33
|
|
34
34
|
it "lets you find an account by full name" do
|
35
|
-
@subject.find_account_by_full_name("Assets
|
35
|
+
@subject.find_account_by_full_name("Assets:Current Assets:Savings Account").id.should == "67e6e7daadc35716eb6152769373e974"
|
36
36
|
end
|
37
37
|
end
|
38
38
|
end
|
@@ -8,10 +8,12 @@ module Gnucash
|
|
8
8
|
split_node = "split_node"
|
9
9
|
value_text = "value_text"
|
10
10
|
account_text = "account_text"
|
11
|
+
date_text = "date_text"
|
11
12
|
|
12
|
-
node.should_receive(:xpath).with('trn:id').and_return(text)
|
13
13
|
text.stub(:text) {"hi there"}
|
14
|
-
node.should_receive(:xpath).with('trn:
|
14
|
+
node.should_receive(:xpath).with('trn:id').and_return(text)
|
15
|
+
date_text.should_receive(:text).and_return("2014-01-20")
|
16
|
+
node.should_receive(:xpath).with('trn:date-posted/ts:date').and_return(date_text)
|
15
17
|
value_text.should_receive(:text).and_return("1177/100")
|
16
18
|
account_text.should_receive(:text).and_return("a1s2d3f4")
|
17
19
|
split_node.should_receive(:xpath).with("split:value").and_return(value_text)
|
@@ -27,7 +29,7 @@ module Gnucash
|
|
27
29
|
context "without errors" do
|
28
30
|
before(:all) do
|
29
31
|
@book = Gnucash.open("spec/books/sample.gnucash")
|
30
|
-
@txn = @book.find_account_by_full_name("Assets
|
32
|
+
@txn = @book.find_account_by_full_name("Assets:Current Assets:Cash in Wallet").transactions.first
|
31
33
|
end
|
32
34
|
|
33
35
|
it "keeps track of the transaction description" do
|
metadata
CHANGED
@@ -1,20 +1,18 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gnucash
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
5
|
-
prerelease:
|
4
|
+
version: 1.2.0
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Josh Holtrop
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2014-01-20 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: nokogiri
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
17
|
- - ! '>='
|
20
18
|
- !ruby/object:Gem::Version
|
@@ -22,7 +20,6 @@ dependencies:
|
|
22
20
|
type: :runtime
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
24
|
- - ! '>='
|
28
25
|
- !ruby/object:Gem::Version
|
@@ -30,7 +27,6 @@ dependencies:
|
|
30
27
|
- !ruby/object:Gem::Dependency
|
31
28
|
name: simplecov
|
32
29
|
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
30
|
requirements:
|
35
31
|
- - ! '>='
|
36
32
|
- !ruby/object:Gem::Version
|
@@ -38,7 +34,6 @@ dependencies:
|
|
38
34
|
type: :development
|
39
35
|
prerelease: false
|
40
36
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
37
|
requirements:
|
43
38
|
- - ! '>='
|
44
39
|
- !ruby/object:Gem::Version
|
@@ -46,7 +41,6 @@ dependencies:
|
|
46
41
|
- !ruby/object:Gem::Dependency
|
47
42
|
name: rspec
|
48
43
|
requirement: !ruby/object:Gem::Requirement
|
49
|
-
none: false
|
50
44
|
requirements:
|
51
45
|
- - ! '>='
|
52
46
|
- !ruby/object:Gem::Version
|
@@ -54,7 +48,6 @@ dependencies:
|
|
54
48
|
type: :development
|
55
49
|
prerelease: false
|
56
50
|
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
none: false
|
58
51
|
requirements:
|
59
52
|
- - ! '>='
|
60
53
|
- !ruby/object:Gem::Version
|
@@ -62,7 +55,6 @@ dependencies:
|
|
62
55
|
- !ruby/object:Gem::Dependency
|
63
56
|
name: rspec-core
|
64
57
|
requirement: !ruby/object:Gem::Requirement
|
65
|
-
none: false
|
66
58
|
requirements:
|
67
59
|
- - ! '>='
|
68
60
|
- !ruby/object:Gem::Version
|
@@ -70,7 +62,6 @@ dependencies:
|
|
70
62
|
type: :development
|
71
63
|
prerelease: false
|
72
64
|
version_requirements: !ruby/object:Gem::Requirement
|
73
|
-
none: false
|
74
65
|
requirements:
|
75
66
|
- - ! '>='
|
76
67
|
- !ruby/object:Gem::Version
|
@@ -78,7 +69,6 @@ dependencies:
|
|
78
69
|
- !ruby/object:Gem::Dependency
|
79
70
|
name: rspec-expectations
|
80
71
|
requirement: !ruby/object:Gem::Requirement
|
81
|
-
none: false
|
82
72
|
requirements:
|
83
73
|
- - ! '>='
|
84
74
|
- !ruby/object:Gem::Version
|
@@ -86,7 +76,6 @@ dependencies:
|
|
86
76
|
type: :development
|
87
77
|
prerelease: false
|
88
78
|
version_requirements: !ruby/object:Gem::Requirement
|
89
|
-
none: false
|
90
79
|
requirements:
|
91
80
|
- - ! '>='
|
92
81
|
- !ruby/object:Gem::Version
|
@@ -94,7 +83,6 @@ dependencies:
|
|
94
83
|
- !ruby/object:Gem::Dependency
|
95
84
|
name: rspec-mocks
|
96
85
|
requirement: !ruby/object:Gem::Requirement
|
97
|
-
none: false
|
98
86
|
requirements:
|
99
87
|
- - ! '>='
|
100
88
|
- !ruby/object:Gem::Version
|
@@ -102,7 +90,48 @@ dependencies:
|
|
102
90
|
type: :development
|
103
91
|
prerelease: false
|
104
92
|
version_requirements: !ruby/object:Gem::Requirement
|
105
|
-
|
93
|
+
requirements:
|
94
|
+
- - ! '>='
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: rake
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ! '>='
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ! '>='
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: rdoc
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ! '>='
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ! '>='
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: yard
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - ! '>='
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
106
135
|
requirements:
|
107
136
|
- - ! '>='
|
108
137
|
- !ruby/object:Gem::Version
|
@@ -139,27 +168,26 @@ files:
|
|
139
168
|
homepage: https://github.com/holtrop/ruby-gnucash
|
140
169
|
licenses:
|
141
170
|
- MIT
|
171
|
+
metadata: {}
|
142
172
|
post_install_message:
|
143
173
|
rdoc_options: []
|
144
174
|
require_paths:
|
145
175
|
- lib
|
146
176
|
required_ruby_version: !ruby/object:Gem::Requirement
|
147
|
-
none: false
|
148
177
|
requirements:
|
149
178
|
- - ! '>='
|
150
179
|
- !ruby/object:Gem::Version
|
151
180
|
version: '0'
|
152
181
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
153
|
-
none: false
|
154
182
|
requirements:
|
155
183
|
- - ! '>='
|
156
184
|
- !ruby/object:Gem::Version
|
157
185
|
version: '0'
|
158
186
|
requirements: []
|
159
187
|
rubyforge_project:
|
160
|
-
rubygems_version:
|
188
|
+
rubygems_version: 2.2.1
|
161
189
|
signing_key:
|
162
|
-
specification_version:
|
190
|
+
specification_version: 4
|
163
191
|
summary: Extract data from GnuCash data files
|
164
192
|
test_files:
|
165
193
|
- spec/books/sample-text.gnucash
|