jp_bank 0.0.1 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +5 -0
- data/jp_bank.gemspec +1 -0
- data/lib/jp_bank/bank.rb +8 -0
- data/lib/jp_bank/version.rb +1 -1
- data/spec/jp_bank/bank_spec.rb +19 -0
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 682588ab71cd1db9a630d8957202ccdb91933164
|
4
|
+
data.tar.gz: b4250d8104ea5cc2f3af82041496bce2c6ed9db9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4a4c99a5c68e6efbc472b94b5d4747eb885b1a1d0bd14862233decf821611b8b318a1382c3c934bd145c2fb42ab851ae0cc8fa76df5ea8038094c14955bc2e62
|
7
|
+
data.tar.gz: 4ffaa1779543a5f94dff574ed9e56f1cee0330cf86d1106ea3bd797f808b0067d0125d76314783af21efd6078e22f8a219166096ad1ec85e5bbea482d24602b1
|
data/.travis.yml
ADDED
data/jp_bank.gemspec
CHANGED
@@ -12,6 +12,7 @@ Gem::Specification.new do |spec|
|
|
12
12
|
spec.description = %q{Provide mapping from bank code to bank information}
|
13
13
|
spec.homepage = ""
|
14
14
|
spec.license = "MIT"
|
15
|
+
spec.required_ruby_version = ">= 1.9.3"
|
15
16
|
|
16
17
|
spec.files = `git ls-files -z`.split("\x0")
|
17
18
|
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
data/lib/jp_bank/bank.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
module JpBank
|
2
2
|
class Bank
|
3
|
+
class NotFound < StandardError; end
|
4
|
+
|
3
5
|
def self.codes
|
4
6
|
self.load_banks unless @bank_codes
|
5
7
|
@bank_codes.keys
|
@@ -21,6 +23,12 @@ module JpBank
|
|
21
23
|
self.fetch_bank_from_name(code_or_name)
|
22
24
|
end
|
23
25
|
|
26
|
+
def self.find!(code_or_name)
|
27
|
+
bank = find(code_or_name)
|
28
|
+
raise NotFound if bank.nil?
|
29
|
+
bank
|
30
|
+
end
|
31
|
+
|
24
32
|
def initialize(data)
|
25
33
|
@data = data
|
26
34
|
end
|
data/lib/jp_bank/version.rb
CHANGED
data/spec/jp_bank/bank_spec.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
|
3
5
|
describe JpBank::Bank do
|
@@ -33,6 +35,23 @@ describe JpBank::Bank do
|
|
33
35
|
end
|
34
36
|
end
|
35
37
|
|
38
|
+
describe '.find!' do
|
39
|
+
context 'When given a valid bank code(name)' do
|
40
|
+
let(:bank) { JpBank::Bank.find!('0036') }
|
41
|
+
|
42
|
+
specify 'responds the bank object with the given bank code(name)' do
|
43
|
+
expect(bank).to_not be_nil
|
44
|
+
expect(bank.name).to eq('楽天銀行')
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
context 'When given an invalid bank code(name)' do
|
49
|
+
specify 'raises error' do
|
50
|
+
expect { JpBank::Bank.find!('invalid code or name') }.to raise_error(JpBank::Bank::NotFound)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
36
55
|
describe '.codes' do
|
37
56
|
specify 'returns an array of codes with 4 digits' do
|
38
57
|
JpBank::Bank.codes.each do |code|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jp_bank
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tatsuya Sato
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-02-
|
11
|
+
date: 2014-02-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -75,6 +75,7 @@ extra_rdoc_files: []
|
|
75
75
|
files:
|
76
76
|
- .gitignore
|
77
77
|
- .rspec
|
78
|
+
- .travis.yml
|
78
79
|
- Gemfile
|
79
80
|
- LICENSE.txt
|
80
81
|
- README.md
|
@@ -99,7 +100,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
99
100
|
requirements:
|
100
101
|
- - '>='
|
101
102
|
- !ruby/object:Gem::Version
|
102
|
-
version:
|
103
|
+
version: 1.9.3
|
103
104
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
104
105
|
requirements:
|
105
106
|
- - '>='
|