judge-simple_form 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +10 -2
- data/lib/judge/simple_form.rb +6 -3
- data/lib/judge/simple_form/version.rb +1 -1
- metadata +41 -62
- data/.travis.yml +0 -5
- data/Gemfile +0 -3
- data/Rakefile +0 -6
- data/judge-simple_form.gemspec +0 -28
- data/spec/factories.rb +0 -5
- data/spec/judge-simple_form_spec.rb +0 -21
- data/spec/setup.rb +0 -20
- data/spec/spec_helper.rb +0 -17
data/README.md
CHANGED
@@ -1,12 +1,14 @@
|
|
1
1
|
# judge-simple_form
|
2
2
|
|
3
|
+
[![Build status](https://secure.travis-ci.org/joecorcoran/judge-simple_form.png?branch=master)](http://travis-ci.org/joecorcoran/judge-simple_form)
|
4
|
+
|
3
5
|
This is an adapter gem which allows you to use [Judge](http://judge.joecorcoran.co.uk) from within your [SimpleForm](http://github.com/plataformatec/simple_form) forms.
|
4
6
|
|
5
7
|
## Usage
|
6
8
|
|
7
9
|
Do this in your Gemfile:
|
8
10
|
|
9
|
-
gem
|
11
|
+
gem 'judge-simple_form'
|
10
12
|
|
11
13
|
Then add <code>:validate => true</code> to the input options in your views. That's all.
|
12
14
|
|
@@ -16,4 +18,10 @@ Then add <code>:validate => true</code> to the input options in your views. That
|
|
16
18
|
|
17
19
|
## Judge
|
18
20
|
|
19
|
-
Judge is a client-side validation gem for Rails 3. You can read more about it at [judge.joecorcoran.co.uk](http://judge.joecorcoran.co.uk).
|
21
|
+
Judge is a client-side validation gem for Rails 3. You can read more about it at [judge.joecorcoran.co.uk](http://judge.joecorcoran.co.uk).
|
22
|
+
|
23
|
+
## License
|
24
|
+
|
25
|
+
Released under an MIT license (see LICENSE.txt).
|
26
|
+
|
27
|
+
http://blog.joecorcoran.co.uk
|
data/lib/judge/simple_form.rb
CHANGED
@@ -1,16 +1,19 @@
|
|
1
|
-
require
|
1
|
+
require 'judge' unless defined?(::Judge::VERSION)
|
2
|
+
require 'simple_form' unless defined?(::SimpleForm)
|
2
3
|
|
3
4
|
module Judge
|
4
5
|
module SimpleForm
|
5
6
|
module Inputs
|
6
7
|
|
8
|
+
include Judge::Html
|
9
|
+
|
7
10
|
def self.included(base)
|
8
11
|
base.send(:alias_method, :old_input_html_options, :input_html_options)
|
9
12
|
base.send(:alias_method, :input_html_options, :new_input_html_options)
|
10
13
|
end
|
11
14
|
|
12
15
|
def new_input_html_options
|
13
|
-
attrs = options[:validate].present? ?
|
16
|
+
attrs = options[:validate].present? ? attrs_for(object, attribute_name) : {}
|
14
17
|
attrs.merge(old_input_html_options)
|
15
18
|
end
|
16
19
|
|
@@ -18,4 +21,4 @@ module Judge
|
|
18
21
|
end
|
19
22
|
end
|
20
23
|
|
21
|
-
::SimpleForm::Inputs::Base.send(:include, Judge::SimpleForm::Inputs)
|
24
|
+
::SimpleForm::Inputs::Base.send(:include, ::Judge::SimpleForm::Inputs)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: judge-simple_form
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,22 +9,27 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2013-02-27 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: judge
|
16
|
-
requirement:
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version: '
|
21
|
+
version: '2.0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements:
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '2.0'
|
25
30
|
- !ruby/object:Gem::Dependency
|
26
31
|
name: simple_form
|
27
|
-
requirement:
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
28
33
|
none: false
|
29
34
|
requirements:
|
30
35
|
- - ~>
|
@@ -32,10 +37,15 @@ dependencies:
|
|
32
37
|
version: '2.0'
|
33
38
|
type: :runtime
|
34
39
|
prerelease: false
|
35
|
-
version_requirements:
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ~>
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '2.0'
|
36
46
|
- !ruby/object:Gem::Dependency
|
37
47
|
name: rake
|
38
|
-
requirement:
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
39
49
|
none: false
|
40
50
|
requirements:
|
41
51
|
- - ! '>='
|
@@ -43,10 +53,15 @@ dependencies:
|
|
43
53
|
version: '0'
|
44
54
|
type: :development
|
45
55
|
prerelease: false
|
46
|
-
version_requirements:
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
47
62
|
- !ruby/object:Gem::Dependency
|
48
63
|
name: rails
|
49
|
-
requirement:
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
50
65
|
none: false
|
51
66
|
requirements:
|
52
67
|
- - ~>
|
@@ -54,80 +69,54 @@ dependencies:
|
|
54
69
|
version: '3.2'
|
55
70
|
type: :development
|
56
71
|
prerelease: false
|
57
|
-
version_requirements:
|
58
|
-
- !ruby/object:Gem::Dependency
|
59
|
-
name: sqlite3-ruby
|
60
|
-
requirement: &2153224740 !ruby/object:Gem::Requirement
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
61
73
|
none: false
|
62
74
|
requirements:
|
63
75
|
- - ~>
|
64
76
|
- !ruby/object:Gem::Version
|
65
|
-
version:
|
66
|
-
type: :development
|
67
|
-
prerelease: false
|
68
|
-
version_requirements: *2153224740
|
77
|
+
version: '3.2'
|
69
78
|
- !ruby/object:Gem::Dependency
|
70
|
-
name:
|
71
|
-
requirement:
|
79
|
+
name: sqlite3
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
72
81
|
none: false
|
73
82
|
requirements:
|
74
83
|
- - ~>
|
75
84
|
- !ruby/object:Gem::Version
|
76
|
-
version:
|
85
|
+
version: 1.3.7
|
77
86
|
type: :development
|
78
87
|
prerelease: false
|
79
|
-
version_requirements:
|
80
|
-
- !ruby/object:Gem::Dependency
|
81
|
-
name: formtastic
|
82
|
-
requirement: &2153223600 !ruby/object:Gem::Requirement
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
83
89
|
none: false
|
84
90
|
requirements:
|
85
91
|
- - ~>
|
86
92
|
- !ruby/object:Gem::Version
|
87
|
-
version:
|
88
|
-
type: :development
|
89
|
-
prerelease: false
|
90
|
-
version_requirements: *2153223600
|
93
|
+
version: 1.3.7
|
91
94
|
- !ruby/object:Gem::Dependency
|
92
95
|
name: rspec
|
93
|
-
requirement:
|
96
|
+
requirement: !ruby/object:Gem::Requirement
|
94
97
|
none: false
|
95
98
|
requirements:
|
96
99
|
- - ~>
|
97
100
|
- !ruby/object:Gem::Version
|
98
|
-
version: '2.
|
101
|
+
version: '2.13'
|
99
102
|
type: :development
|
100
103
|
prerelease: false
|
101
|
-
version_requirements:
|
102
|
-
- !ruby/object:Gem::Dependency
|
103
|
-
name: factory_girl
|
104
|
-
requirement: &2153222460 !ruby/object:Gem::Requirement
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
105
105
|
none: false
|
106
106
|
requirements:
|
107
107
|
- - ~>
|
108
108
|
- !ruby/object:Gem::Version
|
109
|
-
version: '2.
|
110
|
-
|
111
|
-
prerelease: false
|
112
|
-
version_requirements: *2153222460
|
113
|
-
description: Easily add Judge client side validation to your SimpleForm forms
|
109
|
+
version: '2.13'
|
110
|
+
description: Easily add Judge client side validation to your SimpleForm forms.
|
114
111
|
email: joe@tribesports.com
|
115
112
|
executables: []
|
116
113
|
extensions: []
|
117
114
|
extra_rdoc_files: []
|
118
115
|
files:
|
119
|
-
- .
|
120
|
-
-
|
116
|
+
- lib/judge/simple_form/version.rb
|
117
|
+
- lib/judge/simple_form.rb
|
121
118
|
- LICENSE.txt
|
122
119
|
- README.md
|
123
|
-
- Rakefile
|
124
|
-
- judge-simple_form.gemspec
|
125
|
-
- lib/judge/simple_form.rb
|
126
|
-
- lib/judge/simple_form/version.rb
|
127
|
-
- spec/factories.rb
|
128
|
-
- spec/judge-simple_form_spec.rb
|
129
|
-
- spec/setup.rb
|
130
|
-
- spec/spec_helper.rb
|
131
120
|
homepage: http://github.com/joecorcoran/judge-simple_form
|
132
121
|
licenses: []
|
133
122
|
post_install_message:
|
@@ -140,26 +129,16 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
140
129
|
- - ! '>='
|
141
130
|
- !ruby/object:Gem::Version
|
142
131
|
version: '0'
|
143
|
-
segments:
|
144
|
-
- 0
|
145
|
-
hash: -2996361724237842793
|
146
132
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
147
133
|
none: false
|
148
134
|
requirements:
|
149
135
|
- - ! '>='
|
150
136
|
- !ruby/object:Gem::Version
|
151
137
|
version: '0'
|
152
|
-
segments:
|
153
|
-
- 0
|
154
|
-
hash: -2996361724237842793
|
155
138
|
requirements: []
|
156
139
|
rubyforge_project:
|
157
|
-
rubygems_version: 1.8.
|
140
|
+
rubygems_version: 1.8.25
|
158
141
|
signing_key:
|
159
142
|
specification_version: 3
|
160
143
|
summary: SimpleForm adapter for Judge
|
161
|
-
test_files:
|
162
|
-
- spec/factories.rb
|
163
|
-
- spec/judge-simple_form_spec.rb
|
164
|
-
- spec/setup.rb
|
165
|
-
- spec/spec_helper.rb
|
144
|
+
test_files: []
|
data/.travis.yml
DELETED
data/Gemfile
DELETED
data/Rakefile
DELETED
data/judge-simple_form.gemspec
DELETED
@@ -1,28 +0,0 @@
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
2
|
-
$:.push File.expand_path("../lib", __FILE__)
|
3
|
-
require "judge/simple_form/version"
|
4
|
-
|
5
|
-
Gem::Specification.new do |s|
|
6
|
-
s.name = "judge-simple_form"
|
7
|
-
s.version = Judge::SimpleForm::VERSION
|
8
|
-
s.authors = ["Joe Corcoran"]
|
9
|
-
s.email = "joe@tribesports.com"
|
10
|
-
s.homepage = "http://github.com/joecorcoran/judge-simple_form"
|
11
|
-
s.summary = "SimpleForm adapter for Judge"
|
12
|
-
s.description = "Easily add Judge client side validation to your SimpleForm forms"
|
13
|
-
|
14
|
-
s.files = `git ls-files`.split("\n")
|
15
|
-
s.test_files = `git ls-files -- spec/*`.split("\n")
|
16
|
-
s.require_paths = ["lib"]
|
17
|
-
|
18
|
-
s.add_runtime_dependency "judge", "~> 1.1"
|
19
|
-
s.add_runtime_dependency "simple_form", "~> 2.0"
|
20
|
-
|
21
|
-
s.add_development_dependency "rake"
|
22
|
-
s.add_development_dependency "rails", "~> 3.2"
|
23
|
-
s.add_development_dependency "sqlite3-ruby", "~> 1.3.3"
|
24
|
-
s.add_development_dependency "judge", "~> 1.1"
|
25
|
-
s.add_development_dependency "formtastic", "~> 2.0"
|
26
|
-
s.add_development_dependency "rspec", "~> 2.8"
|
27
|
-
s.add_development_dependency "factory_girl", "~> 2.6"
|
28
|
-
end
|
data/spec/factories.rb
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
describe Judge::SimpleForm do
|
4
|
-
let(:template) do
|
5
|
-
ActionView::Base.new(nil, {}, UsersController.new)
|
6
|
-
end
|
7
|
-
let(:builder) do
|
8
|
-
SimpleForm::FormBuilder.new(:user, FactoryGirl.build(:user), template, {}, nil)
|
9
|
-
end
|
10
|
-
let(:expected) do
|
11
|
-
/data\-validate\=\"\[.+\]\"/
|
12
|
-
end
|
13
|
-
|
14
|
-
it "adds data attribute when :validate option is true" do
|
15
|
-
builder.input(:name, :validate => true).should match expected
|
16
|
-
end
|
17
|
-
|
18
|
-
it "does not add data attribute otherwise" do
|
19
|
-
builder.input(:name).should_not match expected
|
20
|
-
end
|
21
|
-
end
|
data/spec/setup.rb
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
# setup simple schema and class
|
2
|
-
ActiveRecord::Base.establish_connection(:adapter => "sqlite3", :database => ":memory:")
|
3
|
-
ActiveRecord::Schema.define(:version => 1) do
|
4
|
-
create_table :users do |t|
|
5
|
-
t.string :name
|
6
|
-
end
|
7
|
-
end
|
8
|
-
class User < ActiveRecord::Base
|
9
|
-
validates :name, :presence => true
|
10
|
-
end
|
11
|
-
|
12
|
-
# hack to stop #url_for error
|
13
|
-
module ActionDispatch::Routing::PolymorphicRoutes
|
14
|
-
def polymorphic_path(record_or_hash_or_array, options = {})
|
15
|
-
""
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
class UsersController < ActionController::Base
|
20
|
-
end
|
data/spec/spec_helper.rb
DELETED
@@ -1,17 +0,0 @@
|
|
1
|
-
require "bundler/setup"
|
2
|
-
|
3
|
-
require "active_record"
|
4
|
-
require "action_view"
|
5
|
-
require "action_controller"
|
6
|
-
require "judge"
|
7
|
-
require "simple_form"
|
8
|
-
require "judge/simple_form"
|
9
|
-
require "factory_girl"
|
10
|
-
require "rspec"
|
11
|
-
|
12
|
-
require_relative "setup"
|
13
|
-
require_relative "factories"
|
14
|
-
|
15
|
-
RSpec.configure do |config|
|
16
|
-
config.color_enabled = true
|
17
|
-
end
|