banktools-at 0.1.0

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: c18e4b4830e413534c604bf30ec952385bddf4c8
4
+ data.tar.gz: b692af6ca030ce14388be35af02abc3165164a69
5
+ SHA512:
6
+ metadata.gz: e04c2be255f1516b4b3532032121e748fd27c13f0e04156a88a2ee55ae826f87945c43b51c258d9dde679276bf2e9b4892a996e16d4c13b16a8c45c43f86eccb
7
+ data.tar.gz: 373e4f2ad51a02b499dcb4a4d96132c537dc7bc97ba5a2b0851f8381c08a7e5ab631c810bd8d880d88d62f0b5c7f8b8ac9a7b2136d4f9d12cb741ec8e0f84c39
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/.travis.yml ADDED
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.3.0
4
+ before_install: gem install bundler -v 1.11.2
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in banktools-at.gemspec
4
+ gemspec
data/README.md ADDED
@@ -0,0 +1,60 @@
1
+ # Austrian bank tools
2
+
3
+ Ruby gem to validate Austrian bank account numbers.
4
+
5
+ ## Usage
6
+
7
+ account = BankTools::AT::Account.new("12345678901")
8
+ account.valid? # => true
9
+ account.errors # => []
10
+
11
+ bad_account = BankTools::AT::Account.new("1")
12
+ bad_account.valid? # => false
13
+ bad_account.errors # => [:too_short]
14
+
15
+ blz = BankTools::AT::BLZ.new("12345")
16
+ blz.valid? # => true
17
+ blz.errors # => []
18
+
19
+ bad_blz = BankTools::AT::BLZ.new("1")
20
+ bad_blz.valid? # => false
21
+ bad_blz.errors # => [:too_short]
22
+
23
+ # Error codes
24
+
25
+ BankTools::AT::Errors::TOO_SHORT # => :too_short
26
+ BankTools::AT::Errors::TOO_LONG # => :too_long
27
+ BankTools::AT::Errors::INVALID_CHARACTERS # => :invalid_characters
28
+
29
+ ## Tests
30
+
31
+ bundle
32
+ rspec # or: rake
33
+
34
+
35
+ ## Installation
36
+
37
+ Add this line to your application's Gemfile:
38
+
39
+ gem "banktools-at"
40
+
41
+ And then execute:
42
+
43
+ $ bundle
44
+
45
+ Or install it yourself as:
46
+
47
+ $ gem install banktools-at
48
+
49
+ ## TODO
50
+
51
+ * Use [check digit](http://www.cnb.cz/cs/platebni_styk/iban/download/TR201.pdf)
52
+
53
+ ## Also see
54
+
55
+ * [Our other BankTools](https://github.com/barsoom?query=banktools)
56
+ * [iban-tools](https://github.com/iulianu/iban-tools)
57
+
58
+ ## License
59
+
60
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
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
@@ -0,0 +1,26 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "banktools-at/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "banktools-at"
8
+ spec.version = BankTools::AT::VERSION
9
+ spec.authors = ["Henrik Nyh", "Kim Persson"]
10
+ spec.email = ["devs@auctionet.com"]
11
+
12
+ spec.summary = %q{Validate Austrian bank account numbers.}
13
+ spec.homepage = ""
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
17
+ spec.bindir = "exe"
18
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_dependency "attr_extras", "~> 5"
22
+
23
+ spec.add_development_dependency "bundler"
24
+ spec.add_development_dependency "rake"
25
+ spec.add_development_dependency "rspec"
26
+ end
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "banktools/at"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,3 @@
1
+ require "banktools-at/version"
2
+ require "banktools-at/account"
3
+ require "banktools-at/blz"
@@ -0,0 +1,39 @@
1
+ require "attr_extras/explicit"
2
+ require "banktools-at/errors"
3
+
4
+ module BankTools
5
+ module AT
6
+ class Account
7
+ extend AttrExtras.mixin
8
+
9
+ MIN_LENGTH = 4
10
+ MAX_LENGTH = 11
11
+
12
+ pattr_initialize :original_value
13
+
14
+ def valid?
15
+ errors.none?
16
+ end
17
+
18
+ def errors
19
+ errors = []
20
+
21
+ errors << Errors::TOO_SHORT if compacted_value.length < MIN_LENGTH
22
+ errors << Errors::TOO_LONG if compacted_value.length > MAX_LENGTH
23
+ errors << Errors::INVALID_CHARACTERS if any_non_digits?
24
+
25
+ errors
26
+ end
27
+
28
+ private
29
+
30
+ def any_non_digits?
31
+ compacted_value.match(/\D/)
32
+ end
33
+
34
+ def compacted_value
35
+ original_value.to_s.gsub(/[\s-]/, "")
36
+ end
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,37 @@
1
+ require "banktools-at/errors"
2
+
3
+ module BankTools
4
+ module AT
5
+ class BLZ
6
+ extend AttrExtras.mixin
7
+
8
+ LENGTH = 5
9
+
10
+ pattr_initialize :original_value
11
+
12
+ def valid?
13
+ errors.none?
14
+ end
15
+
16
+ def errors
17
+ errors = []
18
+
19
+ errors << Errors::TOO_SHORT if compacted_value.length < LENGTH
20
+ errors << Errors::TOO_LONG if compacted_value.length > LENGTH
21
+ errors << Errors::INVALID_CHARACTERS if any_non_digits?
22
+
23
+ errors
24
+ end
25
+
26
+ private
27
+
28
+ def any_non_digits?
29
+ compacted_value.match(/\D/)
30
+ end
31
+
32
+ def compacted_value
33
+ original_value.to_s.gsub(/[\s-]/, "")
34
+ end
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,9 @@
1
+ module BankTools
2
+ module AT
3
+ module Errors
4
+ TOO_SHORT = :too_short
5
+ TOO_LONG = :too_long
6
+ INVALID_CHARACTERS = :invalid_characters
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,5 @@
1
+ module BankTools
2
+ module AT
3
+ VERSION = "0.1.0"
4
+ end
5
+ end
metadata ADDED
@@ -0,0 +1,114 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: banktools-at
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Henrik Nyh
8
+ - Kim Persson
9
+ autorequire:
10
+ bindir: exe
11
+ cert_chain: []
12
+ date: 2016-10-12 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: attr_extras
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - "~>"
19
+ - !ruby/object:Gem::Version
20
+ version: '5'
21
+ type: :runtime
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - "~>"
26
+ - !ruby/object:Gem::Version
27
+ version: '5'
28
+ - !ruby/object:Gem::Dependency
29
+ name: bundler
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - ">="
33
+ - !ruby/object:Gem::Version
34
+ version: '0'
35
+ type: :development
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - ">="
40
+ - !ruby/object:Gem::Version
41
+ version: '0'
42
+ - !ruby/object:Gem::Dependency
43
+ name: rake
44
+ requirement: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - ">="
47
+ - !ruby/object:Gem::Version
48
+ version: '0'
49
+ type: :development
50
+ prerelease: false
51
+ version_requirements: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ version: '0'
56
+ - !ruby/object:Gem::Dependency
57
+ name: rspec
58
+ requirement: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - ">="
61
+ - !ruby/object:Gem::Version
62
+ version: '0'
63
+ type: :development
64
+ prerelease: false
65
+ version_requirements: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ description:
71
+ email:
72
+ - devs@auctionet.com
73
+ executables: []
74
+ extensions: []
75
+ extra_rdoc_files: []
76
+ files:
77
+ - ".gitignore"
78
+ - ".travis.yml"
79
+ - Gemfile
80
+ - README.md
81
+ - Rakefile
82
+ - banktools-at.gemspec
83
+ - bin/console
84
+ - bin/setup
85
+ - lib/banktools-at.rb
86
+ - lib/banktools-at/account.rb
87
+ - lib/banktools-at/blz.rb
88
+ - lib/banktools-at/errors.rb
89
+ - lib/banktools-at/version.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.5.1
111
+ signing_key:
112
+ specification_version: 4
113
+ summary: Validate Austrian bank account numbers.
114
+ test_files: []