qiflib 0.0.4alpha → 0.0.6

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.
@@ -1,6 +1,6 @@
1
1
  module Qiflib
2
- VERSION = '0.0.4alpha'
3
- DATE = '2012-04-07'
2
+ VERSION = '0.0.6'
3
+ DATE = '2012-04-08'
4
4
  SOURCE_QUICKEN = 'quicken'
5
5
  SOURCE_IBANK = 'ibank'
6
6
 
@@ -41,4 +41,5 @@ module Qiflib
41
41
  )
42
42
  end
43
43
 
44
- end
44
+ end
45
+
data/lib/qiflib_money.rb CHANGED
@@ -25,4 +25,4 @@ module Qiflib
25
25
 
26
26
  end
27
27
 
28
- end
28
+ end
@@ -1,34 +1,8 @@
1
1
 
2
- =begin
3
-
4
- Quicken:
5
- D3/10/09
6
- PDuke Energy
7
- M$61.01 due 3/23
8
- T-62.00
9
- A
10
- A
11
- A
12
- A
13
- A
14
- A
15
- N4548
16
- L120 Electric
17
- ^
18
-
19
- iBank:
20
- D3/10/09
21
- PDuke Energy
22
- M$61.01 due 3/23
23
- T-62.
24
- C4548
25
- NCheck
26
- L120 Electric
27
- ^
28
-
29
- =end
30
-
31
2
  module Qiflib
3
+
4
+ # Instances of this class represent a transaction parsed within an
5
+ # !Account section of a qif file.
32
6
 
33
7
  class Transaction
34
8
 
@@ -150,7 +124,7 @@ module Qiflib
150
124
  array << splits[i]['category']
151
125
  array << splits[i]['memo']
152
126
  else
153
- array << ''
127
+ array << '0.0'
154
128
  array << ''
155
129
  array << ''
156
130
  end
data/lib/qiflib_util.rb CHANGED
@@ -1,9 +1,15 @@
1
1
 
2
2
  module Qiflib
3
+
4
+ # This is the API class of the 'qiflib' library; all functionality
5
+ # is accessed via the class/static methods of this class.
3
6
 
4
7
  class Util
5
8
 
6
- def self.catetory_names(files_list)
9
+ # Return lines in CSV format which contain the list of categories
10
+ # within the given Array of filenames.
11
+
12
+ def self.catetory_names_to_csv(files_list)
7
13
  categories, csv_lines = [], []
8
14
  csv_lines << Qiflib::Category.csv_header
9
15
  if files_list
@@ -34,10 +40,26 @@ module Qiflib
34
40
  }
35
41
  end
36
42
  categories.uniq.sort.each_with_index { | name, idx |
37
- cat = Qiflib::Category.new(name)
43
+ cat = Qiflib::Category.new(name.strip)
38
44
  csv_lines << cat.to_csv(idx)
39
45
  }
40
46
  csv_lines
47
+ end
48
+
49
+ def self.catetory_names_to_delim(files_list)
50
+ delim_lines, csv_lines = [], catetory_names_to_csv(files_list)
51
+ csv_lines.each_with_index { | csv_line, idx |
52
+ if idx > 0
53
+ sio = StringIO.new
54
+ field_array = CSV.parse(csv_line)[0]
55
+ field_array.each { | field |
56
+ sio << field
57
+ sio << '^'
58
+ }
59
+ delim_lines << "#{sio.string.strip.chop}\n"
60
+ end
61
+ }
62
+ delim_lines
41
63
  end
42
64
 
43
65
  def self.transactions_to_csv(input_list)
@@ -55,8 +77,85 @@ module Qiflib
55
77
  }
56
78
  end
57
79
  csv_lines
80
+ end
81
+
82
+ def self.transactions_to_delim(input_list)
83
+ delim_lines, csv_lines = [], transactions_to_csv(input_list)
84
+ csv_lines.each_with_index { | csv_line, idx |
85
+ if idx > 0
86
+ sio = StringIO.new
87
+ field_array = CSV.parse(csv_line)[0]
88
+ field_array.each { | field |
89
+ sio << field
90
+ sio << '^'
91
+ }
92
+ delim_lines << "#{sio.string.strip.chop}\n"
93
+ end
94
+ }
95
+ delim_lines
96
+ end
97
+
98
+ def self.generate_sqlite_ddl
99
+ lines = []
100
+ lines << ''
101
+ lines << 'drop table if exists transactions;'
102
+ lines << 'drop table if exists categories;'
103
+ lines << ''
104
+ lines << 'create table transactions('
105
+ lines << ' id integer,'
106
+ lines << ' acct_owner varchar(80),'
107
+ lines << ' acct_name varchar(80),'
108
+ lines << ' acct_type varchar(80),'
109
+ lines << ' date varchar(80),'
110
+ lines << ' amount real,'
111
+ lines << ' number varchar(80),'
112
+ lines << ' ibank_n varchar(80),'
113
+ lines << ' cleared varchar(80),'
114
+ lines << ' payee varchar(80),'
115
+ lines << ' category varchar(80),'
116
+ lines << ' memo varchar(80),'
117
+ lines << ' split1_amount real,'
118
+ lines << ' split1_category varchar(80),'
119
+ lines << ' split1_memo real,'
120
+ lines << ' split2_amount varchar(80),'
121
+ lines << ' split2_category varchar(80),'
122
+ lines << ' split2_memo varchar(80),'
123
+ lines << ' split3_amount real,'
124
+ lines << ' split3_category varchar(80),'
125
+ lines << ' split3_memo varchar(80),'
126
+ lines << ' address1 varchar(80),'
127
+ lines << ' address2 varchar(80),'
128
+ lines << ' address3 varchar(80),'
129
+ lines << ' address4 varchar(80),'
130
+ lines << ' address5 varchar(80),'
131
+ lines << ' address6 varchar(80),'
132
+ lines << ' eol_ind char(1)'
133
+ lines << ');'
134
+ lines << ''
135
+ lines << 'create table categories('
136
+ lines << ' id integer,'
137
+ lines << ' name varchar(80)'
138
+ lines << ');'
139
+ lines << ''
140
+ lines << ".separator '^'"
141
+ lines << ''
142
+ lines << '.import qiflib_transactions.txt transactions'
143
+ lines << '.import qiflib_categories.txt categories'
144
+ lines << ''
145
+ lines
58
146
  end
59
147
 
148
+ def self.generate_sqlite_load_script(db_name='qiflib.db', ddl_name='qiflib.ddl')
149
+ lines = []
150
+ lines << '#!/bin/bash'
151
+ lines << ''
152
+ lines << "sqlite3 #{db_name} < #{ddl_name}"
153
+ lines << ''
154
+ lines
155
+ end
156
+
157
+ private
158
+
60
159
  def self.process_file_for_transactions(owner, filename, source, transactions)
61
160
  begin
62
161
  file = File.new(filename, 'r')
metadata CHANGED
@@ -1,19 +1,19 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: qiflib
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4alpha
5
- prerelease: 5
4
+ version: 0.0.6
5
+ prerelease:
6
6
  platform: ruby
7
7
  authors:
8
8
  - Chris Joakim
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-04-07 00:00:00.000000000Z
12
+ date: 2012-04-08 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
16
- requirement: &70361534557220 !ruby/object:Gem::Requirement
16
+ requirement: &70146959247960 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,13 +21,30 @@ dependencies:
21
21
  version: 2.9.0
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *70361534557220
24
+ version_requirements: *70146959247960
25
25
  description: A ruby library for qif file processing.
26
26
  email: cjoakim@bellsouth.net
27
27
  executables: []
28
28
  extensions: []
29
29
  extra_rdoc_files: []
30
30
  files:
31
+ - README.rdoc
32
+ - html/index.html
33
+ - html/lib/qiflib_category_rb.html
34
+ - html/lib/qiflib_constants_rb.html
35
+ - html/lib/qiflib_date_rb.html
36
+ - html/lib/qiflib_money_rb.html
37
+ - html/lib/qiflib_rb.html
38
+ - html/lib/qiflib_transaction_rb.html
39
+ - html/lib/qiflib_util_rb.html
40
+ - html/Qiflib/Category.html
41
+ - html/Qiflib/Date.html
42
+ - html/Qiflib/Money.html
43
+ - html/Qiflib/Transaction.html
44
+ - html/Qiflib/Util.html
45
+ - html/Qiflib.html
46
+ - html/README_rdoc.html
47
+ - html/rdoc.css
31
48
  - lib/qiflib.rb
32
49
  - lib/qiflib_category.rb
33
50
  - lib/qiflib_constants.rb
@@ -35,11 +52,9 @@ files:
35
52
  - lib/qiflib_money.rb
36
53
  - lib/qiflib_transaction.rb
37
54
  - lib/qiflib_util.rb
38
- - README.md
39
55
  homepage: http://rubygems.org/gems/qiflib
40
56
  licenses:
41
- - MIT
42
- - GPL-2
57
+ - GPL-3
43
58
  post_install_message:
44
59
  rdoc_options: []
45
60
  require_paths:
@@ -53,9 +68,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
53
68
  required_rubygems_version: !ruby/object:Gem::Requirement
54
69
  none: false
55
70
  requirements:
56
- - - ! '>'
71
+ - - ! '>='
57
72
  - !ruby/object:Gem::Version
58
- version: 1.3.1
73
+ version: '0'
59
74
  requirements: []
60
75
  rubyforge_project:
61
76
  rubygems_version: 1.8.17
data/README.md DELETED
@@ -1,12 +0,0 @@
1
- README for qiflib
2
-
3
- file data/New_IMac_2009.qif
4
- data/New_IMac_2009.qif: ISO-8859 English text, with CR line terminators
5
-
6
- file data/ibank_20120328.qif
7
- data/ibank_20120328.qif: ASCII English text
8
-
9
- iconv -c -f ISO-8859 -t ASCII New_IMac_2009.qif > quicken_ascii.qif
10
- iconv -c -f ISO-8859-15 -t ASCII New_IMac_2009.qif > quicken_ascii.qif
11
- iconv -c -f ISO-8859-15 -t UTF-8 New_IMac_2009.qif > quicken_utf8.qif
12
-