abn 2.0.0 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CHANGELOG +3 -0
- data/{README.rdoc → README.markdown} +15 -14
- data/lib/abn.rb +1 -1
- data/spec/abn_spec.rb +21 -25
- metadata +49 -98
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: f49ac5ef0ea62f6204adcbfa6945b30ce4f4ebb4
|
4
|
+
data.tar.gz: f45c0205b87086ad67988d24adbc896be1739738
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 77b47c166cc6da204236485d738f4bdd0b0d113d4acae26c483142fe8121a2da6112a01c76c75d3dee4c41bee0c94bf1727422db0aafb450b8d74167fa59b53b
|
7
|
+
data.tar.gz: ba230921117bde94908a418f7fbf022e18f54cc32e8dfbcbe0812763c87de2dee9b1148f42e01661d9be5d0e560df89dc26d5654285d5552936c505b9b04469f
|
data/CHANGELOG
CHANGED
@@ -1,27 +1,27 @@
|
|
1
1
|
A small library for validating Australian Business Numbers (ABN)
|
2
2
|
|
3
|
-
|
3
|
+
# Installation
|
4
4
|
|
5
|
-
|
5
|
+
gem install abn
|
6
6
|
|
7
|
-
|
7
|
+
# Usage
|
8
8
|
|
9
|
-
|
9
|
+
require 'abn'
|
10
10
|
|
11
|
-
|
12
|
-
|
11
|
+
ABN.new("12042168743").valid?
|
12
|
+
=> true
|
13
13
|
|
14
|
-
|
15
|
-
|
14
|
+
ABN.valid?("12042168743")
|
15
|
+
=> true
|
16
16
|
|
17
|
-
|
18
|
-
|
17
|
+
ABN.valid?("12042168744")
|
18
|
+
=> false
|
19
19
|
|
20
|
-
|
20
|
+
## With ActiveRecord
|
21
21
|
|
22
22
|
Version 1.3 of this gem had an active record mixin for validating ABN fields in
|
23
23
|
models. I removed it in version 2.0 to avoid complications of supporting active
|
24
|
-
record 2.x and 3.x.
|
24
|
+
record 2.x and 3.x (and Datamapper, Mongoid, etc).
|
25
25
|
|
26
26
|
To validate an ABN field in your model add the ABN gem to your Gemfile and
|
27
27
|
use the following pattern:
|
@@ -40,6 +40,7 @@ use the following pattern:
|
|
40
40
|
end
|
41
41
|
end
|
42
42
|
|
43
|
-
|
43
|
+
# Further Reading
|
44
44
|
|
45
|
-
- http://www.clearwater.com.au
|
45
|
+
- http://www.clearwater.com.au/code
|
46
|
+
- https://en.wikipedia.org/wiki/Australian_Business_Number
|
data/lib/abn.rb
CHANGED
data/spec/abn_spec.rb
CHANGED
@@ -1,68 +1,64 @@
|
|
1
|
-
require "rubygems"
|
2
|
-
require "bundler"
|
3
|
-
Bundler.setup
|
4
|
-
|
5
1
|
require "abn"
|
6
2
|
|
7
3
|
describe ABN, "valid? class method" do
|
8
4
|
it "should identify a valid ABN" do
|
9
|
-
ABN.valid?("12042168743").
|
10
|
-
ABN.valid?(12042168743).
|
5
|
+
expect(ABN.valid?("12042168743")).to be_truthy
|
6
|
+
expect(ABN.valid?(12042168743)).to be_truthy
|
11
7
|
end
|
12
8
|
|
13
9
|
it "should identify a preformatted valid ABN" do
|
14
|
-
ABN.valid?("12 042 168 743").
|
10
|
+
expect(ABN.valid?("12 042 168 743")).to be_truthy
|
15
11
|
end
|
16
12
|
|
17
13
|
it "should have a problem with a pre-formatted invalid ABN" do
|
18
|
-
ABN.valid?("12 042 168 744").
|
14
|
+
expect(ABN.valid?("12 042 168 744")).to be_falsey
|
19
15
|
end
|
20
16
|
|
21
17
|
it "should have a problem with an invalid ABN" do
|
22
|
-
ABN.valid?("12042168744").
|
23
|
-
ABN.valid?("902865").
|
18
|
+
expect(ABN.valid?("12042168744")).to be_falsey
|
19
|
+
expect(ABN.valid?("902865")).to be_falsey
|
24
20
|
end
|
25
21
|
|
26
22
|
it "should have a problem with invalid parameters" do
|
27
|
-
ABN.valid?(nil).
|
28
|
-
ABN.valid?(Array).
|
29
|
-
ABN.valid?(Array.new).
|
23
|
+
expect(ABN.valid?(nil)).to be_falsey
|
24
|
+
expect(ABN.valid?(Array)).to be_falsey
|
25
|
+
expect(ABN.valid?(Array.new)).to be_falsey
|
30
26
|
end
|
31
27
|
|
32
28
|
it "should have a problem with invalid parameter type that has a #length of 11" do
|
33
29
|
bad_parameter = (1..11).to_a
|
34
|
-
bad_parameter.length.
|
35
|
-
ABN.valid?(bad_parameter).
|
30
|
+
expect(bad_parameter.length).to eql(11)
|
31
|
+
expect(ABN.valid?(bad_parameter)).to be_falsey
|
36
32
|
end
|
37
33
|
end
|
38
34
|
|
39
35
|
describe ABN, "to_s instance method" do
|
40
36
|
it "should be able to format a valid ABN" do
|
41
|
-
ABN.new("12042168743").to_s.
|
37
|
+
expect(ABN.new("12042168743").to_s).to eql("12 042 168 743")
|
42
38
|
end
|
43
39
|
|
44
40
|
it "should be able to return a pre-formatted ABN" do
|
45
|
-
ABN.new("12 042 168 743").to_s.
|
41
|
+
expect(ABN.new("12 042 168 743").to_s).to eql("12 042 168 743")
|
46
42
|
end
|
47
43
|
|
48
44
|
it "should not format invalid parameter" do
|
49
|
-
ABN.new(nil).to_s.
|
50
|
-
ABN.new(Array).to_s.
|
51
|
-
ABN.new(Array.new).to_s.
|
45
|
+
expect(ABN.new(nil).to_s).to eql("")
|
46
|
+
expect(ABN.new(Array).to_s).to eql("")
|
47
|
+
expect(ABN.new(Array.new).to_s).to eql("")
|
52
48
|
end
|
53
49
|
|
54
50
|
it "should not format an invalid parameter type that has a #length of 11" do
|
55
51
|
bad_parameter = (1..11).to_a
|
56
|
-
bad_parameter.length.
|
57
|
-
ABN.new(bad_parameter).to_s.
|
52
|
+
expect(bad_parameter.length).to eql(11)
|
53
|
+
expect(ABN.new(bad_parameter).to_s).to eql("")
|
58
54
|
end
|
59
55
|
|
60
56
|
it "should not format an invalid ABN" do
|
61
|
-
ABN.new("12042168744").to_s.
|
62
|
-
ABN.new("902865").to_s.
|
57
|
+
expect(ABN.new("12042168744").to_s).to eql("")
|
58
|
+
expect(ABN.new("902865").to_s).to eql("")
|
63
59
|
end
|
64
60
|
|
65
61
|
it "should not format an pre-formatted invalid ABN" do
|
66
|
-
ABN.new("12 042 168 744").to_s.
|
62
|
+
expect(ABN.new("12 042 168 744").to_s).to eql("")
|
67
63
|
end
|
68
64
|
end
|
metadata
CHANGED
@@ -1,130 +1,81 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: abn
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
prerelease: false
|
6
|
-
segments:
|
7
|
-
- 2
|
8
|
-
- 0
|
9
|
-
- 0
|
10
|
-
version: 2.0.0
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 2.1.0
|
11
5
|
platform: ruby
|
12
|
-
authors:
|
6
|
+
authors:
|
13
7
|
- James Healy
|
14
8
|
autorequire:
|
15
9
|
bindir: bin
|
16
10
|
cert_chain: []
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
dependencies:
|
21
|
-
- !ruby/object:Gem::Dependency
|
11
|
+
date: 2017-07-15 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
22
14
|
name: rake
|
23
|
-
|
24
|
-
|
25
|
-
none: false
|
26
|
-
requirements:
|
27
|
-
- - ">="
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
hash: 3
|
30
|
-
segments:
|
31
|
-
- 0
|
32
|
-
version: "0"
|
33
|
-
type: :development
|
34
|
-
version_requirements: *id001
|
35
|
-
- !ruby/object:Gem::Dependency
|
36
|
-
name: rcov
|
37
|
-
prerelease: false
|
38
|
-
requirement: &id002 !ruby/object:Gem::Requirement
|
39
|
-
none: false
|
40
|
-
requirements:
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
41
17
|
- - ">="
|
42
|
-
- !ruby/object:Gem::Version
|
43
|
-
|
44
|
-
segments:
|
45
|
-
- 0
|
46
|
-
version: "0"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
47
20
|
type: :development
|
48
|
-
version_requirements: *id002
|
49
|
-
- !ruby/object:Gem::Dependency
|
50
|
-
name: roodi
|
51
21
|
prerelease: false
|
52
|
-
|
53
|
-
|
54
|
-
requirements:
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
55
24
|
- - ">="
|
56
|
-
- !ruby/object:Gem::Version
|
57
|
-
|
58
|
-
|
59
|
-
- 0
|
60
|
-
version: "0"
|
61
|
-
type: :development
|
62
|
-
version_requirements: *id003
|
63
|
-
- !ruby/object:Gem::Dependency
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
64
28
|
name: rspec
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
- !ruby/object:Gem::Version
|
71
|
-
hash: 3
|
72
|
-
segments:
|
73
|
-
- 2
|
74
|
-
- 0
|
75
|
-
version: "2.0"
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '3.0'
|
76
34
|
type: :development
|
77
|
-
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '3.0'
|
78
41
|
description: a (very) small library for working with Australian Business Numbers.
|
79
|
-
email:
|
42
|
+
email:
|
80
43
|
- jimmy@deefa.com
|
81
44
|
executables: []
|
82
|
-
|
83
45
|
extensions: []
|
84
|
-
|
85
46
|
extra_rdoc_files: []
|
86
|
-
|
87
|
-
files:
|
88
|
-
- lib/abn.rb
|
47
|
+
files:
|
89
48
|
- CHANGELOG
|
90
49
|
- MIT-LICENSE
|
91
|
-
- README.
|
50
|
+
- README.markdown
|
51
|
+
- lib/abn.rb
|
92
52
|
- spec/abn_spec.rb
|
93
|
-
has_rdoc: true
|
94
53
|
homepage: http://github.com/yob/abn
|
95
|
-
licenses:
|
96
|
-
|
54
|
+
licenses:
|
55
|
+
- MIT
|
56
|
+
metadata: {}
|
97
57
|
post_install_message:
|
98
|
-
rdoc_options:
|
99
|
-
- --title
|
58
|
+
rdoc_options:
|
59
|
+
- "--title"
|
100
60
|
- ABN
|
101
|
-
- --line-numbers
|
102
|
-
require_paths:
|
61
|
+
- "--line-numbers"
|
62
|
+
require_paths:
|
103
63
|
- lib
|
104
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
105
|
-
|
106
|
-
requirements:
|
64
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
107
66
|
- - ">="
|
108
|
-
- !ruby/object:Gem::Version
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
version: "0"
|
113
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
114
|
-
none: false
|
115
|
-
requirements:
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 1.9.3
|
69
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
70
|
+
requirements:
|
116
71
|
- - ">="
|
117
|
-
- !ruby/object:Gem::Version
|
118
|
-
|
119
|
-
segments:
|
120
|
-
- 0
|
121
|
-
version: "0"
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
version: '0'
|
122
74
|
requirements: []
|
123
|
-
|
124
75
|
rubyforge_project: yob-projects
|
125
|
-
rubygems_version:
|
76
|
+
rubygems_version: 2.6.11
|
126
77
|
signing_key:
|
127
|
-
specification_version:
|
78
|
+
specification_version: 4
|
128
79
|
summary: a (very) small library for working with Australian Business Numbers.
|
129
|
-
test_files:
|
80
|
+
test_files:
|
130
81
|
- spec/abn_spec.rb
|