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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8da8e92bbaf541c9c46d0510e1a6b402594d29ac
4
- data.tar.gz: 5f45b3a3ab1d5f822c13245888dcd398189eedc7
3
+ metadata.gz: 682588ab71cd1db9a630d8957202ccdb91933164
4
+ data.tar.gz: b4250d8104ea5cc2f3af82041496bce2c6ed9db9
5
5
  SHA512:
6
- metadata.gz: 0cdef0893448ad079a978933f7af824cb4f7fd6f8e492e162488c05ad2993812e1acb0249d2c300450577388a3e5b481fb8ef3b81f1c7ece4f82a13d80cd6c9d
7
- data.tar.gz: f36463080e9cdf8fd3c4f02bd342a824af2361a4f4bd3fc79194cb5a7e14b80e07ef7ba1909ca3f29309de551a0d18ff87b11544aa1932a7a6b505fad38a99cc
6
+ metadata.gz: 4a4c99a5c68e6efbc472b94b5d4747eb885b1a1d0bd14862233decf821611b8b318a1382c3c934bd145c2fb42ab851ae0cc8fa76df5ea8038094c14955bc2e62
7
+ data.tar.gz: 4ffaa1779543a5f94dff574ed9e56f1cee0330cf86d1106ea3bd797f808b0067d0125d76314783af21efd6078e22f8a219166096ad1ec85e5bbea482d24602b1
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.9.3
4
+ - 2.0.0
5
+ - 2.1.0
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
@@ -1,3 +1,3 @@
1
1
  module JpBank
2
- VERSION = "0.0.1"
2
+ VERSION = "0.1.0"
3
3
  end
@@ -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.1
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-26 00:00:00.000000000 Z
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: '0'
103
+ version: 1.9.3
103
104
  required_rubygems_version: !ruby/object:Gem::Requirement
104
105
  requirements:
105
106
  - - '>='