quicken 0.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.
@@ -0,0 +1,5 @@
1
+ require "spec_helper"
2
+
3
+ describe Quicken::Account do
4
+ should_be_child_of_foundation
5
+ end
@@ -0,0 +1,38 @@
1
+ require "spec_helper"
2
+
3
+ class Foo < Quicken::Foundation
4
+ ACCOUNT = {
5
+ :number => /^N(.+)/,
6
+ :type => /^T(.+)/
7
+ }
8
+
9
+ accessors_for_spec ACCOUNT
10
+ end
11
+
12
+ describe Quicken::Foundation do
13
+
14
+ describe "when create" do
15
+
16
+ it "should receive args and define each one as attribute" do
17
+ foo = Foo.new({:number=>"0833_5710633", :type=>"Bank"})
18
+ foo.number.should == "0833_5710633"
19
+ foo.type.should == "Bank"
20
+ end
21
+
22
+ it "should have accessors based on his SPEC" do
23
+ foo = Foo.new
24
+
25
+ Foo::ACCOUNT.each do |key,item|
26
+ foo.should respond_to(key)
27
+ foo.should respond_to("#{key}=")
28
+ end
29
+ end
30
+
31
+ it "should skip the attributes that doesn't fit in SPEC" do
32
+ account = Foo.new({:number=>"0833_5710633", :anything=>"blabla"})
33
+ account.number.should == "0833_5710633"
34
+ account.should_not respond_to(:anything)
35
+ end
36
+
37
+ end
38
+ end
@@ -0,0 +1,47 @@
1
+ require "spec_helper"
2
+
3
+ describe Quicken::Parser do
4
+ let (:file) do
5
+ qif = Quicken::Parser.new('spec/fixtures/default.qif').parse!
6
+ end
7
+
8
+ context "account section" do
9
+ it "should return the account" do
10
+ file.account.should == Quicken::Account.new({:number=>"0833_5710633", :type=>"Bank"})
11
+ end
12
+
13
+ it "should return nil when the file don't have an account" do
14
+ qif = Quicken::Parser.new('spec/fixtures/ms_money.qif').parse!
15
+ qif.account.should be_nil
16
+ end
17
+ end
18
+
19
+ context "transactions section" do
20
+ it "should return the transactions" do
21
+ file.transactions.should_not be_empty
22
+ end
23
+
24
+ it "should map each transaction to Transaction objects" do
25
+ file.transactions.first.should be_instance_of(Quicken::Transaction)
26
+ file.transactions.size.should be(4)
27
+ end
28
+
29
+ it "should remove carriage return" do
30
+ qif = Quicken::Parser.new('spec/fixtures/ms_money.qif').parse!
31
+ qif.transactions.first.payee.should_not match(/\r/)
32
+ end
33
+
34
+ describe "regard to date_format" do
35
+ it "should delegate this to each transaction" do
36
+ qif = Quicken::Parser.new('spec/fixtures/bco_real.qif', [:day, :month, :year]).parse!
37
+ qif.transactions.first.date.should == Date.civil(2010, 04, 19)
38
+ end
39
+
40
+ it "should use default value when didn't receive the format" do
41
+ qif = Quicken::Parser.new('spec/fixtures/default.qif').parse!
42
+ qif.transactions.first.date.should == Date.civil(2010, 04, 19)
43
+ end
44
+ end
45
+
46
+ end
47
+ end
@@ -0,0 +1,23 @@
1
+ require "spec_helper"
2
+
3
+ describe Quicken::Spec do
4
+
5
+ it "should be conform with account section of Qif specification" do
6
+ [ :number, :type ].each do |i|
7
+ Quicken::Spec::ACCOUNT.keys.should include(i)
8
+ end
9
+ end
10
+
11
+ it "should be conform with transaction section of Qif specification" do
12
+ [
13
+ :number, :amount, :date, :memo, :cleared, :payee,
14
+ :address, :category, :flag, :split_category, :split_memo,
15
+ :split_or_investment_amount, :split_percentage, :investment,
16
+ :investment_security, :investment_price,
17
+ :investment_shares_quantity, :investment_commission
18
+ ].each do |i|
19
+ Quicken::Spec::TRANSACTION.keys.should include(i)
20
+ end
21
+ end
22
+
23
+ end
@@ -0,0 +1,48 @@
1
+ require "spec_helper"
2
+
3
+ describe Quicken::Transaction do
4
+ should_be_child_of_foundation
5
+
6
+ context "date" do
7
+ it "should parse dates in Date instances" do
8
+ transaction.date.should == Date.civil(2010,4,19)
9
+ end
10
+
11
+ it "should use date_order as setting for conversion" do
12
+ t = transaction({:date=>"19/06/10", :date_format=>[:day,:month,:year]})
13
+ t.date.should == Date.civil(2010,6,19)
14
+ end
15
+
16
+ it "should accept the '9 format for year" do
17
+ t = transaction({:date=>"4/1'09"})
18
+ t.date.should == Date.civil(2009,4,1)
19
+ end
20
+
21
+ it "should accept - as separator" do
22
+ t = transaction({:date=>"12-25-09"})
23
+ t.date.should == Date.civil(2009,12,25)
24
+ end
25
+
26
+ end
27
+
28
+ context "money fields" do
29
+ subject { transaction(
30
+ :investment_price => "234.30",
31
+ :investment_shares_quantity => "3,000.23",
32
+ :investment_commission => "2120.18",
33
+ :split_or_investment_amount => "340.12"
34
+ )}
35
+
36
+ specify { subject.amount.should be_money }
37
+ specify { subject.investment_price.should be_money }
38
+ specify { subject.investment_shares_quantity .should be_money }
39
+ specify { subject.investment_commission.should be_money }
40
+ specify { subject.split_or_investment_amount.should be_money }
41
+ end
42
+
43
+ def transaction(args={})
44
+ defaults = { :date=>"04/19/10", :amount=>"6960.00", :number=>"0002593", :memo=>"TED 790.234.526-15" }
45
+ Quicken::Transaction.new(defaults.merge(args))
46
+ end
47
+
48
+ end
@@ -0,0 +1 @@
1
+ --color
@@ -0,0 +1,12 @@
1
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
2
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
3
+ require 'quicken'
4
+ require 'spec'
5
+ require 'spec/autorun'
6
+
7
+ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
8
+
9
+ Spec::Runner.configure do |config|
10
+ config.include MoneyMatcher
11
+ config.extend FoundationMacro
12
+ end
@@ -0,0 +1,10 @@
1
+ module FoundationMacro
2
+
3
+ def should_be_child_of_foundation
4
+ it "should be a child of Quicken::Foundation" do
5
+ klass = described_class
6
+ klass.ancestors.should include(Quicken::Foundation)
7
+ end
8
+ end
9
+
10
+ end
@@ -0,0 +1,19 @@
1
+ require 'bigdecimal'
2
+
3
+ module MoneyMatcher
4
+ Spec::Matchers.define :be_money do
5
+
6
+ match do |amount|
7
+ amount.should be_instance_of(BigDecimal)
8
+ end
9
+
10
+ failure_message_for_should do |amount|
11
+ "expected #{amount} to be money (an instance of BigDecimal)"
12
+ end
13
+
14
+ description do |amount|
15
+ "expect #{amount} to be money"
16
+ end
17
+
18
+ end
19
+ end
metadata ADDED
@@ -0,0 +1,107 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: quicken
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 0
8
+ - 1
9
+ version: 0.0.1
10
+ platform: ruby
11
+ authors:
12
+ - Daniel Lopes
13
+ autorequire:
14
+ bindir: bin
15
+ cert_chain: []
16
+
17
+ date: 2010-05-25 00:00:00 -03:00
18
+ default_executable:
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: rspec
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - ">="
26
+ - !ruby/object:Gem::Version
27
+ segments:
28
+ - 1
29
+ - 3
30
+ - 0
31
+ version: 1.3.0
32
+ type: :development
33
+ version_requirements: *id001
34
+ description: QIF (Quicken Interchange Format) parser
35
+ email: danielvlopes@gmail.com
36
+ executables: []
37
+
38
+ extensions: []
39
+
40
+ extra_rdoc_files:
41
+ - LICENSE
42
+ - README.rdoc
43
+ files:
44
+ - .document
45
+ - .gitignore
46
+ - LICENSE
47
+ - README.rdoc
48
+ - Rakefile
49
+ - VERSION
50
+ - lib/quicken.rb
51
+ - lib/quicken/account.rb
52
+ - lib/quicken/foundation.rb
53
+ - lib/quicken/parser.rb
54
+ - lib/quicken/spec.rb
55
+ - lib/quicken/transaction.rb
56
+ - quicken.gemspec
57
+ - spec/fixtures/bco_real.qif
58
+ - spec/fixtures/default.qif
59
+ - spec/fixtures/ms_money.qif
60
+ - spec/quicken/account_spec.rb
61
+ - spec/quicken/foundation_spec.rb
62
+ - spec/quicken/parser_spec.rb
63
+ - spec/quicken/spec_spec.rb
64
+ - spec/quicken/transaction_spec.rb
65
+ - spec/spec.opts
66
+ - spec/spec_helper.rb
67
+ - spec/support/macros/foundation_macro.rb
68
+ - spec/support/matchers/money_matcher.rb
69
+ has_rdoc: true
70
+ homepage: http://github.com/danielvlopes/quicken
71
+ licenses: []
72
+
73
+ post_install_message:
74
+ rdoc_options:
75
+ - --charset=UTF-8
76
+ require_paths:
77
+ - lib
78
+ required_ruby_version: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ segments:
83
+ - 0
84
+ version: "0"
85
+ required_rubygems_version: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ segments:
90
+ - 0
91
+ version: "0"
92
+ requirements: []
93
+
94
+ rubyforge_project:
95
+ rubygems_version: 1.3.6
96
+ signing_key:
97
+ specification_version: 3
98
+ summary: simple QIF parser
99
+ test_files:
100
+ - spec/quicken/account_spec.rb
101
+ - spec/quicken/foundation_spec.rb
102
+ - spec/quicken/parser_spec.rb
103
+ - spec/quicken/spec_spec.rb
104
+ - spec/quicken/transaction_spec.rb
105
+ - spec/spec_helper.rb
106
+ - spec/support/macros/foundation_macro.rb
107
+ - spec/support/matchers/money_matcher.rb