luhnacy 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Rakefile +8 -29
- data/VERSION +1 -1
- data/luhnacy.gemspec +18 -43
- data/spec/luhnacy_spec.rb +10 -10
- data/spec/spec_helper.rb +1 -6
- metadata +72 -64
- data/.gitignore +0 -21
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 523977326fd241aed7a7ea6a3e2856a2dcaf434a0b4ea9b39656d68f92b83a72
|
4
|
+
data.tar.gz: e8ea922c5d203b2ef30cf3690dde167fdb17555df6ba03caf403c9a26afff146
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 792706eeeb4935d0d382d5398b8a6f1ce68ec1756f6b03fb436025cfa64bd6bd9c900f635f79fa3dbf0a4663c6ad6996061accacac749685c4f3f78c829ef1bc
|
7
|
+
data.tar.gz: 0632e1a6ad0125a0caa1352791d69d9800b8bc4d1e18a681773e06783b4620bbffb8fb492f4eefdc2c7f6a11d341396914d335f188a2065ab8025eeb1d1e2c65
|
data/Rakefile
CHANGED
@@ -1,42 +1,21 @@
|
|
1
|
-
require '
|
2
|
-
require '
|
1
|
+
require 'bundler/setup'
|
2
|
+
require 'bundler/gem_tasks'
|
3
3
|
|
4
|
-
|
5
|
-
require 'jeweler'
|
6
|
-
Jeweler::Tasks.new do |gem|
|
7
|
-
gem.name = "luhnacy"
|
8
|
-
gem.summary = %Q{A gem tohelp with the tedium of validating Luhn-compliant strings}
|
9
|
-
gem.description = %Q{luhnacy can be used to validate strings for Luhn compliance as well as generating valid or invalid strings for the purposes of testing }
|
10
|
-
gem.email = "rorymckinley@gmail.com"
|
11
|
-
gem.homepage = "http://github.com/rorymckinley/luhnacy"
|
12
|
-
gem.authors = ["Rory McKinley"]
|
13
|
-
gem.add_development_dependency "rspec", ">= 1.2.9"
|
14
|
-
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
15
|
-
end
|
16
|
-
Jeweler::GemcutterTasks.new
|
17
|
-
rescue LoadError
|
18
|
-
puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
|
19
|
-
end
|
4
|
+
require 'rspec/core/rake_task'
|
20
5
|
|
21
|
-
|
22
|
-
Spec::Rake::SpecTask.new(:spec) do |spec|
|
23
|
-
spec.libs << 'lib' << 'spec'
|
24
|
-
spec.spec_files = FileList['spec/**/*_spec.rb']
|
6
|
+
RSpec::Core::RakeTask.new(:spec) do |spec|
|
25
7
|
end
|
26
8
|
|
27
|
-
|
28
|
-
spec.libs << 'lib' << 'spec'
|
9
|
+
RSpec::Core::RakeTask.new(:rcov) do |spec|
|
29
10
|
spec.pattern = 'spec/**/*_spec.rb'
|
30
11
|
spec.rcov = true
|
31
12
|
end
|
32
13
|
|
33
|
-
task :spec => :check_dependencies
|
34
|
-
|
35
14
|
task :default => :spec
|
36
15
|
|
37
|
-
require '
|
38
|
-
|
39
|
-
version = File.
|
16
|
+
require 'rdoc/task'
|
17
|
+
RDoc::Task.new do |rdoc|
|
18
|
+
version = File.read('VERSION')
|
40
19
|
|
41
20
|
rdoc.rdoc_dir = 'rdoc'
|
42
21
|
rdoc.title = "luhnacy #{version}"
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.2
|
data/luhnacy.gemspec
CHANGED
@@ -1,55 +1,30 @@
|
|
1
|
-
# Generated by jeweler
|
2
|
-
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
-
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
|
4
|
-
# -*- encoding: utf-8 -*-
|
5
|
-
|
6
1
|
Gem::Specification.new do |s|
|
7
|
-
s.name =
|
8
|
-
s.version =
|
2
|
+
s.name = "luhnacy"
|
3
|
+
s.version = File.read('VERSION')
|
9
4
|
|
10
|
-
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
5
|
s.authors = ["Rory McKinley"]
|
12
|
-
s.
|
13
|
-
s.
|
14
|
-
s.email = %q{rorymckinley@gmail.com}
|
6
|
+
s.description = "luhnacy can be used to validate strings for Luhn compliance as well as generating valid or invalid strings for the purposes of testing "
|
7
|
+
s.email = "rorymckinley@gmail.com"
|
15
8
|
s.extra_rdoc_files = [
|
16
9
|
"LICENSE",
|
17
|
-
|
10
|
+
"README.rdoc"
|
18
11
|
]
|
19
12
|
s.files = [
|
20
13
|
".document",
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
"luhnacy.gemspec",
|
28
|
-
"spec/luhnacy_spec.rb",
|
29
|
-
"spec/spec.opts",
|
30
|
-
"spec/spec_helper.rb"
|
31
|
-
]
|
32
|
-
s.homepage = %q{http://github.com/rorymckinley/luhnacy}
|
33
|
-
s.rdoc_options = ["--charset=UTF-8"]
|
34
|
-
s.require_paths = ["lib"]
|
35
|
-
s.rubygems_version = %q{1.3.7}
|
36
|
-
s.summary = %q{A gem tohelp with the tedium of validating Luhn-compliant strings}
|
37
|
-
s.test_files = [
|
14
|
+
"LICENSE",
|
15
|
+
"README.rdoc",
|
16
|
+
"Rakefile",
|
17
|
+
"VERSION",
|
18
|
+
"lib/luhnacy.rb",
|
19
|
+
"luhnacy.gemspec",
|
38
20
|
"spec/luhnacy_spec.rb",
|
39
|
-
|
21
|
+
"spec/spec.opts",
|
22
|
+
"spec/spec_helper.rb"
|
40
23
|
]
|
24
|
+
s.homepage = "http://github.com/rorymckinley/luhnacy"
|
25
|
+
s.summary = "A gem tohelp with the tedium of validating Luhn-compliant strings"
|
41
26
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
47
|
-
s.add_development_dependency(%q<rspec>, [">= 1.2.9"])
|
48
|
-
else
|
49
|
-
s.add_dependency(%q<rspec>, [">= 1.2.9"])
|
50
|
-
end
|
51
|
-
else
|
52
|
-
s.add_dependency(%q<rspec>, [">= 1.2.9"])
|
53
|
-
end
|
27
|
+
s.add_development_dependency "rspec", ">= 2", "< 3"
|
28
|
+
s.add_development_dependency "rake", "~> 13.0.3"
|
29
|
+
s.add_development_dependency "bundler-audit"
|
54
30
|
end
|
55
|
-
|
data/spec/luhnacy_spec.rb
CHANGED
@@ -3,25 +3,25 @@ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
|
3
3
|
describe "Luhnacy" do
|
4
4
|
it "should be able to identify if a number satisfies Luhn" do
|
5
5
|
valid_number = '49927398716'
|
6
|
-
Luhnacy.valid?(valid_number).should
|
6
|
+
Luhnacy.valid?(valid_number).should be_truthy
|
7
7
|
end
|
8
8
|
|
9
9
|
it "should be able to identify if a number does not satisfy Luhn" do
|
10
10
|
invalid_number = '49927398715'
|
11
|
-
Luhnacy.valid?(invalid_number).should
|
11
|
+
Luhnacy.valid?(invalid_number).should be_falsey
|
12
12
|
end
|
13
13
|
|
14
14
|
it "should return a string of digits that satisfies Luhn" do
|
15
15
|
string_size = 5
|
16
16
|
candidate = Luhnacy.generate(string_size)
|
17
17
|
candidate.should match /^\d{#{string_size}}$/
|
18
|
-
Luhnacy.valid?(candidate).should
|
18
|
+
Luhnacy.valid?(candidate).should be_truthy
|
19
19
|
end
|
20
20
|
|
21
21
|
it "should return a string of digits that does not satisfy Luhn" do
|
22
22
|
string_size = 5
|
23
23
|
candidate = Luhnacy.generate(string_size, :invalid => true)
|
24
|
-
Luhnacy.valid?(candidate).should
|
24
|
+
Luhnacy.valid?(candidate).should be_falsey
|
25
25
|
end
|
26
26
|
|
27
27
|
it "should return a string that satisfies luhn and includes a given prefix" do
|
@@ -40,30 +40,30 @@ describe "Luhnacy" do
|
|
40
40
|
context "Named generators and validators" do
|
41
41
|
it "should validate a correct number" do
|
42
42
|
number = '5354334446769063'
|
43
|
-
Luhnacy.mastercard?(number).should
|
43
|
+
Luhnacy.mastercard?(number).should be_truthy
|
44
44
|
end
|
45
45
|
|
46
46
|
it "should not validate a number if it does not satisfy Luhn" do
|
47
47
|
number = '5354334446769064'
|
48
|
-
Luhnacy.mastercard?(number).should
|
48
|
+
Luhnacy.mastercard?(number).should be_falsey
|
49
49
|
end
|
50
50
|
|
51
51
|
it "should not validate a number if it does not have the correct prefix" do
|
52
52
|
number = Luhnacy.generate(16, :prefix => '49')
|
53
|
-
Luhnacy.mastercard?(number).should
|
53
|
+
Luhnacy.mastercard?(number).should be_falsey
|
54
54
|
end
|
55
55
|
|
56
56
|
it "should not validate a number if it does not have the correct length" do
|
57
57
|
number = Luhnacy.generate(12, :prefix => '52')
|
58
|
-
Luhnacy.mastercard?(number).should
|
58
|
+
Luhnacy.mastercard?(number).should be_falsey
|
59
59
|
end
|
60
60
|
|
61
61
|
it "should generate a valid number" do
|
62
|
-
Luhnacy.mastercard?(Luhnacy.mastercard).should
|
62
|
+
Luhnacy.mastercard?(Luhnacy.mastercard).should be_truthy
|
63
63
|
end
|
64
64
|
|
65
65
|
it "should generate an invalid number" do
|
66
|
-
Luhnacy.mastercard?(Luhnacy.mastercard(:invalid => true)).should
|
66
|
+
Luhnacy.mastercard?(Luhnacy.mastercard(:invalid => true)).should be_falsey
|
67
67
|
end
|
68
68
|
|
69
69
|
it "should raise an error if there is no matcher or validator with a given name" do
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,51 +1,73 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: luhnacy
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
prerelease: false
|
6
|
-
segments:
|
7
|
-
- 0
|
8
|
-
- 2
|
9
|
-
- 1
|
10
|
-
version: 0.2.1
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.2.2
|
11
5
|
platform: ruby
|
12
|
-
authors:
|
6
|
+
authors:
|
13
7
|
- Rory McKinley
|
14
|
-
autorequire:
|
8
|
+
autorequire:
|
15
9
|
bindir: bin
|
16
10
|
cert_chain: []
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
dependencies:
|
21
|
-
- !ruby/object:Gem::Dependency
|
11
|
+
date: 2021-01-09 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
22
14
|
name: rspec
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '2'
|
20
|
+
- - "<"
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '3'
|
23
|
+
type: :development
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '2'
|
30
|
+
- - "<"
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '3'
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: rake
|
35
|
+
requirement: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - "~>"
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: 13.0.3
|
40
|
+
type: :development
|
23
41
|
prerelease: false
|
24
|
-
|
25
|
-
|
26
|
-
|
42
|
+
version_requirements: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - "~>"
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: 13.0.3
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: bundler-audit
|
49
|
+
requirement: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
27
51
|
- - ">="
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
|
30
|
-
segments:
|
31
|
-
- 1
|
32
|
-
- 2
|
33
|
-
- 9
|
34
|
-
version: 1.2.9
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
35
54
|
type: :development
|
36
|
-
|
37
|
-
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - ">="
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '0'
|
61
|
+
description: 'luhnacy can be used to validate strings for Luhn compliance as well
|
62
|
+
as generating valid or invalid strings for the purposes of testing '
|
38
63
|
email: rorymckinley@gmail.com
|
39
64
|
executables: []
|
40
|
-
|
41
65
|
extensions: []
|
42
|
-
|
43
|
-
extra_rdoc_files:
|
66
|
+
extra_rdoc_files:
|
44
67
|
- LICENSE
|
45
68
|
- README.rdoc
|
46
|
-
files:
|
47
|
-
- .document
|
48
|
-
- .gitignore
|
69
|
+
files:
|
70
|
+
- ".document"
|
49
71
|
- LICENSE
|
50
72
|
- README.rdoc
|
51
73
|
- Rakefile
|
@@ -55,40 +77,26 @@ files:
|
|
55
77
|
- spec/luhnacy_spec.rb
|
56
78
|
- spec/spec.opts
|
57
79
|
- spec/spec_helper.rb
|
58
|
-
has_rdoc: true
|
59
80
|
homepage: http://github.com/rorymckinley/luhnacy
|
60
81
|
licenses: []
|
61
|
-
|
62
|
-
post_install_message:
|
63
|
-
rdoc_options:
|
64
|
-
|
65
|
-
require_paths:
|
82
|
+
metadata: {}
|
83
|
+
post_install_message:
|
84
|
+
rdoc_options: []
|
85
|
+
require_paths:
|
66
86
|
- lib
|
67
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
68
|
-
|
69
|
-
requirements:
|
87
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
88
|
+
requirements:
|
70
89
|
- - ">="
|
71
|
-
- !ruby/object:Gem::Version
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
version: "0"
|
76
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
77
|
-
none: false
|
78
|
-
requirements:
|
90
|
+
- !ruby/object:Gem::Version
|
91
|
+
version: '0'
|
92
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
79
94
|
- - ">="
|
80
|
-
- !ruby/object:Gem::Version
|
81
|
-
|
82
|
-
segments:
|
83
|
-
- 0
|
84
|
-
version: "0"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
85
97
|
requirements: []
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
signing_key:
|
90
|
-
specification_version: 3
|
98
|
+
rubygems_version: 3.1.4
|
99
|
+
signing_key:
|
100
|
+
specification_version: 4
|
91
101
|
summary: A gem tohelp with the tedium of validating Luhn-compliant strings
|
92
|
-
test_files:
|
93
|
-
- spec/luhnacy_spec.rb
|
94
|
-
- spec/spec_helper.rb
|
102
|
+
test_files: []
|