gnucash 1.0.0 → 1.0.1

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.
data/README.md CHANGED
@@ -18,8 +18,25 @@ Or install it yourself as:
18
18
 
19
19
  ## Usage
20
20
 
21
+ require "gnucash"
22
+
21
23
  book = Gnucash.open("MyBook.gnucash")
22
24
 
25
+ book.accounts.each do |account|
26
+ puts "#{account.full_name}: #{account.final_balance}"
27
+ end
28
+
29
+ act = book.find_account_by_full_name("Assets::Checking")
30
+ balance = Gnucash::Value.zero
31
+ act.transactions.each do |txn|
32
+ balance += txn.value
33
+ $stdout.puts(sprintf("%s %8s %8s %s",
34
+ txn.date,
35
+ txn.value,
36
+ balance,
37
+ txn.description))
38
+ end
39
+
23
40
  ## Contributing
24
41
 
25
42
  1. Fork it
data/gnucash.gemspec CHANGED
@@ -10,7 +10,8 @@ Gem::Specification.new do |gem|
10
10
  gem.email = ["jholtrop@gmail.com"]
11
11
  gem.description = %q{Ruby library for extracting data from GnuCash data files}
12
12
  gem.summary = %q{Extract data from GnuCash data files}
13
- gem.homepage = ""
13
+ gem.homepage = "https://github.com/holtrop/ruby-gnucash"
14
+ gem.license = "MIT"
14
15
 
15
16
  gem.files = `git ls-files`.split($/)
16
17
  gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
@@ -32,14 +32,7 @@ module Gnucash
32
32
 
33
33
  # Return the fully qualified account name
34
34
  def full_name
35
- prefix = ""
36
- if @parent_id
37
- parent = @book.find_account_by_id(@parent_id)
38
- if parent and parent.type != 'ROOT'
39
- prefix = parent.full_name + "::"
40
- end
41
- end
42
- prefix + name
35
+ @full_name ||= calculate_full_name
43
36
  end
44
37
 
45
38
  # Internal method used to associate a transaction with the account
@@ -87,5 +80,18 @@ module Gnucash
87
80
  end
88
81
  @balances[idx][:value]
89
82
  end
83
+
84
+ private
85
+
86
+ def calculate_full_name
87
+ prefix = ""
88
+ if @parent_id
89
+ parent = @book.find_account_by_id(@parent_id)
90
+ if parent and parent.type != 'ROOT'
91
+ prefix = parent.full_name + "::"
92
+ end
93
+ end
94
+ prefix + name
95
+ end
90
96
  end
91
97
  end
data/lib/gnucash/book.rb CHANGED
@@ -76,6 +76,9 @@ module Gnucash
76
76
  end
77
77
 
78
78
  def finalize
79
+ @accounts.sort! do |a, b|
80
+ a.full_name <=> b.full_name
81
+ end
79
82
  @accounts.each do |account|
80
83
  account.finalize
81
84
  end
@@ -1,4 +1,4 @@
1
1
  module Gnucash
2
2
  # gem version
3
- VERSION = "1.0.0"
3
+ VERSION = "1.0.1"
4
4
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gnucash
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-08-14 00:00:00.000000000 Z
12
+ date: 2013-08-15 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: nokogiri
@@ -136,8 +136,9 @@ files:
136
136
  - spec/gnucash/value_spec.rb
137
137
  - spec/gnucash_spec.rb
138
138
  - spec/spec_helper.rb
139
- homepage: ''
140
- licenses: []
139
+ homepage: https://github.com/holtrop/ruby-gnucash
140
+ licenses:
141
+ - MIT
141
142
  post_install_message:
142
143
  rdoc_options: []
143
144
  require_paths: