judge-formtastic 0.1.1 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE.txt +20 -0
- data/README.md +23 -1
- data/lib/judge/formtastic.rb +7 -2
- data/lib/judge/formtastic/version.rb +1 -1
- metadata +44 -64
- data/.travis.yml +0 -5
- data/Gemfile +0 -4
- data/Rakefile +0 -6
- data/judge-formtastic.gemspec +0 -31
- data/spec/factories.rb +0 -5
- data/spec/judge-formtastic_spec.rb +0 -16
- data/spec/setup.rb +0 -26
- data/spec/spec_helper.rb +0 -17
data/LICENSE.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2012 Joe Corcoran
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
CHANGED
@@ -1,3 +1,25 @@
|
|
1
1
|
# judge-formtastic
|
2
2
|
|
3
|
-
|
3
|
+
[![Build status](https://secure.travis-ci.org/joecorcoran/judge-formtastic.png?branch=master)](http://travis-ci.org/joecorcoran/judge-formtastic)
|
4
|
+
|
5
|
+
This is an adapter gem which allows you to use [Judge](http://judge.joecorcoran.co.uk) from within your [Formtastic](http://github.com/justinfrench/formtastic) forms.
|
6
|
+
|
7
|
+
## Usage
|
8
|
+
|
9
|
+
gem 'judge-formtastic'
|
10
|
+
|
11
|
+
Then add <code>:validate => true</code> to the input options in your views. That's all.
|
12
|
+
|
13
|
+
<%= semantic_form_for(@user) do |f| %>
|
14
|
+
<%= f.input :name, :validate => true %>
|
15
|
+
<% end %>
|
16
|
+
|
17
|
+
## Judge
|
18
|
+
|
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).
|
20
|
+
|
21
|
+
## License
|
22
|
+
|
23
|
+
Released under an MIT license (see LICENSE.txt).
|
24
|
+
|
25
|
+
http://blog.joecorcoran.co.uk
|
data/lib/judge/formtastic.rb
CHANGED
@@ -1,9 +1,14 @@
|
|
1
|
+
require "judge" unless defined?(::Judge::VERSION)
|
2
|
+
require "formtastic" unless defined?(::Formtastic)
|
3
|
+
|
1
4
|
module Judge
|
2
5
|
module Formtastic
|
3
6
|
module Html
|
7
|
+
|
8
|
+
include Judge::Html
|
4
9
|
|
5
10
|
def input_html_options
|
6
|
-
attrs = options[:validate].present? ?
|
11
|
+
attrs = options[:validate].present? ? attrs_for(object, method) : {}
|
7
12
|
attrs.merge(super)
|
8
13
|
end
|
9
14
|
|
@@ -11,4 +16,4 @@ module Judge
|
|
11
16
|
end
|
12
17
|
end
|
13
18
|
|
14
|
-
Formtastic::Inputs::Base.send(:include, Judge::Formtastic::Html)
|
19
|
+
::Formtastic::Inputs::Base.send(:include, ::Judge::Formtastic::Html)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: judge-formtastic
|
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,33 +9,43 @@ 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: formtastic
|
27
|
-
requirement:
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
28
33
|
none: false
|
29
34
|
requirements:
|
30
35
|
- - ~>
|
31
36
|
- !ruby/object:Gem::Version
|
32
|
-
version: '2.
|
37
|
+
version: '2.2'
|
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.2'
|
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,55 @@ 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: &2157397060 !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: *2157397060
|
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: &2157440060 !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: *2157440060
|
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: &2157438820 !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
|
-
type: :development
|
111
|
-
prerelease: false
|
112
|
-
version_requirements: *2157438820
|
109
|
+
version: '2.13'
|
113
110
|
description: Easily add Judge client side validation to your Formtastic forms.
|
114
111
|
email:
|
115
|
-
-
|
112
|
+
- joe@tribesports.com
|
116
113
|
executables: []
|
117
114
|
extensions: []
|
118
115
|
extra_rdoc_files: []
|
119
116
|
files:
|
120
|
-
- .travis.yml
|
121
|
-
- Gemfile
|
122
|
-
- README.md
|
123
|
-
- Rakefile
|
124
|
-
- judge-formtastic.gemspec
|
125
|
-
- lib/judge/formtastic.rb
|
126
117
|
- lib/judge/formtastic/version.rb
|
127
|
-
-
|
128
|
-
-
|
129
|
-
-
|
130
|
-
- spec/spec_helper.rb
|
118
|
+
- lib/judge/formtastic.rb
|
119
|
+
- LICENSE.txt
|
120
|
+
- README.md
|
131
121
|
homepage: http://github.com/joecorcoran/judge-formtastic
|
132
122
|
licenses: []
|
133
123
|
post_install_message:
|
@@ -140,26 +130,16 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
140
130
|
- - ! '>='
|
141
131
|
- !ruby/object:Gem::Version
|
142
132
|
version: '0'
|
143
|
-
segments:
|
144
|
-
- 0
|
145
|
-
hash: -1377600811236618586
|
146
133
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
147
134
|
none: false
|
148
135
|
requirements:
|
149
136
|
- - ! '>='
|
150
137
|
- !ruby/object:Gem::Version
|
151
138
|
version: '0'
|
152
|
-
segments:
|
153
|
-
- 0
|
154
|
-
hash: -1377600811236618586
|
155
139
|
requirements: []
|
156
|
-
rubyforge_project:
|
157
|
-
rubygems_version: 1.8.
|
140
|
+
rubyforge_project:
|
141
|
+
rubygems_version: 1.8.25
|
158
142
|
signing_key:
|
159
143
|
specification_version: 3
|
160
144
|
summary: Formtastic adapter for Judge
|
161
|
-
test_files:
|
162
|
-
- spec/factories.rb
|
163
|
-
- spec/judge-formtastic_spec.rb
|
164
|
-
- spec/setup.rb
|
165
|
-
- spec/spec_helper.rb
|
145
|
+
test_files: []
|
data/.travis.yml
DELETED
data/Gemfile
DELETED
data/Rakefile
DELETED
data/judge-formtastic.gemspec
DELETED
@@ -1,31 +0,0 @@
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
2
|
-
$:.push File.expand_path("../lib", __FILE__)
|
3
|
-
require "judge/formtastic/version"
|
4
|
-
|
5
|
-
Gem::Specification.new do |s|
|
6
|
-
s.name = "judge-formtastic"
|
7
|
-
s.version = Judge::Formtastic::VERSION
|
8
|
-
s.authors = ["Joe Corcoran"]
|
9
|
-
s.email = ["joecorcoran@gmail.com"]
|
10
|
-
s.homepage = "http://github.com/joecorcoran/judge-formtastic"
|
11
|
-
s.summary = "Formtastic adapter for Judge"
|
12
|
-
s.description = %q{Easily add Judge client side validation to your Formtastic forms.}
|
13
|
-
|
14
|
-
s.rubyforge_project = "judge-formtastic"
|
15
|
-
|
16
|
-
s.files = `git ls-files`.split("\n")
|
17
|
-
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
18
|
-
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
19
|
-
s.require_paths = ["lib"]
|
20
|
-
|
21
|
-
s.add_runtime_dependency "judge", "~> 1.1"
|
22
|
-
s.add_runtime_dependency "formtastic", "~> 2.0"
|
23
|
-
|
24
|
-
s.add_development_dependency "rake"
|
25
|
-
s.add_development_dependency "rails", "~> 3.2"
|
26
|
-
s.add_development_dependency "sqlite3-ruby", "~> 1.3.3"
|
27
|
-
s.add_development_dependency "judge", "~> 1.1"
|
28
|
-
s.add_development_dependency "formtastic", "~> 2.0"
|
29
|
-
s.add_development_dependency "rspec", "~> 2.8"
|
30
|
-
s.add_development_dependency "factory_girl", "~> 2.5.2"
|
31
|
-
end
|
data/spec/factories.rb
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
describe Judge::Formtastic do
|
4
|
-
let(:builder) { Formtastic::FormBuilder.new(:user, FactoryGirl.build(:user), ActionView::Base.new, {}, nil) }
|
5
|
-
let(:expected) do
|
6
|
-
/data\-validate\=\"\[.+\]\"/
|
7
|
-
end
|
8
|
-
|
9
|
-
it "adds data attribute when :validate option is true" do
|
10
|
-
builder.input(:name, :validate => true).should match expected
|
11
|
-
end
|
12
|
-
|
13
|
-
it "does not add data attribute otherwise" do
|
14
|
-
builder.input(:name).should_not match expected
|
15
|
-
end
|
16
|
-
end
|
data/spec/setup.rb
DELETED
@@ -1,26 +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
|
-
# stop formtastic whining about rails
|
20
|
-
Rails = OpenStruct.new({
|
21
|
-
:application => OpenStruct.new({
|
22
|
-
:config => OpenStruct.new({
|
23
|
-
:cache_classes => false
|
24
|
-
})
|
25
|
-
})
|
26
|
-
})
|
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 "judge"
|
6
|
-
require "formtastic"
|
7
|
-
require "judge/formtastic"
|
8
|
-
require "factory_girl"
|
9
|
-
require "rspec"
|
10
|
-
require "ostruct"
|
11
|
-
|
12
|
-
require_relative "setup"
|
13
|
-
require_relative "factories"
|
14
|
-
|
15
|
-
RSpec.configure do |config|
|
16
|
-
config.color_enabled = true
|
17
|
-
end
|