bankscrap 2.1.0 → 2.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 65f598489f53a242aa5cb5a24f13ac4cb7311743
4
- data.tar.gz: 75729f1b0fceb649218919b8a58a416ddaddb321
3
+ metadata.gz: 675dfa484d4f1b85f991d07d1a0ede73a22e17d4
4
+ data.tar.gz: 84ccd1a5a224ebbef6915d9beb90a4f260dba047
5
5
  SHA512:
6
- metadata.gz: 9304e7a9d6df0162edc510847e99a9a037214d7cd2237e6cde5b4c4cef183bcdea4cd2fbfe8f4f30a45f4460114e07489522d02dc3661874b3ab0062d0ccf3e5
7
- data.tar.gz: 2c6e2c11d7613f0c7ad1f5721663d4a601ee7897c105746a47b1f69f6167f8dbb42cd6a43f971b87fcdae495f7e3b12e85235ab4c617b18da54d6b91896fcca8
6
+ metadata.gz: 90f5cc316fe3afd9d9ff4ae2e33e97fc26b8a481b821581b987fc6efd4d3a4a7b560e9e2eec398b91c7573958f960a3b0293eb6eabd43b620866d506437bf5ba
7
+ data.tar.gz: d9f0f35f21ebea4580878353c6efb8f6de55ac64dd239e73926a27e39dc7b0a5b485d101d7cc5c8a021da898cc0fd84f37c6400e705603143741011986af1d3f
@@ -12,14 +12,14 @@ module Bankscrap
12
12
  self.destination_root = File.expand_path('.', gem_name)
13
13
  directory '.'
14
14
 
15
- STDERR.puts ''
16
- STDERR.puts "Great! Now you can start implementing your bank's adapter for Bankscrap.".yellow
17
- STDERR.puts ''
18
- STDERR.puts 'To get started take a look to:', :yellow
19
- STDERR.puts "#{destination_root}/lib/bankscrap/#{bank_name_dasherized}/bank.rb".yellow
20
- STDERR.puts ''
21
- STDERR.puts 'If you need help you can join our Slack chat room. Click the Slack badge on Github:'.yellow
22
- STDERR.puts 'https://github.com/bankscrap/bankscrap'.yellow
15
+ say ''
16
+ say "Great! Now you can start implementing your bank's adapter for Bankscrap.", :yellow
17
+ say ''
18
+ say 'To get started take a look to:', :yellow
19
+ say "#{destination_root}/lib/bankscrap/#{bank_name_dasherized}/bank.rb", :yellow
20
+ say ''
21
+ say 'If you need help you can join our Slack chat room. Click the Slack badge on Github:', :yellow
22
+ say 'https://github.com/bankscrap/bankscrap', :yellow
23
23
  end
24
24
 
25
25
  protected
@@ -27,10 +27,10 @@ module Bankscrap
27
27
  export_to_file(nil, @client.accounts, options[:format], options[:output])
28
28
  else
29
29
  @client.accounts.each do |account|
30
- STDERR.puts "Account: #{account.description} (#{account.iban})".cyan
31
- STDERR.puts "Balance: #{account.balance.format}".green
30
+ say "Account: #{account.description} (#{account.iban})", :cyan
31
+ say "Balance: #{account.balance.format}", :green
32
32
  if account.balance != account.available_balance
33
- STDERR.puts "Available: #{account.available_balance.format}".yellow
33
+ say "Available: #{account.available_balance.format}", :yellow
34
34
  end
35
35
  end
36
36
  end
@@ -46,7 +46,7 @@ module Bankscrap
46
46
  export_to_file(nil, @client.cards, options[:format], options[:output])
47
47
  else
48
48
  @client.cards.each do |card|
49
- STDERR.puts "Card: #{card.name} #{card.description} #{card.amount.format}".green
49
+ say "Card: #{card.name} #{card.description} #{card.amount.format}", :green
50
50
  end
51
51
  end
52
52
  end
@@ -61,7 +61,7 @@ module Bankscrap
61
61
  export_to_file(nil, @client.loans, options[:format], options[:output])
62
62
  else
63
63
  @client.loans.each do |loan|
64
- STDERR.puts "Loan: #{loan.name} #{loan.description} #{loan.amount.format}".green
64
+ say "Loan: #{loan.name} #{loan.description} #{loan.amount.format}", :green
65
65
  end
66
66
  end
67
67
  end
@@ -81,7 +81,7 @@ module Bankscrap
81
81
 
82
82
  if start_date && end_date
83
83
  if start_date > end_date
84
- STDERR.puts 'From date must be lower than to date'.red
84
+ say 'From date must be lower than to date', :red
85
85
  exit
86
86
  end
87
87
 
@@ -93,7 +93,7 @@ module Bankscrap
93
93
  if options[:format]
94
94
  export_to_file(account, transactions, options[:format], options[:output])
95
95
  else
96
- STDERR.puts "Transactions for: #{account.description} (#{account.iban})".cyan
96
+ say "Transactions for: #{account.description} (#{account.iban})", :cyan
97
97
  print_transactions_header
98
98
  transactions.each { |t| print_transaction(t) }
99
99
  end
@@ -130,7 +130,7 @@ module Bankscrap
130
130
  def parse_date(string)
131
131
  Date.strptime(string, '%d-%m-%Y')
132
132
  rescue ArgumentError
133
- STDERR.puts 'Invalid date format. Correct format d-m-Y (eg: 31-12-2016)'.red
133
+ say 'Invalid date format. Correct format d-m-Y (eg: 31-12-2016)', :red
134
134
  exit
135
135
  end
136
136
 
@@ -145,26 +145,26 @@ module Bankscrap
145
145
  when 'json'
146
146
  BankScrap::Exporter::Json.new(account)
147
147
  else
148
- STDERR.puts 'Sorry, file format not supported.'.red
148
+ say 'Sorry, file format not supported.', :red
149
149
  exit
150
150
  end
151
151
  end
152
152
 
153
153
  def print_transactions_header
154
- STDERR.puts "\n"
155
- STDERR.puts 'DATE'.ljust(13)
156
- STDERR.puts 'DESCRIPTION'.ljust(50) + SPACER
157
- STDERR.puts 'AMOUNT'.rjust(15) + SPACER
158
- STDERR.puts 'BALANCE'.rjust(15)
159
- STDERR.puts '-' * 99
154
+ say "\n"
155
+ say 'DATE'.ljust(13)
156
+ say 'DESCRIPTION'.ljust(50) + SPACER
157
+ say 'AMOUNT'.rjust(15) + SPACER
158
+ say 'BALANCE'.rjust(15)
159
+ say '-' * 99
160
160
  end
161
161
 
162
162
  def print_transaction(transaction)
163
163
  color = (transaction.amount.to_i > 0 ? :green : :red)
164
- STDERR.puts transaction.effective_date.strftime('%d/%m/%Y') + SPACER
165
- STDERR.puts Utils::CliString.new(transaction.description).squish.truncate(50).ljust(50) + SPACER.colorize(color)
166
- STDERR.puts Utils::CliString.new(transaction.amount.format).rjust(15) + SPACER.colorize(color)
167
- STDERR.puts Utils::CliString.new(transaction.balance.format).rjust(15)
164
+ say transaction.effective_date.strftime('%d/%m/%Y') + SPACER
165
+ say Utils::CliString.new(transaction.description).squish.truncate(50).ljust(50) + SPACER, color
166
+ say Utils::CliString.new(transaction.amount.format).rjust(15) + SPACER, color
167
+ say Utils::CliString.new(transaction.balance.format).rjust(15)
168
168
  end
169
169
  end
170
170
  end
@@ -3,8 +3,9 @@ require 'thor'
3
3
 
4
4
  module BankScrap
5
5
  module Exporter
6
- # Csv exporter
7
- class Csv
6
+ class Csv < Thor::Group
7
+ include Thor::Actions
8
+
8
9
  def initialize(account)
9
10
  @account = account
10
11
  end
@@ -40,25 +41,25 @@ module BankScrap
40
41
  csv << %w[Date Description Amount]
41
42
  data.each { |line| csv << line.to_a }
42
43
  end
43
- STDERR.puts "Transactions for: #{@account.description} (#{@account.iban}) exported to #{output}".cyan
44
+ say "Transactions for: #{@account.description} (#{@account.iban}) exported to #{output}", :cyan
44
45
  elsif check_array_class(data, Bankscrap::Account)
45
46
  CSV.open(output, 'wb') do |csv|
46
47
  csv << %w[Id Iban Name Description Bank Balance]
47
48
  data.each { |line| csv << line.to_a }
48
49
  end
49
- STDERR.puts "Accounts exported to #{output}".cyan
50
+ say "Accounts exported to #{output}", :cyan
50
51
  elsif check_array_class(data, Bankscrap::Loan)
51
52
  CSV.open(output, 'wb') do |csv|
52
53
  csv << %w[Id Name Description Amount]
53
54
  data.each { |line| csv << line.to_a }
54
55
  end
55
- STDERR.puts "Accounts exported to #{output}".cyan
56
+ say "Accounts exported to #{output}", :cyan
56
57
  elsif check_array_class(data, Bankscrap::Card)
57
58
  CSV.open(output, 'wb') do |csv|
58
59
  csv << %w[Id Name Description Pan Amount Avaliable Is_credit]
59
60
  data.each { |line| csv << line.to_a }
60
61
  end
61
- STDERR.puts "Accounts exported to #{output}".cyan
62
+ say "Accounts exported to #{output}", :cyan
62
63
  end
63
64
  end
64
65
  end
@@ -1,10 +1,11 @@
1
1
  require 'json'
2
- require 'colorize'
2
+ require 'thor'
3
3
 
4
4
  module BankScrap
5
5
  module Exporter
6
- # Json exporter
7
- class Json
6
+ class Json < Thor::Group
7
+ include Thor::Actions
8
+
8
9
  def initialize(account)
9
10
  @account = account
10
11
  end
@@ -75,13 +76,13 @@ module BankScrap
75
76
  f.write(JSON.pretty_generate(json_hash) + "\n")
76
77
  end
77
78
  if check_array_class(data, Bankscrap::Transaction)
78
- STDERR.puts "Transactions for: #{@account.description} (#{@account.iban}) exported to #{output}".cyan
79
+ say "Transactions for: #{@account.description} (#{@account.iban}) exported to #{output}", :cyan
79
80
  elsif check_array_class(data, Bankscrap::Account)
80
- STDERR.puts "Accounts exported to #{output}".cyan
81
+ say "Accounts exported to #{output}", :cyan
81
82
  elsif check_array_class(data, Bankscrap::Loan)
82
- STDERR.puts "Loans exported to #{output}".cyan
83
+ say "Loans exported to #{output}", :cyan
83
84
  elsif check_array_class(data, Bankscrap::Card)
84
- STDERR.puts "Cards exported to #{output}".cyan
85
+ say "Cards exported to #{output}", :cyan
85
86
  end
86
87
  end
87
88
  end
@@ -1,3 +1,3 @@
1
1
  module Bankscrap
2
- VERSION = '2.1.0'.freeze
2
+ VERSION = '2.1.1'.freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bankscrap
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.0
4
+ version: 2.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Javier Cuevas
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2018-07-16 00:00:00.000000000 Z
12
+ date: 2018-07-19 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -67,20 +67,6 @@ dependencies:
67
67
  - - ">="
68
68
  - !ruby/object:Gem::Version
69
69
  version: '0'
70
- - !ruby/object:Gem::Dependency
71
- name: colorize
72
- requirement: !ruby/object:Gem::Requirement
73
- requirements:
74
- - - ">="
75
- - !ruby/object:Gem::Version
76
- version: '0'
77
- type: :runtime
78
- prerelease: false
79
- version_requirements: !ruby/object:Gem::Requirement
80
- requirements:
81
- - - ">="
82
- - !ruby/object:Gem::Version
83
- version: '0'
84
70
  - !ruby/object:Gem::Dependency
85
71
  name: json
86
72
  requirement: !ruby/object:Gem::Requirement