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 CHANGED
@@ -1,7 +1,15 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: ced62afb282a65e3909d66a1ab3f29fbad68b349
4
- data.tar.gz: 6f320cb4aa083544294cf977e07e238cb1cb248f
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ M2UwYjBlYjI3ODkwNjM5ZWM2Yjc2ZGViMDE4NDU0YTQ2MzIyMTdjZQ==
5
+ data.tar.gz: !binary |-
6
+ MmMxODRkZWQ2NzFmODQzNzQyZmVmMGY2ZWNhZGMzODEzYTM5ZGU2NA==
5
7
  SHA512:
6
- metadata.gz: c857bc8a9cdad32c9511c2d2e7e992875491d185c23dc554810999d5ed4d64b5b15a94e97cb58314e19a3fbd3752cd11f609752a6566972dd7bb4a6b8a0a7d3d
7
- data.tar.gz: 5948e644784876607ae588aedc95a829b9ce283aaf945c94ac0c595909bfcafeb958dc30d92e1a0ea413c1e233e7c428afa3aae46d0a5283cc3c8fc76234281e
8
+ metadata.gz: !binary |-
9
+ NzhlYTJjZWM0N2ExNzkwMTFiZTEwNDMwYTgxMzVhYzk1Y2EwYmI0NGJjNWE0
10
+ ODE5NDk3NjVlYmUwNDU5NDBkZjU2MDdkMjY0MDg1MTFiMGI3NGRlODM2MDIz
11
+ NzBiNzk2MzBlZTU5MDY0NjRhOWMxNTMwYzFiOTA5MDJiZjk0Yjk=
12
+ data.tar.gz: !binary |-
13
+ ZDBlZDMzNWU5MWM3NTc0M2FlNTk1OTY1ZWNiNDQzOTkyODk2YzFlNGNlYWI4
14
+ ZmI2NjcyNjQ4NTBhMDE5ZmE5Y2IzMGM1NWY2NWViYjM4NTg3OTYyMzViMjZh
15
+ Yzc2OGYyZWMxYzNlYWM2MTFhMTg3MzJiZGIzZmI4Njk5NDRlMjI=
@@ -0,0 +1 @@
1
+ 2.1.5
@@ -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.4"
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 'supermodel'
16
+ gem 'rake'
17
17
  end
@@ -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
 
@@ -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
@@ -1,2 +1,11 @@
1
1
  require 'bundler'
2
2
  Bundler::GemHelper.install_tasks
3
+
4
+ begin
5
+ require 'rspec/core/rake_task'
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ task :default => :spec
9
+ rescue LoadError
10
+ # no rspec available
11
+ end
@@ -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
@@ -5,7 +5,7 @@ module GreenLight
5
5
 
6
6
  module ClassMethods
7
7
  def numericality_validator(params = {})
8
- {:regex => "^[0-9]*$"}
8
+ {:regex => "^[0-9\.]*$"}
9
9
  end
10
10
  end
11
11
  end
@@ -1,3 +1,3 @@
1
1
  module GreenLight
2
- VERSION = "0.2.5"
2
+ VERSION = "0.3.1"
3
3
  end
@@ -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.should == "{\"errorElement\":\"span\",\"rules\":{\"format_of_model[title]\":{\"regex\":\"(^[A-Za-z]$)\"}}}"
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.should == "{\"errorElement\":\"span\",\"rules\":{\"presence_of_model[title]\":{\"required\":true}}}"
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.should == "{\"errorElement\":\"span\",\"rules\":{\"length_of_model[title]\":{\"maxlength\":10,\"minlength\":5}}}"
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.should == "{\"errorElement\":\"span\",\"rules\":{\"numericality_of_model[age]\":{\"regex\":\"^[0-9]*$\"}}}"
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.should == "{\"errorElement\":\"span\",\"rules\":{\"uniqueness_of_model[title]\":{\"remote\":\"/javascripts/check_for_uniqueness?model=UniquenessOfModel&field=title\"}}}"
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 FormatOfModel < SuperModel::Base
34
- validates_format_of :title, :with => /^[A-Za-z]$/
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 < SuperModel::Base
40
+ class PresenceOfModel
41
+ include ActiveModel::Model
38
42
  validates_presence_of :title
39
43
  end
40
44
 
41
- class LengthOfModel < SuperModel::Base
45
+ class LengthOfModel
46
+ include ActiveModel::Model
42
47
  validates_length_of :title, :within => 5..10
43
48
  end
44
49
 
45
- class NumericalityOfModel < SuperModel::Base
50
+ class NumericalityOfModel
51
+ include ActiveModel::Model
46
52
  validates_numericality_of :age
47
53
  end
48
54
 
49
- class UniquenessOfModel < SuperModel::Base
50
- validates_uniqueness_of :title
51
- end
55
+
@@ -2,5 +2,4 @@ require 'rubygems'
2
2
  require 'rspec'
3
3
  require 'rails'
4
4
  require 'active_record'
5
- require 'supermodel'
6
5
  require File.dirname(__FILE__) + '/../lib/green_light'
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.2.5
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: 2014-08-18 00:00:00.000000000 Z
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
- - ".DS_Store"
21
- - ".gitignore"
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.2.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: []