html5_validators 1.3.0 → 1.4.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: dec1cf5335bfb01cad02332dbd5630bb2312f023
4
- data.tar.gz: fc500e31d89cd2643d3b84f44b3fcd3730abb9f9
3
+ metadata.gz: 8891b35efbfb6e9971f313d0d12e8444f0c4dae2
4
+ data.tar.gz: 2647e789f4e01c23c02c30edf310410fb70d44a5
5
5
  SHA512:
6
- metadata.gz: 1e5b3f52300d49e0ebbd992e60ce5b7c21192311e80ccebf555599a5942485ba853568d3b05d8c030ee1662e7be7b561d1dd2292ff1f1f591994349771b2c576
7
- data.tar.gz: 8236980db90776ac268c598154ece5f5fff3c006cc45053d84cb2de1006769f510243d034ec79ce67bc85c233a5287b26ae92ff65877481834f611530aa4bf54
6
+ metadata.gz: bf6eccda55ec7bb0b0aabfb012d6ba3609b269aaba7e5f0489aa165447f6677f6c5b74127bbae6d146af5e3e2b3e45ff5eda273f144c13626e4ce06d2fe51196
7
+ data.tar.gz: 55d5b995754d8ba2bec5201a49bad590d5c73e8224927e6e577e655a2669f261be05dc53b1d722b2ea69de84f6fb9a06bf27419c3b04296dc8c395e45810d2f4
data/.travis.yml CHANGED
@@ -1,16 +1,13 @@
1
1
  language: ruby
2
2
 
3
3
  rvm:
4
- - 1.8.7
5
- - 1.9.3
6
4
  - 2.0.0
7
5
  - 2.1
8
- - 2.2.2
6
+ - 2.2.4
7
+ - 2.3.0
9
8
  - ruby-head
10
9
 
11
10
  gemfile:
12
- - gemfiles/Gemfile.rails-3.0
13
- - gemfiles/Gemfile.rails-3.1
14
11
  - gemfiles/Gemfile.rails-3.2
15
12
  - gemfiles/Gemfile.rails-4.0
16
13
  - gemfiles/Gemfile.rails-4.1
@@ -21,30 +18,14 @@ sudo: false
21
18
 
22
19
  matrix:
23
20
  exclude:
24
- - rvm: 1.8.7
25
- gemfile: gemfiles/Gemfile.rails-4.0
26
- - rvm: 1.8.7
27
- gemfile: gemfiles/Gemfile.rails-4.1
28
- - rvm: 1.8.7
29
- gemfile: gemfiles/Gemfile.rails-4.2
30
- - rvm: 1.8.7
31
- gemfile: gemfiles/Gemfile.rails-edge
32
- - rvm: 1.9.3
33
- gemfile: gemfiles/Gemfile.rails-edge
34
21
  - rvm: 2.0.0
35
22
  gemfile: gemfiles/Gemfile.rails-edge
36
23
  - rvm: 2.1
37
24
  gemfile: gemfiles/Gemfile.rails-edge
38
- - rvm: 2.2.2
39
- gemfile: gemfiles/Gemfile.rails-3.0
40
- - rvm: 2.2.2
41
- gemfile: gemfiles/Gemfile.rails-3.1
42
- - rvm: 2.2.2
25
+ - rvm: 2.2.4
26
+ gemfile: gemfiles/Gemfile.rails-3.2
27
+ - rvm: 2.3.0
43
28
  gemfile: gemfiles/Gemfile.rails-3.2
44
- - rvm: ruby-head
45
- gemfile: gemfiles/Gemfile.rails-3.0
46
- - rvm: ruby-head
47
- gemfile: gemfiles/Gemfile.rails-3.1
48
29
  - rvm: ruby-head
49
30
  gemfile: gemfiles/Gemfile.rails-3.2
50
31
  allow_failures:
data/README.md CHANGED
@@ -167,9 +167,9 @@ end
167
167
 
168
168
  ## Supported versions
169
169
 
170
- * Ruby 1.8.7, 1.9.2, 1.9.3, 2.0, 2.1, 2.2, 2.3 (trunk)
170
+ * Ruby 2.0, 2.1, 2.2, 2.3, 2.4 (trunk)
171
171
 
172
- * Rails 3.0.x, 3.1.x, 3.2.x, 4.0.x, 4.1, 4.2, 5.0 (edge)
172
+ * Rails 3.2.x, 4.0.x, 4.1, 4.2, 5.0 (edge)
173
173
 
174
174
  * HTML5 compatible browsers
175
175
 
data/Rakefile CHANGED
@@ -5,6 +5,6 @@ require 'rspec/core'
5
5
  require 'rspec/core/rake_task'
6
6
 
7
7
  task :noop do; end
8
- task :default => :spec
8
+ task default: :spec
9
9
 
10
- RSpec::Core::RakeTask.new(:spec => :noop)
10
+ RSpec::Core::RakeTask.new(spec: :noop)
@@ -2,14 +2,12 @@ source 'https://rubygems.org'
2
2
 
3
3
  gem 'railties', '~> 3.2.0'
4
4
  gem 'activerecord', '~> 3.2.0'
5
- if RUBY_VERSION <= '1.8.7'
6
- gem 'i18n', '~> 0.6.11'
7
- end
8
5
  gem 'nokogiri', '~> 1.5.0'
9
6
  gem 'rspec-rails', '~> 2.14.1'
7
+ gem 'test-unit'
10
8
  gem 'capybara', '~> 2.0.0'
11
9
  # stick to versions that work under Ruby 1.8 for now
12
10
  gem 'mime-types', '< 2'
13
11
  gem 'rubyzip', '< 1'
14
12
 
15
- gemspec :path => '..'
13
+ gemspec path: '..'
@@ -3,4 +3,4 @@ source 'https://rubygems.org'
3
3
  gem 'railties', '~> 4.0.0'
4
4
  gem 'activerecord', '~> 4.0.0'
5
5
 
6
- gemspec :path => '..'
6
+ gemspec path: '..'
@@ -3,4 +3,4 @@ source 'https://rubygems.org'
3
3
  gem 'railties', '~> 4.1.0'
4
4
  gem 'activerecord', '~> 4.1.0'
5
5
 
6
- gemspec :path => '..'
6
+ gemspec path: '..'
@@ -3,4 +3,4 @@ source 'https://rubygems.org'
3
3
  gem 'railties', '~> 4.2.0'
4
4
  gem 'activerecord', '~> 4.2.0'
5
5
 
6
- gemspec :path => '..'
6
+ gemspec path: '..'
@@ -1,7 +1,8 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
- gem 'railties', :git => 'git://github.com/rails/rails.git'
4
- gem 'activerecord', :git => 'git://github.com/rails/rails.git'
5
- gem 'arel', :git => 'git://github.com/rails/arel.git'
3
+ gem 'railties', git: 'git://github.com/rails/rails.git'
4
+ gem 'rack', git: 'git://github.com/rack/rack.git'
5
+ gem 'activerecord', git: 'git://github.com/rails/rails.git'
6
+ gem 'arel', git: 'git://github.com/rails/arel.git'
6
7
 
7
- gemspec :path => '..'
8
+ gemspec path: '..'
@@ -9,7 +9,7 @@ module ActiveModel
9
9
 
10
10
  def attribute_maxlength(attribute)
11
11
  self.validators.grep(LengthValidator).select {|v|
12
- v.attributes.include?(attribute.to_sym) && (v.options.keys & [:maximum, :is]).any? && (v.options.keys & [:if, :unless, :allow_nil, :allow_blank, :tokenizer]).empty?
12
+ v.attributes.include?(attribute.to_sym) && (v.options.keys & [:maximum, :is]).any? && (v.options.keys & [:if, :unless, :tokenizer]).empty?
13
13
  }.map {|v| v.options.slice(:maximum, :is)}.map(&:values).flatten.max
14
14
  end
15
15
 
@@ -3,7 +3,7 @@ module Html5Validators
3
3
  extend ActiveSupport::Concern
4
4
 
5
5
  included do
6
- cattr_accessor :auto_html5_validation, :instance_accessor => false, :instance_reader => false, :instance_writer => false
6
+ cattr_accessor :auto_html5_validation, instance_accessor: false, instance_reader: false, instance_writer: false
7
7
  end
8
8
  end
9
9
  end
@@ -8,7 +8,7 @@ module Html5Validators
8
8
  def inherited(kls)
9
9
  super
10
10
  kls.class_eval do
11
- cattr_accessor :auto_html5_validation, :instance_accessor => false, :instance_reader => false, :instance_writer => false
11
+ cattr_accessor :auto_html5_validation, instance_accessor: false, instance_reader: false, instance_writer: false
12
12
  end if kls.superclass == ActiveRecord::Base
13
13
  end
14
14
  end
@@ -16,7 +16,7 @@ module Html5Validators
16
16
  included do
17
17
  # Existing subclasses pick up the model extension as well
18
18
  self.descendants.each do |kls|
19
- cattr_accessor :auto_html5_validation, :instance_accessor => false, :instance_reader => false, :instance_writer => false if kls.superclass == ActiveRecord::Base
19
+ kls.cattr_accessor :auto_html5_validation, instance_accessor: false, instance_reader: false, instance_writer: false if kls.superclass == ActiveRecord::Base
20
20
  end
21
21
  end
22
22
  end
@@ -1,3 +1,3 @@
1
1
  module Html5Validators
2
- VERSION = '1.3.0'
2
+ VERSION = '1.4.0'
3
3
  end
@@ -16,18 +16,11 @@ module Html5Validators
16
16
  ActiveSupport.on_load(:active_record) do
17
17
  require 'html5_validators/active_model/helper_methods'
18
18
  require 'html5_validators/active_model/validations'
19
- if (Rails.version < '3.1.0.beta2') && (Rails.version != '3.1.0')
20
- require 'html5_validators/active_model/initializer_monkey_patches'
21
- end
22
19
  require 'html5_validators/active_record/base'
23
20
  end
24
21
  ActiveSupport.on_load(:action_view) do
25
22
  if ActionPack::VERSION::STRING >= '4'
26
- if RUBY_VERSION > '2'
27
- require 'html5_validators/action_view/form_helpers'
28
- else
29
- require 'html5_validators/action_view/form_helpers_ruby1'
30
- end
23
+ require 'html5_validators/action_view/form_helpers'
31
24
  else
32
25
  require 'html5_validators/action_view/form_helpers_rails3'
33
26
  end
data/spec/fake_app.rb CHANGED
@@ -2,24 +2,24 @@ require 'active_record'
2
2
  require 'action_controller/railtie'
3
3
 
4
4
  # config
5
- ActiveRecord::Base.establish_connection(:adapter => 'sqlite3', :database => ':memory:')
5
+ ActiveRecord::Base.establish_connection(adapter: 'sqlite3', database: ':memory:')
6
6
 
7
7
  app = Class.new(Rails::Application)
8
8
  app.config.secret_token = "You know I'm born to lose, and gambling's for fools, But that's the way I like it baby, I don't wanna live for ever, And don't forget the joker!"
9
- app.config.session_store :cookie_store, :key => '_myapp_session'
9
+ app.config.session_store :cookie_store, key: '_myapp_session'
10
10
  app.config.active_support.deprecation = :log
11
11
  app.config.eager_load = false
12
12
  app.initialize!
13
13
 
14
14
  # routes
15
15
  app.routes.draw do
16
- resources :people, :only => [:new, :create] do
16
+ resources :people, only: [:new, :create] do
17
17
  collection do
18
18
  get :new_without_html5_validation
19
19
  get :new_with_required_true
20
20
  end
21
21
  end
22
- resources :items, :only => [:new, :create] do
22
+ resources :items, only: [:new, :create] do
23
23
  collection do
24
24
  get :new_without_html5_validation
25
25
  get :new_with_required_true
@@ -47,7 +47,7 @@ class ApplicationController < ActionController::Base; end
47
47
  class PeopleController < ApplicationController
48
48
  def new
49
49
  @person = Person.new
50
- render :inline => <<-ERB
50
+ render inline: <<-ERB
51
51
  <%= form_for @person do |f| %>
52
52
  <%= f.text_field :name %>
53
53
  <%= f.text_area :bio %>
@@ -57,8 +57,8 @@ ERB
57
57
 
58
58
  def new_without_html5_validation
59
59
  @person = Person.new
60
- render :inline => <<-ERB
61
- <%= form_for @person, :auto_html5_validation => false do |f| %>
60
+ render inline: <<-ERB
61
+ <%= form_for @person, auto_html5_validation: false do |f| %>
62
62
  <%= f.text_field :name %>
63
63
  <%= f.text_field :email %>
64
64
  <% end %>
@@ -67,9 +67,9 @@ ERB
67
67
 
68
68
  def new_with_required_true
69
69
  @person = Person.new
70
- render :inline => <<-ERB
70
+ render inline: <<-ERB
71
71
  <%= form_for @person do |f| %>
72
- <%= f.text_field :email, :required => true %>
72
+ <%= f.text_field :email, required: true %>
73
73
  <% end %>
74
74
  ERB
75
75
  end
@@ -77,7 +77,7 @@ end
77
77
  class ItemsController < ApplicationController
78
78
  def new
79
79
  @item = Item.new
80
- render :inline => <<-ERB
80
+ render inline: <<-ERB
81
81
  <%= form_for @item do |f| %>
82
82
  <%= f.text_field :name %>
83
83
  <%= f.text_area :description %>
@@ -87,8 +87,8 @@ ERB
87
87
 
88
88
  def new_without_html5_validation
89
89
  @item = Item.new
90
- render :inline => <<-ERB
91
- <%= form_for @item, :auto_html5_validation => false do |f| %>
90
+ render inline: <<-ERB
91
+ <%= form_for @item, auto_html5_validation: false do |f| %>
92
92
  <%= f.text_field :name %>
93
93
  <%= f.text_area :description %>
94
94
  <% end %>
@@ -97,9 +97,9 @@ ERB
97
97
 
98
98
  def new_with_required_true
99
99
  @item = Item.new
100
- render :inline => <<-ERB
100
+ render inline: <<-ERB
101
101
  <%= form_for @item do |f| %>
102
- <%= f.text_field :name, :required => true %>
102
+ <%= f.text_field :name, required: true %>
103
103
  <% end %>
104
104
  ERB
105
105
  end
@@ -75,8 +75,8 @@ feature 'person#new' do
75
75
 
76
76
  context 'with maxlength validation' do
77
77
  background do
78
- Person.validates_length_of :name, {:maximum => 20}
79
- Person.validates_length_of :bio, {:maximum => 100}
78
+ Person.validates_length_of :name, maximum: 20
79
+ Person.validates_length_of :bio, maximum: 100
80
80
  end
81
81
 
82
82
  scenario 'new form' do
@@ -89,8 +89,8 @@ feature 'person#new' do
89
89
 
90
90
  context 'with minlength validation' do
91
91
  background do
92
- Person.validates_length_of :name, {:minimum => 3}
93
- Person.validates_length_of :bio, {:minimum => 10}
92
+ Person.validates_length_of :name, minimum: 3
93
+ Person.validates_length_of :bio, minimum: 10
94
94
  end
95
95
 
96
96
  scenario 'new form' do
@@ -177,8 +177,8 @@ feature 'item#new' do
177
177
 
178
178
  context 'with maxlength validation' do
179
179
  background do
180
- Item.validates_length_of :name, {:maximum => 20 }
181
- Item.validates_length_of :description, {:maximum => 100}
180
+ Item.validates_length_of :name, maximum: 20
181
+ Item.validates_length_of :description, maximum: 100
182
182
  end
183
183
 
184
184
  scenario 'new form' do
@@ -191,8 +191,8 @@ feature 'item#new' do
191
191
 
192
192
  context 'with minlength validation' do
193
193
  background do
194
- Item.validates_length_of :name, {:minimum => 3}
195
- Item.validates_length_of :description, {:minimum => 10}
194
+ Item.validates_length_of :name, minimum: 3
195
+ Item.validates_length_of :description, minimum: 10
196
196
  end
197
197
 
198
198
  scenario 'new form' do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: html5_validators
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0
4
+ version: 1.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Akira Matsuda
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-07-23 00:00:00.000000000 Z
11
+ date: 2016-03-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec-rails
@@ -81,8 +81,6 @@ files:
81
81
  - MIT-LICENSE
82
82
  - README.md
83
83
  - Rakefile
84
- - gemfiles/Gemfile.rails-3.0
85
- - gemfiles/Gemfile.rails-3.1
86
84
  - gemfiles/Gemfile.rails-3.2
87
85
  - gemfiles/Gemfile.rails-4.0
88
86
  - gemfiles/Gemfile.rails-4.1
@@ -92,9 +90,7 @@ files:
92
90
  - lib/html5_validators.rb
93
91
  - lib/html5_validators/action_view/form_helpers.rb
94
92
  - lib/html5_validators/action_view/form_helpers_rails3.rb
95
- - lib/html5_validators/action_view/form_helpers_ruby1.rb
96
93
  - lib/html5_validators/active_model/helper_methods.rb
97
- - lib/html5_validators/active_model/initializer_monkey_patches.rb
98
94
  - lib/html5_validators/active_model/validations.rb
99
95
  - lib/html5_validators/active_record/base.rb
100
96
  - lib/html5_validators/version.rb
@@ -122,7 +118,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
122
118
  version: '0'
123
119
  requirements: []
124
120
  rubyforge_project: html5_validators
125
- rubygems_version: 2.4.5
121
+ rubygems_version: 2.5.1
126
122
  signing_key:
127
123
  specification_version: 4
128
124
  summary: Automatic client side validation using HTML5 Form Validation
@@ -131,3 +127,4 @@ test_files:
131
127
  - spec/features/validation_spec.rb
132
128
  - spec/models/active_record/inherited_spec.rb
133
129
  - spec/spec_helper.rb
130
+ has_rdoc:
@@ -1,12 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- gem 'railties', '~> 3.0.0'
4
- gem 'activerecord', '~> 3.0.0'
5
- gem 'nokogiri', '~> 1.5.0'
6
- gem 'rspec-rails', '~> 2.14.1'
7
- gem 'capybara', '~> 2.0.0'
8
- # stick to versions that work under Ruby 1.8 for now
9
- gem 'mime-types', '< 2'
10
- gem 'rubyzip', '< 1'
11
-
12
- gemspec :path => '..'
@@ -1,15 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- gem 'railties', '~> 3.1.0'
4
- gem 'activerecord', '~> 3.1.0'
5
- if RUBY_VERSION <= '1.8.7'
6
- gem 'i18n', '~> 0.6.11'
7
- end
8
- gem 'nokogiri', '~> 1.5.0'
9
- gem 'rspec-rails', '~> 2.14.1'
10
- gem 'capybara', '~> 2.0.0'
11
- # stick to versions that work under Ruby 1.8 for now
12
- gem 'mime-types', '< 2'
13
- gem 'rubyzip', '< 1'
14
-
15
- gemspec :path => '..'
@@ -1,79 +0,0 @@
1
- # Legacy Ruby 1.x on Rails 4.x support
2
- module Html5Validators
3
- module ActionViewExtension
4
- def inject_required_attribute
5
- if object.class.ancestors.include?(ActiveModel::Validations) && (object.auto_html5_validation != false) && (object.class.auto_html5_validation != false)
6
- @options["required"] ||= @options[:required] || object.class.attribute_required?(@method_name)
7
- end
8
- end
9
-
10
- def inject_maxlength_attribute
11
- if object.class.ancestors.include?(ActiveModel::Validations) && (object.auto_html5_validation != false) && (object.class.auto_html5_validation != false)
12
- @options["maxlength"] ||= @options[:maxlength] || object.class.attribute_maxlength(@method_name)
13
- @options["minlength"] ||= @options[:minlength] || object.class.attribute_minlength(@method_name)
14
- end
15
- end
16
-
17
- def inject_numericality_attributes
18
- if object.class.ancestors.include?(ActiveModel::Validations) && (object.auto_html5_validation != false) && (object.class.auto_html5_validation != false)
19
- @options["max"] ||= @options["max"] || @options[:max] || object.class.attribute_max(@method_name)
20
- @options["min"] ||= @options["min"] || @options[:min] || object.class.attribute_min(@method_name)
21
- end
22
- end
23
- end
24
- end
25
-
26
-
27
- module ActionView
28
- module Helpers
29
- module FormHelper
30
- def form_for_with_auto_html5_validation_option(record, options = {}, &proc)
31
- if record.respond_to?(:auto_html5_validation=)
32
- if !Html5Validators.enabled || (options[:auto_html5_validation] == false)
33
- record.auto_html5_validation = false
34
- end
35
- end
36
- form_for_without_auto_html5_validation_option record, options, &proc
37
- end
38
- alias_method_chain :form_for, :auto_html5_validation_option
39
- end
40
-
41
- module Tags
42
- class Base #:nodoc:
43
- include Html5Validators::ActionViewExtension
44
- end
45
-
46
- class TextField
47
- def render_with_html5_attributes
48
- inject_required_attribute
49
- inject_maxlength_attribute
50
- inject_numericality_attributes
51
-
52
- render_without_html5_attributes
53
- end
54
- alias_method_chain :render, :html5_attributes
55
- end
56
-
57
- class TextArea
58
- def render_with_html5_attributes
59
- inject_required_attribute
60
- inject_maxlength_attribute
61
-
62
- render_without_html5_attributes
63
- end
64
- alias_method_chain :render, :html5_attributes
65
- end
66
-
67
- #TODO probably I have to add some more classes here
68
- [RadioButton, CheckBox, Select, DateSelect, TimeZoneSelect].each do |kls|
69
- kls.class_eval do
70
- def render_with_html5_attributes
71
- inject_required_attribute
72
- render_without_html5_attributes
73
- end
74
- alias_method_chain :render, :html5_attributes
75
- end
76
- end
77
- end
78
- end
79
- end
@@ -1,29 +0,0 @@
1
- # A freedom patch for AMo 3.0.x and 3.1.0.beta1
2
- # see: https://github.com/rails/rails/pull/1085
3
- module ActiveModel
4
- module Validations
5
- class LengthValidator
6
- def initialize(options)
7
- if range = (options.delete(:in) || options.delete(:within))
8
- raise ArgumentError, ":in and :within must be a Range" unless range.is_a?(Range)
9
- options[:minimum], options[:maximum] = range.begin, range.end
10
- options[:maximum] -= 1 if range.exclude_end?
11
- end
12
-
13
- super
14
- end
15
-
16
- def validate_each_with_default_tokenizer(record, attribute, value)
17
- @options = (options || {}).reverse_merge(:tokenizer => DEFAULT_TOKENIZER).freeze
18
- validate_each_without_default_tokenizer record, attribute, value
19
- end
20
- alias_method_chain :validate_each, :default_tokenizer
21
- end
22
-
23
- class NumericalityValidator
24
- def initialize(options)
25
- super
26
- end
27
- end
28
- end
29
- end