jp_bank 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 8da8e92bbaf541c9c46d0510e1a6b402594d29ac
4
+ data.tar.gz: 5f45b3a3ab1d5f822c13245888dcd398189eedc7
5
+ SHA512:
6
+ metadata.gz: 0cdef0893448ad079a978933f7af824cb4f7fd6f8e492e162488c05ad2993812e1acb0249d2c300450577388a3e5b481fb8ef3b81f1c7ece4f82a13d80cd6c9d
7
+ data.tar.gz: f36463080e9cdf8fd3c4f02bd342a824af2361a4f4bd3fc79194cb5a7e14b80e07ef7ba1909ca3f29309de551a0d18ff87b11544aa1932a7a6b505fad38a99cc
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format progress
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in jp_bank.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Tatsuya Sato
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,37 @@
1
+ # JpBank
2
+
3
+ Provide mapping from bank codes to bank information
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'jp_bank'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install jp_bank
18
+
19
+ ## Usage
20
+
21
+
22
+ ```ruby
23
+ require 'jp_bank'
24
+
25
+ bank = JpBank::Bank.find(36)
26
+ bank.name #=> "楽天銀行"
27
+ bank.code #=> "0036"
28
+ ```
29
+
30
+
31
+ ## Contributing
32
+
33
+ 1. Fork it ( http://github.com/<my-github-username>/jp_bank/fork )
34
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
35
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
36
+ 4. Push to the branch (`git push origin my-new-feature`)
37
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/jp_bank.gemspec ADDED
@@ -0,0 +1,25 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'jp_bank/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "jp_bank"
8
+ spec.version = JpBank::VERSION
9
+ spec.authors = ["Tatsuya Sato"]
10
+ spec.email = ["satoryu.1981@gmail.com"]
11
+ spec.summary = %q{Provide mapping from bank code to bank information}
12
+ spec.description = %q{Provide mapping from bank code to bank information}
13
+ spec.homepage = ""
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(spec)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.5"
22
+ spec.add_development_dependency "rake"
23
+ spec.add_development_dependency "rspec", "~> 2.0"
24
+ spec.add_development_dependency "tapp"
25
+ end
@@ -0,0 +1,406 @@
1
+ ---
2
+ -
3
+ code: '0001'
4
+ name: 'みずほ銀行'
5
+ -
6
+ code: '0005'
7
+ name: '三菱東京UFJ銀行'
8
+ -
9
+ code: '0009'
10
+ name: '三井住友銀行'
11
+ -
12
+ code: '0010'
13
+ name: 'りそな銀行'
14
+ -
15
+ code: '0017'
16
+ name: '埼玉りそな銀行'
17
+ -
18
+ code: '0033'
19
+ name: 'ジャパンネット銀行'
20
+ -
21
+ code: '0034'
22
+ name: 'セブン銀行'
23
+ -
24
+ code: '0035'
25
+ name: 'ソニー銀行'
26
+ -
27
+ code: '0036'
28
+ name: '楽天銀行'
29
+ -
30
+ code: '0038'
31
+ name: '住信SBIネット銀行'
32
+ -
33
+ code: '0039'
34
+ name: 'じぶん銀行'
35
+ -
36
+ code: '0040'
37
+ name: 'イオン銀行'
38
+ -
39
+ code: '0041'
40
+ name: '大和ネクスト銀行'
41
+ -
42
+ code: '0116'
43
+ name: '北海道銀行'
44
+ -
45
+ code: '0117'
46
+ name: '青森銀行'
47
+ -
48
+ code: '0118'
49
+ name: 'みちのく銀行'
50
+ -
51
+ code: '0119'
52
+ name: '秋田銀行'
53
+ -
54
+ code: '0120'
55
+ name: '北都銀行'
56
+ -
57
+ code: '0121'
58
+ name: '荘内銀行'
59
+ -
60
+ code: '0122'
61
+ name: '山形銀行'
62
+ -
63
+ code: '0123'
64
+ name: '岩手銀行'
65
+ -
66
+ code: '0124'
67
+ name: '東北銀行'
68
+ -
69
+ code: '0125'
70
+ name: '七十七銀行'
71
+ -
72
+ code: '0126'
73
+ name: '東邦銀行'
74
+ -
75
+ code: '0128'
76
+ name: '群馬銀行'
77
+ -
78
+ code: '0129'
79
+ name: '足利銀行'
80
+ -
81
+ code: '0130'
82
+ name: '常陽銀行'
83
+ -
84
+ code: '0131'
85
+ name: '筑波銀行'
86
+ -
87
+ code: '0133'
88
+ name: '武蔵野銀行'
89
+ -
90
+ code: '0134'
91
+ name: '千葉銀行'
92
+ -
93
+ code: '0135'
94
+ name: '千葉興業銀行'
95
+ -
96
+ code: '0137'
97
+ name: '東京都民銀行'
98
+ -
99
+ code: '0138'
100
+ name: '横浜銀行'
101
+ -
102
+ code: '0140'
103
+ name: '第四銀行'
104
+ -
105
+ code: '0141'
106
+ name: '北越銀行'
107
+ -
108
+ code: '0142'
109
+ name: '山梨中央銀行'
110
+ -
111
+ code: '0143'
112
+ name: '八十二銀行'
113
+ -
114
+ code: '0144'
115
+ name: '北陸銀行'
116
+ -
117
+ code: '0145'
118
+ name: '富山銀行'
119
+ -
120
+ code: '0146'
121
+ name: '北國銀行'
122
+ -
123
+ code: '0147'
124
+ name: '福井銀行'
125
+ -
126
+ code: '0149'
127
+ name: '静岡銀行'
128
+ -
129
+ code: '0150'
130
+ name: 'スルガ銀行'
131
+ -
132
+ code: '0151'
133
+ name: '清水銀行'
134
+ -
135
+ code: '0152'
136
+ name: '大垣共立銀行'
137
+ -
138
+ code: '0153'
139
+ name: '十六銀行'
140
+ -
141
+ code: '0154'
142
+ name: '三重銀行'
143
+ -
144
+ code: '0155'
145
+ name: '百五銀行'
146
+ -
147
+ code: '0157'
148
+ name: '滋賀銀行'
149
+ -
150
+ code: '0158'
151
+ name: '京都銀行'
152
+ -
153
+ code: '0159'
154
+ name: '近畿大阪銀行'
155
+ -
156
+ code: '0161'
157
+ name: '泉田泉州銀行'
158
+ -
159
+ code: '0162'
160
+ name: '南都銀行'
161
+ -
162
+ code: '0163'
163
+ name: '紀陽銀行'
164
+ -
165
+ code: '0164'
166
+ name: '但馬銀行'
167
+ -
168
+ code: '0166'
169
+ name: '鳥取銀行'
170
+ -
171
+ code: '0167'
172
+ name: '山陰合同銀行'
173
+ -
174
+ code: '0168'
175
+ name: '中国銀行'
176
+ -
177
+ code: '0169'
178
+ name: '中国銀行'
179
+ -
180
+ code: '0170'
181
+ name: '山口銀行'
182
+ -
183
+ code: '0172'
184
+ name: '阿波銀行'
185
+ -
186
+ code: '0173'
187
+ name: '百十四銀行'
188
+ -
189
+ code: '0174'
190
+ name: '伊予銀行'
191
+ -
192
+ code: '0175'
193
+ name: '四国銀行'
194
+ -
195
+ code: '0177'
196
+ name: '福岡銀行'
197
+ -
198
+ code: '0178'
199
+ name: '筑邦銀行'
200
+ -
201
+ code: '0179'
202
+ name: '佐賀銀行'
203
+ -
204
+ code: '0180'
205
+ name: '十八銀行'
206
+ -
207
+ code: '0181'
208
+ name: '親和銀行'
209
+ -
210
+ code: '0182'
211
+ name: '肥後銀行'
212
+ -
213
+ code: '0183'
214
+ name: '大分銀行'
215
+ -
216
+ code: '0184'
217
+ name: '宮崎銀行'
218
+ -
219
+ code: '0185'
220
+ name: '鹿児島銀行'
221
+ -
222
+ code: '0187'
223
+ name: '琉球銀行'
224
+ -
225
+ code: '0188'
226
+ name: '沖縄銀行'
227
+ -
228
+ code: '0190'
229
+ name: '西日本シティ銀行'
230
+ -
231
+ code: '0191'
232
+ name: '北九州銀行'
233
+ -
234
+ code: '0288'
235
+ name: '三菱東京UFJ信託銀行'
236
+ -
237
+ code: '0289'
238
+ name: 'みずほ信託銀行'
239
+ -
240
+ code: '0294'
241
+ name: '三井住友信託銀行'
242
+ -
243
+ code: '0297'
244
+ name: '日本マスタートラスト信託銀行'
245
+ -
246
+ code: '0304'
247
+ name: '野村信託銀行'
248
+ -
249
+ code: '0307'
250
+ name: 'オリックス銀行'
251
+ -
252
+ code: '0322'
253
+ name: '新銀行東京'
254
+ -
255
+ code: '0324'
256
+ name: '日本トラスティサービス信託銀行'
257
+ -
258
+ code: '0325'
259
+ name: '資産管理サービス信託銀行'
260
+ -
261
+ code: '0397'
262
+ name: '新生銀行'
263
+ -
264
+ code: '0398'
265
+ name: 'あおぞら銀行'
266
+ -
267
+ code: '0401'
268
+ name: 'シティバンク銀行'
269
+ -
270
+ code: '0402'
271
+ name: 'ジェーピーモルガン銀行'
272
+ -
273
+ code: '0403'
274
+ name: 'アメリカ銀行'
275
+ -
276
+ code: '0411'
277
+ name: '香港上海銀行'
278
+ -
279
+ code: '0430'
280
+ name: 'ドイツ銀行'
281
+ -
282
+ code: '0472'
283
+ name: 'SBJ銀行'
284
+ -
285
+ code: '0501'
286
+ name: '北洋銀行'
287
+ -
288
+ code: '0508'
289
+ name: 'きらやか銀行'
290
+ -
291
+ code: '0509'
292
+ name: '北日本銀行'
293
+ -
294
+ code: '0512'
295
+ name: '仙台銀行'
296
+ -
297
+ code: '0513'
298
+ name: '福島銀行'
299
+ -
300
+ code: '0514'
301
+ name: '大東銀行'
302
+ -
303
+ code: '0516'
304
+ name: '東和銀行'
305
+ -
306
+ code: '0517'
307
+ name: '栃木銀行'
308
+ -
309
+ code: '0522'
310
+ name: '京葉銀行'
311
+ -
312
+ code: '0525'
313
+ name: '東日本銀行'
314
+ -
315
+ code: '0526'
316
+ name: '東京スター銀行'
317
+ -
318
+ code: '0530'
319
+ name: '神奈川銀行'
320
+ -
321
+ code: '0532'
322
+ name: '大光銀行'
323
+ -
324
+ code: '0533'
325
+ name: '長野銀行'
326
+ -
327
+ code: '0534'
328
+ name: '富山第一銀行'
329
+ -
330
+ code: '0537'
331
+ name: '福邦銀行'
332
+ -
333
+ code: '0538'
334
+ name: '静岡中央銀行'
335
+ -
336
+ code: '0542'
337
+ name: '愛知銀行'
338
+ -
339
+ code: '0543'
340
+ name: '名古屋銀行'
341
+ -
342
+ code: '0544'
343
+ name: '中京銀行'
344
+ -
345
+ code: '0546'
346
+ name: '第三銀行'
347
+ -
348
+ code: '0554'
349
+ name: '関西アーバン銀行'
350
+ -
351
+ code: '0555'
352
+ name: '大正銀行'
353
+ -
354
+ code: '0562'
355
+ name: 'みなと銀行'
356
+ -
357
+ code: '0565'
358
+ name: '島根銀行'
359
+ -
360
+ code: '0566'
361
+ name: 'トマト銀行'
362
+ -
363
+ code: '0569'
364
+ name: 'もみじ銀行'
365
+ -
366
+ code: '0570'
367
+ name: '西京銀行'
368
+ -
369
+ code: '0572'
370
+ name: '徳島銀行'
371
+ -
372
+ code: '0573'
373
+ name: '香川銀行'
374
+ -
375
+ code: '0576'
376
+ name: '愛媛銀行'
377
+ -
378
+ code: '0578'
379
+ name: '高知銀行'
380
+ -
381
+ code: '0582'
382
+ name: '福岡中央銀行'
383
+ -
384
+ code: '0583'
385
+ name: '佐賀共栄銀行'
386
+ -
387
+ code: '0585'
388
+ name: '長崎銀行'
389
+ -
390
+ code: '0587'
391
+ name: '熊本銀行'
392
+ -
393
+ code: '0590'
394
+ name: '豊和銀行'
395
+ -
396
+ code: '0591'
397
+ name: '宮崎太陽銀行'
398
+ -
399
+ code: '0594'
400
+ name: '南日本銀行'
401
+ -
402
+ code: '0596'
403
+ name: '沖縄海邦銀行'
404
+ -
405
+ code: '0597'
406
+ name: '八千代銀行'
@@ -0,0 +1,55 @@
1
+ module JpBank
2
+ class Bank
3
+ def self.codes
4
+ self.load_banks unless @bank_codes
5
+ @bank_codes.keys
6
+ end
7
+
8
+ def self.fetch_bank_from_code(code)
9
+ self.load_banks unless @bank_codes
10
+ code = '%04d' % code if code.is_a?(Integer)
11
+ @bank_codes[code]
12
+ end
13
+
14
+ def self.fetch_bank_from_name(name)
15
+ self.load_banks unless @bank_names
16
+ @bank_names[name]
17
+ end
18
+
19
+ def self.find(code_or_name)
20
+ self.fetch_bank_from_code(code_or_name) or
21
+ self.fetch_bank_from_name(code_or_name)
22
+ end
23
+
24
+ def initialize(data)
25
+ @data = data
26
+ end
27
+
28
+ def code
29
+ @data['code']
30
+ end
31
+
32
+ def name
33
+ @data['name']
34
+ end
35
+
36
+ private
37
+ def self.load_banks
38
+ require 'yaml'
39
+
40
+ @banks = data_file_paths.inject([]) do |data, data_path|
41
+ data + YAML.load_file(data_path)
42
+ end.map { |data| new(data) }
43
+ @bank_codes = {}
44
+ @banks.each do |bank|
45
+ @bank_codes[bank.code] = bank
46
+ end
47
+ @bank_names = {}
48
+ @banks.each { |bank| @bank_names[bank.name] = bank }
49
+ end
50
+
51
+ def self.data_file_paths
52
+ [ File.expand_path('../../data/banks.yml', __FILE__) ]
53
+ end
54
+ end
55
+ end
@@ -0,0 +1,3 @@
1
+ module JpBank
2
+ VERSION = "0.0.1"
3
+ end
data/lib/jp_bank.rb ADDED
@@ -0,0 +1,5 @@
1
+ require "jp_bank/version"
2
+
3
+ module JpBank
4
+ autoload :Bank, File.expand_path('../jp_bank/bank', __FILE__)
5
+ end
@@ -0,0 +1,43 @@
1
+ require 'spec_helper'
2
+
3
+ describe JpBank::Bank do
4
+ describe '.find' do
5
+ let(:bank) { JpBank::Bank.find(code_or_name) }
6
+
7
+ context 'When bank code given as Integer' do
8
+ let(:code_or_name) { 36 }
9
+
10
+ specify 'load the bank information specified by the given code' do
11
+ expect(bank.code).to eq('0036')
12
+ expect(bank.name).to eq('楽天銀行')
13
+ end
14
+ end
15
+
16
+ context 'When bank code given as String' do
17
+ let(:code_or_name) { '0036' }
18
+
19
+ specify 'load the bank information specified by the given code' do
20
+ expect(bank.code).to eq('0036')
21
+ expect(bank.name).to eq('楽天銀行')
22
+ end
23
+ end
24
+
25
+ context 'When bank name given' do
26
+ let(:code_or_name) { '楽天銀行' }
27
+
28
+ specify 'load the bank information specified by the given code' do
29
+ expect(bank.code).to eq('0036')
30
+ expect(bank.name).to eq('楽天銀行')
31
+ end
32
+
33
+ end
34
+ end
35
+
36
+ describe '.codes' do
37
+ specify 'returns an array of codes with 4 digits' do
38
+ JpBank::Bank.codes.each do |code|
39
+ expect(code).to match(/^\d{4}$/)
40
+ end
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,5 @@
1
+ require 'spec_helper'
2
+
3
+ describe JpBank do
4
+
5
+ end
@@ -0,0 +1,11 @@
1
+ $: << File.expand_path(File.join('..', 'lib'), __FILE__)
2
+
3
+ require 'jp_bank'
4
+
5
+ RSpec.configure do |config|
6
+ config.treat_symbols_as_metadata_keys_with_true_values = true
7
+ config.run_all_when_everything_filtered = true
8
+ config.filter_run :focus
9
+
10
+ config.order = 'random'
11
+ end
metadata ADDED
@@ -0,0 +1,117 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: jp_bank
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Tatsuya Sato
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-02-26 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '1.5'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.5'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ~>
46
+ - !ruby/object:Gem::Version
47
+ version: '2.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: '2.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: tapp
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ description: Provide mapping from bank code to bank information
70
+ email:
71
+ - satoryu.1981@gmail.com
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - .gitignore
77
+ - .rspec
78
+ - Gemfile
79
+ - LICENSE.txt
80
+ - README.md
81
+ - Rakefile
82
+ - jp_bank.gemspec
83
+ - lib/data/banks.yml
84
+ - lib/jp_bank.rb
85
+ - lib/jp_bank/bank.rb
86
+ - lib/jp_bank/version.rb
87
+ - spec/jp_bank/bank_spec.rb
88
+ - spec/jp_bank_spec.rb
89
+ - spec/spec_helper.rb
90
+ homepage: ''
91
+ licenses:
92
+ - MIT
93
+ metadata: {}
94
+ post_install_message:
95
+ rdoc_options: []
96
+ require_paths:
97
+ - lib
98
+ required_ruby_version: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - '>='
101
+ - !ruby/object:Gem::Version
102
+ version: '0'
103
+ required_rubygems_version: !ruby/object:Gem::Requirement
104
+ requirements:
105
+ - - '>='
106
+ - !ruby/object:Gem::Version
107
+ version: '0'
108
+ requirements: []
109
+ rubyforge_project:
110
+ rubygems_version: 2.0.14
111
+ signing_key:
112
+ specification_version: 4
113
+ summary: Provide mapping from bank code to bank information
114
+ test_files:
115
+ - spec/jp_bank/bank_spec.rb
116
+ - spec/jp_bank_spec.rb
117
+ - spec/spec_helper.rb