jcheck_rails 0.1.1 → 0.2.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.
- data/.gitignore +1 -0
- data/Gemfile +2 -1
- data/Gemfile.lock +4 -2
- data/README.textile +29 -1
- data/Rakefile +2 -0
- data/VERSION +1 -1
- data/jcheck_rails.gemspec +7 -3
- data/lib/jcheck_rails.rb +25 -0
- data/tasks/jcheck_tasks.rake +45 -0
- metadata +22 -7
data/.gitignore
CHANGED
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -41,7 +41,7 @@ GEM
|
|
41
41
|
gemcutter (>= 0.1.0)
|
42
42
|
git (>= 1.2.5)
|
43
43
|
rubyforge (>= 2.0.0)
|
44
|
-
json_pure (1.4.
|
44
|
+
json_pure (1.4.6)
|
45
45
|
mail (2.2.5)
|
46
46
|
activesupport (>= 2.3.6)
|
47
47
|
mime-types
|
@@ -81,11 +81,13 @@ GEM
|
|
81
81
|
treetop (1.4.8)
|
82
82
|
polyglot (>= 0.3.1)
|
83
83
|
tzinfo (0.3.22)
|
84
|
+
zip (2.0.2)
|
84
85
|
|
85
86
|
PLATFORMS
|
86
87
|
ruby
|
87
88
|
|
88
89
|
DEPENDENCIES
|
89
|
-
jeweler
|
90
|
+
jeweler (= 1.4.0)
|
90
91
|
rails (= 3.0.0.rc)
|
91
92
|
rspec (= 2.0.0.beta.19)
|
93
|
+
zip (= 2.0.2)
|
data/README.textile
CHANGED
@@ -5,7 +5,35 @@ to validate form according to ActiveModel record validations.
|
|
5
5
|
|
6
6
|
h2. Installation
|
7
7
|
|
8
|
-
|
8
|
+
Just configure your Gemfile with
|
9
|
+
|
10
|
+
bc. gem 'jcheck_rails'
|
11
|
+
|
12
|
+
h2. Basic Usage
|
13
|
+
|
14
|
+
To make a basic usage of @jcheck_rails@ is really simple, first you need to
|
15
|
+
setup your application view to use jcheck, to make it just go to "jCheck site":http://jcheck.net,
|
16
|
+
download the latest version, drop the files in your public directory (the zip
|
17
|
+
contains the correct folders, js in javascripts folder and css in stylesheets
|
18
|
+
folder), and them add there files in you layout.
|
19
|
+
|
20
|
+
With the front-end setup done, go to your form and do:
|
21
|
+
|
22
|
+
bc. <%= jcheck_for @post %>
|
23
|
+
|
24
|
+
Replace the @@post@ with variable of your object to current form. This will
|
25
|
+
make a reflection into your model validations and will write the respective
|
26
|
+
ones using @jCheck@.
|
27
|
+
|
28
|
+
It's highly recommendable that you read the @jCheck@ documentation at
|
29
|
+
"http://jcheck.net/documentation":http://jcheck.net/documentation for a full
|
30
|
+
knowledge on @jCheck@.
|
31
|
+
|
32
|
+
h2. TODO
|
33
|
+
|
34
|
+
* Option to filter fields that should has exposed validations
|
35
|
+
* Get messages from i18n and append automatic
|
36
|
+
* Get field names from i18n and use automatic
|
9
37
|
|
10
38
|
h2. Copyright
|
11
39
|
|
data/Rakefile
CHANGED
@@ -13,6 +13,8 @@ begin
|
|
13
13
|
gem.email = "wilkerlucio@gmail.com"
|
14
14
|
gem.homepage = "http://github.com/wilkerlucio/jcheck_rails"
|
15
15
|
gem.authors = ["Wilker Lucio"]
|
16
|
+
gem.files.include ["lib/**/*", "tasks/**/*"]
|
17
|
+
gem.add_dependency('zip', '>= 2.0.2')
|
16
18
|
end
|
17
19
|
Jeweler::GemcutterTasks.new
|
18
20
|
rescue LoadError
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.2.0
|
data/jcheck_rails.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{jcheck_rails}
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "0.2.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Wilker Lucio"]
|
12
|
-
s.date = %q{2010-08-
|
12
|
+
s.date = %q{2010-08-17}
|
13
13
|
s.description = %q{Generate jCheck code according to ActiveModel validations}
|
14
14
|
s.email = %q{wilkerlucio@gmail.com}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -31,7 +31,8 @@ Gem::Specification.new do |s|
|
|
31
31
|
"lib/jcheck_rails/encoder.rb",
|
32
32
|
"spec/encoder_spec.rb",
|
33
33
|
"spec/jcheck_rails_spec.rb",
|
34
|
-
"spec/spec_helper.rb"
|
34
|
+
"spec/spec_helper.rb",
|
35
|
+
"tasks/jcheck_tasks.rake"
|
35
36
|
]
|
36
37
|
s.homepage = %q{http://github.com/wilkerlucio/jcheck_rails}
|
37
38
|
s.rdoc_options = ["--charset=UTF-8"]
|
@@ -49,9 +50,12 @@ Gem::Specification.new do |s|
|
|
49
50
|
s.specification_version = 3
|
50
51
|
|
51
52
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
53
|
+
s.add_runtime_dependency(%q<zip>, [">= 2.0.2"])
|
52
54
|
else
|
55
|
+
s.add_dependency(%q<zip>, [">= 2.0.2"])
|
53
56
|
end
|
54
57
|
else
|
58
|
+
s.add_dependency(%q<zip>, [">= 2.0.2"])
|
55
59
|
end
|
56
60
|
end
|
57
61
|
|
data/lib/jcheck_rails.rb
CHANGED
@@ -1,8 +1,33 @@
|
|
1
1
|
require 'jcheck_rails/encoder'
|
2
2
|
|
3
3
|
module JcheckRails
|
4
|
+
class Engine < Rails::Engine
|
5
|
+
rake_tasks do
|
6
|
+
load File.expand_path('../../tasks/jcheck_tasks.rake', __FILE__)
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
4
10
|
extend self
|
5
11
|
|
12
|
+
# This will reflect into your model and generate correct jCheck validations
|
13
|
+
# for you. In first argument you should send the current object of model, if
|
14
|
+
# you want to get just the validations for an given attribute, send the
|
15
|
+
# attribute name as second parameter. In third parameter you can send options
|
16
|
+
# to be used in jCheck initialization, but there some special keys that can
|
17
|
+
# be sent in the options.
|
18
|
+
#
|
19
|
+
# <%= form_for(@object) do |f| %>
|
20
|
+
# ...
|
21
|
+
# <% end %>
|
22
|
+
# <%= jcheck_for(@object) %>
|
23
|
+
#
|
24
|
+
# Configuration options:
|
25
|
+
# * <tt>:variable</tt> - Variable name to be used in javascript (default is: "validator")
|
26
|
+
# * <tt>:form_id</tt> - The id of form in html to be used in jQuery selector (default is same behaviour as +form_for+ do to generate form id)
|
27
|
+
# * <tt>:field_prefix</tt> - Field prefix to be used into jCheck, send nil to avoid field_prefix (default is same prefix as form_for will do)
|
28
|
+
#
|
29
|
+
# Also, any other configuration option will be sent to jCheck() initializer.
|
30
|
+
#
|
6
31
|
def jcheck_for(object, attribute = nil, options = {})
|
7
32
|
return jcheck_for_object_attribute(object, attribute) if attribute
|
8
33
|
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
require 'open-uri'
|
3
|
+
require 'zip'
|
4
|
+
|
5
|
+
namespace :jcheck do
|
6
|
+
desc "Download latest version of jcheck"
|
7
|
+
task :setup => :environment do
|
8
|
+
puts "Downloading jCheck..."
|
9
|
+
|
10
|
+
tmp_dir = File.join(Rails.root, "tmp")
|
11
|
+
|
12
|
+
FileUtils.mkdir_p(tmp_dir)
|
13
|
+
|
14
|
+
tmp_path = File.join(tmp_dir, "jcheck.zip")
|
15
|
+
|
16
|
+
File.open(tmp_path, "wb") { |f| f << open("http://jcheck.net/download/latest").read }
|
17
|
+
|
18
|
+
public_path = File.join(Rails.root, "public")
|
19
|
+
|
20
|
+
version = '0.0.0'
|
21
|
+
|
22
|
+
Zip::ZipFile.open(tmp_path) do |zip|
|
23
|
+
zip.each do |entry|
|
24
|
+
next unless entry.file?
|
25
|
+
|
26
|
+
version = $1 if entry.name =~ /jcheck-(\d+\.\d+\.\d+)/
|
27
|
+
|
28
|
+
puts "Extracting #{entry.name}..."
|
29
|
+
entry.extract(File.join(public_path, entry.name)) {true}
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
puts
|
34
|
+
puts "------------------------------------------------------------"
|
35
|
+
puts "Now you need to configure your views, use following snippet:"
|
36
|
+
puts
|
37
|
+
puts "<%= stylesheet_link_tag 'jcheck' %>"
|
38
|
+
puts "<%= javascript_include_tag 'jcheck-#{version}.min' %>"
|
39
|
+
puts
|
40
|
+
puts "And you also need to include the jQuery 1.4.2+ into your\nviews in order to jCheck works."
|
41
|
+
puts "------------------------------------------------------------"
|
42
|
+
|
43
|
+
File.delete(tmp_path)
|
44
|
+
end
|
45
|
+
end
|
metadata
CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
|
|
4
4
|
prerelease: false
|
5
5
|
segments:
|
6
6
|
- 0
|
7
|
-
-
|
8
|
-
-
|
9
|
-
version: 0.
|
7
|
+
- 2
|
8
|
+
- 0
|
9
|
+
version: 0.2.0
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Wilker Lucio
|
@@ -14,10 +14,24 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-08-
|
17
|
+
date: 2010-08-17 00:00:00 -03:00
|
18
18
|
default_executable:
|
19
|
-
dependencies:
|
20
|
-
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
name: zip
|
22
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
23
|
+
none: false
|
24
|
+
requirements:
|
25
|
+
- - ">="
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
segments:
|
28
|
+
- 2
|
29
|
+
- 0
|
30
|
+
- 2
|
31
|
+
version: 2.0.2
|
32
|
+
type: :runtime
|
33
|
+
prerelease: false
|
34
|
+
version_requirements: *id001
|
21
35
|
description: Generate jCheck code according to ActiveModel validations
|
22
36
|
email: wilkerlucio@gmail.com
|
23
37
|
executables: []
|
@@ -43,6 +57,7 @@ files:
|
|
43
57
|
- spec/encoder_spec.rb
|
44
58
|
- spec/jcheck_rails_spec.rb
|
45
59
|
- spec/spec_helper.rb
|
60
|
+
- tasks/jcheck_tasks.rake
|
46
61
|
has_rdoc: true
|
47
62
|
homepage: http://github.com/wilkerlucio/jcheck_rails
|
48
63
|
licenses: []
|
@@ -57,7 +72,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
57
72
|
requirements:
|
58
73
|
- - ">="
|
59
74
|
- !ruby/object:Gem::Version
|
60
|
-
hash: -
|
75
|
+
hash: -654179293814273617
|
61
76
|
segments:
|
62
77
|
- 0
|
63
78
|
version: "0"
|