jcheck_rails 0.2.0 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.bundle/config +2 -0
- data/README.textile +41 -18
- data/VERSION +1 -1
- data/jcheck_rails.gemspec +5 -6
- data/lib/jcheck_rails.rb +35 -5
- data/spec/jcheck_rails_spec.rb +82 -14
- data/spec/spec_helper.rb +26 -1
- metadata +5 -6
- data/LICENSE +0 -202
data/.bundle/config
ADDED
data/README.textile
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
h1. jCheck Rails
|
2
2
|
|
3
3
|
jCheck Rails provide a ease way to generate "jCheck":http://jcheck.net code
|
4
|
-
to validate
|
4
|
+
to validate forms according to ActiveModel record validations.
|
5
5
|
|
6
6
|
h2. Installation
|
7
7
|
|
@@ -11,30 +11,53 @@ bc. gem 'jcheck_rails'
|
|
11
11
|
|
12
12
|
h2. Basic Usage
|
13
13
|
|
14
|
-
|
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.
|
14
|
+
You can easily download latest version of jcheck using the provided rake task:
|
19
15
|
|
20
|
-
|
16
|
+
bc. rake jcheck:setup
|
21
17
|
|
22
|
-
|
18
|
+
This will download latest version of jcheck and will extract in correct directories for you. Them you just need to include files in your view layout.
|
23
19
|
|
24
|
-
|
25
|
-
make a reflection into your model validations and will write the respective
|
26
|
-
ones using @jCheck@.
|
20
|
+
With the library included, on your form views add the following:
|
27
21
|
|
28
|
-
|
22
|
+
bc. <%= jcheck_for resource %>
|
23
|
+
|
24
|
+
Replace @resource@ with the instance variable of the resource for form e.g. @@user@. This will
|
25
|
+
use reflection, to detect the model validations and will convert these to @jCheck@.
|
26
|
+
|
27
|
+
It's highly recommended that you read the @jCheck@ documentation at
|
29
28
|
"http://jcheck.net/documentation":http://jcheck.net/documentation for a full
|
30
|
-
|
29
|
+
overview on @jCheck@.
|
31
30
|
|
32
31
|
h2. TODO
|
33
32
|
|
34
|
-
*
|
35
|
-
|
36
|
-
|
33
|
+
* Get messages from i18n and append automatically
|
34
|
+
|
35
|
+
h2. Change Log
|
36
|
+
|
37
|
+
h3. 0.2.0
|
38
|
+
|
39
|
+
* Added rake task for setup
|
40
|
+
|
41
|
+
h3. 0.1.1
|
42
|
+
|
43
|
+
* Initial Release
|
44
|
+
|
45
|
+
h2. Maintainers
|
46
|
+
|
47
|
+
* Wilker Lucio (http://github.com/wilkerlucio/jcheck)
|
48
|
+
|
49
|
+
h2. License
|
50
|
+
|
51
|
+
Copyright 2010 Wilker Lucio.
|
52
|
+
|
53
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
54
|
+
you may not use this file except in compliance with the License.
|
55
|
+
You may obtain a copy of the License at
|
37
56
|
|
38
|
-
|
57
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
39
58
|
|
40
|
-
|
59
|
+
Unless required by applicable law or agreed to in writing, software
|
60
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
61
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
62
|
+
See the License for the specific language governing permissions and
|
63
|
+
limitations under the License.
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.5.0
|
data/jcheck_rails.gemspec
CHANGED
@@ -5,23 +5,22 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{jcheck_rails}
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "0.5.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-22}
|
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 = [
|
16
|
-
"
|
17
|
-
"README.textile"
|
16
|
+
"README.textile"
|
18
17
|
]
|
19
18
|
s.files = [
|
20
|
-
".
|
19
|
+
".bundle/config",
|
20
|
+
".document",
|
21
21
|
".gitignore",
|
22
22
|
"Gemfile",
|
23
23
|
"Gemfile.lock",
|
24
|
-
"LICENSE",
|
25
24
|
"README.textile",
|
26
25
|
"Rakefile",
|
27
26
|
"VERSION",
|
data/lib/jcheck_rails.rb
CHANGED
@@ -9,12 +9,15 @@ module JcheckRails
|
|
9
9
|
|
10
10
|
extend self
|
11
11
|
|
12
|
+
KNOW_VALIDATORS = [:acceptance, :confirmation, :exclusion, :format, :inclusion, :length, :numericality, :presence]
|
13
|
+
|
12
14
|
# This will reflect into your model and generate correct jCheck validations
|
13
15
|
# for you. In first argument you should send the current object of model, if
|
14
16
|
# you want to get just the validations for an given attribute, send the
|
15
17
|
# attribute name as second parameter. In third parameter you can send options
|
16
18
|
# to be used in jCheck initialization, but there some special keys that can
|
17
|
-
# be sent in the options.
|
19
|
+
# be sent in the options. You can also send options as second parameter, in
|
20
|
+
# this case the attribute will be considered nil.
|
18
21
|
#
|
19
22
|
# <%= form_for(@object) do |f| %>
|
20
23
|
# ...
|
@@ -25,37 +28,64 @@ module JcheckRails
|
|
25
28
|
# * <tt>:variable</tt> - Variable name to be used in javascript (default is: "validator")
|
26
29
|
# * <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
30
|
# * <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)
|
31
|
+
# * <tt>:generate_field_names</tt> - Define if it should generate field custom_label for jCheck (default is true)
|
32
|
+
# * <tt>:only_attributes</tt> - Filter the attributes that should be reflected (default nil)
|
33
|
+
# * <tt>:exclude_attributes</tt> - Filter the attributes that should not be reflected (default nil)
|
28
34
|
#
|
29
35
|
# Also, any other configuration option will be sent to jCheck() initializer.
|
30
36
|
#
|
31
|
-
def jcheck_for(
|
37
|
+
def jcheck_for(*args)
|
38
|
+
options = args.extract_options!
|
39
|
+
object = args.shift
|
40
|
+
attribute = args.length > 0 ? args[0] : nil
|
41
|
+
|
32
42
|
return jcheck_for_object_attribute(object, attribute) if attribute
|
33
43
|
|
34
44
|
options.reverse_merge!(
|
35
45
|
:variable => "validator",
|
36
46
|
:form_id => ActionController::RecordIdentifier.dom_id(object, (object.respond_to?(:persisted?) && object.persisted? ? :edit : nil)),
|
37
|
-
:field_prefix => ActiveModel::Naming.singular(object)
|
47
|
+
:field_prefix => ActiveModel::Naming.singular(object),
|
48
|
+
:generate_field_names => true,
|
49
|
+
:only_attributes => nil,
|
50
|
+
:exclude_attributes => nil
|
38
51
|
)
|
39
52
|
|
53
|
+
only_attributes = options.delete :only_attributes
|
54
|
+
exclude_attributes = options.delete :exclude_attributes
|
40
55
|
variable = options.delete :variable
|
41
56
|
form_id = options.delete :form_id
|
57
|
+
generate_field_names = options.delete :generate_field_names
|
42
58
|
|
43
59
|
validations = []
|
60
|
+
field_names = []
|
44
61
|
|
45
62
|
object.class._validators.each do |attribute, validators|
|
63
|
+
next if only_attributes and !(only_attributes.include?(attribute))
|
64
|
+
next if exclude_attributes and exclude_attributes.include?(attribute)
|
65
|
+
|
46
66
|
attr_validations = jcheck_for_object_attribute(object, attribute)
|
47
67
|
|
68
|
+
field_names << "#{variable}.field(#{Encoder.convert_to_javascript attribute}).custom_label = #{Encoder.convert_to_javascript jcheck_attribute_name(object, attribute)};" if generate_field_names
|
48
69
|
validations << "#{variable}.validates(#{Encoder.convert_to_javascript attribute}, #{attr_validations});"
|
49
70
|
end
|
50
71
|
|
51
|
-
%{<script type="text/javascript"> jQuery(function() { var #{variable} = jQuery('##{form_id}').jcheck(#{Encoder.convert_to_javascript(options)}); #{validations.join(" ")} }); </script>}.html_safe
|
72
|
+
%{<script type="text/javascript"> jQuery(function() { var #{variable} = jQuery('##{form_id}').jcheck(#{Encoder.convert_to_javascript(options)}); #{validations.join(" ")} #{field_names.join(" ")} }); </script>}.html_safe
|
73
|
+
end
|
74
|
+
|
75
|
+
def jcheck_attribute_name(object, attribute)
|
76
|
+
if object.class.respond_to? :human_attribute_name
|
77
|
+
object.class.human_attribute_name(attribute)
|
78
|
+
else
|
79
|
+
attribute.to_s.humanize
|
80
|
+
end
|
52
81
|
end
|
53
82
|
|
54
83
|
def jcheck_for_object_attribute(object, attribute)
|
55
84
|
validations = object.class._validators[attribute].inject([]) do |acc, validator|
|
56
85
|
options = filter_validator_options(validator)
|
57
86
|
|
58
|
-
acc << "#{Encoder.convert_to_javascript validator.kind}: #{Encoder.convert_to_javascript(options)}"
|
87
|
+
acc << "#{Encoder.convert_to_javascript validator.kind}: #{Encoder.convert_to_javascript(options)}" if KNOW_VALIDATORS.include? validator.kind
|
88
|
+
acc
|
59
89
|
end
|
60
90
|
|
61
91
|
"{#{validations.join(', ')}}"
|
data/spec/jcheck_rails_spec.rb
CHANGED
@@ -186,6 +186,58 @@ describe "JcheckRails" do
|
|
186
186
|
jcheck(m, :name).should == "{'presence': true}"
|
187
187
|
end
|
188
188
|
end
|
189
|
+
|
190
|
+
it "should not generate for other validations" do
|
191
|
+
m = mock_model do
|
192
|
+
attr_accessor :name
|
193
|
+
validates_presence_of :name
|
194
|
+
validates_sample_of :name
|
195
|
+
end
|
196
|
+
|
197
|
+
jcheck(m, :name).should == "{'presence': true}"
|
198
|
+
end
|
199
|
+
end
|
200
|
+
|
201
|
+
context "i18n" do
|
202
|
+
context "field names" do
|
203
|
+
it "should get result of humanized attribute" do
|
204
|
+
m = mock_model do
|
205
|
+
def self.human_attribute_name(attribute)
|
206
|
+
attribute == "name" ? "Nome" : attribute.to_s.humanize
|
207
|
+
end
|
208
|
+
end
|
209
|
+
|
210
|
+
JcheckRails::jcheck_attribute_name(m, "name").should == "Nome"
|
211
|
+
JcheckRails::jcheck_attribute_name(m, "other").should == "Other"
|
212
|
+
end
|
213
|
+
|
214
|
+
it "should generate field names for attributes with validations" do
|
215
|
+
m = mock_model do
|
216
|
+
attr_accessor :name, :email, :main_address
|
217
|
+
|
218
|
+
validates_presence_of :name, :main_address
|
219
|
+
end
|
220
|
+
|
221
|
+
T = m.class
|
222
|
+
|
223
|
+
output = jcheck(m)
|
224
|
+
output.should include("validator.field('name').custom_label = 'Name'", "validator.field('main_address').custom_label = 'Main address'")
|
225
|
+
output.should_not include("validator.field('email')")
|
226
|
+
end
|
227
|
+
|
228
|
+
it "should not generate field names if it's disabled by option" do
|
229
|
+
m = mock_model do
|
230
|
+
attr_accessor :name, :email, :main_address
|
231
|
+
|
232
|
+
validates_presence_of :name
|
233
|
+
end
|
234
|
+
|
235
|
+
T2 = m.class
|
236
|
+
|
237
|
+
output = jcheck(m, nil, :generate_field_names => false)
|
238
|
+
output.should_not include("validator.field('name').custom_label = 'Name'")
|
239
|
+
end
|
240
|
+
end
|
189
241
|
end
|
190
242
|
|
191
243
|
context "generating all script for model" do
|
@@ -194,37 +246,53 @@ describe "JcheckRails" do
|
|
194
246
|
attr_accessor :name
|
195
247
|
|
196
248
|
validates_presence_of :name
|
197
|
-
|
198
|
-
def persisted?
|
199
|
-
false
|
200
|
-
end
|
201
|
-
|
202
|
-
def to_key
|
203
|
-
nil
|
204
|
-
end
|
205
249
|
end
|
206
250
|
|
207
251
|
SampleModel = @m.class
|
208
252
|
end
|
209
253
|
|
210
254
|
it "should generate all data" do
|
211
|
-
jcheck(@m).should == "<script type=\"text/javascript\"> jQuery(function() { var validator = jQuery('#new_sample_model').jcheck({'field_prefix': 'sample_model'}); validator.validates('name', {'presence': true}); }); </script>"
|
255
|
+
jcheck(@m).should == "<script type=\"text/javascript\"> jQuery(function() { var validator = jQuery('#new_sample_model').jcheck({'field_prefix': 'sample_model'}); validator.validates('name', {'presence': true}); validator.field('name').custom_label = 'Name'; }); </script>"
|
256
|
+
end
|
257
|
+
|
258
|
+
context "filtering attributes" do
|
259
|
+
before :all do
|
260
|
+
@md = mock_model do
|
261
|
+
attr_accessor :name, :email, :address
|
262
|
+
|
263
|
+
validates_presence_of :name, :email, :address
|
264
|
+
end
|
265
|
+
|
266
|
+
FilterTest = @md.class
|
267
|
+
end
|
268
|
+
|
269
|
+
it "should get only some attributes if using only_attributes option" do
|
270
|
+
output = jcheck(@md, :only_attributes => [:name, :email])
|
271
|
+
output.should include("validates('name'", "validates('email'")
|
272
|
+
output.should_not include("validates('address'")
|
273
|
+
end
|
274
|
+
|
275
|
+
it "should exclude some attributes if it's sent" do
|
276
|
+
output = jcheck(@md, :exclude_attributes => [:name, :address])
|
277
|
+
output.should include("validates('email'")
|
278
|
+
output.should_not include("validates('name'", "validates('address'")
|
279
|
+
end
|
212
280
|
end
|
213
281
|
|
214
282
|
it "should be able to customize form id" do
|
215
|
-
jcheck(@m,
|
283
|
+
jcheck(@m, :form_id => "custom_form_id").should include("jQuery('#custom_form_id')")
|
216
284
|
end
|
217
285
|
|
218
286
|
it "should be able to customize field prefix" do
|
219
|
-
jcheck(@m,
|
287
|
+
jcheck(@m, :field_prefix => "custom_field_prefix").should include("'field_prefix': 'custom_field_prefix'")
|
220
288
|
end
|
221
289
|
|
222
290
|
it "should be able to add custom values" do
|
223
|
-
jcheck(@m,
|
291
|
+
jcheck(@m, :notifiers => ["custom_notifier"], :prevent_submit => false).should include("'notifiers': ['custom_notifier']", "'prevent_submit': false")
|
224
292
|
end
|
225
293
|
|
226
294
|
it "should be able customize javascript variable name" do
|
227
|
-
jcheck(@m,
|
295
|
+
jcheck(@m, :variable => "v").should include("var v = jQuery", "v.validates")
|
228
296
|
end
|
229
297
|
end
|
230
298
|
|
@@ -247,7 +315,7 @@ describe "JcheckRails" do
|
|
247
315
|
|
248
316
|
CusCla = m.class
|
249
317
|
|
250
|
-
jcheck(m).should == "<script type=\"text/javascript\"> jQuery(function() { var validator = jQuery('#new_cus_cla').jcheck({'field_prefix': 'cus_cla'}); validator.validates('name', {'presence': true});
|
318
|
+
jcheck(m, :generate_field_names => false).should == "<script type=\"text/javascript\"> jQuery(function() { var validator = jQuery('#new_cus_cla').jcheck({'field_prefix': 'cus_cla'}); validator.validates('name', {'presence': true}); }); </script>"
|
251
319
|
end
|
252
320
|
end
|
253
321
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -19,8 +19,33 @@ def jcheck(*args)
|
|
19
19
|
end
|
20
20
|
|
21
21
|
def mock_model(&block)
|
22
|
-
cls = Class.new
|
22
|
+
cls = Class.new do
|
23
|
+
def persisted?
|
24
|
+
false
|
25
|
+
end
|
26
|
+
|
27
|
+
def to_key
|
28
|
+
nil
|
29
|
+
end
|
30
|
+
end
|
23
31
|
cls.send :include, ActiveModel::Validations
|
24
32
|
cls.class_eval &block
|
25
33
|
cls.new
|
26
34
|
end
|
35
|
+
|
36
|
+
module ActiveModel
|
37
|
+
module Validations
|
38
|
+
class SampleValidator < EachValidator
|
39
|
+
def validate_each(record, attribute, value)
|
40
|
+
record.errors.add(attribute, "test")
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
module HelperMethods
|
45
|
+
def validates_sample_of(*attr_names)
|
46
|
+
validates_with SampleValidator, _merge_attributes(attr_names)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
metadata
CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
|
|
4
4
|
prerelease: false
|
5
5
|
segments:
|
6
6
|
- 0
|
7
|
-
-
|
7
|
+
- 5
|
8
8
|
- 0
|
9
|
-
version: 0.
|
9
|
+
version: 0.5.0
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Wilker Lucio
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-08-
|
17
|
+
date: 2010-08-22 00:00:00 -03:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -39,14 +39,13 @@ executables: []
|
|
39
39
|
extensions: []
|
40
40
|
|
41
41
|
extra_rdoc_files:
|
42
|
-
- LICENSE
|
43
42
|
- README.textile
|
44
43
|
files:
|
44
|
+
- .bundle/config
|
45
45
|
- .document
|
46
46
|
- .gitignore
|
47
47
|
- Gemfile
|
48
48
|
- Gemfile.lock
|
49
|
-
- LICENSE
|
50
49
|
- README.textile
|
51
50
|
- Rakefile
|
52
51
|
- VERSION
|
@@ -72,7 +71,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
72
71
|
requirements:
|
73
72
|
- - ">="
|
74
73
|
- !ruby/object:Gem::Version
|
75
|
-
hash:
|
74
|
+
hash: 430536012187104030
|
76
75
|
segments:
|
77
76
|
- 0
|
78
77
|
version: "0"
|
data/LICENSE
DELETED
@@ -1,202 +0,0 @@
|
|
1
|
-
|
2
|
-
Apache License
|
3
|
-
Version 2.0, January 2004
|
4
|
-
http://www.apache.org/licenses/
|
5
|
-
|
6
|
-
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
7
|
-
|
8
|
-
1. Definitions.
|
9
|
-
|
10
|
-
"License" shall mean the terms and conditions for use, reproduction,
|
11
|
-
and distribution as defined by Sections 1 through 9 of this document.
|
12
|
-
|
13
|
-
"Licensor" shall mean the copyright owner or entity authorized by
|
14
|
-
the copyright owner that is granting the License.
|
15
|
-
|
16
|
-
"Legal Entity" shall mean the union of the acting entity and all
|
17
|
-
other entities that control, are controlled by, or are under common
|
18
|
-
control with that entity. For the purposes of this definition,
|
19
|
-
"control" means (i) the power, direct or indirect, to cause the
|
20
|
-
direction or management of such entity, whether by contract or
|
21
|
-
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
22
|
-
outstanding shares, or (iii) beneficial ownership of such entity.
|
23
|
-
|
24
|
-
"You" (or "Your") shall mean an individual or Legal Entity
|
25
|
-
exercising permissions granted by this License.
|
26
|
-
|
27
|
-
"Source" form shall mean the preferred form for making modifications,
|
28
|
-
including but not limited to software source code, documentation
|
29
|
-
source, and configuration files.
|
30
|
-
|
31
|
-
"Object" form shall mean any form resulting from mechanical
|
32
|
-
transformation or translation of a Source form, including but
|
33
|
-
not limited to compiled object code, generated documentation,
|
34
|
-
and conversions to other media types.
|
35
|
-
|
36
|
-
"Work" shall mean the work of authorship, whether in Source or
|
37
|
-
Object form, made available under the License, as indicated by a
|
38
|
-
copyright notice that is included in or attached to the work
|
39
|
-
(an example is provided in the Appendix below).
|
40
|
-
|
41
|
-
"Derivative Works" shall mean any work, whether in Source or Object
|
42
|
-
form, that is based on (or derived from) the Work and for which the
|
43
|
-
editorial revisions, annotations, elaborations, or other modifications
|
44
|
-
represent, as a whole, an original work of authorship. For the purposes
|
45
|
-
of this License, Derivative Works shall not include works that remain
|
46
|
-
separable from, or merely link (or bind by name) to the interfaces of,
|
47
|
-
the Work and Derivative Works thereof.
|
48
|
-
|
49
|
-
"Contribution" shall mean any work of authorship, including
|
50
|
-
the original version of the Work and any modifications or additions
|
51
|
-
to that Work or Derivative Works thereof, that is intentionally
|
52
|
-
submitted to Licensor for inclusion in the Work by the copyright owner
|
53
|
-
or by an individual or Legal Entity authorized to submit on behalf of
|
54
|
-
the copyright owner. For the purposes of this definition, "submitted"
|
55
|
-
means any form of electronic, verbal, or written communication sent
|
56
|
-
to the Licensor or its representatives, including but not limited to
|
57
|
-
communication on electronic mailing lists, source code control systems,
|
58
|
-
and issue tracking systems that are managed by, or on behalf of, the
|
59
|
-
Licensor for the purpose of discussing and improving the Work, but
|
60
|
-
excluding communication that is conspicuously marked or otherwise
|
61
|
-
designated in writing by the copyright owner as "Not a Contribution."
|
62
|
-
|
63
|
-
"Contributor" shall mean Licensor and any individual or Legal Entity
|
64
|
-
on behalf of whom a Contribution has been received by Licensor and
|
65
|
-
subsequently incorporated within the Work.
|
66
|
-
|
67
|
-
2. Grant of Copyright License. Subject to the terms and conditions of
|
68
|
-
this License, each Contributor hereby grants to You a perpetual,
|
69
|
-
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
70
|
-
copyright license to reproduce, prepare Derivative Works of,
|
71
|
-
publicly display, publicly perform, sublicense, and distribute the
|
72
|
-
Work and such Derivative Works in Source or Object form.
|
73
|
-
|
74
|
-
3. Grant of Patent License. Subject to the terms and conditions of
|
75
|
-
this License, each Contributor hereby grants to You a perpetual,
|
76
|
-
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
77
|
-
(except as stated in this section) patent license to make, have made,
|
78
|
-
use, offer to sell, sell, import, and otherwise transfer the Work,
|
79
|
-
where such license applies only to those patent claims licensable
|
80
|
-
by such Contributor that are necessarily infringed by their
|
81
|
-
Contribution(s) alone or by combination of their Contribution(s)
|
82
|
-
with the Work to which such Contribution(s) was submitted. If You
|
83
|
-
institute patent litigation against any entity (including a
|
84
|
-
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
85
|
-
or a Contribution incorporated within the Work constitutes direct
|
86
|
-
or contributory patent infringement, then any patent licenses
|
87
|
-
granted to You under this License for that Work shall terminate
|
88
|
-
as of the date such litigation is filed.
|
89
|
-
|
90
|
-
4. Redistribution. You may reproduce and distribute copies of the
|
91
|
-
Work or Derivative Works thereof in any medium, with or without
|
92
|
-
modifications, and in Source or Object form, provided that You
|
93
|
-
meet the following conditions:
|
94
|
-
|
95
|
-
(a) You must give any other recipients of the Work or
|
96
|
-
Derivative Works a copy of this License; and
|
97
|
-
|
98
|
-
(b) You must cause any modified files to carry prominent notices
|
99
|
-
stating that You changed the files; and
|
100
|
-
|
101
|
-
(c) You must retain, in the Source form of any Derivative Works
|
102
|
-
that You distribute, all copyright, patent, trademark, and
|
103
|
-
attribution notices from the Source form of the Work,
|
104
|
-
excluding those notices that do not pertain to any part of
|
105
|
-
the Derivative Works; and
|
106
|
-
|
107
|
-
(d) If the Work includes a "NOTICE" text file as part of its
|
108
|
-
distribution, then any Derivative Works that You distribute must
|
109
|
-
include a readable copy of the attribution notices contained
|
110
|
-
within such NOTICE file, excluding those notices that do not
|
111
|
-
pertain to any part of the Derivative Works, in at least one
|
112
|
-
of the following places: within a NOTICE text file distributed
|
113
|
-
as part of the Derivative Works; within the Source form or
|
114
|
-
documentation, if provided along with the Derivative Works; or,
|
115
|
-
within a display generated by the Derivative Works, if and
|
116
|
-
wherever such third-party notices normally appear. The contents
|
117
|
-
of the NOTICE file are for informational purposes only and
|
118
|
-
do not modify the License. You may add Your own attribution
|
119
|
-
notices within Derivative Works that You distribute, alongside
|
120
|
-
or as an addendum to the NOTICE text from the Work, provided
|
121
|
-
that such additional attribution notices cannot be construed
|
122
|
-
as modifying the License.
|
123
|
-
|
124
|
-
You may add Your own copyright statement to Your modifications and
|
125
|
-
may provide additional or different license terms and conditions
|
126
|
-
for use, reproduction, or distribution of Your modifications, or
|
127
|
-
for any such Derivative Works as a whole, provided Your use,
|
128
|
-
reproduction, and distribution of the Work otherwise complies with
|
129
|
-
the conditions stated in this License.
|
130
|
-
|
131
|
-
5. Submission of Contributions. Unless You explicitly state otherwise,
|
132
|
-
any Contribution intentionally submitted for inclusion in the Work
|
133
|
-
by You to the Licensor shall be under the terms and conditions of
|
134
|
-
this License, without any additional terms or conditions.
|
135
|
-
Notwithstanding the above, nothing herein shall supersede or modify
|
136
|
-
the terms of any separate license agreement you may have executed
|
137
|
-
with Licensor regarding such Contributions.
|
138
|
-
|
139
|
-
6. Trademarks. This License does not grant permission to use the trade
|
140
|
-
names, trademarks, service marks, or product names of the Licensor,
|
141
|
-
except as required for reasonable and customary use in describing the
|
142
|
-
origin of the Work and reproducing the content of the NOTICE file.
|
143
|
-
|
144
|
-
7. Disclaimer of Warranty. Unless required by applicable law or
|
145
|
-
agreed to in writing, Licensor provides the Work (and each
|
146
|
-
Contributor provides its Contributions) on an "AS IS" BASIS,
|
147
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
148
|
-
implied, including, without limitation, any warranties or conditions
|
149
|
-
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
150
|
-
PARTICULAR PURPOSE. You are solely responsible for determining the
|
151
|
-
appropriateness of using or redistributing the Work and assume any
|
152
|
-
risks associated with Your exercise of permissions under this License.
|
153
|
-
|
154
|
-
8. Limitation of Liability. In no event and under no legal theory,
|
155
|
-
whether in tort (including negligence), contract, or otherwise,
|
156
|
-
unless required by applicable law (such as deliberate and grossly
|
157
|
-
negligent acts) or agreed to in writing, shall any Contributor be
|
158
|
-
liable to You for damages, including any direct, indirect, special,
|
159
|
-
incidental, or consequential damages of any character arising as a
|
160
|
-
result of this License or out of the use or inability to use the
|
161
|
-
Work (including but not limited to damages for loss of goodwill,
|
162
|
-
work stoppage, computer failure or malfunction, or any and all
|
163
|
-
other commercial damages or losses), even if such Contributor
|
164
|
-
has been advised of the possibility of such damages.
|
165
|
-
|
166
|
-
9. Accepting Warranty or Additional Liability. While redistributing
|
167
|
-
the Work or Derivative Works thereof, You may choose to offer,
|
168
|
-
and charge a fee for, acceptance of support, warranty, indemnity,
|
169
|
-
or other liability obligations and/or rights consistent with this
|
170
|
-
License. However, in accepting such obligations, You may act only
|
171
|
-
on Your own behalf and on Your sole responsibility, not on behalf
|
172
|
-
of any other Contributor, and only if You agree to indemnify,
|
173
|
-
defend, and hold each Contributor harmless for any liability
|
174
|
-
incurred by, or claims asserted against, such Contributor by reason
|
175
|
-
of your accepting any such warranty or additional liability.
|
176
|
-
|
177
|
-
END OF TERMS AND CONDITIONS
|
178
|
-
|
179
|
-
APPENDIX: How to apply the Apache License to your work.
|
180
|
-
|
181
|
-
To apply the Apache License to your work, attach the following
|
182
|
-
boilerplate notice, with the fields enclosed by brackets "[]"
|
183
|
-
replaced with your own identifying information. (Don't include
|
184
|
-
the brackets!) The text should be enclosed in the appropriate
|
185
|
-
comment syntax for the file format. We also recommend that a
|
186
|
-
file or class name and description of purpose be included on the
|
187
|
-
same "printed page" as the copyright notice for easier
|
188
|
-
identification within third-party archives.
|
189
|
-
|
190
|
-
Copyright (c) 2010 Wilker Lúcio <wilkerlucio@gmail.com>
|
191
|
-
|
192
|
-
Licensed under the Apache License, Version 2.0 (the "License");
|
193
|
-
you may not use this file except in compliance with the License.
|
194
|
-
You may obtain a copy of the License at
|
195
|
-
|
196
|
-
http://www.apache.org/licenses/LICENSE-2.0
|
197
|
-
|
198
|
-
Unless required by applicable law or agreed to in writing, software
|
199
|
-
distributed under the License is distributed on an "AS IS" BASIS,
|
200
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
201
|
-
See the License for the specific language governing permissions and
|
202
|
-
limitations under the License.
|