luhn 1.0.2 → 1.0.3
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 +5 -5
- data/README.md +55 -0
- data/lib/luhn/version.rb +1 -1
- metadata +25 -16
- data/README.rdoc +0 -44
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 48cccdf14be3fc83b329b2b7407ebd4410c889d62e5fc9e526b5beded1a4f137
|
4
|
+
data.tar.gz: 31fb9fa178dcfc3068a5e4563fecd2756786334ffcda5dcb1c02831a7c085030
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1ed8c51ba3cf801e1f2ec7eb17b244e7bd0fc06b40899ef7f5d1a230ddd327ff01376fe54d5af9ec15676261ac09844e0f0c747dda0acc8122be805bbcb55482
|
7
|
+
data.tar.gz: bce0cbb1eb0a0b31e8d77e6794935c01377424139c21252536419376e70a0116e81dbdab0645844a60bbb2c863ae570a738593f576329f37870d79c20eec4582
|
data/README.md
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
# Ruby class for handling basic Luhn number generation and verification
|
2
|
+
|
3
|
+
Includes a class to handle Swedish civic numbers (Personnummer).
|
4
|
+
|
5
|
+
The interface supports checking validity (length, valid date and satisfies luhn),
|
6
|
+
returning the sex, the control digit, and generating random civic numbers.
|
7
|
+
|
8
|
+
## Install
|
9
|
+
|
10
|
+
```shell
|
11
|
+
$ gem install luhn
|
12
|
+
```
|
13
|
+
|
14
|
+
## Usage:
|
15
|
+
|
16
|
+
### Basic Luhn
|
17
|
+
|
18
|
+
```ruby
|
19
|
+
Luhn.valid?('0465827879483596') # true
|
20
|
+
Luhn.control_digit('046582787948359') # 6
|
21
|
+
Luhn.generate(n) # returns a random number of n length that satisfies luhn
|
22
|
+
|
23
|
+
'0465827879483596'.valid_luhn? # true
|
24
|
+
0465827879483596.valid_luhn? # true
|
25
|
+
```
|
26
|
+
|
27
|
+
### Swedish civic numbers
|
28
|
+
|
29
|
+
```ruby
|
30
|
+
civic_number = Luhn::CivicNumber.new('19391030-3183')
|
31
|
+
civic_number.valid? # true
|
32
|
+
civic_number.sex # 'male'
|
33
|
+
civic_number.male? # true
|
34
|
+
civic_number.control_digit # 3
|
35
|
+
|
36
|
+
'391030-3183'.civic_number? # true
|
37
|
+
3910303183.civic_number? # true
|
38
|
+
```
|
39
|
+
|
40
|
+
## About the Luhn algorithm
|
41
|
+
|
42
|
+
The following is an excerpt from [the Wikipedia article on the Luhn algorithm.](https://en.wikipedia.org/wiki/Luhn_algorithm)
|
43
|
+
|
44
|
+
The Luhn algorithm or Luhn formula, also known as the "modulus 10" or "mod 10"
|
45
|
+
algorithm, is a simple checksum formula used to validate a variety of
|
46
|
+
identification numbers, such as credit card numbers, IMEI numbers,
|
47
|
+
National Provider Identifier numbers in US and Canadian Social Insurance Numbers,
|
48
|
+
and even South African ID numbers.
|
49
|
+
|
50
|
+
It was created by IBM scientist Hans Peter Luhn and described in U.S. Patent
|
51
|
+
No. 2,950,048, filed on January 6, 1954, and granted on August 23, 1960.
|
52
|
+
|
53
|
+
## Copyright
|
54
|
+
|
55
|
+
Copyright (c) 2010 Joel Junström. See [LICENSE](LICENSE) for details.
|
data/lib/luhn/version.rb
CHANGED
metadata
CHANGED
@@ -1,69 +1,78 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: luhn
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joel Junström
|
8
|
-
autorequire:
|
9
8
|
bindir: bin
|
10
9
|
cert_chain: []
|
11
|
-
date:
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
12
11
|
dependencies:
|
12
|
+
- !ruby/object:Gem::Dependency
|
13
|
+
name: ostruct
|
14
|
+
requirement: !ruby/object:Gem::Requirement
|
15
|
+
requirements:
|
16
|
+
- - "~>"
|
17
|
+
- !ruby/object:Gem::Version
|
18
|
+
version: '0'
|
19
|
+
type: :runtime
|
20
|
+
prerelease: false
|
21
|
+
version_requirements: !ruby/object:Gem::Requirement
|
22
|
+
requirements:
|
23
|
+
- - "~>"
|
24
|
+
- !ruby/object:Gem::Version
|
25
|
+
version: '0'
|
13
26
|
- !ruby/object:Gem::Dependency
|
14
27
|
name: minitest
|
15
28
|
requirement: !ruby/object:Gem::Requirement
|
16
29
|
requirements:
|
17
|
-
- - ~>
|
30
|
+
- - "~>"
|
18
31
|
- !ruby/object:Gem::Version
|
19
32
|
version: 2.6.0
|
20
33
|
type: :development
|
21
34
|
prerelease: false
|
22
35
|
version_requirements: !ruby/object:Gem::Requirement
|
23
36
|
requirements:
|
24
|
-
- - ~>
|
37
|
+
- - "~>"
|
25
38
|
- !ruby/object:Gem::Version
|
26
39
|
version: 2.6.0
|
27
|
-
description:
|
28
40
|
email:
|
29
41
|
- joel.junstrom@gmail.com
|
30
42
|
executables: []
|
31
43
|
extensions: []
|
32
44
|
extra_rdoc_files: []
|
33
45
|
files:
|
46
|
+
- LICENSE
|
47
|
+
- README.md
|
48
|
+
- lib/luhn.rb
|
34
49
|
- lib/luhn/civic_number.rb
|
50
|
+
- lib/luhn/extensions.rb
|
35
51
|
- lib/luhn/extensions/numeric.rb
|
36
52
|
- lib/luhn/extensions/string.rb
|
37
|
-
- lib/luhn/extensions.rb
|
38
53
|
- lib/luhn/version.rb
|
39
|
-
- lib/luhn.rb
|
40
54
|
- spec/helper.rb
|
41
55
|
- spec/spec_civic_number.rb
|
42
56
|
- spec/spec_extensions.rb
|
43
57
|
- spec/spec_luhn.rb
|
44
|
-
- LICENSE
|
45
|
-
- README.rdoc
|
46
58
|
homepage: http://github.com/joeljunstrom/ruby_luhn
|
47
59
|
licenses: []
|
48
60
|
metadata: {}
|
49
|
-
post_install_message:
|
50
61
|
rdoc_options: []
|
51
62
|
require_paths:
|
52
63
|
- lib
|
53
64
|
required_ruby_version: !ruby/object:Gem::Requirement
|
54
65
|
requirements:
|
55
|
-
- -
|
66
|
+
- - ">="
|
56
67
|
- !ruby/object:Gem::Version
|
57
68
|
version: '0'
|
58
69
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
59
70
|
requirements:
|
60
|
-
- -
|
71
|
+
- - ">="
|
61
72
|
- !ruby/object:Gem::Version
|
62
73
|
version: '0'
|
63
74
|
requirements: []
|
64
|
-
|
65
|
-
rubygems_version: 2.0.14
|
66
|
-
signing_key:
|
75
|
+
rubygems_version: 3.7.2
|
67
76
|
specification_version: 4
|
68
77
|
summary: A small implementation of the Luhn algorithm.
|
69
78
|
test_files: []
|
data/README.rdoc
DELETED
@@ -1,44 +0,0 @@
|
|
1
|
-
= Ruby class for handling basic Luhn number generation and verification
|
2
|
-
|
3
|
-
Includes a class to handle Swedish civic numbers (Personnummer)
|
4
|
-
That interface supports checking validity (length, valid date and satisfies luhn),
|
5
|
-
returning the sex, the control digit and generating random civic numbers.
|
6
|
-
|
7
|
-
== Install
|
8
|
-
|
9
|
-
$ gem install luhn
|
10
|
-
|
11
|
-
== Usage:
|
12
|
-
|
13
|
-
=== Basic Luhn
|
14
|
-
|
15
|
-
Luhn.valid?('0465827879483596') # true
|
16
|
-
Luhn.control_digit('046582787948359') # 6
|
17
|
-
Luhn.generate(n) # returns a random number of n length that satisfies luhn
|
18
|
-
|
19
|
-
'0465827879483596'.valid_luhn? # true
|
20
|
-
0465827879483596.valid_luhn? # true
|
21
|
-
|
22
|
-
=== Swedish civic numbers
|
23
|
-
|
24
|
-
civic_number = Luhn::CivicNumber.new('19391030-3183')
|
25
|
-
civic_number.valid? # true
|
26
|
-
civic_number.sex # 'male'
|
27
|
-
civic_number.male? # true
|
28
|
-
civic_number.control_digit # 3
|
29
|
-
|
30
|
-
'391030-3183'.civic_number? # true
|
31
|
-
3910303183.civic_number? # true
|
32
|
-
|
33
|
-
== About the Luhn algorithm (from http://en.wikipedia.org/wiki/Luhn_formula)
|
34
|
-
|
35
|
-
The Luhn algorithm or Luhn formula, also known as the "modulus 10" or "mod 10"
|
36
|
-
algorithm, is a simple checksum formula used to validate a variety of
|
37
|
-
identification numbers, such as credit card numbers, IMEI numbers,
|
38
|
-
National Provider Identifier numbers in US and Canadian Social Insurance Numbers.
|
39
|
-
It was created by IBM scientist Hans Peter Luhn and described in U.S. Patent
|
40
|
-
No. 2,950,048, filed on January 6, 1954, and granted on August 23, 1960.
|
41
|
-
|
42
|
-
== Copyright
|
43
|
-
|
44
|
-
Copyright (c) 2010 Joel Junström. See LICENSE for details.
|