ibanomat 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: 76e4e810a057a2f21337f50c6f130cbbe764c4bf
4
+ data.tar.gz: f2820107f6e46f2359f9b8fb8d32b5d02f15c9b7
5
+ SHA512:
6
+ metadata.gz: d4576c9af69acfb500df61a8f9ec288253107ff2596c9506fe35c42fa829f049458ccbd3c3887b23fe26358217f7d3dc50ab6e50c957c2f1ab6cb9a33198b65f
7
+ data.tar.gz: 769aa0d16f6efc064ebef70b3997cffc9bf69344fb0b6755011629490815fcad9250deeb4f70e7b4f56e31d42a569027dd16eec43a6466fe15977b140e5fe9e1
data/.gitignore ADDED
@@ -0,0 +1,18 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ coverage
6
+ InstalledFiles
7
+ lib/bundler/man
8
+ pkg
9
+ rdoc
10
+ spec/reports
11
+ test/tmp
12
+ test/version_tmp
13
+ tmp
14
+
15
+ # YARD artifacts
16
+ .yardoc
17
+ _yardoc
18
+ doc/
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format progress
data/.travis.yml ADDED
@@ -0,0 +1,4 @@
1
+ rvm:
2
+ - 1.9.2
3
+ - 1.9.3
4
+ - 2.0.0
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in ibanomat.gemspec
4
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,41 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ ibanomat (0.0.1)
5
+ json
6
+ rest-client
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ addressable (2.3.5)
12
+ crack (0.4.1)
13
+ safe_yaml (~> 0.9.0)
14
+ diff-lcs (1.2.4)
15
+ json (1.8.0)
16
+ mime-types (1.24)
17
+ rake (10.1.0)
18
+ rest-client (1.6.7)
19
+ mime-types (>= 1.16)
20
+ rspec (2.14.1)
21
+ rspec-core (~> 2.14.0)
22
+ rspec-expectations (~> 2.14.0)
23
+ rspec-mocks (~> 2.14.0)
24
+ rspec-core (2.14.5)
25
+ rspec-expectations (2.14.2)
26
+ diff-lcs (>= 1.1.3, < 2.0)
27
+ rspec-mocks (2.14.3)
28
+ safe_yaml (0.9.5)
29
+ webmock (1.13.0)
30
+ addressable (>= 2.2.7)
31
+ crack (>= 0.3.2)
32
+
33
+ PLATFORMS
34
+ ruby
35
+
36
+ DEPENDENCIES
37
+ bundler (~> 1.3)
38
+ ibanomat!
39
+ rake
40
+ rspec (~> 2.14)
41
+ webmock
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2013 Georg Ledermann
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
6
+ this software and associated documentation files (the "Software"), to deal in
7
+ the Software without restriction, including without limitation the rights to
8
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9
+ the Software, and to permit persons to whom the Software is furnished to do so,
10
+ subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,48 @@
1
+ # IBANomat
2
+
3
+ [![Build Status](https://secure.travis-ci.org/ledermann/ibanomat.png)](http://travis-ci.org/ledermann/ibanomat)
4
+ [![Code Climate](https://codeclimate.com/github/ledermann/ibanomat.png)](https://codeclimate.com/github/ledermann/ibanomat)
5
+ [![Gem Version](https://badge.fury.io/rb/ibanomat.png)](http://badge.fury.io/rb/ibanomat)
6
+ [![Dependency Status](https://gemnasium.com/ledermann/ibanomat.png)](https://gemnasium.com/ledermann/ibanomat)
7
+
8
+ The gem is a wrapper for a [web service of the german "Sparkasse"](http://www.sparkasse.de/firmenkunden/konto-karte/iban-rechner.html). It calculates the **IBAN** for a given Bankleitzahl (BLZ) and bank account number. Behind the scenes the web service returns JSON ([Example here](http://www.sparkasse.de/firmenkunden/konto-karte/iban-resources/iban/iban.php?bank-code=37040044&bank-account-number=0532013000))
9
+
10
+ **WARNING: I'm not affiliated in any way with the web service or the Sparkasse. The web service seems not to be official. Maybe it will be offline soon. I don't find any terms of use on their website. Use this gem at your own risk!**
11
+
12
+
13
+ ## Installation
14
+
15
+ Add this line to your application's Gemfile:
16
+
17
+ gem 'ibanomat'
18
+
19
+ And then execute:
20
+
21
+ $ bundle
22
+
23
+ Or install it yourself as:
24
+
25
+ $ gem install ibanomat
26
+
27
+
28
+ ## Usage
29
+
30
+ ```ruby
31
+ Ibanomat.find :bank_code => '37040044', :bank_account_number => '0532013000'
32
+
33
+ # =>
34
+ # {
35
+ # :bank_name => 'Commerzbank',
36
+ # :bic => 'COBADEFFXXX',
37
+ # :iban => 'DE89370400440532013000',
38
+ # }
39
+ ```
40
+
41
+
42
+ ## Contributing
43
+
44
+ 1. Fork it
45
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
46
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
47
+ 4. Push to the branch (`git push origin my-new-feature`)
48
+ 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/ibanomat.gemspec ADDED
@@ -0,0 +1,30 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'ibanomat/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'ibanomat'
8
+ spec.version = Ibanomat::VERSION
9
+ spec.authors = ['Georg Ledermann']
10
+ spec.email = ['mail@georg-ledermann.de']
11
+ spec.description = 'Germany only: Bankleitzahl & Kontonummer => IBAN'
12
+ spec.summary = 'Wrapper for a web service to calculate the IBAN of german bank account numbers'
13
+ spec.homepage = 'http://github.com/ledermann/ibanomat'
14
+ spec.license = 'MIT'
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ['lib']
20
+
21
+ spec.required_ruby_version = '>= 1.9.2'
22
+
23
+ spec.add_dependency 'rest-client'
24
+ spec.add_dependency 'json'
25
+
26
+ spec.add_development_dependency 'bundler', '~> 1.3'
27
+ spec.add_development_dependency 'rake'
28
+ spec.add_development_dependency 'rspec', '~> 2.14'
29
+ spec.add_development_dependency 'webmock'
30
+ end
@@ -0,0 +1,33 @@
1
+ require 'rest-client'
2
+ require 'json'
3
+
4
+ module Ibanomat
5
+ URL = 'http://www.sparkasse.de/firmenkunden/konto-karte/iban-resources/iban/iban.php'
6
+
7
+ def self.find(options)
8
+ raise ArgumentError.new unless options.is_a?(Hash)
9
+ raise ArgumentError.new('Option :bank_code is missing!') if options[:bank_code].empty?
10
+ raise ArgumentError.new('Option :bank_code_number is missing!') if options[:bank_account_number].empty?
11
+
12
+ response = RestClient.get URL, {
13
+ :params => {
14
+ 'bank-code' => options[:bank_code],
15
+ 'bank-account-number' => options[:bank_account_number]
16
+ },
17
+ :accept => :json
18
+ }
19
+ if response.code == 200
20
+ hash = JSON.parse(response)
21
+
22
+ case hash['RetCode']
23
+ when '00'
24
+ { :bank_name => hash['Institutsname'],
25
+ :bic => hash['BIC'],
26
+ :iban => hash['IBAN']
27
+ }
28
+ else
29
+ :error
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,3 @@
1
+ module Ibanomat
2
+ VERSION = '0.0.1'
3
+ end
data/lib/ibanomat.rb ADDED
@@ -0,0 +1,2 @@
1
+ require 'ibanomat/version'
2
+ require 'ibanomat/client'
@@ -0,0 +1,98 @@
1
+ require 'spec_helper'
2
+
3
+ describe Ibanomat do
4
+ describe :find do
5
+ subject {
6
+ Ibanomat.find :bank_code => '37040044', :bank_account_number => '0532013000'
7
+ }
8
+
9
+ context 'Webservice is live' do
10
+ context 'returns valid IBAN' do
11
+ before :each do
12
+ json_response = {
13
+ 'Institutsname' => 'Commerzbank',
14
+ 'BIC' => 'COBADEFFXXX',
15
+ 'BLZ' => '37040044',
16
+ 'IBAN' => 'DE89370400440532013000',
17
+ 'KtoNr' => '0532013000',
18
+ 'RetCode' => '00'
19
+ }.to_json
20
+
21
+ stub_request(:get, Ibanomat::URL).
22
+ with(:query => {
23
+ 'bank-code' => '37040044',
24
+ 'bank-account-number' => '0532013000'
25
+ }).
26
+ to_return(:status => 200, :body => json_response)
27
+ end
28
+
29
+ it 'should return bank_name' do
30
+ subject[:bank_name].should == 'Commerzbank'
31
+ end
32
+
33
+ it 'should return BIC' do
34
+ subject[:bic].should == 'COBADEFFXXX'
35
+ end
36
+
37
+ it 'should return IBAN' do
38
+ subject[:iban].should == 'DE89370400440532013000'
39
+ end
40
+ end
41
+
42
+ context 'can not calculate IBAN' do
43
+ before :each do
44
+ json_response = {
45
+ 'BLZ' => '37040044',
46
+ 'KtoNr' => '0532013000',
47
+ 'RetCode' => '10'
48
+ }.to_json
49
+
50
+ stub_request(:get, Ibanomat::URL).
51
+ with(:query => {
52
+ 'bank-code' => '37040044',
53
+ 'bank-account-number' => '0532013000'
54
+ }).
55
+ to_return(:status => 200, :body => json_response)
56
+ end
57
+
58
+ it 'should return error' do
59
+ subject.should == :error
60
+ end
61
+ end
62
+ end
63
+
64
+ context 'Webservice not found' do
65
+ before :each do
66
+ stub_request(:get, Ibanomat::URL).
67
+ with(:query => {
68
+ 'bank-code' => '37040044',
69
+ 'bank-account-number' => '0532013000'
70
+ }).
71
+ to_return(:status => 404)
72
+ end
73
+
74
+ it 'should raise exception' do
75
+ expect {
76
+ subject
77
+ }.to raise_error(RestClient::ResourceNotFound)
78
+ end
79
+ end
80
+
81
+ context 'Webservice does not respond' do
82
+ before :each do
83
+ stub_request(:get, Ibanomat::URL).
84
+ with(:query => {
85
+ 'bank-code' => '37040044',
86
+ 'bank-account-number' => '0532013000'
87
+ }).
88
+ to_timeout
89
+ end
90
+
91
+ it 'should raise exception' do
92
+ expect {
93
+ subject
94
+ }.to raise_error(RestClient::RequestTimeout)
95
+ end
96
+ end
97
+ end
98
+ end
@@ -0,0 +1,20 @@
1
+ # This file was generated by the `rspec --init` command. Conventionally, all
2
+ # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
3
+ # Require this file using `require "spec_helper"` to ensure that it is only
4
+ # loaded once.
5
+ #
6
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
7
+ RSpec.configure do |config|
8
+ config.treat_symbols_as_metadata_keys_with_true_values = true
9
+ config.run_all_when_everything_filtered = true
10
+ config.filter_run :focus
11
+
12
+ # Run specs in random order to surface order dependencies. If you find an
13
+ # order dependency and want to debug it, you can fix the order by providing
14
+ # the seed, which is printed after each run.
15
+ # --seed 1234
16
+ config.order = 'random'
17
+ end
18
+
19
+ require 'ibanomat'
20
+ require 'webmock/rspec'
metadata ADDED
@@ -0,0 +1,144 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ibanomat
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Georg Ledermann
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-08-30 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rest-client
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: json
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
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: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ~>
46
+ - !ruby/object:Gem::Version
47
+ version: '1.3'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: '1.3'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
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
+ - !ruby/object:Gem::Dependency
70
+ name: rspec
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ~>
74
+ - !ruby/object:Gem::Version
75
+ version: '2.14'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ~>
81
+ - !ruby/object:Gem::Version
82
+ version: '2.14'
83
+ - !ruby/object:Gem::Dependency
84
+ name: webmock
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - '>='
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - '>='
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ description: 'Germany only: Bankleitzahl & Kontonummer => IBAN'
98
+ email:
99
+ - mail@georg-ledermann.de
100
+ executables: []
101
+ extensions: []
102
+ extra_rdoc_files: []
103
+ files:
104
+ - .gitignore
105
+ - .rspec
106
+ - .travis.yml
107
+ - Gemfile
108
+ - Gemfile.lock
109
+ - LICENSE
110
+ - README.md
111
+ - Rakefile
112
+ - ibanomat.gemspec
113
+ - lib/ibanomat.rb
114
+ - lib/ibanomat/client.rb
115
+ - lib/ibanomat/version.rb
116
+ - spec/ibanomat_spec.rb
117
+ - spec/spec_helper.rb
118
+ homepage: http://github.com/ledermann/ibanomat
119
+ licenses:
120
+ - MIT
121
+ metadata: {}
122
+ post_install_message:
123
+ rdoc_options: []
124
+ require_paths:
125
+ - lib
126
+ required_ruby_version: !ruby/object:Gem::Requirement
127
+ requirements:
128
+ - - '>='
129
+ - !ruby/object:Gem::Version
130
+ version: 1.9.2
131
+ required_rubygems_version: !ruby/object:Gem::Requirement
132
+ requirements:
133
+ - - '>='
134
+ - !ruby/object:Gem::Version
135
+ version: '0'
136
+ requirements: []
137
+ rubyforge_project:
138
+ rubygems_version: 2.0.7
139
+ signing_key:
140
+ specification_version: 4
141
+ summary: Wrapper for a web service to calculate the IBAN of german bank account numbers
142
+ test_files:
143
+ - spec/ibanomat_spec.rb
144
+ - spec/spec_helper.rb