client_side_validations 8.0.0 → 8.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f49979931218b2246d124cd4a5e1829cb86443de
4
- data.tar.gz: 9b4587a126d31aa338aed01dbf98df62445724be
3
+ metadata.gz: 58bb726eb3177b25d2b654c6f876fd012927ed44
4
+ data.tar.gz: 99f29f39c7336b9346a30978e8151bb846240022
5
5
  SHA512:
6
- metadata.gz: b60d2af0e7c814f60930d6b82fa18185c13e38c8939ca23c1396e1ecaf9881054d1bef455196302daaa7b0e73245adf8d3e3462a77531225978ae6d4e77891ed
7
- data.tar.gz: d6a4c75565e0bf8343a7c07e7935c135e76fb8bce76623702a583ff021aa849da91547d086f4f75b6f509ebc46311d7cb19e38d7c10edcd2fe722ce5dcc10d29
6
+ metadata.gz: 1d1cf22aa5f09915484bf014081e3676856b2b3b65ac8db187340a58a7511eeb3a4d658ddf2731dee8e2d4ad30734fe4f1879ca519c8aa30b3fc3d9204892285
7
+ data.tar.gz: c8b8c742525848a3779d7a7326791f520901dbf0dcabc54873284775e368464ce075a843c66dc57957cf16382dd4c7fe1ac59d6407fcd5cb2bb37ef8cd9e6449
@@ -1,5 +1,10 @@
1
1
  # Changelog
2
2
 
3
+ ## 8.0.1 (2017-01-26)
4
+
5
+ * Under the hood improvements to the form helper
6
+ * Include license in the gem
7
+
3
8
  ## 8.0.0 (2017-01-22)
4
9
 
5
10
  * Change internals to get 4.0 score on Code Climate
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2017 Geremia Taglialatela, Brian Cardarella
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -9,9 +9,7 @@ module ClientSideValidations
9
9
  def form_for(record, options = {}, &block)
10
10
  return super unless options[:validate]
11
11
 
12
- # Always turn off HTML5 Validations
13
- options[:html] ||= {}
14
- options[:html][:novalidate] = 'novalidate'
12
+ turn_off_html5_validations! options
15
13
 
16
14
  case record
17
15
  when String, Symbol
@@ -33,14 +31,12 @@ module ClientSideValidations
33
31
  if assign_script_to_content_for(options[:validate], script)
34
32
  form
35
33
  else
36
- # rubocop:disable OutputSafety
37
- [form, script].join.html_safe
38
- # rubocop:enable OutputSafety
34
+ form << script
39
35
  end
40
36
  end
41
37
 
42
38
  def assign_script_to_content_for(name, script)
43
- return false unless name && name != true
39
+ return false if name == true
44
40
 
45
41
  # rubocop:disable OutputSafety
46
42
  content_for name, script.html_safe
@@ -54,7 +50,7 @@ module ClientSideValidations
54
50
  options[:html][:validate] = true if options[:validate]
55
51
  end
56
52
 
57
- def fields_for(record_or_name_or_array, record_object = nil, options = {}, &block)
53
+ def fields_for(record_name, record_object = nil, options = {}, &block)
58
54
  # Order matters here. Rails mutates the `options` object
59
55
  output = super
60
56
 
@@ -79,21 +75,17 @@ module ClientSideValidations
79
75
 
80
76
  def construct_validators
81
77
  @validators.each_with_object({}) do |object_opts, validator_hash|
78
+ next unless object_opts[0].respond_to?(:client_side_validation_hash)
79
+
82
80
  option_hash = object_opts[1].each_with_object({}) do |attr, result|
83
81
  result[attr[0]] = attr[1][:options]
84
82
  end
85
83
 
86
- validation_hash =
87
- if object_opts[0].respond_to?(:client_side_validation_hash)
88
- object_opts[0].client_side_validation_hash(option_hash)
89
- else
90
- {}
91
- end
84
+ validation_hash = object_opts[0].client_side_validation_hash(option_hash)
92
85
 
93
86
  option_hash.each_key do |attr|
94
- if validation_hash[attr]
95
- validator_hash.merge!(object_opts[1][attr][:name] => validation_hash[attr])
96
- end
87
+ next unless validation_hash.key?(attr)
88
+ validator_hash[object_opts[1][attr][:name]] = validation_hash[attr]
97
89
  end
98
90
  end
99
91
  end
@@ -114,6 +106,11 @@ module ClientSideValidations
114
106
  def numericality_patterns
115
107
  "/^(-|\\+)?(?:\\d+|\\d{1,3}(?:\\#{number_format[:delimiter]}\\d{3})+)(?:\\#{number_format[:separator]}\\d*)?$/"
116
108
  end
109
+
110
+ def turn_off_html5_validations!(options)
111
+ options[:html] ||= {}
112
+ options[:html][:novalidate] = 'novalidate'
113
+ end
117
114
  end
118
115
  end
119
116
  end
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module ClientSideValidations
3
- VERSION = '8.0.0'.freeze
3
+ VERSION = '8.0.1'.freeze
4
4
  end
@@ -1,6 +1,6 @@
1
1
 
2
2
  /*!
3
- * Client Side Validations - v8.0.0 (https://github.com/DavyJonesLocker/client_side_validations)
3
+ * Client Side Validations - v8.0.1 (https://github.com/DavyJonesLocker/client_side_validations)
4
4
  * Copyright (c) 2017 Geremia Taglialatela, Brian Cardarella
5
5
  * Licensed under MIT (http://opensource.org/licenses/mit-license.php)
6
6
  */
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: client_side_validations
3
3
  version: !ruby/object:Gem::Version
4
- version: 8.0.0
4
+ version: 8.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Geremia Taglialatela
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2017-01-22 00:00:00.000000000 Z
12
+ date: 2017-01-26 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -264,6 +264,7 @@ extensions: []
264
264
  extra_rdoc_files: []
265
265
  files:
266
266
  - CHANGELOG.md
267
+ - LICENSE.md
267
268
  - README.md
268
269
  - lib/client_side_validations.rb
269
270
  - lib/client_side_validations/action_view.rb