pcai_client_side_validations 3.1.5 → 3.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (39) hide show
  1. metadata +20 -113
  2. data/client_side_validations.gemspec +0 -42
  3. data/lib/client_side_validations.rb +0 -13
  4. data/lib/client_side_validations/action_view.rb +0 -14
  5. data/lib/client_side_validations/action_view/form_builder.rb +0 -157
  6. data/lib/client_side_validations/action_view/form_helper.rb +0 -86
  7. data/lib/client_side_validations/action_view/form_tag_helper.rb +0 -12
  8. data/lib/client_side_validations/active_model.rb +0 -60
  9. data/lib/client_side_validations/active_model/acceptance.rb +0 -10
  10. data/lib/client_side_validations/active_model/exclusion.rb +0 -15
  11. data/lib/client_side_validations/active_model/format.rb +0 -10
  12. data/lib/client_side_validations/active_model/inclusion.rb +0 -15
  13. data/lib/client_side_validations/active_model/length.rb +0 -24
  14. data/lib/client_side_validations/active_model/numericality.rb +0 -31
  15. data/lib/client_side_validations/active_model/presence.rb +0 -10
  16. data/lib/client_side_validations/active_record.rb +0 -11
  17. data/lib/client_side_validations/active_record/middleware.rb +0 -33
  18. data/lib/client_side_validations/active_record/uniqueness.rb +0 -28
  19. data/lib/client_side_validations/core_ext.rb +0 -3
  20. data/lib/client_side_validations/core_ext/range.rb +0 -10
  21. data/lib/client_side_validations/core_ext/regexp.rb +0 -14
  22. data/lib/client_side_validations/engine.rb +0 -6
  23. data/lib/client_side_validations/files.rb +0 -8
  24. data/lib/client_side_validations/formtastic.rb +0 -21
  25. data/lib/client_side_validations/middleware.rb +0 -81
  26. data/lib/client_side_validations/mongo_mapper.rb +0 -9
  27. data/lib/client_side_validations/mongo_mapper/middleware.rb +0 -20
  28. data/lib/client_side_validations/mongo_mapper/uniqueness.rb +0 -28
  29. data/lib/client_side_validations/mongoid.rb +0 -9
  30. data/lib/client_side_validations/mongoid/middleware.rb +0 -20
  31. data/lib/client_side_validations/mongoid/uniqueness.rb +0 -28
  32. data/lib/client_side_validations/simple_form.rb +0 -24
  33. data/lib/client_side_validations/version.rb +0 -3
  34. data/lib/generators/client_side_validations/copy_asset_generator.rb +0 -36
  35. data/lib/generators/client_side_validations/install_generator.rb +0 -45
  36. data/lib/generators/templates/client_side_validations/README.rails.3.0 +0 -6
  37. data/lib/generators/templates/client_side_validations/README.rails.3.1 +0 -7
  38. data/lib/generators/templates/client_side_validations/initializer.rb +0 -14
  39. data/vendor/assets/javascripts/rails.validations.js +0 -410
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pcai_client_side_validations
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.1.5
4
+ version: 3.2.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,18 +13,18 @@ date: 2012-05-26 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
16
- requirement: &22377516 !ruby/object:Gem::Requirement
16
+ requirement: &21633972 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
20
20
  - !ruby/object:Gem::Version
21
- version: 3.1.0
21
+ version: 3.2.0
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *22377516
24
+ version_requirements: *21633972
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: sqlite3
27
- requirement: &22377132 !ruby/object:Gem::Requirement
27
+ requirement: &21633624 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,43 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *22377132
36
- - !ruby/object:Gem::Dependency
37
- name: bson_ext
38
- requirement: &22376352 !ruby/object:Gem::Requirement
39
- none: false
40
- requirements:
41
- - - ! '>='
42
- - !ruby/object:Gem::Version
43
- version: '0'
44
- type: :development
45
- prerelease: false
46
- version_requirements: *22376352
47
- - !ruby/object:Gem::Dependency
48
- name: mongoid
49
- requirement: &22375956 !ruby/object:Gem::Requirement
50
- none: false
51
- requirements:
52
- - - ~>
53
- - !ruby/object:Gem::Version
54
- version: 2.0.0
55
- type: :development
56
- prerelease: false
57
- version_requirements: *22375956
58
- - !ruby/object:Gem::Dependency
59
- name: mongo_mapper
60
- requirement: &22367424 !ruby/object:Gem::Requirement
61
- none: false
62
- requirements:
63
- - - ~>
64
- - !ruby/object:Gem::Version
65
- version: 0.9.0
66
- type: :development
67
- prerelease: false
68
- version_requirements: *22367424
35
+ version_requirements: *21633624
69
36
  - !ruby/object:Gem::Dependency
70
37
  name: mocha
71
- requirement: &22367112 !ruby/object:Gem::Requirement
38
+ requirement: &21633252 !ruby/object:Gem::Requirement
72
39
  none: false
73
40
  requirements:
74
41
  - - ! '>='
@@ -76,32 +43,10 @@ dependencies:
76
43
  version: '0'
77
44
  type: :development
78
45
  prerelease: false
79
- version_requirements: *22367112
80
- - !ruby/object:Gem::Dependency
81
- name: simple_form
82
- requirement: &22366788 !ruby/object:Gem::Requirement
83
- none: false
84
- requirements:
85
- - - ~>
86
- - !ruby/object:Gem::Version
87
- version: 1.5.0
88
- type: :development
89
- prerelease: false
90
- version_requirements: *22366788
91
- - !ruby/object:Gem::Dependency
92
- name: formtastic
93
- requirement: &22366476 !ruby/object:Gem::Requirement
94
- none: false
95
- requirements:
96
- - - ~>
97
- - !ruby/object:Gem::Version
98
- version: 2.0.0
99
- type: :development
100
- prerelease: false
101
- version_requirements: *22366476
46
+ version_requirements: *21633252
102
47
  - !ruby/object:Gem::Dependency
103
48
  name: sinatra
104
- requirement: &22366152 !ruby/object:Gem::Requirement
49
+ requirement: &21632844 !ruby/object:Gem::Requirement
105
50
  none: false
106
51
  requirements:
107
52
  - - ~>
@@ -109,10 +54,10 @@ dependencies:
109
54
  version: '1.0'
110
55
  type: :development
111
56
  prerelease: false
112
- version_requirements: *22366152
57
+ version_requirements: *21632844
113
58
  - !ruby/object:Gem::Dependency
114
59
  name: shotgun
115
- requirement: &22365924 !ruby/object:Gem::Requirement
60
+ requirement: &21632448 !ruby/object:Gem::Requirement
116
61
  none: false
117
62
  requirements:
118
63
  - - ! '>='
@@ -120,10 +65,10 @@ dependencies:
120
65
  version: '0'
121
66
  type: :development
122
67
  prerelease: false
123
- version_requirements: *22365924
68
+ version_requirements: *21632448
124
69
  - !ruby/object:Gem::Dependency
125
70
  name: thin
126
- requirement: &22365648 !ruby/object:Gem::Requirement
71
+ requirement: &21632172 !ruby/object:Gem::Requirement
127
72
  none: false
128
73
  requirements:
129
74
  - - ! '>='
@@ -131,10 +76,10 @@ dependencies:
131
76
  version: '0'
132
77
  type: :development
133
78
  prerelease: false
134
- version_requirements: *22365648
79
+ version_requirements: *21632172
135
80
  - !ruby/object:Gem::Dependency
136
81
  name: json
137
- requirement: &22365396 !ruby/object:Gem::Requirement
82
+ requirement: &21631836 !ruby/object:Gem::Requirement
138
83
  none: false
139
84
  requirements:
140
85
  - - ! '>='
@@ -142,10 +87,10 @@ dependencies:
142
87
  version: '0'
143
88
  type: :development
144
89
  prerelease: false
145
- version_requirements: *22365396
90
+ version_requirements: *21631836
146
91
  - !ruby/object:Gem::Dependency
147
- name: ruby-debug19
148
- requirement: &22365084 !ruby/object:Gem::Requirement
92
+ name: coffee-script
93
+ requirement: &21631464 !ruby/object:Gem::Requirement
149
94
  none: false
150
95
  requirements:
151
96
  - - ! '>='
@@ -153,52 +98,14 @@ dependencies:
153
98
  version: '0'
154
99
  type: :development
155
100
  prerelease: false
156
- version_requirements: *22365084
101
+ version_requirements: *21631464
157
102
  description: Client Side Validations
158
103
  email:
159
104
  - bcardarella@gmail.com
160
105
  executables: []
161
106
  extensions: []
162
107
  extra_rdoc_files: []
163
- files:
164
- - lib/client_side_validations/action_view/form_builder.rb
165
- - lib/client_side_validations/action_view/form_helper.rb
166
- - lib/client_side_validations/action_view/form_tag_helper.rb
167
- - lib/client_side_validations/action_view.rb
168
- - lib/client_side_validations/active_model/acceptance.rb
169
- - lib/client_side_validations/active_model/exclusion.rb
170
- - lib/client_side_validations/active_model/format.rb
171
- - lib/client_side_validations/active_model/inclusion.rb
172
- - lib/client_side_validations/active_model/length.rb
173
- - lib/client_side_validations/active_model/numericality.rb
174
- - lib/client_side_validations/active_model/presence.rb
175
- - lib/client_side_validations/active_model.rb
176
- - lib/client_side_validations/active_record/middleware.rb
177
- - lib/client_side_validations/active_record/uniqueness.rb
178
- - lib/client_side_validations/active_record.rb
179
- - lib/client_side_validations/core_ext/range.rb
180
- - lib/client_side_validations/core_ext/regexp.rb
181
- - lib/client_side_validations/core_ext.rb
182
- - lib/client_side_validations/engine.rb
183
- - lib/client_side_validations/files.rb
184
- - lib/client_side_validations/formtastic.rb
185
- - lib/client_side_validations/middleware.rb
186
- - lib/client_side_validations/mongoid/middleware.rb
187
- - lib/client_side_validations/mongoid/uniqueness.rb
188
- - lib/client_side_validations/mongoid.rb
189
- - lib/client_side_validations/mongo_mapper/middleware.rb
190
- - lib/client_side_validations/mongo_mapper/uniqueness.rb
191
- - lib/client_side_validations/mongo_mapper.rb
192
- - lib/client_side_validations/simple_form.rb
193
- - lib/client_side_validations/version.rb
194
- - lib/client_side_validations.rb
195
- - lib/generators/client_side_validations/copy_asset_generator.rb
196
- - lib/generators/client_side_validations/install_generator.rb
197
- - lib/generators/templates/client_side_validations/initializer.rb
198
- - lib/generators/templates/client_side_validations/README.rails.3.0
199
- - lib/generators/templates/client_side_validations/README.rails.3.1
200
- - vendor/assets/javascripts/rails.validations.js
201
- - client_side_validations.gemspec
108
+ files: []
202
109
  homepage: https://github.com/bcardarella/client_side_validations
203
110
  licenses: []
204
111
  post_install_message:
@@ -1,42 +0,0 @@
1
- # -*- encoding: utf-8 -*-
2
- $:.push File.expand_path("../lib", __FILE__)
3
- require "client_side_validations/version"
4
-
5
- Gem::Specification.new do |s|
6
- s.name = "pcai_client_side_validations"
7
- s.version = ClientSideValidations::VERSION
8
- s.platform = Gem::Platform::RUBY
9
- s.authors = ["Brian Cardarella"]
10
- s.email = ["bcardarella@gmail.com"]
11
- s.homepage = "https://github.com/bcardarella/client_side_validations"
12
- s.summary = %q{Client Side Validations}
13
- s.description = %q{Client Side Validations}
14
-
15
- s.files = Dir.glob("{lib}/**/*") + Dir.glob("{vendor}/**/*") + Dir.glob("*.gemspec")
16
- s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
17
- s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
18
- s.require_paths = ["lib"]
19
-
20
- s.add_development_dependency 'rails', '~> 3.1.0'
21
- s.add_development_dependency 'sqlite3'
22
- s.add_development_dependency 'bson_ext'
23
- s.add_development_dependency 'mongoid', '~> 2.0.0'
24
- s.add_development_dependency 'mongo_mapper','~> 0.9.0'
25
- s.add_development_dependency 'mocha'
26
- s.add_development_dependency 'simple_form', '~> 1.5.0'
27
- s.add_development_dependency 'formtastic', '~> 2.0.0'
28
-
29
- # For QUnit testing
30
- s.add_development_dependency 'sinatra', '~> 1.0'
31
- s.add_development_dependency 'shotgun'
32
- s.add_development_dependency 'thin'
33
- s.add_development_dependency 'json'
34
-
35
- ruby_minor_version = RUBY_VERSION.split('.')[1].to_i
36
- if ruby_minor_version == 8
37
- s.add_development_dependency 'minitest'
38
- s.add_development_dependency 'ruby-debug'
39
- elsif ruby_minor_version == 9
40
- s.add_development_dependency 'ruby-debug19'
41
- end
42
- end
@@ -1,13 +0,0 @@
1
- module ClientSideValidations
2
- end
3
-
4
- require 'client_side_validations/active_model' if defined?(::ActiveModel)
5
- require 'client_side_validations/active_record' if defined?(::ActiveRecord)
6
- require 'client_side_validations/mongoid' if defined?(::Mongoid)
7
- require 'client_side_validations/mongo_mapper' if defined?(::MongoMapper)
8
- require 'client_side_validations/action_view' if defined?(::ActionView)
9
- if defined?(::Rails)
10
- require 'client_side_validations/middleware'
11
- require 'client_side_validations/engine'
12
- end
13
-
@@ -1,14 +0,0 @@
1
- module ClientSideValidations::ActionView
2
- module Helpers
3
- end
4
- end
5
-
6
- require 'client_side_validations/core_ext'
7
- require 'client_side_validations/action_view/form_helper'
8
- require 'client_side_validations/action_view/form_tag_helper'
9
- require 'client_side_validations/action_view/form_builder'
10
-
11
- ActionView::Base.send(:include, ClientSideValidations::ActionView::Helpers::FormHelper)
12
- ActionView::Base.send(:include, ClientSideValidations::ActionView::Helpers::FormTagHelper)
13
- ActionView::Helpers::FormBuilder.send(:include, ClientSideValidations::ActionView::Helpers::FormBuilder)
14
-
@@ -1,157 +0,0 @@
1
- module ClientSideValidations::ActionView::Helpers
2
- module FormBuilder
3
-
4
- def self.included(base)
5
- (base.field_helpers.map(&:to_s) - %w(apply_form_for_options! label check_box radio_button fields_for hidden_field)).each do |selector|
6
- base.class_eval <<-RUBY_EVAL
7
- def #{selector}_with_client_side_validations(method, options = {})
8
- apply_client_side_validators(method, options)
9
- options.delete(:validate)
10
- #{selector}_without_client_side_validations(method, options)
11
- end
12
- RUBY_EVAL
13
-
14
- base.class_eval { alias_method_chain selector, :client_side_validations }
15
- end
16
-
17
- base.class_eval do
18
- alias_method_chain :initialize, :client_side_validations
19
- alias_method_chain :fields_for, :client_side_validations
20
- alias_method_chain :check_box, :client_side_validations
21
- alias_method_chain :radio_button, :client_side_validations
22
- alias_method_chain :select, :client_side_validations
23
- alias_method_chain :collection_select, :client_side_validations
24
- alias_method_chain :grouped_collection_select, :client_side_validations
25
- alias_method_chain :time_zone_select, :client_side_validations
26
-
27
- def self.client_side_form_settings(options, form_helper)
28
- {
29
- :type => self.to_s,
30
- :input_tag => form_helper.class.field_error_proc.call(%{<span id="input_tag" />}, Struct.new(:error_message, :tag_id).new([], "")),
31
- :label_tag => form_helper.class.field_error_proc.call(%{<label id="label_tag" />}, Struct.new(:error_message, :tag_id).new([], ""))
32
- }
33
- end
34
- end
35
- end
36
-
37
- def initialize_with_client_side_validations(object_name, object, template, options, proc)
38
- initialize_without_client_side_validations(object_name, object, template, options, proc)
39
- @options[:validators] = {}
40
- end
41
-
42
- def fields_for_with_client_side_validations(record_or_name_or_array, *args, &block)
43
- options = args.extract_options!
44
- options[:validate] ||= @options[:validate] if @options[:validate] && !options.key?(:validate)
45
- fields_for_without_client_side_validations(record_or_name_or_array, *(args << options), &block)
46
- end
47
-
48
- def check_box_with_client_side_validations(method, options = {}, checked_value = "1", unchecked_value = "0")
49
- apply_client_side_validators(method, options)
50
- check_box_without_client_side_validations(method, options, checked_value, unchecked_value)
51
- end
52
-
53
- def radio_button_with_client_side_validations(method, tag_value, options = {})
54
- apply_client_side_validators(method, options)
55
- radio_button_without_client_side_validations(method, tag_value, options)
56
- end
57
-
58
- def select_with_client_side_validations(method, choices, options = {}, html_options = {})
59
- apply_client_side_validators(method, html_options)
60
- select_without_client_side_validations(method, choices, options, html_options)
61
- end
62
-
63
- def collection_select_with_client_side_validations(method, collection, value_method, text_method, options = {}, html_options = {})
64
- apply_client_side_validators(method, html_options)
65
- collection_select_without_client_side_validations(method, collection, value_method, text_method, options, html_options)
66
- end
67
-
68
- def grouped_collection_select_with_client_side_validations(method, collection, group_method, group_label_method, option_key_method, option_value_method, options = {}, html_options = {})
69
- apply_client_side_validators(method, html_options)
70
- grouped_collection_select_without_client_side_validations(method, collection, group_method, group_label_method, option_key_method, option_value_method, options, html_options)
71
- end
72
-
73
- def time_zone_select_with_client_side_validations(method, priority_zones = nil, options = {}, html_options = {})
74
- apply_client_side_validators(method, html_options)
75
- time_zone_select_without_client_side_validations(method, priority_zones = nil, options, html_options)
76
- end
77
-
78
- private
79
-
80
- def apply_client_side_validators(method, options = {})
81
- if @options[:validate] && options[:validate] != false && validators = filter_validators(method, options[:validate])
82
- options.merge!("data-validate" => true)
83
- @options[:validators].merge!("#{@object_name}[#{method}]#{options[:multiple] ? "[]" : nil}" => validators)
84
- end
85
- end
86
-
87
- def filter_validators(method, filters)
88
- if validators = @object.client_side_validation_hash[method]
89
- unfiltered_validators = validators.inject({}) do |unfiltered_validators, validator|
90
- unfiltered_validators[validator.first] = validator.last
91
- if has_filter_for_validator?(validator, filters)
92
- if filter_validator?(validator, filters)
93
- unfiltered_validators.delete(validator.first)
94
- elsif force_validator_despite_conditional?(validator, filters) && !can_run_validator?(validator, method)
95
- unfiltered_validators.delete(validator.first)
96
- end
97
- else
98
- if (conditional = (validator.last[:if] || validator.last[:unless])) && conditional.is_a?(Symbol) && !conditional_method_is_change_method?(conditional, method)
99
- unfiltered_validators.delete(validator.first)
100
- end
101
- end
102
- unfiltered_validators[validator.first].delete(:if) if unfiltered_validators[validator.first]
103
- unfiltered_validators[validator.first].delete(:unless) if unfiltered_validators[validator.first]
104
- unfiltered_validators
105
- end
106
-
107
- unfiltered_validators.empty? ? nil : unfiltered_validators
108
- end
109
- end
110
-
111
- def has_filter_for_validator?(validator, filters)
112
- filters && (filters == true || filters.key?(validator.first))
113
- end
114
-
115
- def filter_validator?(validator, filters)
116
- filters != true && filters[validator.first] == false
117
- end
118
-
119
- def force_validator_despite_conditional?(validator, filters)
120
- filters == true || filters[validator.first] == true
121
- end
122
-
123
- def can_run_validator?(validator, method)
124
- result = true
125
- if_result = run_if_validator(validator.last[:if], method)
126
- unless_result = run_unless_validator(validator.last[:unless], method)
127
- result = result && if_result unless if_result.nil?
128
- result = result && unless_result unless unless_result.nil?
129
- result
130
- end
131
-
132
- def run_if_validator(conditional, method)
133
- if conditional
134
- if conditional.is_a?(Symbol)
135
- conditional_method_is_change_method?(conditional, method) ? true : !!@object.send(conditional)
136
- else
137
- !!conditional.call(@object)
138
- end
139
- end
140
- end
141
-
142
- def run_unless_validator(conditional, method)
143
- if conditional
144
- if conditional.is_a?(Symbol)
145
- conditional_method_is_change_method?(conditional, method) ? true : !@object.send(conditional)
146
- else
147
- !conditional.call(@object)
148
- end
149
- end
150
- end
151
-
152
- def conditional_method_is_change_method?(conditional, method)
153
- conditional.to_sym == "#{method}_changed?".to_sym
154
- end
155
- end
156
- end
157
-