judge 0.4.2 → 0.4.3
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/docs/judge.html +3 -6
- data/judge.gemspec +2 -2
- data/lib/generators/judge/templates/judge.js +2 -6
- data/spec/javascripts/JudgeSpec.js +0 -5
- metadata +4 -4
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.4.
|
1
|
+
0.4.3
|
data/docs/judge.html
CHANGED
@@ -2,17 +2,14 @@
|
|
2
2
|
You can find a guide and some more traditional API documentation at <a href="http://joecorcoran.github.com/judge/">http://joecorcoran.github.com/judge/</a>.
|
3
3
|
Hopefully this page will help you understand what's happening under the hood.</p> </td> <td class="code"> <div class="highlight"><pre><span class="cm">/*jshint curly: true, evil: true, newcap: true, noarg: true */</span>
|
4
4
|
<span class="cm">/*global _: false, JSON: false */</span> </pre></div> </td> </tr> <tr id="section-2"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-2">¶</a> </div> <p>The judge namespace.</p> </td> <td class="code"> <div class="highlight"><pre><span class="kd">var</span> <span class="nx">judge</span> <span class="o">=</span> <span class="nx">judge</span> <span class="o">||</span> <span class="p">{};</span></pre></div> </td> </tr> <tr id="section-3"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-3">¶</a> </div> <p>A judge.Watcher is a DOM element wrapper that judge uses to store validation info and instance methods.</p> </td> <td class="code"> <div class="highlight"><pre><span class="nx">judge</span><span class="p">.</span><span class="nx">Watcher</span> <span class="o">=</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">element</span><span class="p">)</span> <span class="p">{</span>
|
5
|
-
</pre></div> </td> </tr> <tr id="section-4"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-4">¶</a> </div> <p>Throw dependency errors.</p> </td> <td class="code"> <div class="highlight"><pre> <span class="k">if</span> <span class="p">(</span><span class="
|
5
|
+
</pre></div> </td> </tr> <tr id="section-4"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-4">¶</a> </div> <p>Throw dependency errors.</p> </td> <td class="code"> <div class="highlight"><pre> <span class="k">if</span> <span class="p">(</span><span class="k">typeof</span> <span class="nb">window</span><span class="p">.</span><span class="nx">_</span> <span class="o">===</span> <span class="s2">"undefined"</span><span class="p">)</span> <span class="p">{</span>
|
6
6
|
<span class="k">throw</span> <span class="k">new</span> <span class="nx">ReferenceError</span><span class="p">(</span><span class="s1">'[judge] Underscore.js not found'</span><span class="p">);</span>
|
7
7
|
<span class="p">}</span>
|
8
|
-
<span class="k">if</span> <span class="p">(</span><span class="
|
8
|
+
<span class="k">if</span> <span class="p">(</span><span class="k">typeof</span> <span class="nb">window</span><span class="p">.</span><span class="nx">JSON</span> <span class="o">===</span> <span class="s2">"undefined"</span><span class="p">)</span> <span class="p">{</span>
|
9
9
|
<span class="k">throw</span> <span class="k">new</span> <span class="nx">ReferenceError</span><span class="p">(</span><span class="s1">'[judge] JSON global object not found'</span><span class="p">);</span>
|
10
10
|
<span class="p">}</span></pre></div> </td> </tr> <tr id="section-5"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-5">¶</a> </div> <p>Throw some constructor usage errors.</p> </td> <td class="code"> <div class="highlight"><pre> <span class="k">if</span> <span class="p">(</span><span class="nx">_</span><span class="p">(</span><span class="nx">element</span><span class="p">).</span><span class="nx">isUndefined</span><span class="p">())</span> <span class="p">{</span>
|
11
11
|
<span class="k">throw</span> <span class="k">new</span> <span class="nx">ReferenceError</span><span class="p">(</span><span class="s1">'[judge] No DOM element passed to constructor'</span><span class="p">);</span>
|
12
12
|
<span class="p">}</span>
|
13
|
-
<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">judge</span><span class="p">.</span><span class="nx">utils</span><span class="p">.</span><span class="nx">isValidatable</span><span class="p">(</span><span class="nx">element</span><span class="p">))</span> <span class="p">{</span>
|
14
|
-
<span class="k">throw</span> <span class="k">new</span> <span class="nx">TypeError</span><span class="p">(</span><span class="s1">'[judge] Cannot construct new Watcher for object of this type'</span><span class="p">);</span>
|
15
|
-
<span class="p">}</span>
|
16
13
|
<span class="k">if</span> <span class="p">(</span><span class="nx">element</span><span class="p">.</span><span class="nx">getAttribute</span><span class="p">(</span><span class="s1">'data-validate'</span><span class="p">)</span> <span class="o">===</span> <span class="kc">null</span><span class="p">)</span> <span class="p">{</span>
|
17
14
|
<span class="k">throw</span> <span class="k">new</span> <span class="nx">ReferenceError</span><span class="p">(</span><span class="s1">'[judge] Cannot construct Watcher for this element, use judge form builders'</span><span class="p">);</span>
|
18
15
|
<span class="p">}</span>
|
@@ -265,7 +262,7 @@ using complex regular expressions AND you hope that this will "just work"
|
|
265
262
|
on the client-side too… you are going to be pretty disappointed.</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nx">convertRegExp</span><span class="o">:</span> <span class="kd">function</span><span class="p">(</span><span class="nx">string</span><span class="p">)</span> <span class="p">{</span>
|
266
263
|
<span class="kd">var</span> <span class="nx">p</span> <span class="o">=</span> <span class="nx">string</span><span class="p">.</span><span class="nx">slice</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">).</span><span class="nx">split</span><span class="p">(</span><span class="s1">':'</span><span class="p">),</span>
|
267
264
|
<span class="nx">o</span> <span class="o">=</span> <span class="nx">p</span><span class="p">.</span><span class="nx">shift</span><span class="p">(),</span>
|
268
|
-
<span class="nx">r</span> <span class="o">=</span> <span class="nx">p</span><span class="p">.</span><span class="nx">join</span><span class="p">(</span><span class="s1">':'</span><span class="p">).</span><span class="nx">replace</span><span class="p">(</span><span class="sr"
|
265
|
+
<span class="nx">r</span> <span class="o">=</span> <span class="nx">p</span><span class="p">.</span><span class="nx">join</span><span class="p">(</span><span class="s1">':'</span><span class="p">).</span><span class="nx">replace</span><span class="p">(</span><span class="sr">/\\\\/g</span><span class="p">,</span> <span class="s1">'\\'</span><span class="p">);</span>
|
269
266
|
<span class="k">return</span> <span class="k">new</span> <span class="nb">RegExp</span><span class="p">(</span><span class="nx">r</span><span class="p">,</span> <span class="nx">judge</span><span class="p">.</span><span class="nx">utils</span><span class="p">.</span><span class="nx">convertFlags</span><span class="p">(</span><span class="nx">o</span><span class="p">));</span>
|
270
267
|
<span class="p">},</span>
|
271
268
|
<span class="nx">convertFlags</span><span class="o">:</span> <span class="kd">function</span><span class="p">(</span><span class="nx">string</span><span class="p">)</span> <span class="p">{</span>
|
data/judge.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{judge}
|
8
|
-
s.version = "0.4.
|
8
|
+
s.version = "0.4.3"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Joe Corcoran"]
|
12
|
-
s.date = %q{2011-08-
|
12
|
+
s.date = %q{2011-08-16}
|
13
13
|
s.description = %q{Validate forms in-place using your model validations}
|
14
14
|
s.email = %q{joe@tribesports.com}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -12,10 +12,10 @@ var judge = judge || {};
|
|
12
12
|
judge.Watcher = function (element) {
|
13
13
|
|
14
14
|
// Throw dependency errors.
|
15
|
-
if (
|
15
|
+
if (typeof window._ === "undefined") {
|
16
16
|
throw new ReferenceError('[judge] Underscore.js not found');
|
17
17
|
}
|
18
|
-
if (
|
18
|
+
if (typeof window.JSON === "undefined") {
|
19
19
|
throw new ReferenceError('[judge] JSON global object not found');
|
20
20
|
}
|
21
21
|
|
@@ -23,9 +23,6 @@ judge.Watcher = function (element) {
|
|
23
23
|
if (_(element).isUndefined()) {
|
24
24
|
throw new ReferenceError('[judge] No DOM element passed to constructor');
|
25
25
|
}
|
26
|
-
if (!judge.utils.isValidatable(element)) {
|
27
|
-
throw new TypeError('[judge] Cannot construct new Watcher for object of this type');
|
28
|
-
}
|
29
26
|
if (element.getAttribute('data-validate') === null) {
|
30
27
|
throw new ReferenceError('[judge] Cannot construct Watcher for this element, use judge form builders');
|
31
28
|
}
|
@@ -33,7 +30,6 @@ judge.Watcher = function (element) {
|
|
33
30
|
throw new ReferenceError('[judge] Parent form was not created using judge form helper, please amend');
|
34
31
|
}
|
35
32
|
|
36
|
-
|
37
33
|
// Convenient access to this Watcher.
|
38
34
|
var instance = this;
|
39
35
|
|
@@ -79,11 +79,6 @@ describe('judge', function() {
|
|
79
79
|
expect(function() { new judge.Watcher(); }).toThrow();
|
80
80
|
});
|
81
81
|
|
82
|
-
it('throws error if element is not validatable', function() {
|
83
|
-
var e = document.createElement('p');
|
84
|
-
expect(function() { new judge.Watcher(e); }).toThrow();
|
85
|
-
});
|
86
|
-
|
87
82
|
});
|
88
83
|
|
89
84
|
describe('judge.store', function() {
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 4
|
8
|
-
-
|
9
|
-
version: 0.4.
|
8
|
+
- 3
|
9
|
+
version: 0.4.3
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Joe Corcoran
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2011-08-
|
17
|
+
date: 2011-08-16 00:00:00 +01:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -239,7 +239,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
239
239
|
requirements:
|
240
240
|
- - ">="
|
241
241
|
- !ruby/object:Gem::Version
|
242
|
-
hash: -
|
242
|
+
hash: -1586018578204705053
|
243
243
|
segments:
|
244
244
|
- 0
|
245
245
|
version: "0"
|