moeffju-luhn 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -1,8 +1,6 @@
1
- # Luhn
1
+ # Luhn [![Build Status](https://secure.travis-ci.org/moeffju/luhn.png?branch=master)](http://travis-ci.org/moeffju/luhn)
2
2
 
3
- Adds methods to Fixnum and String to generate and validate Luhn checksums.
4
-
5
- [![Build Status](https://secure.travis-ci.org/moeffju/luhn.png?branch=master)](http://travis-ci.org/moeffju/luhn)
3
+ Adds methods to Numeric and String to generate and validate Luhn checksums.
6
4
 
7
5
  ## Installation
8
6
 
@@ -4,7 +4,7 @@ class Numeric
4
4
  def luhn
5
5
  digits = self.to_s.chars.map(&:to_i)
6
6
  sum = digits.reverse.each_with_index.map{ |x, i| i.even? ? (x * 2).divmod(10).inject(:+) : x }.reverse.inject(:+)
7
- (10 - sum % 10)
7
+ (10 - sum % 10) % 10
8
8
  end
9
9
 
10
10
  def luhn?
@@ -1,3 +1,3 @@
1
1
  module Luhn
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
3
3
  end
@@ -2,8 +2,8 @@
2
2
  require File.expand_path('../lib/luhn/version', __FILE__)
3
3
 
4
4
  Gem::Specification.new do |gem|
5
- gem.authors = ["Matthias Bauer"]
6
- gem.email = ["moeffju@moeffju.net"]
5
+ gem.authors = ["Matthias Bauer", "Ben Rexin"]
6
+ gem.email = ["moeffju@moeffju.net", "salzig@notsitz.info"]
7
7
  gem.description = %q{Adds methods to Fixnum and String to generate and validate Luhn check digits, e.g. for credit card numbers, civic numbers, some account numbers etc. More info: https://en.wikipedia.org/wiki/Luhn_algorithm}
8
8
  gem.summary = %q{Adds methods to Fixnum and String to generate and validate Luhn check digits}
9
9
  gem.homepage = "https://github.com/moeffju/luhn"
@@ -55,4 +55,7 @@ describe "Luhn" do
55
55
  end
56
56
  end
57
57
 
58
+ it "should return valid checksum (one digit)" do
59
+ 123.luhn.should be 0
60
+ end
58
61
  end
metadata CHANGED
@@ -1,15 +1,16 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: moeffju-luhn
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
8
8
  - Matthias Bauer
9
+ - Ben Rexin
9
10
  autorequire:
10
11
  bindir: bin
11
12
  cert_chain: []
12
- date: 2012-08-16 00:00:00.000000000 Z
13
+ date: 2012-09-28 00:00:00.000000000 Z
13
14
  dependencies:
14
15
  - !ruby/object:Gem::Dependency
15
16
  name: rake
@@ -48,6 +49,7 @@ description: ! 'Adds methods to Fixnum and String to generate and validate Luhn
48
49
  info: https://en.wikipedia.org/wiki/Luhn_algorithm'
49
50
  email:
50
51
  - moeffju@moeffju.net
52
+ - salzig@notsitz.info
51
53
  executables: []
52
54
  extensions: []
53
55
  extra_rdoc_files: []