ssn 0.1.0 → 0.2.0

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/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.0
1
+ 0.2.0
data/lib/ssn.rb CHANGED
@@ -4,7 +4,7 @@ require 'ssn/active_record_extensions'
4
4
  require 'ssn/social_security_number'
5
5
 
6
6
  module Ssn
7
- VERSION = '0.1.0'
7
+ VERSION = '0.2.0'
8
8
  end
9
9
 
10
10
  ActiveRecord::Base.send( :include, Ssn::ActiveRecordExtensions ) if defined?( ActiveRecord::Base )
@@ -6,11 +6,15 @@ module Ssn
6
6
 
7
7
  module ActsMethods
8
8
  def has_ssn( *args )
9
+ options = args.extract_options!
10
+
9
11
  unless included_modules.include? InstanceMethods
10
12
  self.class_eval { extend ClassMethods }
11
13
  include InstanceMethods
12
- validates_length_of :raw_ssn, :maximum => 9, :allow_blank => true
13
- validates_format_of :raw_ssn, :with => /^[0-9]{9}$/, :allow_blank => true
14
+ validates_length_of :"raw_#{args.first.to_sym}", :maximum => 9, :allow_blank => true
15
+ validates_format_of :"raw_#{args.first.to_sym}", :with => /^[0-9]{9}$/, :allow_blank => true
16
+
17
+ validates_format_of args.first.to_sym, :with => /^[0-9]{3}-?[0-9]{2}-?[0-9]{4}$/, :allow_blank => true
14
18
  end
15
19
 
16
20
  initialize_has_ssn_from_args args
@@ -38,9 +42,6 @@ module Ssn
38
42
  end
39
43
 
40
44
  define_method "#{str}=" do |value|
41
- unless /^[0-9]{3}-?[0-9]{2}-?[0-9]{4}$/.match( value )
42
- raise 'Invalid SSN format provided for ssn'
43
- end
44
45
  self.raw_ssn = value.gsub( /-/, "" )
45
46
  end
46
47
  end
data/spec/ssn_spec.rb CHANGED
@@ -35,15 +35,8 @@ describe "Ssn" do
35
35
  end
36
36
 
37
37
  it "should not allow a mal-formed social security number" do
38
- lambda { @user.ssn = "1-1345-6789" }.should raise_error
39
- end
40
-
41
- it "should allow correctly formed social security numbers" do
42
- lambda { @user.ssn = "123-45-6789" }.should_not raise_error
43
- end
44
-
45
- it "should allow correctly formed social security numbers" do
46
- lambda { @user.ssn = "123456789" }.should_not raise_error
38
+ @user.ssn = '1-3456789'
39
+ @user.save.should be_false
47
40
  end
48
41
  end
49
42
 
data/ssn.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{ssn}
8
- s.version = "0.1.0"
8
+ s.version = "0.2.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Jason Harrelson"]
12
- s.date = %q{2010-10-05}
12
+ s.date = %q{2010-11-05}
13
13
  s.description = %q{Encapsulates functionality for storing an unformatted SSN but formatting the SSN on print.}
14
14
  s.email = %q{jason@lookforwardenterprises.com}
15
15
  s.extra_rdoc_files = [
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ssn
3
3
  version: !ruby/object:Gem::Version
4
- hash: 27
4
+ hash: 23
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
- - 1
8
+ - 2
9
9
  - 0
10
- version: 0.1.0
10
+ version: 0.2.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Jason Harrelson
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-10-05 00:00:00 -05:00
18
+ date: 2010-11-05 00:00:00 -05:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency