banktools-de 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: b78faf6270b41240ca4265c79c4bc628353a7d30
4
+ data.tar.gz: 33a87d445276e51cbef63049034cbc49eb2bad70
5
+ SHA512:
6
+ metadata.gz: be1e8813bbb8b0cfb0cccf337563ea000a693ad12e5a94a29c3bb2b2b0920956d2afd4cc753e5c4c284843035d28810e43342e30bf0fd4f395fb8dd1bb8f782c
7
+ data.tar.gz: 6032a660b7646be3b186d0eeeba23f383d52d2a4a86b633645fc1ca621d6d2a1a2a2ad0827ed61559d1d6b89da7b47f2ee2062a0202242b19ba44aaa1d2f8b8d
@@ -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/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in banktools-de.gemspec
4
+ gemspec
@@ -0,0 +1,61 @@
1
+ # German bank tools
2
+
3
+ Ruby gem to validate, normalize/prettify and to some extent interpret German Bankleitzahl (BLZ) and bank account numbers.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'banktools-de'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install banktools-de
18
+
19
+ ## Usage
20
+
21
+ (Very much in progress. Expect this list to change rapidly.)
22
+
23
+ blz = BankTools::DE::BLZ.new("10070024")
24
+ blz.normalize # => "100 700 24"
25
+
26
+ ## Tests
27
+
28
+ rspec
29
+ # or: rake
30
+
31
+ ## Also see
32
+
33
+ * [BankTools::SE (Swedish)](https://github.com/barsoom/banktools-se)
34
+ * [iban-tools](https://github.com/iulianu/iban-tools)
35
+
36
+ ## Credits and license
37
+
38
+ By [Henrik Nyh](http://henrik.nyh.se) for [Barsoom](http://barsoom.se) under the MIT license:
39
+
40
+ Copyright (c) 2014 Barsoom AB
41
+
42
+ MIT License
43
+
44
+ Permission is hereby granted, free of charge, to any person obtaining
45
+ a copy of this software and associated documentation files (the
46
+ "Software"), to deal in the Software without restriction, including
47
+ without limitation the rights to use, copy, modify, merge, publish,
48
+ distribute, sublicense, and/or sell copies of the Software, and to
49
+ permit persons to whom the Software is furnished to do so, subject to
50
+ the following conditions:
51
+
52
+ The above copyright notice and this permission notice shall be
53
+ included in all copies or substantial portions of the Software.
54
+
55
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
56
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
57
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
58
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
59
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
60
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
61
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -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
@@ -0,0 +1,24 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'bank_tools/de/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "banktools-de"
8
+ spec.version = BankTools::DE::VERSION
9
+ spec.authors = ["Henrik Nyh"]
10
+ spec.email = ["henrik@nyh.se"]
11
+ spec.summary = %q{Validate and normalize German Bankleitzahl (BLZ) and bank account numbers.}
12
+ spec.homepage = ""
13
+ spec.license = "MIT"
14
+
15
+ spec.files = `git ls-files`.split($/)
16
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
17
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
18
+ spec.require_paths = ["lib"]
19
+
20
+ spec.add_dependency "attr_extras", "> 1.0"
21
+ spec.add_development_dependency "bundler", "~> 1.5"
22
+ spec.add_development_dependency "rake"
23
+ spec.add_development_dependency "rspec"
24
+ end
@@ -0,0 +1,7 @@
1
+ require "bank_tools/de/version"
2
+
3
+ module BankTools
4
+ module DE
5
+ # Your code goes here...
6
+ end
7
+ end
@@ -0,0 +1,23 @@
1
+ require "attr_extras"
2
+
3
+ module BankTools
4
+ module DE
5
+ class BLZ
6
+ pattr_initialize :original_value
7
+
8
+ def normalize
9
+ if compacted_value.match(/\A(\d{3})(\d{3})(\d{2})\z/)
10
+ "#$1 #$2 #$3"
11
+ else
12
+ original_value
13
+ end
14
+ end
15
+
16
+ private
17
+
18
+ def compacted_value
19
+ original_value.to_s.gsub(/\s/, "")
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,5 @@
1
+ module BankTools
2
+ module DE
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
@@ -0,0 +1,18 @@
1
+ require "spec_helper"
2
+ require "bank_tools/de/blz"
3
+
4
+ describe BankTools::DE::BLZ, "#normalize" do
5
+ it "groups the number correctly" do
6
+ expect_normalization "12345678", "123 456 78"
7
+ end
8
+
9
+ it "leaves a bad format as-is" do
10
+ expect_normalization "123", "123"
11
+ expect_normalization "123456789", "123456789"
12
+ expect_normalization "hej", "hej"
13
+ end
14
+
15
+ def expect_normalization(from, unto)
16
+ expect(BankTools::DE::BLZ.new(from).normalize).to eq unto
17
+ end
18
+ end
File without changes
metadata ADDED
@@ -0,0 +1,112 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: banktools-de
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Henrik Nyh
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-01-15 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: attr_extras
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>'
18
+ - !ruby/object:Gem::Version
19
+ version: '1.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>'
25
+ - !ruby/object:Gem::Version
26
+ version: '1.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: '1.5'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: '1.5'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
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:
70
+ email:
71
+ - henrik@nyh.se
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - .gitignore
77
+ - Gemfile
78
+ - README.md
79
+ - Rakefile
80
+ - banktools-de.gemspec
81
+ - lib/bank_tools/de.rb
82
+ - lib/bank_tools/de/blz.rb
83
+ - lib/bank_tools/de/version.rb
84
+ - spec/blz_spec.rb
85
+ - spec/spec_helper.rb
86
+ homepage: ''
87
+ licenses:
88
+ - MIT
89
+ metadata: {}
90
+ post_install_message:
91
+ rdoc_options: []
92
+ require_paths:
93
+ - lib
94
+ required_ruby_version: !ruby/object:Gem::Requirement
95
+ requirements:
96
+ - - '>='
97
+ - !ruby/object:Gem::Version
98
+ version: '0'
99
+ required_rubygems_version: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - '>='
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ requirements: []
105
+ rubyforge_project:
106
+ rubygems_version: 2.2.0
107
+ signing_key:
108
+ specification_version: 4
109
+ summary: Validate and normalize German Bankleitzahl (BLZ) and bank account numbers.
110
+ test_files:
111
+ - spec/blz_spec.rb
112
+ - spec/spec_helper.rb