moeffju-luhn 0.1.1 → 0.1.2

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.
data/README.md CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  Adds methods to Fixnum and String to generate and validate Luhn checksums.
4
4
 
5
+ [![Build Status](https://secure.travis-ci.org/moeffju/luhn.png?branch=master)](http://travis-ci.org/moeffju/luhn)
6
+
5
7
  ## Installation
6
8
 
7
9
  Add this line to your application's Gemfile:
@@ -20,7 +22,7 @@ The gem's name is 'luhn', so you need to `require luhn`.
20
22
 
21
23
  ## Usage
22
24
 
23
- `Fixnum`:
25
+ `Numeric` (`Fixnum`, `Bignum`):
24
26
 
25
27
  ```
26
28
  4100410382.luhn? #=> true
@@ -45,5 +47,6 @@ And for `String`s:
45
47
  1. Fork it
46
48
  2. Create your feature branch (`git checkout -b my-new-feature`)
47
49
  3. Commit your changes (`git commit -am 'Added some feature'`)
48
- 4. Push to the branch (`git push origin my-new-feature`)
49
- 5. Create new Pull Request
50
+ 4. Make sure the specs pass / extend the specs
51
+ 5. Push to the branch (`git push origin my-new-feature`)
52
+ 6. Create new Pull Request
data/Rakefile CHANGED
@@ -1,2 +1,7 @@
1
1
  #!/usr/bin/env rake
2
2
  require "bundler/gem_tasks"
3
+ require "rspec/core/rake_task"
4
+
5
+ RSpec::Core::RakeTask.new(:spec)
6
+
7
+ task :default => :spec
@@ -1,6 +1,6 @@
1
1
  require "luhn/version"
2
2
 
3
- class Fixnum
3
+ 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(:+)
@@ -1,3 +1,3 @@
1
1
  module Luhn
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
@@ -14,4 +14,7 @@ Gem::Specification.new do |gem|
14
14
  gem.name = "moeffju-luhn"
15
15
  gem.require_paths = ["lib"]
16
16
  gem.version = Luhn::VERSION
17
+
18
+ gem.add_development_dependency 'rake'
19
+ gem.add_development_dependency 'rspec'
17
20
  end
@@ -1,7 +1,7 @@
1
1
  require_relative './spec_helper'
2
2
 
3
3
  describe "Luhn" do
4
- describe "on Fixnums" do
4
+ describe "on Numeric" do
5
5
  let(:valid) { 4100410382 }
6
6
  let(:valid_check) { 2 }
7
7
  let(:incomplete) { 410041038 }
@@ -23,12 +23,12 @@ describe "Luhn" do
23
23
  incomplete.luhn!.should == valid
24
24
  end
25
25
 
26
- it "should return Fixnums" do
27
- incomplete.luhn!.should be_a Fixnum
26
+ it "should quack like a Numeric" do
27
+ incomplete.luhn!.should be_a Numeric
28
28
  end
29
29
  end
30
30
 
31
- describe "on Strings" do
31
+ describe "on String" do
32
32
  let(:valid) { '4 10041038 2' }
33
33
  let(:valid_check) { '2' }
34
34
  let(:incomplete) { '410041038' }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: moeffju-luhn
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,7 +10,39 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
  date: 2012-08-16 00:00:00.000000000 Z
13
- dependencies: []
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rake
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: rspec
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :development
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
14
46
  description: ! 'Adds methods to Fixnum and String to generate and validate Luhn check
15
47
  digits, e.g. for credit card numbers, civic numbers, some account numbers etc. More
16
48
  info: https://en.wikipedia.org/wiki/Luhn_algorithm'