reckon 0.3.1 → 0.3.2

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,24 @@
1
+ ## MAC OS
2
+ .DS_Store
3
+
4
+ ## TEXTMATE
5
+ *.tmproj
6
+ tmtags
7
+
8
+ ## EMACS
9
+ *~
10
+ \#*
11
+ .\#*
12
+
13
+ ## VIM
14
+ *.swp
15
+
16
+ ## PROJECT::GENERAL
17
+ coverage
18
+ rdoc
19
+ pkg
20
+
21
+ ## PROJECT::SPECIFIC
22
+ .idea
23
+ reckon_local
24
+ private_tests
data/.rvmrc ADDED
@@ -0,0 +1 @@
1
+ rvm use 1.9.3@reckon --create
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source "http://rubygems.org"
2
+
3
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,32 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ reckon (0.3.1)
5
+ chronic (>= 0.3.0)
6
+ fastercsv (>= 1.5.1)
7
+ highline (>= 1.5.2)
8
+ terminal-table (>= 1.4.2)
9
+
10
+ GEM
11
+ remote: http://rubygems.org/
12
+ specs:
13
+ chronic (0.6.7)
14
+ diff-lcs (1.1.3)
15
+ fastercsv (1.5.5)
16
+ highline (1.6.13)
17
+ rspec (2.11.0)
18
+ rspec-core (~> 2.11.0)
19
+ rspec-expectations (~> 2.11.0)
20
+ rspec-mocks (~> 2.11.0)
21
+ rspec-core (2.11.1)
22
+ rspec-expectations (2.11.2)
23
+ diff-lcs (~> 1.1.3)
24
+ rspec-mocks (2.11.1)
25
+ terminal-table (1.4.5)
26
+
27
+ PLATFORMS
28
+ ruby
29
+
30
+ DEPENDENCIES
31
+ reckon!
32
+ rspec (>= 1.2.9)
data/Rakefile CHANGED
@@ -1,49 +1,6 @@
1
- require 'rubygems'
2
- require 'rake'
1
+ require "bundler/gem_tasks"
2
+ require 'rspec/core/rake_task'
3
3
 
4
- begin
5
- require 'jeweler'
6
- Jeweler::Tasks.new do |gem|
7
- gem.name = "reckon"
8
- gem.summary = %Q{Utility for interactively converting and labeling CSV files for the Ledger accounting tool.}
9
- gem.description = %Q{Reckon automagically converts CSV files for use with the command-line accounting tool Ledger. It also helps you to select the correct accounts associated with the CSV data using Bayesian machine learning.}
10
- gem.email = "andrew@iterationlabs.com"
11
- gem.homepage = "http://github.com/iterationlabs/reckon"
12
- gem.authors = ["Andrew Cantino"]
13
- gem.add_development_dependency "rspec", "1.3.1"
14
- gem.add_development_dependency "jeweler"
15
- gem.add_dependency('fastercsv', '>= 1.5.1')
16
- gem.add_dependency('chronic', '>= 0.3.0')
17
- gem.add_dependency('highline', '>= 1.5.2')
18
- gem.add_dependency('terminal-table', '>= 1.4.2')
19
- end
20
- Jeweler::GemcutterTasks.new
21
- rescue LoadError
22
- puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
23
- end
24
-
25
- require 'spec/rake/spectask'
26
- Spec::Rake::SpecTask.new(:spec) do |spec|
27
- spec.libs << 'lib' << 'spec'
28
- spec.spec_files = FileList['spec/**/*_spec.rb']
29
- end
30
-
31
- Spec::Rake::SpecTask.new(:rcov) do |spec|
32
- spec.libs << 'lib' << 'spec'
33
- spec.pattern = 'spec/**/*_spec.rb'
34
- spec.rcov = true
35
- end
36
-
37
- task :spec => :check_dependencies
4
+ RSpec::Core::RakeTask.new(:spec)
38
5
 
39
6
  task :default => :spec
40
-
41
- require 'rake/rdoctask'
42
- Rake::RDocTask.new do |rdoc|
43
- version = File.exist?('VERSION') ? File.read('VERSION') : ""
44
-
45
- rdoc.rdoc_dir = 'rdoc'
46
- rdoc.title = "reckon #{version}"
47
- rdoc.rdoc_files.include('README*')
48
- rdoc.rdoc_files.include('lib/**/*.rb')
49
- end
data/bin/reckon CHANGED
File without changes
data/lib/reckon/app.rb CHANGED
@@ -1,3 +1,5 @@
1
+ require 'pp'
2
+
1
3
  module Reckon
2
4
  class App
3
5
  VERSION = "Reckon 0.1"
@@ -171,6 +173,7 @@ module Reckon
171
173
  def date_for(index)
172
174
  value = columns[date_column_index][index]
173
175
  value = [$1, $2, $3].join("/") if value =~ /^(\d{4})(\d{2})(\d{2})\d+\[\d+\:GMT\]$/ # chase format
176
+ value = [$3, $2, $1].join("/") if value =~ /^(\d{2})\.(\d{2})\.(\d{4})$/ # chase format
174
177
  begin
175
178
  guess = Chronic.parse(value, :context => :past)
176
179
  if guess.to_i < 953236800 && value =~ /\//
@@ -226,7 +229,7 @@ module Reckon
226
229
 
227
230
  # Try to determine if this is a balance column
228
231
  entry_as_num = entry.gsub(/[^\-\d\.]/, '').to_f
229
- if last && entry_as_num != 0 && last != 0
232
+ if last && entry_as_num != 0 && last != 0
230
233
  row.each do |row_entry|
231
234
  row_entry = row_entry.to_s.gsub(/[^\-\d\.]/, '').to_f
232
235
  if row_entry != 0 && last + row_entry == entry_as_num
@@ -267,7 +270,6 @@ module Reckon
267
270
  output_columns
268
271
  end
269
272
 
270
- require 'pp'
271
273
  def detect_columns
272
274
  results, found_likely_money_column = evaluate_columns(columns)
273
275
  self.money_column_indices = [ results.sort { |a, b| b[:money_score] <=> a[:money_score] }.first[:index] ]
@@ -287,7 +289,7 @@ module Reckon
287
289
  break
288
290
  end
289
291
  end
290
-
292
+
291
293
  if !found_likely_double_money_columns && !settings[:testing]
292
294
  puts "I didn't find a high-likelyhood money column, but I'm taking my best guess with column #{money_column_indices.first + 1}."
293
295
  end
@@ -331,7 +333,9 @@ module Reckon
331
333
 
332
334
  def parse
333
335
  data = options[:string] || File.read(options[:file])
334
- self.csv_data = (RUBY_VERSION =~ /^1\.9/ ? CSV : FasterCSV).parse(data.strip, :col_sep => options[:csv_separator] || ',')
336
+ @csv_data = (RUBY_VERSION =~ /^1\.9/ ? CSV : FasterCSV).parse(data.strip, :col_sep => options[:csv_separator] || ',')
337
+ csv_data.shift if options[:contains_header]
338
+ csv_data
335
339
  end
336
340
 
337
341
  def self.parse_opts(args = ARGV)
@@ -364,7 +368,11 @@ module Reckon
364
368
  options[:ignore_columns] = ignore.split(",").map { |i| i.to_i }
365
369
  end
366
370
 
367
- opts.on("", "--csv-separator ';'", "Separator for parsing the CSV - default is comma.") do |csv_separator|
371
+ opts.on("", "--contains-header", "The first row of the CSV is a header and should be skipped") do |contains_header|
372
+ options[:contains_header] = contains_header
373
+ end
374
+
375
+ opts.on("", "--csv-separator ','", "Separator for parsing the CSV - default is comma.") do |csv_separator|
368
376
  options[:csv_separator] = csv_separator
369
377
  end
370
378
 
@@ -409,10 +417,9 @@ module Reckon
409
417
  def self.settings
410
418
  @settings
411
419
  end
412
-
420
+
413
421
  def settings
414
422
  self.class.settings
415
423
  end
416
424
  end
417
425
  end
418
-
data/reckon.gemspec CHANGED
@@ -1,75 +1,24 @@
1
- # Generated by jeweler
2
- # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
1
  # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
5
3
 
6
4
  Gem::Specification.new do |s|
7
5
  s.name = %q{reckon}
8
- s.version = "0.3.1"
9
-
10
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
6
+ s.version = "0.3.2"
11
7
  s.authors = ["Andrew Cantino"]
12
- s.date = %q{2011-02-07}
13
- s.default_executable = %q{reckon}
14
- s.description = %q{Reckon automagically converts CSV files for use with the command-line accounting tool Ledger. It also helps you to select the correct accounts associated with the CSV data using Bayesian machine learning.}
15
8
  s.email = %q{andrew@iterationlabs.com}
16
- s.executables = ["reckon"]
17
- s.extra_rdoc_files = [
18
- "LICENSE",
19
- "README.rdoc"
20
- ]
21
- s.files = [
22
- ".document",
23
- "LICENSE",
24
- "README.rdoc",
25
- "Rakefile",
26
- "VERSION",
27
- "bin/reckon",
28
- "lib/reckon.rb",
29
- "lib/reckon/app.rb",
30
- "lib/reckon/ledger_parser.rb",
31
- "reckon.gemspec",
32
- "spec/reckon/app_spec.rb",
33
- "spec/reckon/ledger_parser_spec.rb",
34
- "spec/spec.opts",
35
- "spec/spec_helper.rb"
36
- ]
37
9
  s.homepage = %q{http://github.com/iterationlabs/reckon}
38
- s.require_paths = ["lib"]
39
- s.rubygems_version = %q{1.3.7}
10
+ s.description = %q{Reckon automagically converts CSV files for use with the command-line accounting tool Ledger. It also helps you to select the correct accounts associated with the CSV data using Bayesian machine learning.}
40
11
  s.summary = %q{Utility for interactively converting and labeling CSV files for the Ledger accounting tool.}
41
- s.test_files = [
42
- "spec/reckon/app_spec.rb",
43
- "spec/reckon/ledger_parser_spec.rb",
44
- "spec/spec_helper.rb"
45
- ]
46
12
 
47
- if s.respond_to? :specification_version then
48
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
49
- s.specification_version = 3
13
+ s.files = `git ls-files`.split("\n")
14
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
15
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
16
+ s.require_paths = ["lib"]
50
17
 
51
- if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
52
- s.add_development_dependency(%q<rspec>, ["= 1.3.1"])
53
- s.add_development_dependency(%q<jeweler>, [">= 0"])
54
- s.add_runtime_dependency(%q<fastercsv>, [">= 1.5.1"])
55
- s.add_runtime_dependency(%q<chronic>, [">= 0.3.0"])
56
- s.add_runtime_dependency(%q<highline>, [">= 1.5.2"])
57
- s.add_runtime_dependency(%q<terminal-table>, [">= 1.4.2"])
58
- else
59
- s.add_dependency(%q<rspec>, ["= 1.3.1"])
60
- s.add_dependency(%q<jeweler>, [">= 0"])
61
- s.add_dependency(%q<fastercsv>, [">= 1.5.1"])
62
- s.add_dependency(%q<chronic>, [">= 0.3.0"])
63
- s.add_dependency(%q<highline>, [">= 1.5.2"])
64
- s.add_dependency(%q<terminal-table>, [">= 1.4.2"])
65
- end
66
- else
67
- s.add_dependency(%q<rspec>, ["= 1.3.1"])
68
- s.add_dependency(%q<jeweler>, [">= 0"])
69
- s.add_dependency(%q<fastercsv>, [">= 1.5.1"])
70
- s.add_dependency(%q<chronic>, [">= 0.3.0"])
71
- s.add_dependency(%q<highline>, [">= 1.5.2"])
72
- s.add_dependency(%q<terminal-table>, [">= 1.4.2"])
73
- end
18
+ s.add_development_dependency "rspec", ">= 1.2.9"
19
+ s.add_runtime_dependency "fastercsv", ">= 1.5.1"
20
+ s.add_runtime_dependency "chronic", ">= 0.3.0"
21
+ s.add_runtime_dependency "highline", ">= 1.5.2"
22
+ s.add_runtime_dependency "terminal-table", ">= 1.4.2"
74
23
  end
75
24
 
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- require "./#{File.dirname(__FILE__)}/../spec_helper"
3
+ require "spec_helper"
4
4
  require 'rubygems'
5
5
  require 'reckon'
6
6
 
@@ -12,6 +12,7 @@ describe Reckon::App do
12
12
  @some_other_bank = Reckon::App.new(:string => SOME_OTHER_CSV)
13
13
  @two_money_columns = Reckon::App.new(:string => TWO_MONEY_COLUMNS_BANK)
14
14
  @simple_csv = Reckon::App.new(:string => SIMPLE_CSV)
15
+ @german_date = Reckon::App.new(:string => GERMAN_DATE_EXAMPLE)
15
16
  end
16
17
 
17
18
  it "should be in testing mode" do
@@ -101,6 +102,9 @@ describe Reckon::App do
101
102
  @some_other_bank.date_for(1).year.should == Time.parse("2010/12/24").year
102
103
  @some_other_bank.date_for(1).month.should == Time.parse("2010/12/24").month
103
104
  @some_other_bank.date_for(1).day.should == Time.parse("2010/12/24").day
105
+ @german_date.date_for(1).year.should == Time.parse("2009/12/24").year
106
+ @german_date.date_for(1).month.should == Time.parse("2009/12/24").month
107
+ @german_date.date_for(1).day.should == Time.parse("2009/12/24").day
104
108
  end
105
109
  end
106
110
 
@@ -175,4 +179,9 @@ describe Reckon::App do
175
179
  04-Nov-9,1234.00,,,TRANSFER CREDIT INTERNET TRANSFER,INTERNET TRANSFER,1234.00,
176
180
  28-Oct-10,-123.12,,,TRANSFER DEBIT INTERNET TRANSFER,INTERNET TRANSFER SAV TO MORTGAGE,0.00,
177
181
  CSV
182
+ GERMAN_DATE_EXAMPLE = (<<-CSV).strip
183
+ 24.12.2009,Check - 0000000122,122,-$76.00,"","$1,750.06"
184
+ 24.12.2009,BLARG R SH 456930,"","",+$327.49,"$1,826.06"
185
+ 24.12.2009,Check - 0000000112,112,-$800.00,"","$1,498.57"
186
+ CSV
178
187
  end
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- require "./#{File.dirname(__FILE__)}/../spec_helper"
3
+ require "spec_helper"
4
4
  require 'rubygems'
5
5
  require 'reckon'
6
6
  require 'pp'
data/spec/spec_helper.rb CHANGED
@@ -1,9 +1,6 @@
1
- $LOAD_PATH.unshift(File.dirname(__FILE__))
2
- $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
1
+ require 'rubygems'
2
+ require 'rspec'
3
3
  require 'reckon'
4
- require 'spec'
5
- require 'spec/autorun'
6
-
7
- Spec::Runner.configure do |config|
8
4
 
5
+ RSpec.configure do |config|
9
6
  end
metadata CHANGED
@@ -1,128 +1,110 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: reckon
3
- version: !ruby/object:Gem::Version
4
- hash: 17
5
- prerelease: false
6
- segments:
7
- - 0
8
- - 3
9
- - 1
10
- version: 0.3.1
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.3.2
5
+ prerelease:
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - Andrew Cantino
14
9
  autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
-
18
- date: 2011-02-07 00:00:00 -08:00
19
- default_executable: reckon
20
- dependencies:
21
- - !ruby/object:Gem::Dependency
12
+ date: 2012-07-30 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
22
15
  name: rspec
23
- prerelease: false
24
- requirement: &id001 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
25
17
  none: false
26
- requirements:
27
- - - "="
28
- - !ruby/object:Gem::Version
29
- hash: 25
30
- segments:
31
- - 1
32
- - 3
33
- - 1
34
- version: 1.3.1
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: 1.2.9
35
22
  type: :development
36
- version_requirements: *id001
37
- - !ruby/object:Gem::Dependency
38
- name: jeweler
39
23
  prerelease: false
40
- requirement: &id002 !ruby/object:Gem::Requirement
24
+ version_requirements: !ruby/object:Gem::Requirement
41
25
  none: false
42
- requirements:
43
- - - ">="
44
- - !ruby/object:Gem::Version
45
- hash: 3
46
- segments:
47
- - 0
48
- version: "0"
49
- type: :development
50
- version_requirements: *id002
51
- - !ruby/object:Gem::Dependency
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: 1.2.9
30
+ - !ruby/object:Gem::Dependency
52
31
  name: fastercsv
53
- prerelease: false
54
- requirement: &id003 !ruby/object:Gem::Requirement
32
+ requirement: !ruby/object:Gem::Requirement
55
33
  none: false
56
- requirements:
57
- - - ">="
58
- - !ruby/object:Gem::Version
59
- hash: 1
60
- segments:
61
- - 1
62
- - 5
63
- - 1
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
64
37
  version: 1.5.1
65
38
  type: :runtime
66
- version_requirements: *id003
67
- - !ruby/object:Gem::Dependency
68
- name: chronic
69
39
  prerelease: false
70
- requirement: &id004 !ruby/object:Gem::Requirement
40
+ version_requirements: !ruby/object:Gem::Requirement
71
41
  none: false
72
- requirements:
73
- - - ">="
74
- - !ruby/object:Gem::Version
75
- hash: 19
76
- segments:
77
- - 0
78
- - 3
79
- - 0
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: 1.5.1
46
+ - !ruby/object:Gem::Dependency
47
+ name: chronic
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
80
53
  version: 0.3.0
81
54
  type: :runtime
82
- version_requirements: *id004
83
- - !ruby/object:Gem::Dependency
84
- name: highline
85
55
  prerelease: false
86
- requirement: &id005 !ruby/object:Gem::Requirement
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: 0.3.0
62
+ - !ruby/object:Gem::Dependency
63
+ name: highline
64
+ requirement: !ruby/object:Gem::Requirement
87
65
  none: false
88
- requirements:
89
- - - ">="
90
- - !ruby/object:Gem::Version
91
- hash: 7
92
- segments:
93
- - 1
94
- - 5
95
- - 2
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
96
69
  version: 1.5.2
97
70
  type: :runtime
98
- version_requirements: *id005
99
- - !ruby/object:Gem::Dependency
100
- name: terminal-table
101
71
  prerelease: false
102
- requirement: &id006 !ruby/object:Gem::Requirement
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: 1.5.2
78
+ - !ruby/object:Gem::Dependency
79
+ name: terminal-table
80
+ requirement: !ruby/object:Gem::Requirement
103
81
  none: false
104
- requirements:
105
- - - ">="
106
- - !ruby/object:Gem::Version
107
- hash: 3
108
- segments:
109
- - 1
110
- - 4
111
- - 2
82
+ requirements:
83
+ - - ! '>='
84
+ - !ruby/object:Gem::Version
112
85
  version: 1.4.2
113
86
  type: :runtime
114
- version_requirements: *id006
115
- description: Reckon automagically converts CSV files for use with the command-line accounting tool Ledger. It also helps you to select the correct accounts associated with the CSV data using Bayesian machine learning.
87
+ prerelease: false
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ! '>='
92
+ - !ruby/object:Gem::Version
93
+ version: 1.4.2
94
+ description: Reckon automagically converts CSV files for use with the command-line
95
+ accounting tool Ledger. It also helps you to select the correct accounts associated
96
+ with the CSV data using Bayesian machine learning.
116
97
  email: andrew@iterationlabs.com
117
- executables:
98
+ executables:
118
99
  - reckon
119
100
  extensions: []
120
-
121
- extra_rdoc_files:
122
- - LICENSE
123
- - README.rdoc
124
- files:
101
+ extra_rdoc_files: []
102
+ files:
125
103
  - .document
104
+ - .gitignore
105
+ - .rvmrc
106
+ - Gemfile
107
+ - Gemfile.lock
126
108
  - LICENSE
127
109
  - README.rdoc
128
110
  - Rakefile
@@ -136,41 +118,33 @@ files:
136
118
  - spec/reckon/ledger_parser_spec.rb
137
119
  - spec/spec.opts
138
120
  - spec/spec_helper.rb
139
- has_rdoc: true
140
121
  homepage: http://github.com/iterationlabs/reckon
141
122
  licenses: []
142
-
143
123
  post_install_message:
144
124
  rdoc_options: []
145
-
146
- require_paths:
125
+ require_paths:
147
126
  - lib
148
- required_ruby_version: !ruby/object:Gem::Requirement
127
+ required_ruby_version: !ruby/object:Gem::Requirement
149
128
  none: false
150
- requirements:
151
- - - ">="
152
- - !ruby/object:Gem::Version
153
- hash: 3
154
- segments:
155
- - 0
156
- version: "0"
157
- required_rubygems_version: !ruby/object:Gem::Requirement
129
+ requirements:
130
+ - - ! '>='
131
+ - !ruby/object:Gem::Version
132
+ version: '0'
133
+ required_rubygems_version: !ruby/object:Gem::Requirement
158
134
  none: false
159
- requirements:
160
- - - ">="
161
- - !ruby/object:Gem::Version
162
- hash: 3
163
- segments:
164
- - 0
165
- version: "0"
135
+ requirements:
136
+ - - ! '>='
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
166
139
  requirements: []
167
-
168
140
  rubyforge_project:
169
- rubygems_version: 1.3.7
141
+ rubygems_version: 1.8.24
170
142
  signing_key:
171
143
  specification_version: 3
172
- summary: Utility for interactively converting and labeling CSV files for the Ledger accounting tool.
173
- test_files:
144
+ summary: Utility for interactively converting and labeling CSV files for the Ledger
145
+ accounting tool.
146
+ test_files:
174
147
  - spec/reckon/app_spec.rb
175
148
  - spec/reckon/ledger_parser_spec.rb
149
+ - spec/spec.opts
176
150
  - spec/spec_helper.rb