barclays-to-ynab 1.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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: c2a08713374372c870eb61423381d8d2d2962ba6
4
+ data.tar.gz: bd388b6a69e2f1941513c1f0f8494c7fac636a89
5
+ SHA512:
6
+ metadata.gz: a9bb0bb01b68bb1b566ef4b8cd9f2a0f8645e78a10e70a1e93fe9034c793f2da7533b1a8055edee4f8f8e802a03417b0d200931dc7977ef3f3085ce8784f6595
7
+ data.tar.gz: ce889a0908a4b6aa32d28de3a5b8268512576258141acd4b3812663a0fee4a9f78d0f50ffece4e48d5079f076b6e1f67daf657c12b9d766df3e918cc4484a2d8
data/Gemfile ADDED
@@ -0,0 +1,5 @@
1
+ ruby '2.2.2'
2
+
3
+ source 'https://rubygems.org'
4
+
5
+ gem 'smarter_csv'
data/Gemfile.lock ADDED
@@ -0,0 +1,13 @@
1
+ GEM
2
+ remote: https://rubygems.org/
3
+ specs:
4
+ smarter_csv (1.0.19)
5
+
6
+ PLATFORMS
7
+ ruby
8
+
9
+ DEPENDENCIES
10
+ smarter_csv
11
+
12
+ BUNDLED WITH
13
+ 1.10.5
@@ -0,0 +1,18 @@
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'barclays-to-ynab/version'
5
+
6
+ Gem::Specification.new do |gem|
7
+ gem.authors = ['Scott Robertson']
8
+ gem.email = ['scottymeuk@gmail.com']
9
+ gem.description = %q{Convert Barclays CSV exports into YNAB compatible imports}
10
+ gem.summary = %q{Barclays YNAB converter}
11
+ gem.homepage = "https://github.com/scottrobertson/barclays-to-ynab"
12
+ gem.files = `git ls-files`.split($\)
13
+ gem.executables = ["barclays-to-ynab"]
14
+ gem.name = "barclays-to-ynab"
15
+ gem.require_paths = ["lib"]
16
+ gem.version = BarclaysToYnab::VERSION
17
+ gem.licenses = ['MIT']
18
+ end
@@ -0,0 +1,24 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'pathname'
4
+ $:.unshift File.expand_path(File.dirname(Pathname.new(__FILE__).realpath) + '/../lib')
5
+ require 'barclays-to-ynab'
6
+
7
+ file = ARGV.shift
8
+ unless file
9
+ puts 'You must specify an input file'
10
+ exit(1)
11
+ end
12
+
13
+ unless File.exists? file
14
+ puts 'Input file does not exist'
15
+ exit(1)
16
+ end
17
+
18
+ converter = BarclaysToYnab::Converter.new
19
+ new_path = converter.convert(file)
20
+
21
+ if new_path
22
+ puts "File saved to: #{new_path}"
23
+ exit(0)
24
+ end
@@ -0,0 +1,34 @@
1
+ require 'yaml'
2
+ require 'smarter_csv'
3
+ require 'csv'
4
+
5
+ module BarclaysToYnab
6
+ class Converter
7
+ def convert(path)
8
+ new_path = path + '.ynab.csv'
9
+ transactions = SmarterCSV.process(path)
10
+ headers = %w(Date Payee Memo Inflow Outflow Category)
11
+
12
+ File.open(new_path, 'w') do |f|
13
+ f.puts headers.to_csv
14
+ transactions.each do |transaction|
15
+
16
+ transaction_hash = {
17
+ 'Date' => transaction[:date],
18
+ 'Payee' => transaction[:memo].split(' ').first
19
+ }
20
+
21
+ if transaction[:amount] > 0
22
+ transaction_hash['Inflow'] = transaction[:amount].abs
23
+ else
24
+ transaction_hash['Outflow'] = transaction[:amount].abs
25
+ end
26
+
27
+ f.puts headers.map { |h| transaction_hash[h] }.to_csv
28
+ end
29
+ end
30
+
31
+ new_path
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,3 @@
1
+ module BarclaysToYnab
2
+ VERSION = "1.0.1"
3
+ end
metadata ADDED
@@ -0,0 +1,51 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: barclays-to-ynab
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Scott Robertson
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-07-10 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Convert Barclays CSV exports into YNAB compatible imports
14
+ email:
15
+ - scottymeuk@gmail.com
16
+ executables:
17
+ - barclays-to-ynab
18
+ extensions: []
19
+ extra_rdoc_files: []
20
+ files:
21
+ - Gemfile
22
+ - Gemfile.lock
23
+ - barclays-to-ynab.gemspec
24
+ - bin/barclays-to-ynab
25
+ - lib/barclays-to-ynab.rb
26
+ - lib/barclays-to-ynab/version.rb
27
+ homepage: https://github.com/scottrobertson/barclays-to-ynab
28
+ licenses:
29
+ - MIT
30
+ metadata: {}
31
+ post_install_message:
32
+ rdoc_options: []
33
+ require_paths:
34
+ - lib
35
+ required_ruby_version: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ">="
38
+ - !ruby/object:Gem::Version
39
+ version: '0'
40
+ required_rubygems_version: !ruby/object:Gem::Requirement
41
+ requirements:
42
+ - - ">="
43
+ - !ruby/object:Gem::Version
44
+ version: '0'
45
+ requirements: []
46
+ rubyforge_project:
47
+ rubygems_version: 2.4.8
48
+ signing_key:
49
+ specification_version: 4
50
+ summary: Barclays YNAB converter
51
+ test_files: []