phony_rails 0.1.8 → 0.1.9

Sign up to get free protection for your applications and to get access to all the features.
data/lib/phony_rails.rb CHANGED
@@ -66,9 +66,12 @@ module PhonyRails
66
66
  def phony_normalize(*attributes)
67
67
  options = attributes.last.is_a?(Hash) ? attributes.pop : {}
68
68
  options.assert_valid_keys :country_code, :default_country_code, :as
69
- raise ArgumentError, ':as option can not be used on phony_normalize with multiple attribute names! (PhonyRails)' if !options[:as].blank? && attributes.size > 1
69
+ if options[:as].present?
70
+ raise ArgumentError, ':as option can not be used on phony_normalize with multiple attribute names! (PhonyRails)' if attributes.size > 1
71
+ raise ArgumentError, "'#{options[:as]}' is not an attribute on #{self.class}. You might want to use 'phony_normalized_method :#{attributes.first}' (PhonyRails)" if not self.attribute_method?(options[:as])
72
+ end
70
73
  attributes.each do |attribute|
71
- raise ArgumentError, "No attribute #{attribute} found on #{self.class.name} (PhonyRails)" if not self.attribute_method?(attribute)
74
+ raise ArgumentError, "No attribute #{attribute} found on #{self.name} (PhonyRails)" if not self.attribute_method?(attribute)
72
75
  # Add before validation that saves a normalized version of the phone number
73
76
  self.before_validation do
74
77
  set_phony_normalized_numbers(attributes, options)
@@ -1,3 +1,3 @@
1
1
  module PhonyRails
2
- VERSION = "0.1.8"
2
+ VERSION = "0.1.9"
3
3
  end
@@ -68,9 +68,15 @@ describe PhonyRails do
68
68
  }.should raise_error(ArgumentError)
69
69
  end
70
70
 
71
- it "should accept :as option with single attribute name" do
71
+ it "should not accept :as option with single non existing attribute name" do
72
72
  lambda {
73
73
  Home.phony_normalize(:phone_number, :as => 'something_else')
74
+ }.should raise_error(ArgumentError)
75
+ end
76
+
77
+ it "should accept :as option with single existing attribute name" do
78
+ lambda {
79
+ Home.phony_normalize(:phone_number, :as => 'phone_number_as_normalized')
74
80
  }.should_not raise_error(ArgumentError)
75
81
  end
76
82
  end
metadata CHANGED
@@ -1,73 +1,72 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: phony_rails
3
- version: !ruby/object:Gem::Version
4
- prerelease: false
5
- segments:
6
- - 0
7
- - 1
8
- - 8
9
- version: 0.1.8
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.9
5
+ prerelease:
10
6
  platform: ruby
11
- authors:
7
+ authors:
12
8
  - Joost Hietbrink
13
9
  autorequire:
14
10
  bindir: bin
15
11
  cert_chain: []
16
-
17
- date: 2012-07-30 00:00:00 +02:00
18
- default_executable:
19
- dependencies:
20
- - !ruby/object:Gem::Dependency
12
+ date: 2012-08-13 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
21
15
  name: phony
22
- prerelease: false
23
- requirement: &id001 !ruby/object:Gem::Requirement
24
- requirements:
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
25
19
  - - ~>
26
- - !ruby/object:Gem::Version
27
- segments:
28
- - 1
29
- - 7
30
- - 7
20
+ - !ruby/object:Gem::Version
31
21
  version: 1.7.7
32
22
  type: :runtime
33
- version_requirements: *id001
34
- - !ruby/object:Gem::Dependency
35
- name: countries
36
23
  prerelease: false
37
- requirement: &id002 !ruby/object:Gem::Requirement
38
- requirements:
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: 1.7.7
30
+ - !ruby/object:Gem::Dependency
31
+ name: countries
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
39
35
  - - ~>
40
- - !ruby/object:Gem::Version
41
- segments:
42
- - 0
43
- - 8
44
- - 2
36
+ - !ruby/object:Gem::Version
45
37
  version: 0.8.2
46
38
  type: :runtime
47
- version_requirements: *id002
48
- - !ruby/object:Gem::Dependency
49
- name: activerecord
50
39
  prerelease: false
51
- requirement: &id003 !ruby/object:Gem::Requirement
52
- requirements:
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ version: 0.8.2
46
+ - !ruby/object:Gem::Dependency
47
+ name: activerecord
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
53
51
  - - ~>
54
- - !ruby/object:Gem::Version
55
- segments:
56
- - 3
57
- - 0
58
- version: "3.0"
52
+ - !ruby/object:Gem::Version
53
+ version: '3.0'
59
54
  type: :runtime
60
- version_requirements: *id003
61
- description: This Gem adds useful methods to your Rails app to validate, display and save phone numbers.
62
- email:
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: '3.0'
62
+ description: This Gem adds useful methods to your Rails app to validate, display and
63
+ save phone numbers.
64
+ email:
63
65
  - joost@joopp.com
64
66
  executables: []
65
-
66
67
  extensions: []
67
-
68
68
  extra_rdoc_files: []
69
-
70
- files:
69
+ files:
71
70
  - .gitignore
72
71
  - .rspec
73
72
  - Gemfile
@@ -86,37 +85,33 @@ files:
86
85
  - spec/lib/phony_rails_spec.rb
87
86
  - spec/lib/validators/phony_validator_spec.rb
88
87
  - spec/spec_helper.rb
89
- has_rdoc: true
90
88
  homepage: https://github.com/joost/phony_rails
91
89
  licenses: []
92
-
93
90
  post_install_message:
94
91
  rdoc_options: []
95
-
96
- require_paths:
92
+ require_paths:
97
93
  - lib
98
- required_ruby_version: !ruby/object:Gem::Requirement
99
- requirements:
100
- - - ">="
101
- - !ruby/object:Gem::Version
102
- segments:
103
- - 0
104
- version: "0"
105
- required_rubygems_version: !ruby/object:Gem::Requirement
106
- requirements:
107
- - - ">="
108
- - !ruby/object:Gem::Version
109
- segments:
110
- - 0
111
- version: "0"
94
+ required_ruby_version: !ruby/object:Gem::Requirement
95
+ none: false
96
+ requirements:
97
+ - - ! '>='
98
+ - !ruby/object:Gem::Version
99
+ version: '0'
100
+ required_rubygems_version: !ruby/object:Gem::Requirement
101
+ none: false
102
+ requirements:
103
+ - - ! '>='
104
+ - !ruby/object:Gem::Version
105
+ version: '0'
112
106
  requirements: []
113
-
114
107
  rubyforge_project:
115
- rubygems_version: 1.3.6
108
+ rubygems_version: 1.8.24
116
109
  signing_key:
117
110
  specification_version: 3
118
- summary: This Gem adds useful methods to your Rails app to validate, display and save phone numbers.
119
- test_files:
111
+ summary: This Gem adds useful methods to your Rails app to validate, display and save
112
+ phone numbers.
113
+ test_files:
120
114
  - spec/lib/phony_rails_spec.rb
121
115
  - spec/lib/validators/phony_validator_spec.rb
122
116
  - spec/spec_helper.rb
117
+ has_rdoc: