rut_validator 0.0.1 → 0.0.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.
@@ -1,5 +1,4 @@
1
1
  rvm:
2
- - 1.9.2
3
2
  - 1.9.3
3
+ - 2.0.0
4
4
  - jruby-19mode
5
- - ruby-head
@@ -0,0 +1,9 @@
1
+ 2013-07-16 0.0.2
2
+
3
+ Bug fixes
4
+
5
+ * Validation with rut ending with K and 0.
6
+
7
+ 2012-10-23 0.0.1
8
+
9
+ * First Version.
@@ -2,7 +2,7 @@ class Rut
2
2
  attr_reader :code
3
3
 
4
4
  def initialize(rut)
5
- @rut = rut.to_s.strip
5
+ @rut = rut.to_s.strip.upcase
6
6
  @number = @rut.gsub(/[^0-9K]/i,'')[0...-1]
7
7
  @code = @rut[-1]
8
8
  end
@@ -27,7 +27,7 @@ class Rut
27
27
  digit, factor = *a
28
28
  r += digit.to_i * factor
29
29
  end
30
- all_codes[11 - partial_sum%11].to_s
30
+ all_codes[(11 - partial_sum) % 11].to_s
31
31
  end
32
32
 
33
33
  def number_with_delimiter(delimiter='.')
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
 
5
5
  Gem::Specification.new do |gem|
6
6
  gem.name = "rut_validator"
7
- gem.version = "0.0.1"
7
+ gem.version = "0.0.2"
8
8
  gem.authors = ["Ignacio Ortega"]
9
9
  gem.email = ["ignacio.ortega@gmail.com"]
10
10
  gem.description = %q{Chilean RUT validator for rails 3. See homepage for details http://github.com/iortega/rut_validator}
@@ -2,10 +2,10 @@ require 'spec_helper'
2
2
 
3
3
  describe Rut do
4
4
 
5
- context 'valid inputs' do
5
+ context "Rut format" do
6
6
 
7
7
  [11222333, '11222333', '11222333-9', '11.222.333-9'].each do |r|
8
- let(:rut) { Rut.new(r) }
8
+ subject(:rut) { Rut.new(r) }
9
9
 
10
10
  it "#{r.inspect} formatted" do
11
11
  rut.format.should == '11.222.333-9'
@@ -20,7 +20,18 @@ describe Rut do
20
20
  end
21
21
 
22
22
  it "#{r.inspect} should be valid" do
23
- rut.valid?.should be_true
23
+ rut.should be_valid
24
+ end
25
+ end
26
+ end
27
+
28
+ context "Rut validation" do
29
+
30
+ ["6660982-0", "10461906-1", "6101821-2", "19516159-3", "11094848-4", "6209751-5", "13421096-6", "24651197-7", "5387375-8", "16551610-9", "7615998-k", "16562775-K"].each do |valid_rut|
31
+ subject(:rut) { Rut.new(valid_rut) }
32
+
33
+ it "#{valid_rut} should be valid" do
34
+ rut.should be_valid
24
35
  end
25
36
  end
26
37
 
@@ -30,7 +41,7 @@ describe Rut do
30
41
 
31
42
  ['invalid', '112223338', 1234, nil].each do |r|
32
43
  it "#{r.inspect} should be invalid" do
33
- Rut.new(r).valid?.should be_false
44
+ Rut.new(r).should_not be_valid
34
45
  end
35
46
  end
36
47
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rut_validator
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-10-25 00:00:00.000000000 Z
12
+ date: 2013-12-05 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activemodel
@@ -86,6 +86,7 @@ files:
86
86
  - .rspec
87
87
  - .simplecov
88
88
  - .travis.yml
89
+ - CHANGELOG
89
90
  - Gemfile
90
91
  - LICENSE.txt
91
92
  - README.md
@@ -110,12 +111,18 @@ required_ruby_version: !ruby/object:Gem::Requirement
110
111
  - - ! '>='
111
112
  - !ruby/object:Gem::Version
112
113
  version: '0'
114
+ segments:
115
+ - 0
116
+ hash: -543635619699236401
113
117
  required_rubygems_version: !ruby/object:Gem::Requirement
114
118
  none: false
115
119
  requirements:
116
120
  - - ! '>='
117
121
  - !ruby/object:Gem::Version
118
122
  version: '0'
123
+ segments:
124
+ - 0
125
+ hash: -543635619699236401
119
126
  requirements: []
120
127
  rubyforge_project:
121
128
  rubygems_version: 1.8.23