gnucash 1.2.2 → 1.3.0

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: f48cb558de94a0cc405d31710c076c1b0d58de28
4
- data.tar.gz: 5196aee0a2081291d4515c1830115d1a74cd3610
3
+ metadata.gz: 3b8e70e39febe1d2afe7ff866b5715f2e18620b1
4
+ data.tar.gz: 7bfd0b8791a02046d5cd61ccb37023ed1d2b613d
5
5
  SHA512:
6
- metadata.gz: 284f0728714930290f64939f6ca4f112394e5c4edd0b9c805c53876f59a93198c84881e7fbd74e8c70bed5dff051b014d26122ed32d53af0ec3b059d811f1032
7
- data.tar.gz: 6e3f0ecbe2419c4ac2a774cffabd844c2f59463fd9a3af77e9ff0febad969d83a3ee931e6aeaf74f87922aab7be9f95e5a41b5cc827d1c24624ffd1f367b922b
6
+ metadata.gz: e77495aabd9da8f62edc77c990ec4f547771fe80a9c31cc0ce5736b2e1923d12d1f13d7800bf6dafc2ba1784764aa150f5a326b75af110061ad581f376966d23
7
+ data.tar.gz: ebbbd48420074fe267d137897ecffbe7dd38c717b1b56763e29e677379b65922b890b2879014e7045a8b7ff63d341fb4a8a4f83f4a12435cb45f84bc2064202c
@@ -0,0 +1,22 @@
1
+ # ChangeLog
2
+
3
+ ## v1.2.2
4
+
5
+ - Allow mixing Value objects with different divisors - fix #7
6
+ - Replace Fixnum with Integer to avoid Ruby 2.4 deprecation warnings
7
+
8
+ ## v1.2.1
9
+
10
+ - Determine a transaction split's value in the split account's currency - fix #6
11
+
12
+ ## v1.2.0
13
+
14
+ - use Date objects instead of formatted strings for dates
15
+ - use a single colon instead of a double colon in account names
16
+ - use 'require_relative' instead of 'require'
17
+
18
+ ## v1.1.0
19
+
20
+ - store and provide access to the account description
21
+ - change many attributes to read-only
22
+ - add 'placeholder' Account attribute
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- gnucash (1.2.2)
4
+ gnucash (1.3.0)
5
5
  nokogiri
6
6
 
7
7
  GEM
@@ -10,9 +10,9 @@ GEM
10
10
  diff-lcs (1.3)
11
11
  docile (1.1.5)
12
12
  json (2.1.0)
13
- mini_portile2 (2.2.0)
14
- nokogiri (1.8.0)
15
- mini_portile2 (~> 2.2.0)
13
+ mini_portile2 (2.3.0)
14
+ nokogiri (1.8.1)
15
+ mini_portile2 (~> 2.3.0)
16
16
  rake (12.0.0)
17
17
  rdoc (5.1.0)
18
18
  rspec (3.6.0)
@@ -47,4 +47,4 @@ DEPENDENCIES
47
47
  yard
48
48
 
49
49
  BUNDLED WITH
50
- 1.10.6
50
+ 1.15.0
data/README.md CHANGED
@@ -20,38 +20,30 @@ Or install it yourself as:
20
20
 
21
21
  ## Usage
22
22
 
23
- require "gnucash"
24
-
25
- book = Gnucash.open("MyBook.gnucash")
26
-
27
- book.accounts.each do |account|
28
- puts "#{account.full_name}: #{account.final_balance}"
29
- end
30
-
31
- act = book.find_account_by_full_name("Assets:Checking")
32
- balance = Gnucash::Value.zero
33
- act.transactions.each do |txn|
34
- balance += txn.value
35
- $stdout.puts(sprintf("%s %8s %8s %s",
36
- txn.date,
37
- txn.value,
38
- balance,
39
- txn.description))
40
- end
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
23
+ ```ruby
24
+ require "gnucash"
25
+
26
+ book = Gnucash.open("MyBook.gnucash")
27
+
28
+ book.accounts.each do |account|
29
+ puts "#{account.full_name}: #{account.final_balance}"
30
+ end
31
+
32
+ act = book.find_account_by_full_name("Assets:Checking")
33
+ balance = Gnucash::Value.zero
34
+ act.transactions.each do |txn|
35
+ balance += txn.value
36
+ $stdout.printf("%s %8s %8s %s\n",
37
+ txn.date,
38
+ txn.value,
39
+ balance,
40
+ txn.description))
41
+ end
42
+
43
+ year = Date.today.year
44
+ delta = act.balance_on("#{year}-12-31") - act.balance_on("#{year - 1}-12-31")
45
+ puts "You've saved #{delta} this year so far!"
46
+ ```
55
47
 
56
48
  ## Contributing
57
49
 
@@ -13,8 +13,8 @@ module Gnucash
13
13
  # @return [String] The GUID of the account.
14
14
  attr_reader :id
15
15
 
16
- # @return [Array<AccountTransaction>] List of transactions associated with
17
- # this account.
16
+ # @return [Array<AccountTransaction>]
17
+ # List of transactions associated with this account.
18
18
  attr_reader :transactions
19
19
 
20
20
  # @return [Boolean] Whether the account is a placeholder or not.
@@ -81,27 +81,33 @@ module Gnucash
81
81
 
82
82
  # Multiply a Value object.
83
83
  #
84
- # @param other [Numeric] Multiplier.
84
+ # @param other [Numeric, Value] Multiplier.
85
85
  #
86
86
  # @return [Numeric] Result of multiplication.
87
87
  def *(other)
88
+ if other.is_a?(Value)
89
+ other = other.to_f
90
+ end
88
91
  if other.is_a?(Numeric)
89
92
  (to_f * other).round(2)
90
93
  else
91
- raise "Unexpected argument"
94
+ raise "Unexpected argument (#{other.inspect})"
92
95
  end
93
96
  end
94
97
 
95
98
  # Divide a Value object.
96
99
  #
97
- # @param other [Numeric] Divisor.
100
+ # @param other [Numeric, Value] Divisor.
98
101
  #
99
102
  # @return [Numeric] Result of division.
100
103
  def /(other)
104
+ if other.is_a?(Value)
105
+ other = other.to_f
106
+ end
101
107
  if other.is_a?(Numeric)
102
108
  (to_f / other).round(2)
103
109
  else
104
- raise "Unexpected argument"
110
+ raise "Unexpected argument (#{other.inspect})"
105
111
  end
106
112
  end
107
113
 
@@ -1,4 +1,4 @@
1
1
  module Gnucash
2
2
  # gem version
3
- VERSION = "1.2.2"
3
+ VERSION = "1.3.0"
4
4
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gnucash
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.2
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Josh Holtrop
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-09-14 00:00:00.000000000 Z
11
+ date: 2017-11-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri
@@ -103,6 +103,7 @@ extra_rdoc_files: []
103
103
  files:
104
104
  - ".gitignore"
105
105
  - ".rspec"
106
+ - CHANGELOG.md
106
107
  - Gemfile
107
108
  - Gemfile.lock
108
109
  - LICENSE.txt
@@ -144,7 +145,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
144
145
  version: '0'
145
146
  requirements: []
146
147
  rubyforge_project:
147
- rubygems_version: 2.6.12
148
+ rubygems_version: 2.5.2
148
149
  signing_key:
149
150
  specification_version: 4
150
151
  summary: Extract data from XML GnuCash data files