client_side_validations 0.6.0 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -1,16 +1,6 @@
1
- = ar_client_side_validations
1
+ = client_side_validations
2
2
 
3
- ActiveRecord Client Side Validations
4
-
5
- == Note on Patches/Pull Requests
6
-
7
- * Fork the project.
8
- * Make your feature addition or bug fix.
9
- * Add tests for it. This is important so I don't break it in a
10
- future version unintentionally.
11
- * Commit, do not mess with rakefile, version, or history.
12
- (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
13
- * Send me a pull request. Bonus points for topic branches.
3
+ Client Side Validations
14
4
 
15
5
  == Copyright
16
6
 
data/Rakefile CHANGED
@@ -4,15 +4,14 @@ require 'rake'
4
4
  begin
5
5
  require 'jeweler'
6
6
  Jeweler::Tasks.new do |gem|
7
- gem.name = "client_side_validations"
8
- gem.summary = %Q{Client Side Validations}
7
+ gem.name = "client_side_validations"
8
+ gem.summary = %Q{Client Side Validations}
9
9
  gem.description = %Q{ORM and Framework agnostic Client Side Validations}
10
- gem.email = "cardarellab@dnc.org"
11
- gem.homepage = "http://github.com/dnclabs/client_side_validations"
12
- gem.authors = ["Brian Cardarella"]
10
+ gem.email = "cardarellab@dnc.org"
11
+ gem.homepage = "http://github.com/dnclabs/client_side_validations"
12
+ gem.authors = ["Brian Cardarella"]
13
13
  gem.add_development_dependency "rspec", ">= 1.2.9"
14
14
  gem.add_dependency 'validation_reflection', '>= 0.3.6'
15
- # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
16
15
  end
17
16
  Jeweler::GemcutterTasks.new
18
17
  rescue LoadError
@@ -28,7 +27,7 @@ end
28
27
  Spec::Rake::SpecTask.new(:rcov) do |spec|
29
28
  spec.libs << 'lib' << 'spec'
30
29
  spec.pattern = 'spec/**/*_spec.rb'
31
- spec.rcov = true
30
+ spec.rcov = true
32
31
  end
33
32
 
34
33
  task :spec => :check_dependencies
@@ -39,7 +38,7 @@ Rake::RDocTask.new do |rdoc|
39
38
  version = File.exist?('VERSION') ? File.read('VERSION') : ""
40
39
 
41
40
  rdoc.rdoc_dir = 'rdoc'
42
- rdoc.title = "ar_client_side_validations #{version}"
41
+ rdoc.title = "client_side_validations #{version}"
43
42
  rdoc.rdoc_files.include('README*')
44
43
  rdoc.rdoc_files.include('lib/**/*.rb')
45
44
  end
data/TODO CHANGED
@@ -1,2 +1,2 @@
1
1
  - Add Rails Generators
2
- - Check ActionView code against Rails 3
2
+ - Accept options in helper to extend the given validation plugin
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.6.0
1
+ 0.8.0
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{client_side_validations}
8
- s.version = "0.6.0"
8
+ s.version = "0.8.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Brian Cardarella"]
12
- s.date = %q{2010-06-07}
12
+ s.date = %q{2010-06-08}
13
13
  s.description = %q{ORM and Framework agnostic Client Side Validations}
14
14
  s.email = %q{cardarellab@dnc.org}
15
15
  s.extra_rdoc_files = [
@@ -26,6 +26,7 @@ Gem::Specification.new do |s|
26
26
  "TODO",
27
27
  "VERSION",
28
28
  "client_side_validations.gemspec",
29
+ "generators/client_side_validations/client_side_validations_generator.rb",
29
30
  "javascript/jspec/commands/example_command.rb",
30
31
  "javascript/jspec/rhino.js",
31
32
  "javascript/jspec/unit/jquery.validate.spec.js",
@@ -0,0 +1,16 @@
1
+ class ClientSideValidationsGenerator < Rails::Generator::Base
2
+
3
+ def initialize(runtime_args, runtime_options = {})
4
+ runtime_options[:source] = File.join(spec.path, '../../javascript/lib')
5
+ super
6
+ end
7
+
8
+
9
+ def manifest
10
+ record do |c|
11
+ c.directory('public/javascripts')
12
+ c.file('client_side_validations.js', 'public/javascripts/client_side_validations.js')
13
+ end
14
+ end
15
+
16
+ end
@@ -8,13 +8,12 @@ module DNCLabs
8
8
  url = options.delete(:url)
9
9
  raise "No URL Specified!" unless url
10
10
  adapter = options.delete(:adapter) || 'jquery.validate'
11
- <<-JS
12
- <script type="text/javascript">
13
- $(document).ready(function() {
14
- $('##{dom_id(options[:object])}').clientSideValidations('#{url}', '#{adapter}');
15
- })
16
- </script>
17
- JS
11
+ js = %{<script type="text/javascript">$(document).ready(function(){$('##{dom_id(options[:object])}').clientSideValidations('#{url}','#{adapter}');});</script>}
12
+ if js.respond_to?(:html_safe)
13
+ js.html_safe
14
+ else
15
+ js
16
+ end
18
17
  end
19
18
 
20
19
  end # BaseMethods
@@ -10,15 +10,9 @@ describe 'ActionView 2.x Form Helper' do
10
10
 
11
11
  context 'only the url' do
12
12
  before do
13
- @object_name = 'object'
14
- @url = '/objects/new.json'
15
- @expected_javascript = <<-JS
16
- <script type="text/javascript">
17
- $(document).ready(function() {
18
- $('##{@object_name}').clientSideValidations('#{@url}', 'jquery.validate');
19
- })
20
- </script>
21
- JS
13
+ @object_name = 'object'
14
+ @url = '/objects/new.json'
15
+ @expected_javascript = %{<script type="text/javascript">$(document).ready(function(){$('##{@object_name}').clientSideValidations('#{@url}','jquery.validate');});</script>}
22
16
  subject.should_receive(:dom_id).and_return(@object_name)
23
17
  end
24
18
 
@@ -30,16 +24,10 @@ describe 'ActionView 2.x Form Helper' do
30
24
 
31
25
  context 'a different adapter' do
32
26
  before do
33
- @object_name = 'object'
34
- @url = '/objects/new.json'
35
- @adapter = 'some.other.adapter'
36
- @expected_javascript = <<-JS
37
- <script type="text/javascript">
38
- $(document).ready(function() {
39
- $('##{@object_name}').clientSideValidations('#{@url}', '#{@adapter}');
40
- })
41
- </script>
42
- JS
27
+ @object_name = 'object'
28
+ @url = '/objects/new.json'
29
+ @adapter = 'some.other.adapter'
30
+ @expected_javascript = %{<script type="text/javascript">$(document).ready(function(){$('##{@object_name}').clientSideValidations('#{@url}','#{@adapter}');});</script>}
43
31
  subject.should_receive(:dom_id).and_return(@object_name)
44
32
  end
45
33
 
@@ -53,13 +41,6 @@ describe 'ActionView 2.x Form Helper' do
53
41
  before do
54
42
  @object_name = 'object'
55
43
  @adapter = 'some.other.adapter'
56
- @expected_javascript = <<-JS
57
- <script type="text/javascript">
58
- $(document).ready(function() {
59
- $('##{@object_name}').clientSideValidations('#{@url}', '#{@some_other_adapter}');
60
- })
61
- </script>
62
- JS
63
44
  end
64
45
 
65
46
  it 'should raise an error' do
@@ -4,71 +4,52 @@ require 'action_pack'
4
4
  require 'action_view'
5
5
  require 'client_side_validations'
6
6
 
7
- describe 'ActionView 2.x Form Helper' do
8
- context 'ActionView::Base' do
9
- subject { ActionView::Base.new }
10
-
11
- context 'only the url' do
12
- before do
13
- @object_name = 'object'
14
- @url = '/objects/new.json'
15
- @expected_javascript = <<-JS
16
- <script type="text/javascript">
17
- $(document).ready(function() {
18
- $('##{@object_name}').clientSideValidations('#{@url}', 'jquery.validate');
19
- })
20
- </script>
21
- JS
22
- subject.should_receive(:dom_id).and_return(@object_name)
23
- end
24
-
25
- it 'should generate the proper javascript' do
26
- subject.client_side_validations(@object_name,
27
- :url => @url).should == @expected_javascript
28
- end
29
- end
30
-
31
- context 'a different adapter' do
32
- before do
33
- @object_name = 'object'
34
- @url = '/objects/new.json'
35
- @adapter = 'some.other.adapter'
36
- @expected_javascript = <<-JS
37
- <script type="text/javascript">
38
- $(document).ready(function() {
39
- $('##{@object_name}').clientSideValidations('#{@url}', '#{@adapter}');
40
- })
41
- </script>
42
- JS
43
- subject.should_receive(:dom_id).and_return(@object_name)
44
- end
45
-
46
- it 'should generate the proper javascript' do
47
- subject.client_side_validations(@object_name,
48
- :url => @url, :adapter => @adapter).should == @expected_javascript
49
- end
50
- end
7
+ describe 'ActionView 3.x Form Helper' do
8
+ context 'ActionView::Base' do
9
+ subject { ActionView::Base.new }
10
+
11
+ context 'only the url' do
12
+ before do
13
+ @object_name = 'object'
14
+ @url = '/objects/new.json'
15
+ @expected_javascript = %{<script type="text/javascript">$(document).ready(function(){$('##{@object_name}').clientSideValidations('#{@url}','jquery.validate');});</script>}
16
+ subject.should_receive(:dom_id).and_return(@object_name)
17
+ end
51
18
 
52
- context 'not including the :url' do
53
- before do
54
- @object_name = 'object'
55
- @adapter = 'some.other.adapter'
56
- @expected_javascript = <<-JS
57
- <script type="text/javascript">
58
- $(document).ready(function() {
59
- $('##{@object_name}').clientSideValidations('#{@url}', '#{@some_other_adapter}');
60
- })
61
- </script>
62
- JS
19
+ it 'should generate the proper javascript' do
20
+ subject.client_side_validations(@object_name,
21
+ :url => @url).should == @expected_javascript
22
+ end
63
23
  end
64
-
65
- it 'should raise an error' do
66
- expect {
24
+
25
+ context 'a different adapter' do
26
+ before do
27
+ @object_name = 'object'
28
+ @url = '/objects/new.json'
29
+ @adapter = 'some.other.adapter'
30
+ @expected_javascript = %{<script type="text/javascript">$(document).ready(function(){$('##{@object_name}').clientSideValidations('#{@url}','#{@adapter}');});</script>}
31
+ subject.should_receive(:dom_id).and_return(@object_name)
32
+ end
33
+
34
+ it 'should generate the proper javascript' do
67
35
  subject.client_side_validations(@object_name,
68
- :adapter => @some_other_adapter)
69
- }.to raise_error
36
+ :url => @url, :adapter => @adapter).should == @expected_javascript
37
+ end
70
38
  end
39
+
40
+ context 'not including the :url' do
41
+ before do
42
+ @object_name = 'object'
43
+ @adapter = 'some.other.adapter'
44
+ end
45
+
46
+ it 'should raise an error' do
47
+ expect {
48
+ subject.client_side_validations(@object_name,
49
+ :adapter => @some_other_adapter)
50
+ }.to raise_error
51
+ end
52
+ end
53
+
71
54
  end
72
-
73
- end
74
- end
55
+ end
metadata CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 0
7
- - 6
7
+ - 8
8
8
  - 0
9
- version: 0.6.0
9
+ version: 0.8.0
10
10
  platform: ruby
11
11
  authors:
12
12
  - Brian Cardarella
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-06-07 00:00:00 -04:00
17
+ date: 2010-06-08 00:00:00 -04:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -64,6 +64,7 @@ files:
64
64
  - TODO
65
65
  - VERSION
66
66
  - client_side_validations.gemspec
67
+ - generators/client_side_validations/client_side_validations_generator.rb
67
68
  - javascript/jspec/commands/example_command.rb
68
69
  - javascript/jspec/rhino.js
69
70
  - javascript/jspec/unit/jquery.validate.spec.js