luhn_checksum 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 46aca18fcd7985b4da04e379dc2d7453d08396ff
4
- data.tar.gz: fa5c9d60a868ac681a3a3ec541a3a5796f15564b
2
+ SHA256:
3
+ metadata.gz: 839ea68cee699473a76283d337612d1708733b4780ad21a1e50e8c1fb9482d1e
4
+ data.tar.gz: c3a4a127013ea153c4ead716105d3dfde9154c3b972a30e8f1d27a6d249c63d8
5
5
  SHA512:
6
- metadata.gz: daa599c9e2e3433a46e62ec62c08a7608d470efe386824796c94cd058b0d4106aceedfa2e74e4351b663dbdf5034a67876440d61a4effdbd38d4ff91fa3ca96f
7
- data.tar.gz: b6d09468e83cd5e809cc02ec27cb74ee80ded127ab8d534e7222fe13201dee73c998a7465707e3e172ca108977587c0ba7aefb5945542a8b1fcec6347d8a886d
6
+ metadata.gz: 8af2c32da4be6f4a9fce58e163a888aaa497faa68c8ee5453d77d1d6f6a0c3356561aa30b6d50858a4ce8d3f25d81951f7587041668faa3d76a6f9a0f83c5363
7
+ data.tar.gz: f9246c28cf4c428801af777cdbde183dd9a71e03c1286f822d6ba61b2daf7116aea8bf9dd41a6389cb48def506549763980a389975b50dedcc913c6381ee7500
@@ -0,0 +1,34 @@
1
+ name: CI
2
+
3
+ on: push
4
+
5
+ jobs:
6
+ test:
7
+ runs-on: ubuntu-latest
8
+
9
+ strategy:
10
+ fail-fast: false
11
+ matrix:
12
+ ruby-version:
13
+ - "2.6"
14
+ - "2.7"
15
+ - "3.0"
16
+ steps:
17
+ - uses: zendesk/checkout@v2
18
+ - name: Set up Ruby
19
+ uses: zendesk/setup-ruby@v1
20
+ with:
21
+ ruby-version: ${{ matrix.ruby-version }}
22
+ bundler-cache: true
23
+ - run: bundle exec rake test
24
+
25
+ lint:
26
+ runs-on: ubuntu-latest
27
+ steps:
28
+ - uses: zendesk/checkout@v2
29
+ - name: Set up Ruby
30
+ uses: zendesk/setup-ruby@v1
31
+ with:
32
+ ruby-version: "2.7"
33
+ bundler-cache: true
34
+ - run: bundle exec rake rubocop
data/.rubocop.yml ADDED
@@ -0,0 +1,76 @@
1
+ AllCops:
2
+ DisplayCopNames: true
3
+ TargetRubyVersion: 2.6
4
+
5
+ Metrics:
6
+ Enabled: false
7
+
8
+ # TODO
9
+
10
+ Style/Documentation:
11
+ Exclude:
12
+ - 'lib/credit_card_sanitizer.rb'
13
+
14
+ # Configured
15
+
16
+ # Layout
17
+
18
+ Layout/HashAlignment:
19
+ EnforcedLastArgumentHashStyle: ignore_implicit
20
+ Layout/ParameterAlignment:
21
+ EnforcedStyle: with_fixed_indentation
22
+ Layout/CaseIndentation:
23
+ EnforcedStyle: end
24
+ Layout/FirstParameterIndentation:
25
+ EnforcedStyle: consistent
26
+ Layout/FirstArrayElementIndentation:
27
+ EnforcedStyle: consistent
28
+ Layout/FirstHashElementIndentation:
29
+ EnforcedStyle: consistent
30
+ Layout/MultilineMethodCallIndentation:
31
+ EnforcedStyle: indented
32
+ Layout/MultilineOperationIndentation:
33
+ EnforcedStyle: indented
34
+
35
+ # Allow ▇ in comments
36
+ Style/AsciiComments:
37
+ Exclude:
38
+ - 'lib/credit_card_sanitizer.rb'
39
+
40
+ # Lint
41
+
42
+ Lint/EndAlignment:
43
+ EnforcedStyleAlignWith: variable
44
+
45
+ # Disabled
46
+
47
+ # Layout
48
+
49
+ Layout/EmptyLineAfterMagicComment:
50
+ Enabled: false
51
+
52
+ # Lint
53
+
54
+ Lint/AssignmentInCondition:
55
+ Enabled: false
56
+
57
+ # Style
58
+
59
+ Style/DoubleNegation:
60
+ Enabled: false
61
+ Style/GuardClause:
62
+ Enabled: false
63
+ Style/IfUnlessModifier:
64
+ Enabled: false
65
+ Style/NumericLiterals:
66
+ Enabled: false
67
+ Style/PerlBackrefs:
68
+ Enabled: false
69
+ Style/RegexpLiteral:
70
+ Enabled: false
71
+ Style/SpecialGlobalVars:
72
+ Enabled: false
73
+ Style/SymbolArray:
74
+ Enabled: false
75
+ Style/WordArray:
76
+ Enabled: false
data/Gemfile CHANGED
@@ -1,4 +1,8 @@
1
- source "https://rubygems.org"
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
2
4
 
3
- gemspec
4
5
  gem 'minitest'
6
+ gem 'rubocop'
7
+
8
+ gemspec
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- luhn_checksum (0.1.1)
4
+ luhn_checksum (0.1.2)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -10,16 +10,42 @@ GEM
10
10
  bundler
11
11
  rake
12
12
  thor (>= 0.14.0)
13
+ ast (2.4.2)
14
+ bump (0.10.0)
13
15
  minitest (5.2.0)
16
+ parallel (1.22.1)
17
+ parser (3.1.2.0)
18
+ ast (~> 2.4.1)
19
+ rainbow (3.1.1)
14
20
  rake (10.3.1)
21
+ regexp_parser (2.5.0)
22
+ rexml (3.2.5)
23
+ rubocop (1.30.0)
24
+ parallel (~> 1.10)
25
+ parser (>= 3.1.0.0)
26
+ rainbow (>= 2.2.2, < 4.0)
27
+ regexp_parser (>= 1.8, < 3.0)
28
+ rexml (>= 3.2.5, < 4.0)
29
+ rubocop-ast (>= 1.18.0, < 2.0)
30
+ ruby-progressbar (~> 1.7)
31
+ unicode-display_width (>= 1.4.0, < 3.0)
32
+ rubocop-ast (1.18.0)
33
+ parser (>= 3.1.1.0)
34
+ ruby-progressbar (1.11.0)
15
35
  thor (0.19.1)
36
+ unicode-display_width (2.1.0)
16
37
 
17
38
  PLATFORMS
18
39
  ruby
19
40
 
20
41
  DEPENDENCIES
21
42
  appraisal
43
+ bump
22
44
  bundler
23
45
  luhn_checksum!
24
46
  minitest
25
47
  rake
48
+ rubocop
49
+
50
+ BUNDLED WITH
51
+ 2.3.12
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- [![Build Status](https://travis-ci.org/zendesk/luhn_checksum.png)](https://travis-ci.org/zendesk/luhn_checksum)
1
+ ![Build Status](https://github.com/zendesk/luhn_checksum/actions/workflows/ci.yml/badge.svg)
2
2
 
3
3
  luhn_checksum
4
4
  =============
data/Rakefile CHANGED
@@ -1,8 +1,12 @@
1
- require 'bundler/gem_tasks'
1
+ # frozen_string_literal: true
2
2
 
3
+ require 'bundler/gem_tasks'
4
+ require 'bump/tasks'
3
5
  require 'appraisal'
4
-
5
6
  require 'rake/testtask'
7
+ require 'rubocop/rake_task'
8
+
9
+ RuboCop::RakeTask.new
6
10
 
7
11
  Rake::TestTask.new(:test) do |t|
8
12
  t.libs << 'lib'
@@ -11,4 +15,4 @@ Rake::TestTask.new(:test) do |t|
11
15
  t.verbose = false
12
16
  end
13
17
 
14
- task :default => :test
18
+ task default: [:test, :rubocop]
data/lib/luhn_checksum.rb CHANGED
@@ -1,5 +1,7 @@
1
- module LuhnChecksum
1
+ # frozen_string_literal: true
2
2
 
3
+ # Test numeric sequences to see if they match Luhn checksum
4
+ module LuhnChecksum
3
5
  # Numeric ascii bytes to Luhn value
4
6
  ODD_LUHN_VALUE = {
5
7
  48 => 0,
@@ -25,10 +27,9 @@ module LuhnChecksum
25
27
  54 => 3, # 6 * 2 - 9
26
28
  55 => 5, # etc ...
27
29
  56 => 7,
28
- 57 => 9,
30
+ 57 => 9
29
31
  }.freeze
30
32
 
31
-
32
33
  def self.valid?(numbers)
33
34
  sum = 0
34
35
 
@@ -43,7 +44,6 @@ module LuhnChecksum
43
44
  end
44
45
  end
45
46
 
46
- sum % 10 == 0
47
+ (sum % 10).zero?
47
48
  end
48
-
49
49
  end
@@ -1,19 +1,21 @@
1
- # encoding: utf-8
1
+ # frozen_string_literal: true
2
2
 
3
3
  Gem::Specification.new do |gem|
4
- gem.authors = ["Eric Chapweske", "Gary Grossman"]
5
- gem.email = ["ggrossman@zendesk.com"]
6
- gem.description = "Efficient Luhn checksum validator"
7
- gem.summary = %q{}
8
- gem.homepage = ""
4
+ gem.authors = ['Eric Chapweske', 'Gary Grossman']
5
+ gem.email = ['ggrossman@zendesk.com']
6
+ gem.description = 'Efficient Luhn checksum validator'
7
+ gem.summary = 'Efficient Luhn checksum validator'
8
+ gem.homepage = 'https://github.com/zendesk/luhn_checksum'
9
+ gem.required_ruby_version = '>= 2.6.0'
9
10
 
10
11
  gem.files = `git ls-files`.split($\)
11
- gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
12
+ gem.executables = gem.files.grep(%r{^bin/}).map { |f| File.basename(f) }
12
13
  gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
13
- gem.name = "luhn_checksum"
14
- gem.version = '0.1.1'
14
+ gem.name = 'luhn_checksum'
15
+ gem.version = '0.1.2'
15
16
 
16
17
  gem.add_development_dependency('appraisal')
17
- gem.add_development_dependency('rake')
18
+ gem.add_development_dependency('bump')
18
19
  gem.add_development_dependency('bundler')
20
+ gem.add_development_dependency('rake')
19
21
  end
data/test/helper.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'rubygems'
2
4
  require 'bundler/setup'
3
5
  require 'minitest'
@@ -1,25 +1,24 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative 'helper'
2
4
 
3
5
  # Test data courtsey of:
4
6
  # * https://github.com/square/luhnybin
5
7
  # * http://en.wikipedia.org/wiki/Luhn_algorithm
6
8
  class LuhnChecksumTest < MiniTest::Test
7
-
8
- describe "Luhn filter" do
9
-
10
- it "matches checksums" do
11
- real_luhns = [ '123451234512348', '5678', '49927398716', '1234567812345670', '56613959932537' ]
9
+ describe 'Luhn filter' do
10
+ it 'matches checksums' do
11
+ real_luhns = ['123451234512348', '5678', '49927398716', '1234567812345670', '56613959932537']
12
12
  real_luhns.each do |luhn|
13
13
  assert_equal true, LuhnChecksum.valid?(luhn), luhn
14
14
  end
15
15
  end
16
16
 
17
- it "does not match non-checksums" do
18
- fake_luhns = [ '8765', '49927398717', '1234567812345678' '566139599325370' ]
17
+ it 'does not match non-checksums' do
18
+ fake_luhns = ['8765', '49927398717', '1234567812345678', '566139599325370']
19
19
  fake_luhns.each do |luhn|
20
20
  assert_equal false, LuhnChecksum.valid?(luhn)
21
21
  end
22
22
  end
23
23
  end
24
-
25
24
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: luhn_checksum
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eric Chapweske
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-07-15 00:00:00.000000000 Z
12
+ date: 2022-06-03 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: appraisal
@@ -26,7 +26,7 @@ dependencies:
26
26
  - !ruby/object:Gem::Version
27
27
  version: '0'
28
28
  - !ruby/object:Gem::Dependency
29
- name: rake
29
+ name: bump
30
30
  requirement: !ruby/object:Gem::Requirement
31
31
  requirements:
32
32
  - - ">="
@@ -53,6 +53,20 @@ dependencies:
53
53
  - - ">="
54
54
  - !ruby/object:Gem::Version
55
55
  version: '0'
56
+ - !ruby/object:Gem::Dependency
57
+ name: rake
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'
56
70
  description: Efficient Luhn checksum validator
57
71
  email:
58
72
  - ggrossman@zendesk.com
@@ -60,7 +74,8 @@ executables: []
60
74
  extensions: []
61
75
  extra_rdoc_files: []
62
76
  files:
63
- - ".travis.yml"
77
+ - ".github/workflows/ci.yml"
78
+ - ".rubocop.yml"
64
79
  - Gemfile
65
80
  - Gemfile.lock
66
81
  - LICENSE
@@ -70,7 +85,7 @@ files:
70
85
  - luhn_checksum.gemspec
71
86
  - test/helper.rb
72
87
  - test/luhn_checksum_test.rb
73
- homepage: ''
88
+ homepage: https://github.com/zendesk/luhn_checksum
74
89
  licenses: []
75
90
  metadata: {}
76
91
  post_install_message:
@@ -81,18 +96,17 @@ required_ruby_version: !ruby/object:Gem::Requirement
81
96
  requirements:
82
97
  - - ">="
83
98
  - !ruby/object:Gem::Version
84
- version: '0'
99
+ version: 2.6.0
85
100
  required_rubygems_version: !ruby/object:Gem::Requirement
86
101
  requirements:
87
102
  - - ">="
88
103
  - !ruby/object:Gem::Version
89
104
  version: '0'
90
105
  requirements: []
91
- rubyforge_project:
92
- rubygems_version: 2.2.2
106
+ rubygems_version: 3.1.6
93
107
  signing_key:
94
108
  specification_version: 4
95
- summary: ''
109
+ summary: Efficient Luhn checksum validator
96
110
  test_files:
97
111
  - test/helper.rb
98
112
  - test/luhn_checksum_test.rb
data/.travis.yml DELETED
@@ -1,6 +0,0 @@
1
- language: ruby
2
- bundler_args: ""
3
- rvm:
4
- - 1.9.3
5
- - 2.0.0
6
- - 2.1.1