egg2ofx 0.1.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,27 @@
1
+ require File.join(File.dirname(__FILE__), '..', 'test_helper')
2
+
3
+ module Egg
4
+ class DescriptionTest < Test::Unit::TestCase
5
+
6
+ InternalSample = 'MERCHANDISE INTEREST AT 1.313 PER MONTH'
7
+ PurchaseSample = 'PLAY.COM JERSEY GB'
8
+
9
+ def test_should_parse_and_split_into_payee_and_note_and_territory
10
+ description = Description.new(PurchaseSample)
11
+ assert_equal 'PLAY.COM', description.payee
12
+ assert_equal 'JERSEY', description.note
13
+ assert_equal 'GB', description.territory
14
+ end
15
+
16
+ def test_should_parse_and_leave_content_as_payee
17
+ description = Description.new(InternalSample)
18
+ assert_equal InternalSample, description.payee
19
+ end
20
+
21
+ def test_should_squeeze_compress_duplicate_spaces
22
+ description = Description.new('PLAY.COM 123 JERSEY GB')
23
+ assert_equal 'PLAY.COM 123', description.payee
24
+ end
25
+
26
+ end
27
+ end
@@ -0,0 +1,15 @@
1
+ require 'test_helper'
2
+
3
+ module Ofx
4
+ class OfxTest < Test::Unit::TestCase
5
+
6
+ def test_should_have_the_ofxheader_version_as_the_first_ofx_processing_instruction_attribute_for_wesabe_compatibility
7
+ account = Egg::Account.new('GBP', 'account number')
8
+ statement = Egg::Statement.new('01 Jan 2009 to 01 Jan 2009', '0', account)
9
+ ofx = Statement.new(statement).to_xml
10
+
11
+ assert_match /\?OFX OFXHEADER="200"/, ofx
12
+ end
13
+
14
+ end
15
+ end
@@ -0,0 +1,24 @@
1
+ require 'test_helper'
2
+
3
+ module Egg
4
+ class ParserTest < Test::Unit::TestCase
5
+
6
+ def test_should_instantiate_a_statement_parser_if_the_html_looks_like_a_statement
7
+ html = "Your Egg Card statement"
8
+ StatementDocumentParser.expects(:new).with(html)
9
+ paser = Parser.new(html)
10
+ end
11
+
12
+ def test_should_instantiate_a_recent_transactions_parser_if_the_html_looks_like_it_contains_recent_transactions
13
+ html = "Egg Card Recent transactions"
14
+ RecentTransactionsDocumentParser.expects(:new).with(html)
15
+ paser = Parser.new(html)
16
+ end
17
+
18
+ def test_should_raise_a_malformed_exception_if_it_does_not_look_like_a_statement_or_like_it_contains_recent_transactions
19
+ html = "foo bar baz"
20
+ assert_raise(Egg::Parser::UnparsableHtmlError) { Parser.new(html) }
21
+ end
22
+
23
+ end
24
+ end
@@ -0,0 +1,23 @@
1
+ require 'test_helper'
2
+
3
+ module Egg
4
+ class RecentTransactionsTransactionParserTest < Test::Unit::TestCase
5
+
6
+ def test_should_deal_with_html_encoded_pound_sign
7
+ html = '<tr><td class="money">&pound;9.79</td></tr>'
8
+ doc = Hpricot(html)
9
+ parser = RecentTransactionsTransactionParser.new(doc)
10
+
11
+ assert_equal '9.79 DR', parser.money
12
+ end
13
+
14
+ def test_should_deal_with_html_decoded_pound_sign
15
+ html = '<tr><td class="money">£9.79</td></tr>'
16
+ doc = Hpricot(html)
17
+ parser = RecentTransactionsTransactionParser.new(doc)
18
+
19
+ assert_equal '9.79 DR', parser.money
20
+ end
21
+
22
+ end
23
+ end
@@ -0,0 +1,23 @@
1
+ require 'test_helper'
2
+
3
+ module Egg
4
+ class StatementTransactionParserTest < Test::Unit::TestCase
5
+
6
+ def test_should_deal_with_html_encoded_pound_sign
7
+ html = '<tr><td class="money">&pound;9.79 DR</td></tr>'
8
+ doc = Hpricot(html)
9
+ parser = StatementTransactionParser.new(doc)
10
+
11
+ assert_equal '9.79 DR', parser.money
12
+ end
13
+
14
+ def test_should_deal_with_html_decoded_pound_sign
15
+ html = '<tr><td class="money">£9.79 DR</td></tr>'
16
+ doc = Hpricot(html)
17
+ parser = StatementTransactionParser.new(doc)
18
+
19
+ assert_equal '9.79 DR', parser.money
20
+ end
21
+
22
+ end
23
+ end
metadata ADDED
@@ -0,0 +1,102 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: egg2ofx
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
+ platform: ruby
6
+ authors:
7
+ - Chris Roos
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-11-13 00:00:00 +00:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: hpricot
17
+ type: :runtime
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: "0"
24
+ version:
25
+ - !ruby/object:Gem::Dependency
26
+ name: mocha
27
+ type: :development
28
+ version_requirement:
29
+ version_requirements: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: "0"
34
+ version:
35
+ description:
36
+ email: chris@seagul.co.uk
37
+ executables:
38
+ - egg2ofx
39
+ extensions: []
40
+
41
+ extra_rdoc_files:
42
+ - README
43
+ files:
44
+ - Rakefile
45
+ - README
46
+ - bin/egg2ofx
47
+ - test/fixtures/recent_transactions.html
48
+ - test/fixtures/statement.html
49
+ - test/integration/recent_transactions_integration_test.rb
50
+ - test/integration/statement_integration_test.rb
51
+ - test/test_helper.rb
52
+ - test/unit/description_test.rb
53
+ - test/unit/ofx_test.rb
54
+ - test/unit/parser_test.rb
55
+ - test/unit/parsers/recent_transactions_transaction_parser_test.rb
56
+ - test/unit/parsers/statement_transaction_parser_test.rb
57
+ - lib/egg/account.rb
58
+ - lib/egg/date.rb
59
+ - lib/egg/description.rb
60
+ - lib/egg/money.rb
61
+ - lib/egg/parser.rb
62
+ - lib/egg/parsers/document_parser.rb
63
+ - lib/egg/parsers/recent_transactions_document_parser.rb
64
+ - lib/egg/parsers/recent_transactions_transaction_parser.rb
65
+ - lib/egg/parsers/statement_document_parser.rb
66
+ - lib/egg/parsers/statement_transaction_parser.rb
67
+ - lib/egg/parsers/transaction_parser.rb
68
+ - lib/egg/statement.rb
69
+ - lib/egg/transaction.rb
70
+ - lib/egg.rb
71
+ - lib/ofx.rb
72
+ has_rdoc: true
73
+ homepage: http://chrisroos.co.uk
74
+ licenses: []
75
+
76
+ post_install_message:
77
+ rdoc_options:
78
+ - --main
79
+ - README
80
+ require_paths:
81
+ - lib
82
+ required_ruby_version: !ruby/object:Gem::Requirement
83
+ requirements:
84
+ - - ">="
85
+ - !ruby/object:Gem::Version
86
+ version: "0"
87
+ version:
88
+ required_rubygems_version: !ruby/object:Gem::Requirement
89
+ requirements:
90
+ - - ">="
91
+ - !ruby/object:Gem::Version
92
+ version: "0"
93
+ version:
94
+ requirements: []
95
+
96
+ rubyforge_project: egg2ofx
97
+ rubygems_version: 1.3.5
98
+ signing_key:
99
+ specification_version: 3
100
+ summary: Converts the html statements and recent transactions from the egg site to ofx
101
+ test_files: []
102
+