ubimport 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 164bf922549d0f654bbd00d42cb75de0f3efb2d2
4
+ data.tar.gz: f850f13e21e6a028af5b4e614a37e4500aa7c65e
5
+ SHA512:
6
+ metadata.gz: ec4b85f7acafb9cd4f7daad73860d2eeeb6f18d040f822397f843ae61ddbdc190fed08004713e26bf3f548cba5ae33319a53794f4fc7cce5cbd0cdf7fecbddbe
7
+ data.tar.gz: 4f6ce1cdaeaa58dbb7e5dd9d5e0045be904a3a9ab334afec3ee2d084355806d9b0e72ea6960c3e3347b62bc789aa260ae31bd1e40f73189a8be50c5646b06e22
data/Gemfile CHANGED
@@ -3,13 +3,13 @@ source "http://rubygems.org"
3
3
  # Example:
4
4
  # gem "activesupport", ">= 2.3.5"
5
5
 
6
- gem 'fastercsv'
6
+ gem 'smarter_csv'
7
7
 
8
8
  # Add dependencies to develop your gem here.
9
9
  # Include everything needed to run rake, tests, features, etc.
10
10
  group :development do
11
- gem "rspec", "~> 2.3.0"
12
- gem "bundler", "~> 1.0.0"
13
- gem "jeweler", "~> 1.5.2"
14
- gem "rcov", ">= 0"
11
+ gem "rspec", "~> 3.1.0"
12
+ gem "bundler"
13
+ gem "jeweler", "~> 2.0.1"
14
+ gem 'pry'
15
15
  end
@@ -1,30 +1,79 @@
1
1
  GEM
2
2
  remote: http://rubygems.org/
3
3
  specs:
4
- diff-lcs (1.1.2)
5
- fastercsv (1.5.4)
6
- git (1.2.5)
7
- jeweler (1.5.2)
8
- bundler (~> 1.0.0)
4
+ addressable (2.3.6)
5
+ builder (3.2.2)
6
+ coderay (1.1.0)
7
+ descendants_tracker (0.0.4)
8
+ thread_safe (~> 0.3, >= 0.3.1)
9
+ diff-lcs (1.2.5)
10
+ faraday (0.9.1)
11
+ multipart-post (>= 1.2, < 3)
12
+ git (1.2.9.1)
13
+ github_api (0.12.2)
14
+ addressable (~> 2.3)
15
+ descendants_tracker (~> 0.0.4)
16
+ faraday (~> 0.8, < 0.10)
17
+ hashie (>= 3.3)
18
+ multi_json (>= 1.7.5, < 2.0)
19
+ nokogiri (~> 1.6.3)
20
+ oauth2
21
+ hashie (3.3.2)
22
+ highline (1.6.21)
23
+ jeweler (2.0.1)
24
+ builder
25
+ bundler (>= 1.0)
9
26
  git (>= 1.2.5)
27
+ github_api
28
+ highline (>= 1.6.15)
29
+ nokogiri (>= 1.5.10)
10
30
  rake
11
- rake (0.8.7)
12
- rcov (0.9.9)
13
- rspec (2.3.0)
14
- rspec-core (~> 2.3.0)
15
- rspec-expectations (~> 2.3.0)
16
- rspec-mocks (~> 2.3.0)
17
- rspec-core (2.3.1)
18
- rspec-expectations (2.3.0)
19
- diff-lcs (~> 1.1.2)
20
- rspec-mocks (2.3.0)
31
+ rdoc
32
+ json (1.8.2)
33
+ jwt (1.2.1)
34
+ method_source (0.8.2)
35
+ mini_portile (0.6.2)
36
+ multi_json (1.10.1)
37
+ multi_xml (0.5.5)
38
+ multipart-post (2.0.0)
39
+ nokogiri (1.6.6.2)
40
+ mini_portile (~> 0.6.0)
41
+ oauth2 (1.0.0)
42
+ faraday (>= 0.8, < 0.10)
43
+ jwt (~> 1.0)
44
+ multi_json (~> 1.3)
45
+ multi_xml (~> 0.5)
46
+ rack (~> 1.2)
47
+ pry (0.10.1)
48
+ coderay (~> 1.1.0)
49
+ method_source (~> 0.8.1)
50
+ slop (~> 3.4)
51
+ rack (1.6.0)
52
+ rake (10.4.2)
53
+ rdoc (4.2.0)
54
+ json (~> 1.4)
55
+ rspec (3.1.0)
56
+ rspec-core (~> 3.1.0)
57
+ rspec-expectations (~> 3.1.0)
58
+ rspec-mocks (~> 3.1.0)
59
+ rspec-core (3.1.7)
60
+ rspec-support (~> 3.1.0)
61
+ rspec-expectations (3.1.2)
62
+ diff-lcs (>= 1.2.0, < 2.0)
63
+ rspec-support (~> 3.1.0)
64
+ rspec-mocks (3.1.3)
65
+ rspec-support (~> 3.1.0)
66
+ rspec-support (3.1.2)
67
+ slop (3.6.0)
68
+ smarter_csv (1.0.19)
69
+ thread_safe (0.3.4)
21
70
 
22
71
  PLATFORMS
23
72
  ruby
24
73
 
25
74
  DEPENDENCIES
26
- bundler (~> 1.0.0)
27
- fastercsv
28
- jeweler (~> 1.5.2)
29
- rcov
30
- rspec (~> 2.3.0)
75
+ bundler
76
+ jeweler (~> 2.0.1)
77
+ pry
78
+ rspec (~> 3.1.0)
79
+ smarter_csv
data/Rakefile CHANGED
@@ -1,3 +1,5 @@
1
+ # encoding: utf-8
2
+
1
3
  require 'rubygems'
2
4
  require 'bundler'
3
5
  begin
@@ -17,7 +19,7 @@ PKG_FILES = FileList[
17
19
 
18
20
  require 'jeweler'
19
21
  Jeweler::Tasks.new do |gem|
20
- # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
22
+ # gem is a Gem::Specification... see http://guides.rubygems.org/specification-reference/ for more options
21
23
  gem.name = "ubimport"
22
24
  gem.homepage = "http://github.com/paulca/ubimport"
23
25
  gem.license = "MIT"
@@ -26,27 +28,26 @@ Jeweler::Tasks.new do |gem|
26
28
  gem.email = "paul@rslw.com"
27
29
  gem.authors = ["Paul Campbell"]
28
30
  gem.files = PKG_FILES.to_a
29
- # Include your dependencies below. Runtime dependencies are required when using your gem,
30
- # and development dependencies are only needed for development (ie running rake tasks, tests, etc)
31
- # gem.add_runtime_dependency 'jabber4r', '> 0.1'
32
- # gem.add_development_dependency 'rspec', '> 1.2.3'
31
+ # dependencies defined in Gemfile
33
32
  end
34
33
  Jeweler::RubygemsDotOrgTasks.new
35
34
 
36
- require 'rspec/core'
37
- require 'rspec/core/rake_task'
38
- RSpec::Core::RakeTask.new(:spec) do |spec|
39
- spec.pattern = FileList['spec/**/*_spec.rb']
35
+ require 'rake/testtask'
36
+ Rake::TestTask.new(:test) do |test|
37
+ test.libs << 'lib' << 'test'
38
+ test.pattern = 'test/**/test_*.rb'
39
+ test.verbose = true
40
40
  end
41
41
 
42
- RSpec::Core::RakeTask.new(:rcov) do |spec|
43
- spec.pattern = 'spec/**/*_spec.rb'
44
- spec.rcov = true
42
+ desc "Code coverage detail"
43
+ task :simplecov do
44
+ ENV['COVERAGE'] = "true"
45
+ Rake::Task['test'].execute
45
46
  end
46
47
 
47
- task :default => :spec
48
+ task :default => :test
48
49
 
49
- require 'rake/rdoctask'
50
+ require 'rdoc/task'
50
51
  Rake::RDocTask.new do |rdoc|
51
52
  version = File.exist?('VERSION') ? File.read('VERSION') : ""
52
53
 
@@ -54,4 +55,4 @@ Rake::RDocTask.new do |rdoc|
54
55
  rdoc.title = "ubimport #{version}"
55
56
  rdoc.rdoc_files.include('README*')
56
57
  rdoc.rdoc_files.include('lib/**/*.rb')
57
- end
58
+ end
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.0
1
+ 0.2.0
@@ -1,35 +1,28 @@
1
- require 'fastercsv'
1
+ require 'smarter_csv'
2
+
2
3
  class UBImporter
3
4
 
4
5
  attr_accessor :original_file, :original_lines, :changed_lines
5
6
 
6
7
  def initialize(original_file)
7
8
  @original_file = original_file
8
- @original_lines = []
9
- @changed_lines = []
10
- FasterCSV.foreach(original_file) do |row|
11
- @original_lines << row
12
- end
13
- @original_lines.each do |line|
14
- @changed_lines << process_line(line)
9
+ end
10
+
11
+ def changed_lines
12
+ @changed_lines ||= SmarterCSV.process(original_file,convert_values_to_numeric: false).collect do |row|
13
+ # *Date,*Amount,Description,Reference
14
+ [
15
+ row[:date],
16
+ row[:credit] || row[:debit],
17
+ [row[:"narrative_#1"], row[:"narrative_#2"], row[:"narrative_#3"], row[:"narrative_#4"], row[:"narrative_#5"]].compact.join(' '),
18
+ row[:"narrative_#2"]
19
+ ]
15
20
  end
16
21
  end
17
22
 
18
23
  def output
19
- changed_lines.collect { |line| line.to_csv }.join
20
- end
21
-
22
- def process_line(line)
23
- if line.first == 'Sort Code'
24
- line[17] = 'Amount'
25
- line[16] = 'TxType'
26
- elsif line.last.to_i > 0
27
- line[16] = 'CREDIT'
28
- elsif line[16].to_i < 0
29
- line[17] = line[16]
30
- line[16] = 'DEBIT'
31
- end
32
- line
24
+ headers = ['Date', 'Amount', 'Description','Reference'].to_csv
25
+ lines = changed_lines.collect(&:to_csv).join
26
+ headers + lines
33
27
  end
34
-
35
28
  end
@@ -2,17 +2,18 @@
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
3
  # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
+ # stub: ubimport 0.2.0 ruby lib
5
6
 
6
7
  Gem::Specification.new do |s|
7
- s.name = %q{ubimport}
8
- s.version = "0.1.0"
8
+ s.name = "ubimport"
9
+ s.version = "0.2.0"
9
10
 
10
11
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
12
+ s.require_paths = ["lib"]
11
13
  s.authors = ["Paul Campbell"]
12
- s.date = %q{2011-02-05}
13
- s.default_executable = %q{ubimport}
14
- s.description = %q{A useful tool until Xero.com supports Ulster Bank Ireland}
15
- s.email = %q{paul@rslw.com}
14
+ s.date = "2015-02-02"
15
+ s.description = "A useful tool until Xero.com supports Ulster Bank Ireland"
16
+ s.email = "paul@rslw.com"
16
17
  s.executables = ["ubimport"]
17
18
  s.extra_rdoc_files = [
18
19
  "LICENSE.txt",
@@ -32,38 +33,33 @@ Gem::Specification.new do |s|
32
33
  "lib/ubimport.rb",
33
34
  "ubimport.gemspec"
34
35
  ]
35
- s.homepage = %q{http://github.com/paulca/ubimport}
36
+ s.homepage = "http://github.com/paulca/ubimport"
36
37
  s.licenses = ["MIT"]
37
- s.require_paths = ["lib"]
38
- s.rubygems_version = %q{1.4.2}
39
- s.summary = %q{Convert Ulster Bank Ireland Bankline CSV files into a format compatible with Xero.com}
40
- s.test_files = [
41
- "spec/spec_helper.rb",
42
- "spec/ub_importer_spec.rb"
43
- ]
38
+ s.rubygems_version = "2.2.2"
39
+ s.summary = "Convert Ulster Bank Ireland Bankline CSV files into a format compatible with Xero.com"
44
40
 
45
41
  if s.respond_to? :specification_version then
46
- s.specification_version = 3
42
+ s.specification_version = 4
47
43
 
48
44
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
49
- s.add_runtime_dependency(%q<fastercsv>, [">= 0"])
50
- s.add_development_dependency(%q<rspec>, ["~> 2.3.0"])
51
- s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
52
- s.add_development_dependency(%q<jeweler>, ["~> 1.5.2"])
53
- s.add_development_dependency(%q<rcov>, [">= 0"])
45
+ s.add_runtime_dependency(%q<smarter_csv>, [">= 0"])
46
+ s.add_development_dependency(%q<rspec>, ["~> 3.1.0"])
47
+ s.add_development_dependency(%q<bundler>, [">= 0"])
48
+ s.add_development_dependency(%q<jeweler>, ["~> 2.0.1"])
49
+ s.add_development_dependency(%q<pry>, [">= 0"])
54
50
  else
55
- s.add_dependency(%q<fastercsv>, [">= 0"])
56
- s.add_dependency(%q<rspec>, ["~> 2.3.0"])
57
- s.add_dependency(%q<bundler>, ["~> 1.0.0"])
58
- s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
59
- s.add_dependency(%q<rcov>, [">= 0"])
51
+ s.add_dependency(%q<smarter_csv>, [">= 0"])
52
+ s.add_dependency(%q<rspec>, ["~> 3.1.0"])
53
+ s.add_dependency(%q<bundler>, [">= 0"])
54
+ s.add_dependency(%q<jeweler>, ["~> 2.0.1"])
55
+ s.add_dependency(%q<pry>, [">= 0"])
60
56
  end
61
57
  else
62
- s.add_dependency(%q<fastercsv>, [">= 0"])
63
- s.add_dependency(%q<rspec>, ["~> 2.3.0"])
64
- s.add_dependency(%q<bundler>, ["~> 1.0.0"])
65
- s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
66
- s.add_dependency(%q<rcov>, [">= 0"])
58
+ s.add_dependency(%q<smarter_csv>, [">= 0"])
59
+ s.add_dependency(%q<rspec>, ["~> 3.1.0"])
60
+ s.add_dependency(%q<bundler>, [">= 0"])
61
+ s.add_dependency(%q<jeweler>, ["~> 2.0.1"])
62
+ s.add_dependency(%q<pry>, [">= 0"])
67
63
  end
68
64
  end
69
65
 
metadata CHANGED
@@ -1,110 +1,95 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: ubimport
3
- version: !ruby/object:Gem::Version
4
- hash: 27
5
- prerelease:
6
- segments:
7
- - 0
8
- - 1
9
- - 0
10
- version: 0.1.0
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.0
11
5
  platform: ruby
12
- authors:
6
+ authors:
13
7
  - Paul Campbell
14
8
  autorequire:
15
9
  bindir: bin
16
10
  cert_chain: []
17
-
18
- date: 2011-02-05 00:00:00 +00:00
19
- default_executable: ubimport
20
- dependencies:
21
- - !ruby/object:Gem::Dependency
22
- prerelease: false
23
- name: fastercsv
24
- type: :runtime
25
- version_requirements: &id001 !ruby/object:Gem::Requirement
26
- none: false
27
- requirements:
11
+ date: 2015-02-02 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: smarter_csv
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
28
17
  - - ">="
29
- - !ruby/object:Gem::Version
30
- hash: 3
31
- segments:
32
- - 0
33
- version: "0"
34
- requirement: *id001
35
- - !ruby/object:Gem::Dependency
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
36
21
  prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
37
28
  name: rspec
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 3.1.0
38
34
  type: :development
39
- version_requirements: &id002 !ruby/object:Gem::Requirement
40
- none: false
41
- requirements:
42
- - - ~>
43
- - !ruby/object:Gem::Version
44
- hash: 3
45
- segments:
46
- - 2
47
- - 3
48
- - 0
49
- version: 2.3.0
50
- requirement: *id002
51
- - !ruby/object:Gem::Dependency
52
35
  prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 3.1.0
41
+ - !ruby/object:Gem::Dependency
53
42
  name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
54
48
  type: :development
55
- version_requirements: &id003 !ruby/object:Gem::Requirement
56
- none: false
57
- requirements:
58
- - - ~>
59
- - !ruby/object:Gem::Version
60
- hash: 23
61
- segments:
62
- - 1
63
- - 0
64
- - 0
65
- version: 1.0.0
66
- requirement: *id003
67
- - !ruby/object:Gem::Dependency
68
49
  prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
69
56
  name: jeweler
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: 2.0.1
70
62
  type: :development
71
- version_requirements: &id004 !ruby/object:Gem::Requirement
72
- none: false
73
- requirements:
74
- - - ~>
75
- - !ruby/object:Gem::Version
76
- hash: 7
77
- segments:
78
- - 1
79
- - 5
80
- - 2
81
- version: 1.5.2
82
- requirement: *id004
83
- - !ruby/object:Gem::Dependency
84
63
  prerelease: false
85
- name: rcov
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: 2.0.1
69
+ - !ruby/object:Gem::Dependency
70
+ name: pry
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
86
76
  type: :development
87
- version_requirements: &id005 !ruby/object:Gem::Requirement
88
- none: false
89
- requirements:
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
90
80
  - - ">="
91
- - !ruby/object:Gem::Version
92
- hash: 3
93
- segments:
94
- - 0
95
- version: "0"
96
- requirement: *id005
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
97
83
  description: A useful tool until Xero.com supports Ulster Bank Ireland
98
84
  email: paul@rslw.com
99
- executables:
85
+ executables:
100
86
  - ubimport
101
87
  extensions: []
102
-
103
- extra_rdoc_files:
88
+ extra_rdoc_files:
104
89
  - LICENSE.txt
105
90
  - README.md
106
91
  - README.rdoc
107
- files:
92
+ files:
108
93
  - Gemfile
109
94
  - Gemfile.lock
110
95
  - LICENSE.txt
@@ -116,42 +101,29 @@ files:
116
101
  - lib/ub_importer.rb
117
102
  - lib/ubimport.rb
118
103
  - ubimport.gemspec
119
- - spec/spec_helper.rb
120
- - spec/ub_importer_spec.rb
121
- has_rdoc: true
122
104
  homepage: http://github.com/paulca/ubimport
123
- licenses:
105
+ licenses:
124
106
  - MIT
107
+ metadata: {}
125
108
  post_install_message:
126
109
  rdoc_options: []
127
-
128
- require_paths:
110
+ require_paths:
129
111
  - lib
130
- required_ruby_version: !ruby/object:Gem::Requirement
131
- none: false
132
- requirements:
112
+ required_ruby_version: !ruby/object:Gem::Requirement
113
+ requirements:
133
114
  - - ">="
134
- - !ruby/object:Gem::Version
135
- hash: 3
136
- segments:
137
- - 0
138
- version: "0"
139
- required_rubygems_version: !ruby/object:Gem::Requirement
140
- none: false
141
- requirements:
115
+ - !ruby/object:Gem::Version
116
+ version: '0'
117
+ required_rubygems_version: !ruby/object:Gem::Requirement
118
+ requirements:
142
119
  - - ">="
143
- - !ruby/object:Gem::Version
144
- hash: 3
145
- segments:
146
- - 0
147
- version: "0"
120
+ - !ruby/object:Gem::Version
121
+ version: '0'
148
122
  requirements: []
149
-
150
123
  rubyforge_project:
151
- rubygems_version: 1.4.2
124
+ rubygems_version: 2.2.2
152
125
  signing_key:
153
- specification_version: 3
154
- summary: Convert Ulster Bank Ireland Bankline CSV files into a format compatible with Xero.com
155
- test_files:
156
- - spec/spec_helper.rb
157
- - spec/ub_importer_spec.rb
126
+ specification_version: 4
127
+ summary: Convert Ulster Bank Ireland Bankline CSV files into a format compatible with
128
+ Xero.com
129
+ test_files: []
@@ -1 +0,0 @@
1
- require 'lib/ub_importer'
@@ -1,38 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe UBImporter do
4
-
5
- let(:importer) { UBImporter.new('spec/fixtures/sample.csv') }
6
-
7
- describe "#original_lines" do
8
- it "should load the file" do
9
- importer.should have(3).original_lines
10
- importer.should have(3).changed_lines
11
- end
12
-
13
- it "should change the last few parts of the first line" do
14
- importer.changed_lines.first.length.should == 18
15
- importer.changed_lines.first[17].should == 'Amount'
16
- importer.changed_lines.first[16].should == 'TxType'
17
- end
18
-
19
- it "should change the last few parts of the second line" do
20
- importer.changed_lines[1].length.should == 18
21
- importer.changed_lines[1][17].should == '-900.00'
22
- importer.changed_lines[1][16].should == 'DEBIT'
23
- end
24
-
25
- it "should change the last few parts of the third line" do
26
- importer.changed_lines[2].length.should == 18
27
- importer.changed_lines[2][17].should == '3811.50'
28
- importer.changed_lines[2][16].should == 'CREDIT'
29
- end
30
- end
31
-
32
- describe "#output" do
33
- it "should output the file correctly" do
34
- importer.output.should == File.read('spec/fixtures/sample_output.csv')
35
- end
36
- end
37
-
38
- end