green_light 0.2.5 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +13 -5
- data/.ruby-version +1 -0
- data/.travis.yml +8 -0
- data/Gemfile +2 -2
- data/README.rdoc +1 -1
- data/RELEASE.md +22 -0
- data/Rakefile +9 -0
- data/lib/green_light.rb +1 -1
- data/lib/green_light/validations/validates_numericality_of.rb +1 -1
- data/lib/green_light/version.rb +1 -1
- data/spec/green_light_spec.rb +20 -16
- data/spec/spec_helper.rb +0 -1
- metadata +11 -11
checksums.yaml
CHANGED
@@ -1,7 +1,15 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
M2UwYjBlYjI3ODkwNjM5ZWM2Yjc2ZGViMDE4NDU0YTQ2MzIyMTdjZQ==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
MmMxODRkZWQ2NzFmODQzNzQyZmVmMGY2ZWNhZGMzODEzYTM5ZGU2NA==
|
5
7
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
NzhlYTJjZWM0N2ExNzkwMTFiZTEwNDMwYTgxMzVhYzk1Y2EwYmI0NGJjNWE0
|
10
|
+
ODE5NDk3NjVlYmUwNDU5NDBkZjU2MDdkMjY0MDg1MTFiMGI3NGRlODM2MDIz
|
11
|
+
NzBiNzk2MzBlZTU5MDY0NjRhOWMxNTMwYzFiOTA5MDJiZjk0Yjk=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
ZDBlZDMzNWU5MWM3NTc0M2FlNTk1OTY1ZWNiNDQzOTkyODk2YzFlNGNlYWI4
|
14
|
+
ZmI2NjcyNjQ4NTBhMDE5ZmE5Y2IzMGM1NWY2NWViYjM4NTg3OTYyMzViMjZh
|
15
|
+
Yzc2OGYyZWMxYzNlYWM2MTFhMTg3MzJiZGIzZmI4Njk5NDRlMjI=
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.1.5
|
data/.travis.yml
ADDED
@@ -0,0 +1,8 @@
|
|
1
|
+
language: ruby
|
2
|
+
sudo: false
|
3
|
+
deploy:
|
4
|
+
provider: rubygems
|
5
|
+
api_key:
|
6
|
+
secure: B51IrAkE9tgScezWZ4ZxLY0diopv3a5/CYy3jqQqGea7N2OBQTnD0NaS614zo68bQi2mZu2Tjp4KBagI87aG+3mJW+jJR3M7lasngeOvHgISgOs0NnMqi3n+2ZgBLYrQbyCxjF9CCYzB2ZuJL6tubV7U68ZCD7RPKbt876zHd2Q=
|
7
|
+
on:
|
8
|
+
tags: true
|
data/Gemfile
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
source 'http://rubygems.org'
|
2
|
-
gem 'rails',"4.1.
|
2
|
+
gem 'rails',"4.1.8"
|
3
3
|
|
4
4
|
# Gems used only for assets and not required
|
5
5
|
# in production environments by default.
|
@@ -13,5 +13,5 @@ gem 'jquery-rails'
|
|
13
13
|
|
14
14
|
group :test do
|
15
15
|
gem 'rspec'
|
16
|
-
gem '
|
16
|
+
gem 'rake'
|
17
17
|
end
|
data/README.rdoc
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
= green_light
|
1
|
+
= green_light {<img src="https://travis-ci.org/overture8/green_light.svg?branch=master" alt="Build Status" />}[https://travis-ci.org/overture8/green_light]
|
2
2
|
|
3
3
|
Provides client side validation, with the help of the {jquery validation plugin}[http://bassistance.de/jquery-plugins/jquery-plugin-validation/]. Keeping validation in the model, where it belongs.
|
4
4
|
|
data/RELEASE.md
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
# Release Documentation
|
2
|
+
|
3
|
+
After a commit the version should be bumped based on semver i.e.
|
4
|
+
|
5
|
+
* Bug fix - update 0.0.x
|
6
|
+
* Non API breaking change - update 0.x.0
|
7
|
+
* API breaking change - update x.0.0
|
8
|
+
|
9
|
+
First, the version should be updated in the version.rb file. Then, it should be
|
10
|
+
tagged with git.
|
11
|
+
|
12
|
+
The flow should be this.
|
13
|
+
|
14
|
+
```shell
|
15
|
+
git pull origin master
|
16
|
+
git add . && git commit -am "message"
|
17
|
+
git tag vX.X.X # Following semver instructions above.
|
18
|
+
git push origin master
|
19
|
+
git push --tags
|
20
|
+
# travis is set up to publich the npm on a successful build (see .travis.yml)
|
21
|
+
```
|
22
|
+
|
data/Rakefile
CHANGED
data/lib/green_light.rb
CHANGED
@@ -5,10 +5,10 @@ module GreenLight
|
|
5
5
|
autoload :Rules, 'green_light/rules'
|
6
6
|
|
7
7
|
module Validations
|
8
|
+
autoload :ValidatesUniquenessOf, 'green_light/validations/validates_uniqueness_of'
|
8
9
|
autoload :ValidatesFormatOf, 'green_light/validations/validates_format_of'
|
9
10
|
autoload :ValidatesLengthOf, 'green_light/validations/validates_length_of'
|
10
11
|
autoload :ValidatesNumericalityOf, 'green_light/validations/validates_numericality_of'
|
11
12
|
autoload :ValidatesPresenceOf, 'green_light/validations/validates_presence_of'
|
12
|
-
autoload :ValidatesUniquenessOf, 'green_light/validations/validates_uniqueness_of'
|
13
13
|
end
|
14
14
|
end
|
data/lib/green_light/version.rb
CHANGED
data/spec/green_light_spec.rb
CHANGED
@@ -1,51 +1,55 @@
|
|
1
1
|
require File.dirname(__FILE__) + '/spec_helper'
|
2
2
|
|
3
3
|
describe GreenLight do
|
4
|
-
before(:all) do
|
5
|
-
end
|
6
|
-
|
7
4
|
it "should return a valid json string when validating the format of a field" do
|
8
5
|
rules = GreenLight::Rules.generate(['FormatOfModel'])
|
9
|
-
rules.
|
6
|
+
expect(rules).to eq("{\"rules\":{\"format_of_model[title]\":{\"regex\":\"(\\\\A[A-Za-z]\\\\z)\"}},\"errorElement\":\"span\"}")
|
10
7
|
end
|
11
8
|
|
12
9
|
it "should return a json string when validating the presence of a field" do
|
13
10
|
rules = GreenLight::Rules.generate(['PresenceOfModel'])
|
14
|
-
rules.
|
11
|
+
expect(rules).to eq("{\"rules\":{\"presence_of_model[title]\":{\"required\":true}},\"errorElement\":\"span\"}")
|
15
12
|
end
|
16
13
|
|
17
14
|
it "should return a json string when validating the length of a field" do
|
18
15
|
rules = GreenLight::Rules.generate(['LengthOfModel'])
|
19
|
-
rules.
|
16
|
+
expect(rules).to eq("{\"rules\":{\"length_of_model[title]\":{\"minlength\":5,\"maxlength\":10}},\"errorElement\":\"span\"}")
|
20
17
|
end
|
21
18
|
|
22
19
|
it "should return a json string when validating the numericality of a field" do
|
23
20
|
rules = GreenLight::Rules.generate(['NumericalityOfModel'])
|
24
|
-
rules.
|
21
|
+
expect(rules).to eq("{\"rules\":{\"numericality_of_model[age]\":{\"regex\":\"^[0-9.]*$\"}},\"errorElement\":\"span\"}")
|
25
22
|
end
|
26
23
|
|
27
24
|
it "should return a json string when validating the uniqueness of a field" do
|
28
25
|
rules = GreenLight::Rules.generate(['UniquenessOfModel'])
|
29
|
-
rules.
|
26
|
+
expect(rules).to eq("{\"rules\":{\"uniqueness_of_model[title]\":{\"remote\":\"/javascripts/check_for_uniqueness?model=UniquenessOfModel\\u0026field=title\"}},\"errorElement\":\"span\"}")
|
30
27
|
end
|
31
28
|
end
|
32
29
|
|
33
|
-
class
|
34
|
-
|
30
|
+
class UniquenessOfModel
|
31
|
+
include ActiveRecord::Validations
|
32
|
+
validates_uniqueness_of :title
|
33
|
+
end
|
34
|
+
|
35
|
+
class FormatOfModel
|
36
|
+
include ActiveModel::Model
|
37
|
+
validates_format_of :title, :with => /\A[A-Za-z]\z/
|
35
38
|
end
|
36
39
|
|
37
|
-
class PresenceOfModel
|
40
|
+
class PresenceOfModel
|
41
|
+
include ActiveModel::Model
|
38
42
|
validates_presence_of :title
|
39
43
|
end
|
40
44
|
|
41
|
-
class LengthOfModel
|
45
|
+
class LengthOfModel
|
46
|
+
include ActiveModel::Model
|
42
47
|
validates_length_of :title, :within => 5..10
|
43
48
|
end
|
44
49
|
|
45
|
-
class NumericalityOfModel
|
50
|
+
class NumericalityOfModel
|
51
|
+
include ActiveModel::Model
|
46
52
|
validates_numericality_of :age
|
47
53
|
end
|
48
54
|
|
49
|
-
|
50
|
-
validates_uniqueness_of :title
|
51
|
-
end
|
55
|
+
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: green_light
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Phil McClure
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-10-12 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Simple client side validation that keeps validation in the models
|
14
14
|
email:
|
@@ -17,10 +17,13 @@ executables: []
|
|
17
17
|
extensions: []
|
18
18
|
extra_rdoc_files: []
|
19
19
|
files:
|
20
|
-
-
|
21
|
-
-
|
20
|
+
- .DS_Store
|
21
|
+
- .gitignore
|
22
|
+
- .ruby-version
|
23
|
+
- .travis.yml
|
22
24
|
- Gemfile
|
23
25
|
- README.rdoc
|
26
|
+
- RELEASE.md
|
24
27
|
- Rakefile
|
25
28
|
- app/.DS_Store
|
26
29
|
- app/controllers/assets_controller.rb
|
@@ -54,21 +57,18 @@ require_paths:
|
|
54
57
|
- lib
|
55
58
|
required_ruby_version: !ruby/object:Gem::Requirement
|
56
59
|
requirements:
|
57
|
-
- -
|
60
|
+
- - ! '>='
|
58
61
|
- !ruby/object:Gem::Version
|
59
62
|
version: '0'
|
60
63
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
61
64
|
requirements:
|
62
|
-
- -
|
65
|
+
- - ! '>='
|
63
66
|
- !ruby/object:Gem::Version
|
64
67
|
version: '0'
|
65
68
|
requirements: []
|
66
69
|
rubyforge_project: green_light
|
67
|
-
rubygems_version: 2.
|
70
|
+
rubygems_version: 2.4.5
|
68
71
|
signing_key:
|
69
72
|
specification_version: 4
|
70
73
|
summary: Simple client side validation that keeps validation in the models
|
71
|
-
test_files:
|
72
|
-
- spec/green_light_spec.rb
|
73
|
-
- spec/spec_helper.rb
|
74
|
-
has_rdoc:
|
74
|
+
test_files: []
|