enlightenment 0.0.1.pre.1
Sign up to get free protection for your applications and to get access to all the features.
- data/MIT-LICENSE +20 -0
- data/README.rdoc +3 -0
- data/Rakefile +40 -0
- data/app/assets/javascripts/enlightenment/application.js +15 -0
- data/app/assets/stylesheets/enlightenment/application.css +13 -0
- data/app/controllers/enlightenment/application_controller.rb +13 -0
- data/app/controllers/enlightenment/assets_controller.rb +32 -0
- data/app/controllers/enlightenment/pages_controller.rb +16 -0
- data/app/controllers/enlightenment/validations_controller.rb +27 -0
- data/app/helpers/enlightenment/application_helper.rb +4 -0
- data/app/models/enlightenment/validation.rb +31 -0
- data/app/views/assets/validations.js.erb +136 -0
- data/app/views/layouts/enlightenment/application.html.erb +14 -0
- data/config/routes.rb +15 -0
- data/lib/enlightenment.rb +63 -0
- data/lib/enlightenment/engine.rb +5 -0
- data/lib/enlightenment/rules.rb +87 -0
- data/lib/enlightenment/validations/callback_validator.rb +13 -0
- data/lib/enlightenment/validations/cleanup_validator.rb +13 -0
- data/lib/enlightenment/validations/validates_associated.rb +14 -0
- data/lib/enlightenment/validations/validates_uniqueness.rb +13 -0
- data/lib/enlightenment/version.rb +3 -0
- data/lib/tasks/enlightenment_tasks.rake +4 -0
- metadata +247 -0
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2012 YOURNAME
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
data/Rakefile
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
#!/usr/bin/env rake
|
2
|
+
|
3
|
+
begin
|
4
|
+
require 'bundler/setup'
|
5
|
+
rescue LoadError
|
6
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
7
|
+
end
|
8
|
+
|
9
|
+
begin
|
10
|
+
require 'rdoc/task'
|
11
|
+
rescue LoadError
|
12
|
+
require 'rdoc/rdoc'
|
13
|
+
require 'rake/rdoctask'
|
14
|
+
RDoc::Task = Rake::RDocTask
|
15
|
+
end
|
16
|
+
|
17
|
+
RDoc::Task.new(:rdoc) do |rdoc|
|
18
|
+
rdoc.rdoc_dir = 'rdoc'
|
19
|
+
rdoc.title = 'Enlightenment'
|
20
|
+
rdoc.options << '--line-numbers'
|
21
|
+
rdoc.rdoc_files.include('README.rdoc')
|
22
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
23
|
+
end
|
24
|
+
|
25
|
+
Bundler::GemHelper.install_tasks
|
26
|
+
|
27
|
+
task :default => :spec
|
28
|
+
|
29
|
+
desc 'run the spec suite'
|
30
|
+
task :spec => [:'spec:ruby', :'spec:javascript']
|
31
|
+
|
32
|
+
desc 'run the ruby spec suite'
|
33
|
+
task :'spec:ruby' do
|
34
|
+
system 'rspec spec'
|
35
|
+
end
|
36
|
+
|
37
|
+
desc 'run the javascript spec suite'
|
38
|
+
task :'spec:javascript' do
|
39
|
+
system 'cd spec/dummy && rake jasminerice:run'
|
40
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
// This is a manifest file that'll be compiled into application.js, which will include all the files
|
2
|
+
// listed below.
|
3
|
+
//
|
4
|
+
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
|
5
|
+
// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
|
6
|
+
//
|
7
|
+
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
8
|
+
// the compiled file.
|
9
|
+
//
|
10
|
+
// WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD
|
11
|
+
// GO AFTER THE REQUIRES BELOW.
|
12
|
+
//
|
13
|
+
//= require jquery
|
14
|
+
//= require jquery_ujs
|
15
|
+
//= require_tree .
|
@@ -0,0 +1,13 @@
|
|
1
|
+
/*
|
2
|
+
* This is a manifest file that'll be compiled into application.css, which will include all the files
|
3
|
+
* listed below.
|
4
|
+
*
|
5
|
+
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
|
6
|
+
* or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
|
7
|
+
*
|
8
|
+
* You're free to add application-wide styles to this file and they'll appear at the top of the
|
9
|
+
* compiled file, but it's generally better to create a new file per style scope.
|
10
|
+
*
|
11
|
+
*= require_self
|
12
|
+
*= require_tree .
|
13
|
+
*/
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module Enlightenment
|
2
|
+
class AssetsController < Enlightenment::ApplicationController
|
3
|
+
respond_to :js
|
4
|
+
|
5
|
+
def show
|
6
|
+
super({
|
7
|
+
:layout => false,
|
8
|
+
:locals => {
|
9
|
+
:config => validate_config,
|
10
|
+
:models => validate_models
|
11
|
+
},
|
12
|
+
:formats => [:js]
|
13
|
+
})
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
# handle deprecation warning.
|
19
|
+
def path
|
20
|
+
super.sub(/\.js$/, '')
|
21
|
+
end
|
22
|
+
|
23
|
+
def validate_config
|
24
|
+
config = Enlightenment.validate_config
|
25
|
+
config.present? ? config.to_json : nil
|
26
|
+
end
|
27
|
+
|
28
|
+
def validate_models
|
29
|
+
Enlightenment::Rules.generate(Enlightenment.validate_models)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module Enlightenment
|
2
|
+
class ValidationsController < Enlightenment::ApplicationController
|
3
|
+
respond_to :json
|
4
|
+
|
5
|
+
def create
|
6
|
+
validation = Validation.new(params)
|
7
|
+
|
8
|
+
if validation.pass?
|
9
|
+
pass
|
10
|
+
else
|
11
|
+
fail(validation)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
private
|
16
|
+
|
17
|
+
def pass(body = {})
|
18
|
+
render(:json => body, :status => 201)
|
19
|
+
# render(:text => true, :status => 201)
|
20
|
+
end
|
21
|
+
|
22
|
+
def fail(body = {})
|
23
|
+
render(:json => body, :status => 403)
|
24
|
+
# render(:json => body, :status => 200)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module Enlightenment
|
2
|
+
class Validation
|
3
|
+
attr_reader :model, :field, :attributes
|
4
|
+
|
5
|
+
def initialize(params = {})
|
6
|
+
@model = params[:model].constantize
|
7
|
+
@field = params[:field].to_sym
|
8
|
+
@attributes = params[model.table_name.singularize.to_sym]
|
9
|
+
end
|
10
|
+
|
11
|
+
def as_json(options = {})
|
12
|
+
{
|
13
|
+
:message => (@messages || []).to_sentence,
|
14
|
+
:complete => @complete.map { |k,v| [k, [v].flatten.uniq] }
|
15
|
+
}
|
16
|
+
end
|
17
|
+
|
18
|
+
def pass?
|
19
|
+
instance = model.new(attributes, :without_protection => true)
|
20
|
+
instance.valid?
|
21
|
+
@complete = instance.errors
|
22
|
+
@messages = @complete.messages[field]
|
23
|
+
|
24
|
+
if Enlightenment.message_sanitizer
|
25
|
+
@messages.map! { |msg| Enlightenment.message_sanitizer.call(msg) }
|
26
|
+
end
|
27
|
+
|
28
|
+
@messages.blank?
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,136 @@
|
|
1
|
+
<% if models %>
|
2
|
+
(function($) {
|
3
|
+
var original;
|
4
|
+
var settings = {};
|
5
|
+
var defaults = $.enlightenment.validator.settings;
|
6
|
+
|
7
|
+
<% if config %>
|
8
|
+
settings = <%= config.html_safe %>;
|
9
|
+
<% end %>
|
10
|
+
|
11
|
+
$(function() {
|
12
|
+
original = rulemap(<%= models.html_safe %>);
|
13
|
+
|
14
|
+
$.each(original, function(name, rules) {
|
15
|
+
attach($(['form', name, 'validate'].join('.')), rules.real);
|
16
|
+
});
|
17
|
+
});
|
18
|
+
|
19
|
+
<% if config %>
|
20
|
+
$(document).ajaxComplete(function(e, xhr, options) {
|
21
|
+
var text = xhr.responseText;
|
22
|
+
var conf, json, keys;
|
23
|
+
|
24
|
+
try {
|
25
|
+
json = JSON.parse(text);
|
26
|
+
keys = settings.keys || [];
|
27
|
+
|
28
|
+
$.each(keys, function(i, key) {
|
29
|
+
var html = json[key];
|
30
|
+
var current;
|
31
|
+
|
32
|
+
if(html) {
|
33
|
+
$('form', html).each(function() {
|
34
|
+
var converted = rulemap(this);
|
35
|
+
$.each(converted, function(type, rules) {
|
36
|
+
attach($(['form', type, 'validate'].join('.')), rules.real);
|
37
|
+
});
|
38
|
+
});
|
39
|
+
}
|
40
|
+
});
|
41
|
+
}
|
42
|
+
catch(e) {}
|
43
|
+
});
|
44
|
+
<% end %>
|
45
|
+
|
46
|
+
// ???
|
47
|
+
$.enlightenment.rules = function rules() {
|
48
|
+
return original;
|
49
|
+
};
|
50
|
+
|
51
|
+
// ???
|
52
|
+
$(document).on('revalidate', 'form', function(e) {
|
53
|
+
rulemap(this);
|
54
|
+
});
|
55
|
+
|
56
|
+
// TODO: move to $.enlightenment
|
57
|
+
function attach(forms, config) {
|
58
|
+
if(forms.length) {
|
59
|
+
forms.validate(config);
|
60
|
+
}
|
61
|
+
|
62
|
+
return forms;
|
63
|
+
}
|
64
|
+
|
65
|
+
function elements(selector, context) {
|
66
|
+
return context
|
67
|
+
.find('input, select, textarea')
|
68
|
+
.not(':submit, :reset, :image, [disabled]')
|
69
|
+
.filter(selector);
|
70
|
+
}
|
71
|
+
|
72
|
+
function rulemap(config) {
|
73
|
+
var context;
|
74
|
+
var converted = {};
|
75
|
+
var resources = config.resources;
|
76
|
+
var nestedWrap = 'div.form-inputs'; // TODO: determine better way to handle nested fields_for
|
77
|
+
|
78
|
+
function map(ruleSet, context, mapping) {
|
79
|
+
// only map for existing content (avoids infinite loop)
|
80
|
+
if(context.length) {
|
81
|
+
$.each(ruleSet, function(attribute, rules) {
|
82
|
+
var nested, associated;
|
83
|
+
|
84
|
+
if(rules.associated) {
|
85
|
+
nested = $([nestedWrap, attribute].join('.'), context);
|
86
|
+
associated = resources[rules.associated];
|
87
|
+
|
88
|
+
if(associated) {
|
89
|
+
map((associated.rules || associated.base.rules), nested, mapping);
|
90
|
+
}
|
91
|
+
}
|
92
|
+
else {
|
93
|
+
$(elements('.' + attribute, context)).each(function() {
|
94
|
+
var name = this.name;
|
95
|
+
|
96
|
+
if( ! mapping.rules[name]) {
|
97
|
+
mapping.rules[name] = rules;
|
98
|
+
}
|
99
|
+
});
|
100
|
+
}
|
101
|
+
});
|
102
|
+
}
|
103
|
+
}
|
104
|
+
|
105
|
+
// top-level/ready setup
|
106
|
+
if(resources) {
|
107
|
+
$.each(resources, function(name, config) {
|
108
|
+
var context = $(['form', name, 'validate'].join('.'));
|
109
|
+
var mapping = converted[name] = {
|
110
|
+
base : $.extend(true, {}, config),
|
111
|
+
real : $.extend(true, {}, defaults)
|
112
|
+
};
|
113
|
+
|
114
|
+
map(config.rules, context, mapping.real);
|
115
|
+
});
|
116
|
+
}
|
117
|
+
// contextual additions
|
118
|
+
else {
|
119
|
+
resources = original;
|
120
|
+
context = $(config);
|
121
|
+
|
122
|
+
$.each(original, function(type, config) {
|
123
|
+
if(context.hasClass(type)) {
|
124
|
+
converted[type] = original[type];
|
125
|
+
map(config.base.rules, context, config.real);
|
126
|
+
|
127
|
+
context.removeData('validator');
|
128
|
+
attach(context, config.real);
|
129
|
+
}
|
130
|
+
});
|
131
|
+
}
|
132
|
+
|
133
|
+
return converted;
|
134
|
+
}
|
135
|
+
})(jQuery);
|
136
|
+
<% end %>
|
@@ -0,0 +1,14 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>Enlightenment</title>
|
5
|
+
<%= stylesheet_link_tag "enlightenment/application", :media => "all" %>
|
6
|
+
<%= javascript_include_tag "enlightenment/application" %>
|
7
|
+
<%= csrf_meta_tags %>
|
8
|
+
</head>
|
9
|
+
<body>
|
10
|
+
|
11
|
+
<%= yield %>
|
12
|
+
|
13
|
+
</body>
|
14
|
+
</html>
|
data/config/routes.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
Enlightenment::Engine.routes.draw do
|
2
|
+
{ :assets => :asset, :pages => :page }.each do |controller, as|
|
3
|
+
match "#{controller}/:name" => "#{controller}#show",
|
4
|
+
:as => as,
|
5
|
+
:name => /[a-z].*/,
|
6
|
+
:via => :get
|
7
|
+
end
|
8
|
+
|
9
|
+
match "pages(/?)" => "pages#show",
|
10
|
+
:name => 'index',
|
11
|
+
:via => :get
|
12
|
+
|
13
|
+
match "validations" => "validations#create",
|
14
|
+
:via => :post
|
15
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
require 'enlightenment/engine'
|
2
|
+
require 'i18n-js'
|
3
|
+
|
4
|
+
# TODO
|
5
|
+
#
|
6
|
+
# primary:
|
7
|
+
#
|
8
|
+
# * [*] store validations for non-existent forms (they may show up)
|
9
|
+
# * [*] handle dynamic field additions -- may require patching jquery.validate (DID NOT)
|
10
|
+
# * [*] define validation method for AssociatedValidator
|
11
|
+
# * [*] add validation via AJAX callback
|
12
|
+
# * [ ] add i18n messages -- may require patching jquery.validate
|
13
|
+
# * [ ] add i18n messages WITH interpolation (functions)
|
14
|
+
# * [ ] add support for "field error proc" -- may require patching jquery.validate
|
15
|
+
# * [ ] remove simpleform/bootstrap specifics from validations.js (e.g., '.form-inputs')
|
16
|
+
# * [ ] add sanitize config. e.g., hide email "has already been taken" message.
|
17
|
+
#
|
18
|
+
# secondary:
|
19
|
+
#
|
20
|
+
# * [ ] make js pseudo-agnostic (jQuery, Zepto or Ender)
|
21
|
+
# * [ ] add gon-like "lifting"
|
22
|
+
# * [ ] add asset and page caching, with exception hooks
|
23
|
+
# * [ ] handle duplicate forms (e.g., registration at top AND bottom)
|
24
|
+
# * [ ] add a config option to persist Validation records
|
25
|
+
#
|
26
|
+
# validators:
|
27
|
+
#
|
28
|
+
# * [ ] ActiveModel::Validations::AcceptanceValidator
|
29
|
+
# * [ ] ActiveModel::Validations::ConfirmationValidator
|
30
|
+
# * [ ] ActiveModel::Validations::ExclusionValidator
|
31
|
+
# * [ ] ActiveModel::Validations::FormatValidator --> green_light
|
32
|
+
# * [ ] ActiveModel::Validations::InclusionValidator
|
33
|
+
# * [ ] ActiveModel::Validations::LengthValidator --> green_light
|
34
|
+
# * [ ] ActiveModel::Validations::NumericalityValidator --> green_light
|
35
|
+
# * [ ] ActiveModel::Validations::PresenceValidator --> green_light
|
36
|
+
# * [ ] ActiveModel::Validations::WithValidator
|
37
|
+
# * [ ] ActiveModel::Validator
|
38
|
+
# * [ ] ActiveRecord::Validations::AssociatedValidator
|
39
|
+
# * [ ] ActiveRecord::Validations::UniquenessValidator --> green_light via remote
|
40
|
+
#
|
41
|
+
module Enlightenment
|
42
|
+
autoload :Rules, 'enlightenment/rules'
|
43
|
+
|
44
|
+
module Validations
|
45
|
+
autoload :CallbackValidator, 'enlightenment/validations/callback_validator'
|
46
|
+
autoload :CleanupValidator, 'enlightenment/validations/cleanup_validator'
|
47
|
+
autoload :ValidatesAssociated, 'enlightenment/validations/validates_associated'
|
48
|
+
autoload :ValidatesUniqueness, 'enlightenment/validations/validates_uniqueness'
|
49
|
+
end
|
50
|
+
|
51
|
+
mattr_accessor :validate_models
|
52
|
+
@@validate_models = {}
|
53
|
+
|
54
|
+
mattr_accessor :validate_config
|
55
|
+
@@validate_config = {}
|
56
|
+
|
57
|
+
mattr_accessor :message_sanitizer
|
58
|
+
@@message_sanitizer = nil
|
59
|
+
|
60
|
+
def self.setup
|
61
|
+
yield self
|
62
|
+
end
|
63
|
+
end
|
@@ -0,0 +1,87 @@
|
|
1
|
+
require 'green_light'
|
2
|
+
|
3
|
+
module Enlightenment
|
4
|
+
class Rules < GreenLight::Rules
|
5
|
+
include Validations::CallbackValidator
|
6
|
+
include Validations::CleanupValidator
|
7
|
+
include Validations::ValidatesAssociated
|
8
|
+
include Validations::ValidatesUniqueness
|
9
|
+
|
10
|
+
class << self
|
11
|
+
def generate(models)
|
12
|
+
data = {}
|
13
|
+
|
14
|
+
models.each do |input|
|
15
|
+
model, config = prepare(input)
|
16
|
+
key = model.underscore.downcase
|
17
|
+
rules = {}
|
18
|
+
|
19
|
+
model.constantize._validators.each do |field, validators|
|
20
|
+
options = {
|
21
|
+
:whitelisted => (config.has_key?(:include)),
|
22
|
+
:include => (config[:include] || {})[field],
|
23
|
+
:exclude => (config[:exclude] || {})[field]
|
24
|
+
}
|
25
|
+
|
26
|
+
if (parsed = parse_validators(model, field, validators, options)) && parsed.present?
|
27
|
+
rules[field] = parsed
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
# (config[:cleanup] || []).each do |field|
|
32
|
+
# rules[field] = (rules[field] || {}).merge!(cleanup_validator)
|
33
|
+
# end
|
34
|
+
|
35
|
+
data[key] = { :rules => rules }
|
36
|
+
end
|
37
|
+
|
38
|
+
{ :resources => data }.to_json
|
39
|
+
end
|
40
|
+
|
41
|
+
private
|
42
|
+
|
43
|
+
def add(data, method, params)
|
44
|
+
if respond_to?(method)
|
45
|
+
result = send(method, params)
|
46
|
+
data.merge!(result) unless result.nil?
|
47
|
+
else
|
48
|
+
data.merge!(callback_validator(params))
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
def parse_validators(model, field, validators, options = {})
|
53
|
+
data, params = {}, {}
|
54
|
+
params[:model], params[:field] = model, field
|
55
|
+
whitelisted = options[:whitelisted]
|
56
|
+
includes = options[:include] || []
|
57
|
+
excludes = options[:exclude] || []
|
58
|
+
|
59
|
+
validators.each do |validator|
|
60
|
+
params[:val_obj] = validator
|
61
|
+
method = validator.class.name.split('::').last.underscore
|
62
|
+
|
63
|
+
# whitelisting wins... no excludes allowed if found
|
64
|
+
if whitelisted
|
65
|
+
if includes.include?(method.sub(/_validator$/, '').to_sym)
|
66
|
+
add(data, method, params)
|
67
|
+
end
|
68
|
+
else
|
69
|
+
unless excludes.include?(method.sub(/_validator$/, '').to_sym)
|
70
|
+
add(data, method, params)
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
data
|
76
|
+
end
|
77
|
+
|
78
|
+
def prepare(input)
|
79
|
+
if input.is_a?(String)
|
80
|
+
[input, {}]
|
81
|
+
else
|
82
|
+
input
|
83
|
+
end.flatten
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module Enlightenment
|
2
|
+
module Validations
|
3
|
+
module CallbackValidator
|
4
|
+
extend ActiveSupport::Concern
|
5
|
+
|
6
|
+
module ClassMethods
|
7
|
+
def callback_validator(params = {})
|
8
|
+
{ :remote => "/validations?model=#{params[:model].to_s}&field=#{params[:field]}" }
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module Enlightenment
|
2
|
+
module Validations
|
3
|
+
module ValidatesAssociated
|
4
|
+
extend ActiveSupport::Concern
|
5
|
+
|
6
|
+
module ClassMethods
|
7
|
+
def associated_validator(params = {})
|
8
|
+
field = params[:field].to_s.singularize
|
9
|
+
{ :associated => field.to_sym }
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
metadata
ADDED
@@ -0,0 +1,247 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: enlightenment
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1.pre.1
|
5
|
+
prerelease: 6
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Corey Innis
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-10-15 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rails
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 3.2.3
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 3.2.3
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: green_light
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :runtime
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: i18n-js
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
type: :runtime
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: jquery-rails
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ! '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
type: :runtime
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
- !ruby/object:Gem::Dependency
|
79
|
+
name: capybara
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ! '>='
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
86
|
+
type: :development
|
87
|
+
prerelease: false
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ! '>='
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
94
|
+
- !ruby/object:Gem::Dependency
|
95
|
+
name: coffee-script
|
96
|
+
requirement: !ruby/object:Gem::Requirement
|
97
|
+
none: false
|
98
|
+
requirements:
|
99
|
+
- - ! '>='
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '0'
|
102
|
+
type: :development
|
103
|
+
prerelease: false
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
106
|
+
requirements:
|
107
|
+
- - ! '>='
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
110
|
+
- !ruby/object:Gem::Dependency
|
111
|
+
name: jasmine
|
112
|
+
requirement: !ruby/object:Gem::Requirement
|
113
|
+
none: false
|
114
|
+
requirements:
|
115
|
+
- - ! '>='
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
none: false
|
122
|
+
requirements:
|
123
|
+
- - ! '>='
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: '0'
|
126
|
+
- !ruby/object:Gem::Dependency
|
127
|
+
name: jasminerice
|
128
|
+
requirement: !ruby/object:Gem::Requirement
|
129
|
+
none: false
|
130
|
+
requirements:
|
131
|
+
- - ! '>='
|
132
|
+
- !ruby/object:Gem::Version
|
133
|
+
version: '0'
|
134
|
+
type: :development
|
135
|
+
prerelease: false
|
136
|
+
version_requirements: !ruby/object:Gem::Requirement
|
137
|
+
none: false
|
138
|
+
requirements:
|
139
|
+
- - ! '>='
|
140
|
+
- !ruby/object:Gem::Version
|
141
|
+
version: '0'
|
142
|
+
- !ruby/object:Gem::Dependency
|
143
|
+
name: jasminerice-runner
|
144
|
+
requirement: !ruby/object:Gem::Requirement
|
145
|
+
none: false
|
146
|
+
requirements:
|
147
|
+
- - ! '>='
|
148
|
+
- !ruby/object:Gem::Version
|
149
|
+
version: '0'
|
150
|
+
type: :development
|
151
|
+
prerelease: false
|
152
|
+
version_requirements: !ruby/object:Gem::Requirement
|
153
|
+
none: false
|
154
|
+
requirements:
|
155
|
+
- - ! '>='
|
156
|
+
- !ruby/object:Gem::Version
|
157
|
+
version: '0'
|
158
|
+
- !ruby/object:Gem::Dependency
|
159
|
+
name: rspec-rails
|
160
|
+
requirement: !ruby/object:Gem::Requirement
|
161
|
+
none: false
|
162
|
+
requirements:
|
163
|
+
- - ! '>='
|
164
|
+
- !ruby/object:Gem::Version
|
165
|
+
version: '0'
|
166
|
+
type: :development
|
167
|
+
prerelease: false
|
168
|
+
version_requirements: !ruby/object:Gem::Requirement
|
169
|
+
none: false
|
170
|
+
requirements:
|
171
|
+
- - ! '>='
|
172
|
+
- !ruby/object:Gem::Version
|
173
|
+
version: '0'
|
174
|
+
- !ruby/object:Gem::Dependency
|
175
|
+
name: sqlite3
|
176
|
+
requirement: !ruby/object:Gem::Requirement
|
177
|
+
none: false
|
178
|
+
requirements:
|
179
|
+
- - ! '>='
|
180
|
+
- !ruby/object:Gem::Version
|
181
|
+
version: '0'
|
182
|
+
type: :development
|
183
|
+
prerelease: false
|
184
|
+
version_requirements: !ruby/object:Gem::Requirement
|
185
|
+
none: false
|
186
|
+
requirements:
|
187
|
+
- - ! '>='
|
188
|
+
- !ruby/object:Gem::Version
|
189
|
+
version: '0'
|
190
|
+
description: ! 'WIP: Enlightenment.'
|
191
|
+
email:
|
192
|
+
- corey@coolerator.net
|
193
|
+
executables: []
|
194
|
+
extensions: []
|
195
|
+
extra_rdoc_files: []
|
196
|
+
files:
|
197
|
+
- app/assets/javascripts/enlightenment/application.js
|
198
|
+
- app/assets/stylesheets/enlightenment/application.css
|
199
|
+
- app/controllers/enlightenment/application_controller.rb
|
200
|
+
- app/controllers/enlightenment/assets_controller.rb
|
201
|
+
- app/controllers/enlightenment/pages_controller.rb
|
202
|
+
- app/controllers/enlightenment/validations_controller.rb
|
203
|
+
- app/helpers/enlightenment/application_helper.rb
|
204
|
+
- app/models/enlightenment/validation.rb
|
205
|
+
- app/views/assets/validations.js.erb
|
206
|
+
- app/views/layouts/enlightenment/application.html.erb
|
207
|
+
- config/routes.rb
|
208
|
+
- lib/enlightenment/engine.rb
|
209
|
+
- lib/enlightenment/rules.rb
|
210
|
+
- lib/enlightenment/validations/callback_validator.rb
|
211
|
+
- lib/enlightenment/validations/cleanup_validator.rb
|
212
|
+
- lib/enlightenment/validations/validates_associated.rb
|
213
|
+
- lib/enlightenment/validations/validates_uniqueness.rb
|
214
|
+
- lib/enlightenment/version.rb
|
215
|
+
- lib/enlightenment.rb
|
216
|
+
- lib/tasks/enlightenment_tasks.rake
|
217
|
+
- MIT-LICENSE
|
218
|
+
- Rakefile
|
219
|
+
- README.rdoc
|
220
|
+
homepage: https://github.com/coreyti/enlightenment
|
221
|
+
licenses: []
|
222
|
+
post_install_message:
|
223
|
+
rdoc_options: []
|
224
|
+
require_paths:
|
225
|
+
- lib
|
226
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
227
|
+
none: false
|
228
|
+
requirements:
|
229
|
+
- - ! '>='
|
230
|
+
- !ruby/object:Gem::Version
|
231
|
+
version: '0'
|
232
|
+
segments:
|
233
|
+
- 0
|
234
|
+
hash: -1242535810493599937
|
235
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
236
|
+
none: false
|
237
|
+
requirements:
|
238
|
+
- - ! '>'
|
239
|
+
- !ruby/object:Gem::Version
|
240
|
+
version: 1.3.1
|
241
|
+
requirements: []
|
242
|
+
rubyforge_project:
|
243
|
+
rubygems_version: 1.8.24
|
244
|
+
signing_key:
|
245
|
+
specification_version: 3
|
246
|
+
summary: ! 'WIP: Enlightenment.'
|
247
|
+
test_files: []
|