iso-iban_validation 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 13c63db8660b9cf1d56377ae6f017524702c57f9
4
+ data.tar.gz: 3a735b375b17f07fabe0e31d99cf95fe41cad9b3
5
+ SHA512:
6
+ metadata.gz: 6fb3704499194553a830819ab5bf32fa8b29e0a14fb2bfd1f68030a76cee743ec2cfbd7e2402d6aa46c49de359d9d6d1f8cc7524ae5205bbd4cf8688eed0b78c
7
+ data.tar.gz: 57e9be95220c2c29d3d39bc94f6605654ed502f6b4a7e2fe0f39e40a3af72ecaaa1110b97712baf6f6e7394ff2f422067161bd08a7aa025c340284767a83a0ad
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Roman Simecek
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,48 @@
1
+ # ActiveRecord Validator for IBAN
2
+
3
+ This gem adds a validator to active_record obejcts for IBAN.
4
+ It works on top of the gem 'iso-iban'.
5
+
6
+ ## Installation
7
+
8
+ Add this line to your application's Gemfile:
9
+
10
+ gem 'iso-iban_validation'
11
+
12
+ And then execute:
13
+
14
+ $ bundle
15
+
16
+ Or install it yourself as:
17
+
18
+ $ gem install iso-iban_validation
19
+
20
+ ## Usage
21
+
22
+ Just insert into your model one of the following variants of the validation:
23
+
24
+ validates_iban_format_of :iban_field
25
+
26
+ or
27
+
28
+ validates_iban_of :iban_field
29
+
30
+ or
31
+
32
+ validates :iban_field, iban: true
33
+
34
+ ## Dependency
35
+
36
+ * [iso-iban](https://github.com/apeiros/iso-iban)
37
+
38
+ ## Licence
39
+
40
+ * [MIT](LICENSE.txt)
41
+
42
+ ## Contributing
43
+
44
+ 1. Fork it ( https://github.com/raskhadafi/iso-iban_validation/fork )
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 a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,29 @@
1
+ require "bundler/gem_tasks"
2
+
3
+ rule /^version:bump:.*/ do |t|
4
+ index = ['major', 'minor','patch'].index(t.name.split(':').last)
5
+ file = 'lib/iso/iban_validation/version.rb'
6
+ version_file = File.read(file)
7
+ old_version, *version_parts = version_file.match(/(\d+)\.(\d+)\.(\d+)/).to_a
8
+ version_parts[index] = version_parts[index].to_i + 1
9
+ version_parts[2] = 0 if index < 2
10
+ version_parts[1] = 0 if index < 1
11
+ new_version = version_parts * '.'
12
+
13
+ sh "git status | grep 'nothing to commit'" # ensure we are not dirty
14
+
15
+ File.open(file,'w') do |f|
16
+ f.write(version_file.sub(old_version, new_version))
17
+ end
18
+
19
+ sh "rake install && git add #{file} && git commit -m 'Bump version to #{new_version}'"
20
+
21
+ Rake::Task['release'].execute
22
+ end
23
+
24
+ desc "Show current version"
25
+ task :version do
26
+ require 'iso/iban_validation'
27
+
28
+ puts "Current version is: #{Iso::IbanValidation::VERSION}"
29
+ end
@@ -0,0 +1,34 @@
1
+ lib = File.expand_path('../lib', __FILE__)
2
+
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+
5
+ require 'iso/iban_validation/version'
6
+
7
+ Gem::Specification.new do |spec|
8
+ spec.name = "iso-iban_validation"
9
+ spec.version = Iso::IbanValidation::VERSION
10
+ spec.authors = ["Roman Simecek"]
11
+ spec.email = ["roman@good2go.ch"]
12
+ spec.summary = %q{IBAN rails validator}
13
+ spec.description = %q{IBAN rails validator with iso-iban.}
14
+ spec.homepage = "https://github.com/raskhadafi/iso-iban_validation"
15
+ spec.license = "MIT"
16
+
17
+ spec.files = Dir['bin/**/*'] + Dir['lib/**/*'] + %w[
18
+ iso-iban_validation.gemspec
19
+ LICENSE.txt
20
+ Rakefile
21
+ README.md
22
+ ]
23
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
24
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
25
+ spec.require_paths = ["lib"]
26
+
27
+ spec.add_dependency 'iso-iban'
28
+ spec.add_dependency 'activemodel'
29
+
30
+ spec.required_ruby_version = ">= 1.9.2"
31
+ spec.required_rubygems_version = Gem::Requirement.new("> 1.3.1")
32
+ spec.rubygems_version = "1.3.1"
33
+ spec.specification_version = 3
34
+ end
@@ -0,0 +1,22 @@
1
+ class IbanValidator < ActiveModel::EachValidator
2
+
3
+ def validate_each(record, attribute, value)
4
+ record.errors.add(
5
+ attribute,
6
+ :invalid_iban,
7
+ message: options[:message],
8
+ value: value,
9
+ ) if ISO::IBAN.valid?(value)
10
+ end
11
+
12
+ end
13
+
14
+ module ActiveModel::Validations::HelperMethods
15
+
16
+ def validates_iban_format_of(*attr_names)
17
+ validates_with IbanValidator, _merge_attributes(attr_names)
18
+ end
19
+
20
+ alias_method :validates_iban_format_of, :validates_iban_of
21
+
22
+ end
@@ -0,0 +1,5 @@
1
+ module Iso
2
+ module IbanValidation
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
@@ -0,0 +1,2 @@
1
+ require 'iso/iban'
2
+ require 'iso/iban_validation/iban_validator'
metadata ADDED
@@ -0,0 +1,79 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: iso-iban_validation
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Roman Simecek
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-06-05 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: iso-iban
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: activemodel
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
+ description: IBAN rails validator with iso-iban.
42
+ email:
43
+ - roman@good2go.ch
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - LICENSE.txt
49
+ - README.md
50
+ - Rakefile
51
+ - iso-iban_validation.gemspec
52
+ - lib/iso-iban_validation.rb
53
+ - lib/iso/iban_validation/iban_validator.rb
54
+ - lib/iso/iban_validation/version.rb
55
+ homepage: https://github.com/raskhadafi/iso-iban_validation
56
+ licenses:
57
+ - MIT
58
+ metadata: {}
59
+ post_install_message:
60
+ rdoc_options: []
61
+ require_paths:
62
+ - lib
63
+ required_ruby_version: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - ">="
66
+ - !ruby/object:Gem::Version
67
+ version: 1.9.2
68
+ required_rubygems_version: !ruby/object:Gem::Requirement
69
+ requirements:
70
+ - - ">"
71
+ - !ruby/object:Gem::Version
72
+ version: 1.3.1
73
+ requirements: []
74
+ rubyforge_project:
75
+ rubygems_version: 2.2.2
76
+ signing_key:
77
+ specification_version: 3
78
+ summary: IBAN rails validator
79
+ test_files: []