payoneer_csv 0.1.2 → 0.1.4

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.
@@ -3,11 +3,11 @@ language: ruby
3
3
  rvm:
4
4
  - 1.9.2
5
5
  - 1.9.3
6
- - jruby-19mode
7
6
 
8
7
  before_install:
9
8
  - sudo apt-get update -qq
10
- - sudo apt-get install poppler-utils
9
+ - sudo apt-get install ghostscript
11
10
 
12
11
  script:
13
12
  - "rspec spec"
13
+ - "cucumber features"
data/Gemfile CHANGED
@@ -5,8 +5,10 @@ gemspec
5
5
 
6
6
  group :development, :test do
7
7
  gem 'rspec'
8
+ gem 'cucumber'
9
+ gem 'aruba'
8
10
  gem 'simplecov', require: false
9
11
 
10
12
  gem 'awesome_print'
11
- gem 'debugger', platforms: :ruby
13
+ gem 'debugger'
12
14
  end
data/README.md CHANGED
@@ -6,9 +6,9 @@ Simple tool for converting payoneer pdf report to csv file.
6
6
 
7
7
  ## Installation
8
8
 
9
- First of all install `pdftotext` executable
9
+ First of all install `ps2ascii` executable
10
10
 
11
- $ sudo apt-get install poppler-utils
11
+ $ sudo apt-get install ghostscript
12
12
 
13
13
  Add this line to your application's Gemfile:
14
14
 
@@ -1,18 +1,27 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- unless ARGV[0]
4
- puts 'Usage: payoneer_csv /path/to/transaction_list.pdf'
5
- exit
6
- end
7
-
3
+ require 'optparse'
4
+ require 'methadone'
8
5
  require 'payoneer_csv'
9
6
 
10
- file_path = File.expand_path(ARGV[0])
11
- unless File.exist?(file_path)
12
- puts "Cannot find file: #{file_path}"
13
- exit
14
- end
7
+ class App
8
+ include Methadone::Main
9
+ include Methadone::CLILogging
10
+
11
+ main do |file_path|
12
+ unless File.exist?(file_path)
13
+ puts "Cannot find file: #{file_path}"
14
+ exit
15
+ end
15
16
 
16
- reader = PayoneerCsv::PdfReader.new(file_path)
17
- csv_string = PayoneerCsv::Csv.new(reader.read).generate
18
- puts csv_string
17
+ reader = PayoneerCsv::PdfReader.new(file_path)
18
+ csv_string = PayoneerCsv::Csv.new(reader.read).generate
19
+ puts csv_string
20
+ end
21
+
22
+ arg :file_path
23
+
24
+ version PayoneerCsv::VERSION
25
+
26
+ go!
27
+ end
@@ -0,0 +1,57 @@
1
+ Feature: My bootstrapped app kinda works
2
+ In order to get going on coding my awesome app
3
+ I want to have aruba and cucumber setup
4
+ So I don't have to do it myself
5
+
6
+ Scenario: App just runs
7
+ When I get help for "payoneer_csv"
8
+ Then the exit status should be 0
9
+ And the banner should be present
10
+ And the banner should document that this app takes options
11
+ And the following options should be documented:
12
+ | --version |
13
+ And the banner should document that this app's arguments are:
14
+ | file_path | which is required |
15
+
16
+ Scenario: Run with non existing file
17
+ When I run `payoneer_csv non-existing.pdf`
18
+ Then the output should contain "Cannot find file: non-existing.pdf"
19
+
20
+ Scenario: Run with existing file
21
+ When I run `payoneer_csv Transactions.pdf`
22
+ Then the output should contain:
23
+ """
24
+ Transaction Date,Description,Amount,Currency
25
+ 10/17/2012 5:58:20 AM,ATM Withdrawal - Vaci u. 42.,-75.29,USD
26
+ 10/16/2012 6:41:30 AM,ROSSMANN,-14.2,USD
27
+ 10/15/2012 8:30:15 PM,Prima,-4.98,USD
28
+ 10/15/2012 8:44:18 AM,PKP Intercity,-48.61,USD
29
+ 10/18/2012 2:52:18 AM,ATM Withdrawal - OTP,-51.02,USD
30
+ 10/19/2012 11:38:12 PM,PSS SKLEP NR 54,-17.36,USD
31
+ 10/19/2012 6:41:14 AM,COSTA COFFEE,-7.41,USD
32
+ """
33
+
34
+ Scenario: Run with other existing file
35
+ When I run `payoneer_csv Transactions2.pdf`
36
+ Then the output should contain:
37
+ """
38
+ Transaction Date,Description,Amount,Currency
39
+ 10/18/2012 2:52:18 AM,ATM Withdrawal - OTP,-51.02,USD
40
+ 10/19/2012 6:41:14 AM,COSTA COFFEE,-7.41,USD
41
+ 10/26/2012 8:10:10 PM,Delikatesy Alma,-13.19,USD
42
+ 10/26/2012 12:25:14 AM,DEEZER,-4.87,USD
43
+ 10/19/2012 11:38:12 PM,PSS SKLEP NR 54,-17.36,USD
44
+ 10/26/2012 8:15:31 PM,Delikatesy Alma,-7.83,USD
45
+ 10/23/2012 8:23:51 PM,Delikatesy Alma,-31.42,USD
46
+ 10/21/2012 10:53:31 PM,CAFE ARTE,-3.14,USD
47
+ 10/21/2012 10:21:28 PM,PSS SKLEP,-5.47,USD
48
+ 10/23/2012 6:28:09 AM,SJO Empik,-23.17,USD
49
+ 10/22/2012 2:47:05 AM,Delikatesy Alma,-77.25,USD
50
+ 10/15/2012 8:44:18 AM,PKP Intercity,-48.61,USD
51
+ 10/11/2012 8:31:56 PM,Delikatesy Alma,-42.89,USD
52
+ 10/10/2012 8:10:37 PM,HAPPY,-4.31,USD
53
+ 10/10/2012 8:02:27 PM,Withdrawal Notification Lukasz Bandzarewicz 1198,1198.0,USD
54
+ 10/15/2012 8:30:15 PM,Prima,-4.98,USD
55
+ 10/17/2012 5:58:20 AM,ATM Withdrawal - Vaci u. 42.,-75.29,USD
56
+ 10/16/2012 6:41:30 AM,ROSSMANN,-14.2,USD
57
+ """
@@ -0,0 +1 @@
1
+ # Put your step definitions here
@@ -0,0 +1,17 @@
1
+ require 'aruba/cucumber'
2
+ require 'methadone/cucumber'
3
+
4
+ ENV['PATH'] = "#{File.expand_path(File.dirname(__FILE__) + '/../../bin')}#{File::PATH_SEPARATOR}#{ENV['PATH']}"
5
+ LIB_DIR = File.join(File.expand_path(File.dirname(__FILE__)),'..','..','lib')
6
+
7
+ Before do
8
+ # Using "announce" causes massive warnings on 1.9.2
9
+ @puts = true
10
+ @dirs = ["spec/fixtures"]
11
+ @original_rubylib = ENV['RUBYLIB']
12
+ ENV['RUBYLIB'] = LIB_DIR + File::PATH_SEPARATOR + ENV['RUBYLIB'].to_s
13
+ end
14
+
15
+ After do
16
+ ENV['RUBYLIB'] = @original_rubylib
17
+ end
@@ -21,11 +21,11 @@ module PayoneerCsv
21
21
  end
22
22
 
23
23
  def raw_data
24
- `less #{file_path}`
24
+ `ps2ascii #{file_path}`
25
25
  end
26
26
 
27
27
  def parse(row)
28
- row.match /^(?<created_at>\d{1,2}\/\d{1,2}\/\d{4} \d{1,2}:\d{2}:\d{2} (AM|PM))\s+ (?<description>.+) (?<amount>-?(\d|,)+\.\d{2})\s+USD$/
28
+ row.match /^(?<created_at>\d{1,2}\/\d{1,2}\/\d{4} \d{1,2}:\d{2}:\d{2} (AM|PM))\s(?<description>.+) (?<amount>-?(\d|,)+\.\d{2})\s+USD$/
29
29
  end
30
30
  end
31
31
 
@@ -1,3 +1,3 @@
1
1
  module PayoneerCsv
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.4"
3
3
  end
@@ -14,4 +14,6 @@ Gem::Specification.new do |gem|
14
14
  gem.name = "payoneer_csv"
15
15
  gem.require_paths = ["lib"]
16
16
  gem.version = PayoneerCsv::VERSION
17
+
18
+ gem.add_dependency('methadone', '1.2.2')
17
19
  end
@@ -17,10 +17,10 @@ describe PayoneerCsv::PdfReader do
17
17
  it 'should include some transactions' do
18
18
  should_not be_empty
19
19
 
20
- should include('10/19/2012 11:38:12 PM PSS SKLEP NR 54 -17.36 USD')
21
- should include('10/19/2012 6:41:14 AM COSTA COFFEE -7.41 USD')
20
+ should include('10/19/2012 11:38:12 PM PSS SKLEP NR 54 -17.36 USD')
21
+ should include('10/19/2012 6:41:14 AM COSTA COFFEE -7.41 USD')
22
22
  # ...
23
- should include('10/15/2012 8:44:18 AM PKP Intercity -48.61 USD')
23
+ should include('10/15/2012 8:44:18 AM PKP Intercity -48.61 USD')
24
24
  end
25
25
  end
26
26
  end
@@ -32,20 +32,20 @@ describe PayoneerCsv::PdfReader do
32
32
  subject { reader.parse(row) }
33
33
 
34
34
  context 'on valid row (with negative amount)' do
35
- let(:row) { '10/17/2012 5:58:20 AM ATM Withdrawal - Vaci u. 42. -75.29 USD' }
35
+ let(:row) { '10/17/2012 5:58:20 AM ATM Withdrawal - Vaci u. 42. -75.29 USD' }
36
36
 
37
37
  it { should_not be_nil }
38
38
  its([:created_at]) { should == '10/17/2012 5:58:20 AM' }
39
- its([:description]) { should == 'ATM Withdrawal - Vaci u. 42. ' }
39
+ its([:description]) { should == 'ATM Withdrawal - Vaci u. 42.' }
40
40
  its([:amount]) { should == '-75.29' }
41
41
  end
42
42
 
43
43
  context 'on valid row (with positive amount)' do
44
- let(:row) { '10/19/2012 11:38:12 PM PSS SKLEP NR 54 2,117.36 USD' }
44
+ let(:row) { '10/19/2012 11:38:12 PM PSS SKLEP NR 54 2,117.36 USD' }
45
45
 
46
46
  it { should_not be_nil }
47
47
  its([:created_at]) { should == '10/19/2012 11:38:12 PM' }
48
- its([:description]) { should == 'PSS SKLEP NR 54 ' }
48
+ its([:description]) { should == 'PSS SKLEP NR 54' }
49
49
  its([:amount]) { should == '2,117.36' }
50
50
  end
51
51
 
@@ -66,8 +66,8 @@ describe PayoneerCsv::PdfReader do
66
66
 
67
67
  it { should have(7).items }
68
68
 
69
- describe 'first transaction' do
70
- subject { result.first }
69
+ describe 'a transaction' do
70
+ subject { result[5] }
71
71
 
72
72
  its(:created_at) { should == '10/19/2012 11:38:12 PM' }
73
73
  its(:description) { should == 'PSS SKLEP NR 54' }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: payoneer_csv
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,8 +9,24 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-10-27 00:00:00.000000000 Z
13
- dependencies: []
12
+ date: 2013-09-11 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: methadone
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - '='
20
+ - !ruby/object:Gem::Version
21
+ version: 1.2.2
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - '='
28
+ - !ruby/object:Gem::Version
29
+ version: 1.2.2
14
30
  description: Simple tool for converting payoneer pdf report to csv file
15
31
  email:
16
32
  - lucassus@gmail.com
@@ -27,6 +43,9 @@ files:
27
43
  - README.md
28
44
  - Rakefile
29
45
  - bin/payoneer_csv
46
+ - features/payoneer_csv.feature
47
+ - features/step_definitions/payoneer_csv_steps.rb
48
+ - features/support/env.rb
30
49
  - lib/payoneer_csv.rb
31
50
  - lib/payoneer_csv/csv.rb
32
51
  - lib/payoneer_csv/pdf_reader.rb
@@ -34,6 +53,7 @@ files:
34
53
  - lib/payoneer_csv/version.rb
35
54
  - payoneer_csv.gemspec
36
55
  - spec/fixtures/Transactions.pdf
56
+ - spec/fixtures/Transactions2.pdf
37
57
  - spec/payoneer_csv/csv_spec.rb
38
58
  - spec/payoneer_csv/pdf_reader_spec.rb
39
59
  - spec/payoneer_csv/transaction_spec.rb
@@ -58,12 +78,16 @@ required_rubygems_version: !ruby/object:Gem::Requirement
58
78
  version: '0'
59
79
  requirements: []
60
80
  rubyforge_project:
61
- rubygems_version: 1.8.24
81
+ rubygems_version: 1.8.25
62
82
  signing_key:
63
83
  specification_version: 3
64
84
  summary: Convert payoneer pdf report to csv file
65
85
  test_files:
86
+ - features/payoneer_csv.feature
87
+ - features/step_definitions/payoneer_csv_steps.rb
88
+ - features/support/env.rb
66
89
  - spec/fixtures/Transactions.pdf
90
+ - spec/fixtures/Transactions2.pdf
67
91
  - spec/payoneer_csv/csv_spec.rb
68
92
  - spec/payoneer_csv/pdf_reader_spec.rb
69
93
  - spec/payoneer_csv/transaction_spec.rb