bankscrap 2.0.1 → 2.0.2

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: b5efc7e5d7389c86940e835e58f1e472a21c798e
4
- data.tar.gz: fbe0edfb17bf2f8bd6a187a76b9dc526eb9fa493
3
+ metadata.gz: 13c569f9c25d7e6f84690e4c1bab9d8a2a00f5ed
4
+ data.tar.gz: e76f218f60aa54069fb20e3384bc4004f6f64d10
5
5
  SHA512:
6
- metadata.gz: 1b157a5484ebc5246b58707278693d818b334da890460ad0cd9e4ae04a05bb524aecd215c005a3ea4ddaead74978294ce505ba51a641a9f59b6ea15135179058
7
- data.tar.gz: 29ebadde8aaafd5f182f83649cefffdebb67002abd7dcbca896e35908e55fa3dfb2b756c51cc5de79f99d3e1f40a45189e5976cc0f9b8291edc7031a812f2e2d
6
+ metadata.gz: 8ecdb3929fde61194a69ff1fa5cfb503d94e7c00441d954cc84bc053173ae931a10fcda0a6d9df0292065b64b922bcb3913b11bdee03b09ac45a510d3acc02fb
7
+ data.tar.gz: 154449817ea77620bb04559bdb1f084f5aa798d547bf08ec60e400407dcd465fe041876961a018f1b4ea3e1d1c89b35da9339727bb94cfb756381d27be69faef
data/README.md CHANGED
@@ -1,7 +1,8 @@
1
- # 💸 Bankscrap 💸
1
+ # 💸 Bankscrap 💸
2
2
 
3
3
  [![](http://188.166.39.57:3000/badge.svg)](http://188.166.39.57:3000)
4
- ![build status](https://travis-ci.org/bankscrap/bankscrap.svg?branch=master)
4
+ [![Gem Version](https://badge.fury.io/rb/bankscrap.svg)](https://badge.fury.io/rb/bankscrap)
5
+ [![Build Status](https://travis-ci.org/bankscrap/bankscrap.svg?branch=master)](https://travis-ci.org/bankscrap/bankscrap)
5
6
 
6
7
  Ruby gem to extract account balance and transactions from banks. You can use it either as command line tool or as a library.
7
8
 
@@ -14,6 +15,8 @@ Feel free to contribute and add your bank if it isn't supported.
14
15
  * **ING Direct**: [bankscrap-ing](https://github.com/bankscrap/bankscrap-ing)
15
16
  * **Arquia Banca**: [bankscrap-arquia](https://github.com/bankscrap/bankscrap-arquia)
16
17
  * **Banc Sabadell** (WIP): [bankscrap-banc-sabadell](https://github.com/bankscrap/bankscrap-banc-sabadell)
18
+ * **Santander** (WIP): [bankscrap-santander](https://github.com/bankscrap/bankscrap-santander)
19
+ * **Openbank** (WIP): [bankscrap-openbank](https://github.com/bankscrap/bankscrap-openbank)
17
20
 
18
21
  Interested in any other bank? Open a new Issue and we'll try to help.
19
22
 
@@ -60,7 +63,7 @@ Note that you only need to install the gem for your selected bank – the main g
60
63
 
61
64
  ###### BBVA
62
65
 
63
- $ bankscrap balance YourBank --credentials=user:YOUR_BANK_USER password:YOUR_BANK_PASSWORD
66
+ $ bankscrap balance BBVA --credentials=user:YOUR_BANK_USER password:YOUR_BANK_PASSWORD
64
67
 
65
68
  ###### ING Direct
66
69
  ING needs one more argument: your birthday.
@@ -76,7 +79,7 @@ Replace 01/01/1980 with your actual birthday.
76
79
 
77
80
  ###### ING Direct
78
81
 
79
- $ bankscrap transactions ING --credentials=nif:YOUR_DNI password:YOUR_BANK_PASSWORD birthday:01/01/1980
82
+ $ bankscrap transactions ING --credentials=dni:YOUR_DNI password:YOUR_BANK_PASSWORD birthday:01/01/1980
80
83
 
81
84
  #### Transactions with date range
82
85
 
@@ -86,7 +89,7 @@ Replace 01/01/1980 with your actual birthday.
86
89
 
87
90
  By default it will use your first bank account, if you want to fetch transactions for a different account you can use this syntax:
88
91
 
89
- $ bankscrap transactions YourBank --iban "your_iban" --credentials=user:YOUR_BANK_USER password:YOUR_BANK_PASSWORD
92
+ $ bankscrap transactions YourBank --iban "your_iban" --credentials=user:YOUR_BANK_USER password:YOUR_BANK_PASSWORD
90
93
 
91
94
  If you don't want to pass your user and password everytime you can define them in your .bash_profile by adding:
92
95
 
@@ -94,7 +97,7 @@ If you don't want to pass your user and password everytime you can define them i
94
97
  export BANKSCRAP_[BANK_NAME]_PASSWORD=YOUR_BANK_USER
95
98
  export BANKSCRAP_[BANK_NAME]_ANY_OTHER_CREDENTIAL=ANY_OTHER_CREDENTIAL
96
99
 
97
- eg:
100
+ eg:
98
101
  export BANKSCRAP_BBVA_NET_CASH_USER=YOUR_BANK_USER
99
102
 
100
103
 
@@ -116,7 +119,7 @@ bbva = Bankscrap::BBVA::Bank.new(user: YOUR_BBVA_USER, password: YOUR_BBVA_PASSW
116
119
 
117
120
  # ING
118
121
  require 'bankscrap-ing'
119
- ing = Bankscrap::ING::Bank.new(nif: YOUR_NIF, password: YOUR_ING_PASSWORD, birthday: "dd/mm/yyyy")
122
+ ing = Bankscrap::ING::Bank.new(dni: YOUR_DNI, password: YOUR_ING_PASSWORD, birthday: "dd/mm/yyyy")
120
123
  ```
121
124
 
122
125
 
@@ -129,6 +132,7 @@ bank.accounts
129
132
  ```
130
133
 
131
134
  And get its balance:
135
+
132
136
  ```ruby
133
137
  bank.accounts.first.balance
134
138
  ```
@@ -148,7 +152,20 @@ account.transactions = account.fetch_transactions(start_date: Date.today - 1.yea
148
152
  account.transactions
149
153
  ```
150
154
 
155
+ ### From Ruby code (with IRB, useful when developing)
156
+
157
+ In the terminal:
158
+
159
+ ```
160
+ irb -I lib/ -r 'bankscrap'
161
+ ```
151
162
 
163
+ After that, you can use your bank adapter as usual:
164
+
165
+ ```ruby
166
+ require 'bankscrap-ing'
167
+ ing = Bankscrap::ING::Bank.new(dni: YOUR_DNI, password: YOUR_ING_PASSWORD, birthday: "dd/mm/yyyy")
168
+ ```
152
169
 
153
170
  ## Contributing
154
171
 
@@ -5,21 +5,21 @@ module Bankscrap
5
5
  argument :bank_name
6
6
 
7
7
  def self.source_root
8
- File.join(File.dirname(__FILE__), 'templates')
8
+ File.join(File.dirname(__FILE__), 'templates')
9
9
  end
10
10
 
11
11
  def generate
12
12
  self.destination_root = File.expand_path('.', gem_name)
13
13
  directory '.'
14
14
 
15
- say ""
15
+ say ''
16
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
17
+ say ''
18
+ say 'To get started take a look to:', :yellow
19
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
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,6 +27,7 @@ module Bankscrap
27
27
  def bank_name_dasherized
28
28
  @bank_name_dasherized ||= bank_name.underscore.dasherize
29
29
  end
30
+
30
31
  def gem_name
31
32
  @gem_name ||= 'bankscrap-' + bank_name_dasherized
32
33
  end
@@ -35,4 +36,4 @@ module Bankscrap
35
36
  @module_name ||= bank_name
36
37
  end
37
38
  end
38
- end
39
+ end
@@ -13,7 +13,7 @@ module Bankscrap
13
13
 
14
14
  # TODO: change this for the proper credentials required in your adapter.
15
15
  # It can be anything (user, birthday, ID, whatever you need).
16
- REQUIRED_CREDENTIALS = [:user, :password, :any_other_credential]
16
+ REQUIRED_CREDENTIALS = %i(user password any_other_credential).freeze
17
17
 
18
18
  def initialize(credentials = {})
19
19
  super do
@@ -21,9 +21,7 @@ module Bankscrap
21
21
  # or add custom headers to the HTTP client
22
22
 
23
23
  # user_agent = SecureRandom.hex(32).upcase + ';Android;LGE;Nexus 5;1080x1776;Android;5.1.1;BMES;4.4;xxhd'
24
- # add_headers(
25
- # 'User-Agent' => user_agent
26
- # )
24
+ # add_headers('User-Agent' => user_agent)
27
25
  end
28
26
  end
29
27
 
@@ -79,7 +77,7 @@ module Bankscrap
79
77
  amount: REPLACE_ME, # Should be a Money object
80
78
  description: REPLACE_ME,
81
79
  effective_date: REPLACE_ME,
82
- currency: REPLACE_ME,
80
+ currency: REPLACE_ME,
83
81
  balance: REPLACE_ME # Should be a Money object
84
82
  )
85
83
  end
@@ -1,9 +1,9 @@
1
1
  module Bankscrap
2
2
  class Account
3
3
  include Utils::Inspectable
4
-
5
- attr_accessor :bank, :id, :name, :balance,
6
- :available_balance, :description,
4
+
5
+ attr_accessor :bank, :id, :name, :balance,
6
+ :available_balance, :description,
7
7
  :transactions, :iban, :bic
8
8
 
9
9
  def initialize(params = {})
@@ -7,22 +7,18 @@ module Bankscrap
7
7
  'like Gecko) Chrome/18.0.1025.166 Mobile Safari/535.19'.freeze
8
8
  attr_accessor :headers, :accounts, :investments
9
9
 
10
- REQUIRED_CREDENTIALS = [:user, :password]
10
+ REQUIRED_CREDENTIALS = %i(user password).freeze
11
11
 
12
12
  class MissingCredential < ArgumentError; end
13
13
 
14
14
  def initialize(credentials = {})
15
- # Assign required credentials as env vars.
15
+ # Assign required credentials as env vars.
16
16
  # If empty, use ENV vars as fallback:
17
17
  # BANKSCRAP_MY_BANK_USER, BANKSCRAP_MY_BANK_PASWORD, etc.
18
18
  self.class::REQUIRED_CREDENTIALS.each do |field|
19
19
  value = credentials.with_indifferent_access[field] || ENV["#{env_vars_prefix}_#{field.upcase}"]
20
-
21
- if value.blank?
22
- raise MissingCredential, "Missing credential: '#{field}'"
23
- else
24
- instance_variable_set("@#{field}", value)
25
- end
20
+ raise MissingCredential, "Missing credential: '#{field}'" if value.blank?
21
+ instance_variable_set("@#{field}", value)
26
22
  end
27
23
 
28
24
  initialize_http_client
@@ -34,9 +30,7 @@ module Bankscrap
34
30
  @accounts = fetch_accounts
35
31
 
36
32
  # Not all the adapters have support for investments
37
- if self.respond_to?(:fetch_investments)
38
- @investments = fetch_investments
39
- end
33
+ @investments = fetch_investments if respond_to?(:fetch_investments)
40
34
  end
41
35
 
42
36
  # Interface method placeholders
@@ -112,7 +106,7 @@ module Bankscrap
112
106
 
113
107
  # Prefix for env vars used to store credentials
114
108
  def env_vars_prefix
115
- self.class.parent.name.underscore.upcase.gsub('/', '_')
109
+ self.class.parent.name.underscore.upcase.tr('/', '_')
116
110
  end
117
111
  end
118
112
  end
data/lib/bankscrap/cli.rb CHANGED
@@ -1,10 +1,9 @@
1
1
  require 'thor'
2
2
  require 'active_support/core_ext/string'
3
- Dir[File.expand_path("../../..", __FILE__) + "/generators/*.rb"].each do |generator|
3
+ Dir[File.expand_path('../../..', __FILE__) + '/generators/*.rb'].each do |generator|
4
4
  require generator
5
5
  end
6
6
 
7
-
8
7
  module Bankscrap
9
8
  class CLI < Thor
10
9
  def self.shared_options
@@ -59,12 +58,11 @@ module Bankscrap
59
58
 
60
59
  say "Transactions for: #{account.description} (#{account.iban})", :cyan
61
60
  print_transactions_header
62
- transactions.each { |t| print_transaction(t) }
61
+ transactions.each { |t| print_transaction(t) }
63
62
  end
64
63
 
65
-
66
- register(Bankscrap::AdapterGenerator, "generate_adapter", "generate_adapter MyBankName",
67
- "generates a template for a new Bankscrap bank adapter")
64
+ register(Bankscrap::AdapterGenerator, 'generate_adapter', 'generate_adapter MyBankName',
65
+ 'generates a template for a new Bankscrap bank adapter')
68
66
 
69
67
  private
70
68
 
@@ -113,18 +111,18 @@ module Bankscrap
113
111
 
114
112
  def print_transactions_header
115
113
  say "\n"
116
- say "DATE".ljust(13)
117
- say "DESCRIPTION".ljust(50) + "\s\s\s"
118
- say "AMOUNT".rjust(15) + "\s\s\s"
119
- say "BALANCE".rjust(15)
120
- say "-" * 99
114
+ say 'DATE'.ljust(13)
115
+ say 'DESCRIPTION'.ljust(50) + ' '
116
+ say 'AMOUNT'.rjust(15) + ' '
117
+ say 'BALANCE'.rjust(15)
118
+ say '-' * 99
121
119
  end
122
120
 
123
121
  def print_transaction(transaction)
124
122
  color = (transaction.amount > Money.new(0) ? :green : :red)
125
- say transaction.effective_date.strftime('%d/%m/%Y') + "\s\s\s"
126
- say transaction.description.squish.truncate(50).ljust(50) + "\s\s\s", color
127
- say transaction.amount.format.rjust(15) + "\s\s\s", color
123
+ say transaction.effective_date.strftime('%d/%m/%Y') + ' '
124
+ say transaction.description.squish.truncate(50).ljust(50) + ' ', color
125
+ say transaction.amount.format.rjust(15) + ' ', color
128
126
  say transaction.balance.format.rjust(15)
129
127
  end
130
128
  end
@@ -11,9 +11,7 @@ module Bankscrap
11
11
  private
12
12
 
13
13
  def inspect_attributes
14
- [
15
- :id, :name, :balance, :currency, :investment
16
- ]
14
+ %i(id name balance currency investment)
17
15
  end
18
16
  end
19
17
  end
@@ -2,8 +2,7 @@ module Bankscrap
2
2
  class Transaction
3
3
  include Utils::Inspectable
4
4
 
5
- attr_accessor :id, :amount, :description, :effective_date,
6
- :balance, :account
5
+ attr_accessor :id, :amount, :description, :effective_date, :balance, :account
7
6
 
8
7
  def initialize(params = {})
9
8
  raise NotMoneyObjectError.new(:amount) unless params[:amount].is_a?(Money)
@@ -26,7 +25,7 @@ module Bankscrap
26
25
  private
27
26
 
28
27
  def inspect_attributes
29
- [ :id, :amount, :effective_date, :description, :balance ]
28
+ %i(id amount effective_date description balance)
30
29
  end
31
30
  end
32
31
  end
@@ -12,7 +12,7 @@ module Bankscrap
12
12
  end.map do |attribute|
13
13
  "#{attribute}: #{send(attribute).inspect}"
14
14
  end.join ' '
15
- "#<#{self.class.name}:#{sprintf('0x%x', object_id)} #{attributes}>"
15
+ "#<#{self.class.name}:#{format('0x%x', object_id)} #{attributes}>"
16
16
  end
17
17
  end
18
18
  end
@@ -1,3 +1,3 @@
1
1
  module Bankscrap
2
- VERSION = '2.0.1'.freeze
2
+ VERSION = '2.0.2'.freeze
3
3
  end
data/lib/bankscrap.rb CHANGED
@@ -24,8 +24,7 @@ module Bankscrap
24
24
  end
25
25
  end
26
26
 
27
-
28
27
  self.log = false
29
28
  self.debug = false
30
- # self.proxy = {host: 'localhost', port: 8888}
31
- end
29
+ # self.proxy = { host: 'localhost', port: 8888 }
30
+ 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.0.1
4
+ version: 2.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Javier Cuevas
@@ -9,140 +9,106 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2016-06-16 00:00:00.000000000 Z
12
+ date: 2017-02-23 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  requirements:
18
- - - "~>"
18
+ - - ">="
19
19
  - !ruby/object:Gem::Version
20
- version: '1.7'
20
+ version: '0'
21
21
  type: :development
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
- - - "~>"
25
+ - - ">="
26
26
  - !ruby/object:Gem::Version
27
- version: '1.7'
27
+ version: '0'
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: rake
30
30
  requirement: !ruby/object:Gem::Requirement
31
31
  requirements:
32
- - - "~>"
33
- - !ruby/object:Gem::Version
34
- version: '10.0'
35
- type: :development
36
- prerelease: false
37
- version_requirements: !ruby/object:Gem::Requirement
38
- requirements:
39
- - - "~>"
40
- - !ruby/object:Gem::Version
41
- version: '10.0'
42
- - !ruby/object:Gem::Dependency
43
- name: byebug
44
- requirement: !ruby/object:Gem::Requirement
45
- requirements:
46
- - - "~>"
47
- - !ruby/object:Gem::Version
48
- version: '3.5'
49
32
  - - ">="
50
33
  - !ruby/object:Gem::Version
51
- version: 3.5.1
34
+ version: '0'
52
35
  type: :development
53
36
  prerelease: false
54
37
  version_requirements: !ruby/object:Gem::Requirement
55
38
  requirements:
56
- - - "~>"
57
- - !ruby/object:Gem::Version
58
- version: '3.5'
59
39
  - - ">="
60
40
  - !ruby/object:Gem::Version
61
- version: 3.5.1
62
- - !ruby/object:Gem::Dependency
63
- name: rubocop
64
- requirement: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - "~>"
67
- - !ruby/object:Gem::Version
68
- version: 0.39.0
69
- type: :development
70
- prerelease: false
71
- version_requirements: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - "~>"
74
- - !ruby/object:Gem::Version
75
- version: 0.39.0
41
+ version: '0'
76
42
  - !ruby/object:Gem::Dependency
77
43
  name: rspec
78
44
  requirement: !ruby/object:Gem::Requirement
79
45
  requirements:
80
- - - "~>"
46
+ - - ">="
81
47
  - !ruby/object:Gem::Version
82
- version: 3.4.0
48
+ version: '0'
83
49
  type: :development
84
50
  prerelease: false
85
51
  version_requirements: !ruby/object:Gem::Requirement
86
52
  requirements:
87
- - - "~>"
53
+ - - ">="
88
54
  - !ruby/object:Gem::Version
89
- version: 3.4.0
55
+ version: '0'
90
56
  - !ruby/object:Gem::Dependency
91
57
  name: thor
92
58
  requirement: !ruby/object:Gem::Requirement
93
59
  requirements:
94
- - - "~>"
60
+ - - ">="
95
61
  - !ruby/object:Gem::Version
96
- version: '0.19'
62
+ version: '0'
97
63
  type: :runtime
98
64
  prerelease: false
99
65
  version_requirements: !ruby/object:Gem::Requirement
100
66
  requirements:
101
- - - "~>"
67
+ - - ">="
102
68
  - !ruby/object:Gem::Version
103
- version: '0.19'
69
+ version: '0'
104
70
  - !ruby/object:Gem::Dependency
105
71
  name: mechanize
106
72
  requirement: !ruby/object:Gem::Requirement
107
73
  requirements:
108
- - - "~>"
74
+ - - ">="
109
75
  - !ruby/object:Gem::Version
110
- version: 2.7.4
76
+ version: '0'
111
77
  type: :runtime
112
78
  prerelease: false
113
79
  version_requirements: !ruby/object:Gem::Requirement
114
80
  requirements:
115
- - - "~>"
81
+ - - ">="
116
82
  - !ruby/object:Gem::Version
117
- version: 2.7.4
83
+ version: '0'
118
84
  - !ruby/object:Gem::Dependency
119
85
  name: activesupport
120
86
  requirement: !ruby/object:Gem::Requirement
121
87
  requirements:
122
- - - "~>"
88
+ - - ">="
123
89
  - !ruby/object:Gem::Version
124
- version: '4.1'
90
+ version: '0'
125
91
  type: :runtime
126
92
  prerelease: false
127
93
  version_requirements: !ruby/object:Gem::Requirement
128
94
  requirements:
129
- - - "~>"
95
+ - - ">="
130
96
  - !ruby/object:Gem::Version
131
- version: '4.1'
97
+ version: '0'
132
98
  - !ruby/object:Gem::Dependency
133
99
  name: money
134
100
  requirement: !ruby/object:Gem::Requirement
135
101
  requirements:
136
- - - "~>"
102
+ - - ">="
137
103
  - !ruby/object:Gem::Version
138
- version: 6.5.0
104
+ version: '0'
139
105
  type: :runtime
140
106
  prerelease: false
141
107
  version_requirements: !ruby/object:Gem::Requirement
142
108
  requirements:
143
- - - "~>"
109
+ - - ">="
144
110
  - !ruby/object:Gem::Version
145
- version: 6.5.0
111
+ version: '0'
146
112
  description: Command line tools to get bank account details from some banks.
147
113
  email:
148
114
  - javi@diacode.com
@@ -195,7 +161,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
195
161
  version: '0'
196
162
  requirements: []
197
163
  rubyforge_project:
198
- rubygems_version: 2.5.1
164
+ rubygems_version: 2.6.8
199
165
  signing_key:
200
166
  specification_version: 4
201
167
  summary: Get your bank account details.