format_validators 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (47) hide show
  1. data/CHANGELOG +10 -0
  2. data/Gemfile +14 -1
  3. data/Gemfile.lock +134 -8
  4. data/VERSION +1 -1
  5. data/app/validators/ssn_format_validator.rb +11 -0
  6. data/format_validators.gemspec +125 -0
  7. data/lib/format_validators/railtie.rb +1 -1
  8. data/spec/dummy/Rakefile +7 -0
  9. data/spec/dummy/app/controllers/application_controller.rb +3 -0
  10. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  11. data/spec/dummy/app/views/layouts/application.html.erb +14 -0
  12. data/spec/dummy/config.ru +4 -0
  13. data/spec/dummy/config/application.rb +45 -0
  14. data/spec/dummy/config/boot.rb +10 -0
  15. data/spec/dummy/config/database.yml +22 -0
  16. data/spec/dummy/config/environment.rb +5 -0
  17. data/spec/dummy/config/environments/development.rb +26 -0
  18. data/spec/dummy/config/environments/production.rb +49 -0
  19. data/spec/dummy/config/environments/test.rb +35 -0
  20. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  21. data/spec/dummy/config/initializers/inflections.rb +10 -0
  22. data/spec/dummy/config/initializers/mime_types.rb +5 -0
  23. data/spec/dummy/config/initializers/secret_token.rb +7 -0
  24. data/spec/dummy/config/initializers/session_store.rb +8 -0
  25. data/spec/dummy/config/locales/en.yml +5 -0
  26. data/spec/dummy/config/routes.rb +58 -0
  27. data/spec/dummy/db/test.sqlite3 +0 -0
  28. data/spec/dummy/log/development.log +0 -0
  29. data/spec/dummy/log/production.log +0 -0
  30. data/spec/dummy/log/server.log +0 -0
  31. data/spec/dummy/log/test.log +99 -0
  32. data/spec/dummy/public/404.html +26 -0
  33. data/spec/dummy/public/422.html +26 -0
  34. data/spec/dummy/public/500.html +26 -0
  35. data/spec/dummy/public/favicon.ico +0 -0
  36. data/spec/dummy/public/javascripts/application.js +2 -0
  37. data/spec/dummy/public/javascripts/controls.js +965 -0
  38. data/spec/dummy/public/javascripts/dragdrop.js +974 -0
  39. data/spec/dummy/public/javascripts/effects.js +1123 -0
  40. data/spec/dummy/public/javascripts/prototype.js +6001 -0
  41. data/spec/dummy/public/javascripts/rails.js +191 -0
  42. data/spec/dummy/public/stylesheets/.gitkeep +0 -0
  43. data/spec/dummy/script/rails +6 -0
  44. data/spec/format_validators_spec.rb +0 -3
  45. data/spec/spec_helper.rb +30 -8
  46. data/spec/validators/ssn_format_validator_spec.rb +99 -0
  47. metadata +148 -9
@@ -0,0 +1,10 @@
1
+ == unreleased changes
2
+
3
+ == 0.0.2
4
+
5
+ * Setup dummy app
6
+ * Created and tested ssn format validator
7
+
8
+ == 0.0.1
9
+
10
+ * Initial setup
data/Gemfile CHANGED
@@ -3,10 +3,23 @@ source "http://rubygems.org"
3
3
  # Example:
4
4
  # gem "activesupport", ">= 2.3.5"
5
5
 
6
+ gem "rails", "~> 3.0.7"
7
+
6
8
  # Add dependencies to develop your gem here.
7
9
  # Include everything needed to run rake, tests, features, etc.
8
10
  group :development do
9
- gem "rspec", "~> 2.3.0"
11
+ gem "capybara", ">= 0.4.0"
12
+ gem "sqlite3"
10
13
  gem "bundler", "~> 1.0.0"
11
14
  gem "jeweler", "~> 1.6.4"
15
+
16
+ gem 'ruby-debug19'
17
+
18
+ # rspec
19
+ gem "rspec", "~> 2.6.0"
20
+ gem "rspec-rails", "~>2.6.1"
21
+ gem "shoulda", "~> 3.0.0"
22
+ gem "ruby_parser", "~> 2.3.1" # outputs parsetrees
23
+ gem "ZenTest"
24
+ gem "autotest-rails"
12
25
  end
@@ -1,26 +1,152 @@
1
1
  GEM
2
2
  remote: http://rubygems.org/
3
3
  specs:
4
+ ZenTest (4.6.2)
5
+ abstract (1.0.0)
6
+ actionmailer (3.0.12)
7
+ actionpack (= 3.0.12)
8
+ mail (~> 2.2.19)
9
+ actionpack (3.0.12)
10
+ activemodel (= 3.0.12)
11
+ activesupport (= 3.0.12)
12
+ builder (~> 2.1.2)
13
+ erubis (~> 2.6.6)
14
+ i18n (~> 0.5.0)
15
+ rack (~> 1.2.5)
16
+ rack-mount (~> 0.6.14)
17
+ rack-test (~> 0.5.7)
18
+ tzinfo (~> 0.3.23)
19
+ activemodel (3.0.12)
20
+ activesupport (= 3.0.12)
21
+ builder (~> 2.1.2)
22
+ i18n (~> 0.5.0)
23
+ activerecord (3.0.12)
24
+ activemodel (= 3.0.12)
25
+ activesupport (= 3.0.12)
26
+ arel (~> 2.0.10)
27
+ tzinfo (~> 0.3.23)
28
+ activeresource (3.0.12)
29
+ activemodel (= 3.0.12)
30
+ activesupport (= 3.0.12)
31
+ activesupport (3.0.12)
32
+ archive-tar-minitar (0.5.2)
33
+ arel (2.0.10)
34
+ autotest-rails (4.1.2)
35
+ ZenTest (~> 4.5)
36
+ builder (2.1.2)
37
+ capybara (1.1.2)
38
+ mime-types (>= 1.16)
39
+ nokogiri (>= 1.3.3)
40
+ rack (>= 1.0.0)
41
+ rack-test (>= 0.5.4)
42
+ selenium-webdriver (~> 2.0)
43
+ xpath (~> 0.1.4)
44
+ childprocess (0.3.1)
45
+ ffi (~> 1.0.6)
46
+ columnize (0.3.6)
4
47
  diff-lcs (1.1.3)
48
+ erubis (2.6.6)
49
+ abstract (>= 1.0.0)
50
+ ffi (1.0.11)
5
51
  git (1.2.5)
52
+ i18n (0.5.0)
6
53
  jeweler (1.6.4)
7
54
  bundler (~> 1.0)
8
55
  git (>= 1.2.5)
9
56
  rake
57
+ json (1.6.5)
58
+ linecache19 (0.5.12)
59
+ ruby_core_source (>= 0.1.4)
60
+ mail (2.2.19)
61
+ activesupport (>= 2.3.6)
62
+ i18n (>= 0.4.0)
63
+ mime-types (~> 1.16)
64
+ treetop (~> 1.4.8)
65
+ mime-types (1.17.2)
66
+ multi_json (1.1.0)
67
+ nokogiri (1.5.2)
68
+ polyglot (0.3.3)
69
+ rack (1.2.5)
70
+ rack-mount (0.6.14)
71
+ rack (>= 1.0.0)
72
+ rack-test (0.5.7)
73
+ rack (>= 1.0)
74
+ rails (3.0.12)
75
+ actionmailer (= 3.0.12)
76
+ actionpack (= 3.0.12)
77
+ activerecord (= 3.0.12)
78
+ activeresource (= 3.0.12)
79
+ activesupport (= 3.0.12)
80
+ bundler (~> 1.0)
81
+ railties (= 3.0.12)
82
+ railties (3.0.12)
83
+ actionpack (= 3.0.12)
84
+ activesupport (= 3.0.12)
85
+ rake (>= 0.8.7)
86
+ rdoc (~> 3.4)
87
+ thor (~> 0.14.4)
10
88
  rake (0.9.2.2)
11
- rspec (2.3.0)
12
- rspec-core (~> 2.3.0)
13
- rspec-expectations (~> 2.3.0)
14
- rspec-mocks (~> 2.3.0)
15
- rspec-core (2.3.1)
16
- rspec-expectations (2.3.0)
89
+ rdoc (3.12)
90
+ json (~> 1.4)
91
+ rspec (2.6.0)
92
+ rspec-core (~> 2.6.0)
93
+ rspec-expectations (~> 2.6.0)
94
+ rspec-mocks (~> 2.6.0)
95
+ rspec-core (2.6.4)
96
+ rspec-expectations (2.6.0)
17
97
  diff-lcs (~> 1.1.2)
18
- rspec-mocks (2.3.0)
98
+ rspec-mocks (2.6.0)
99
+ rspec-rails (2.6.1)
100
+ actionpack (~> 3.0)
101
+ activesupport (~> 3.0)
102
+ railties (~> 3.0)
103
+ rspec (~> 2.6.0)
104
+ ruby-debug-base19 (0.11.25)
105
+ columnize (>= 0.3.1)
106
+ linecache19 (>= 0.5.11)
107
+ ruby_core_source (>= 0.1.4)
108
+ ruby-debug19 (0.11.6)
109
+ columnize (>= 0.3.1)
110
+ linecache19 (>= 0.5.11)
111
+ ruby-debug-base19 (>= 0.11.19)
112
+ ruby_core_source (0.1.5)
113
+ archive-tar-minitar (>= 0.5.2)
114
+ ruby_parser (2.3.1)
115
+ sexp_processor (~> 3.0)
116
+ rubyzip (0.9.6.1)
117
+ selenium-webdriver (2.20.0)
118
+ childprocess (>= 0.2.5)
119
+ ffi (~> 1.0)
120
+ multi_json (~> 1.0)
121
+ rubyzip
122
+ sexp_processor (3.1.0)
123
+ shoulda (3.0.1)
124
+ shoulda-context (~> 1.0.0)
125
+ shoulda-matchers (~> 1.0.0)
126
+ shoulda-context (1.0.0)
127
+ shoulda-matchers (1.0.0)
128
+ sqlite3 (1.3.5)
129
+ thor (0.14.6)
130
+ treetop (1.4.10)
131
+ polyglot
132
+ polyglot (>= 0.3.1)
133
+ tzinfo (0.3.32)
134
+ xpath (0.1.4)
135
+ nokogiri (~> 1.3)
19
136
 
20
137
  PLATFORMS
21
138
  ruby
22
139
 
23
140
  DEPENDENCIES
141
+ ZenTest
142
+ autotest-rails
24
143
  bundler (~> 1.0.0)
144
+ capybara (>= 0.4.0)
25
145
  jeweler (~> 1.6.4)
26
- rspec (~> 2.3.0)
146
+ rails (~> 3.0.7)
147
+ rspec (~> 2.6.0)
148
+ rspec-rails (~> 2.6.1)
149
+ ruby-debug19
150
+ ruby_parser (~> 2.3.1)
151
+ shoulda (~> 3.0.0)
152
+ sqlite3
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.1
1
+ 0.0.2
@@ -0,0 +1,11 @@
1
+ # Custom Validations for Social Security Number format
2
+
3
+ # e.g. validates :ssn, :ssn_format => true
4
+ # e.g. validates :ssn, :ssn_format => { :allow_blank => true, :if => :method_returns_true }
5
+ class SsnFormatValidator < ActiveModel::EachValidator
6
+ def validate_each record, attribute, value
7
+ format = /^\A([\d]{3}\-[\d]{2}\-[\d]{4}|[\d]{9})\Z$/
8
+ message = attribute.to_s.humanize + ' does not match the format ###-##-####.'
9
+ record.errors[attribute] << (options[:message] || message ) unless value =~ format
10
+ end
11
+ end
@@ -0,0 +1,125 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = "format_validators"
8
+ s.version = "0.0.2"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Jeremiah Hemphill"]
12
+ s.date = "2012-03-14"
13
+ s.description = "Complex format validators"
14
+ s.email = "jeremiah@cloudspace.com"
15
+ s.extra_rdoc_files = [
16
+ "LICENSE.txt",
17
+ "README.rdoc"
18
+ ]
19
+ s.files = [
20
+ ".document",
21
+ ".rspec",
22
+ "CHANGELOG",
23
+ "Gemfile",
24
+ "Gemfile.lock",
25
+ "LICENSE.txt",
26
+ "README.rdoc",
27
+ "Rakefile",
28
+ "VERSION",
29
+ "app/validators/ssn_format_validator.rb",
30
+ "format_validators.gemspec",
31
+ "lib/format_validators.rb",
32
+ "lib/format_validators/engine.rb",
33
+ "lib/format_validators/railtie.rb",
34
+ "spec/dummy/Rakefile",
35
+ "spec/dummy/app/controllers/application_controller.rb",
36
+ "spec/dummy/app/helpers/application_helper.rb",
37
+ "spec/dummy/app/views/layouts/application.html.erb",
38
+ "spec/dummy/config.ru",
39
+ "spec/dummy/config/application.rb",
40
+ "spec/dummy/config/boot.rb",
41
+ "spec/dummy/config/database.yml",
42
+ "spec/dummy/config/environment.rb",
43
+ "spec/dummy/config/environments/development.rb",
44
+ "spec/dummy/config/environments/production.rb",
45
+ "spec/dummy/config/environments/test.rb",
46
+ "spec/dummy/config/initializers/backtrace_silencers.rb",
47
+ "spec/dummy/config/initializers/inflections.rb",
48
+ "spec/dummy/config/initializers/mime_types.rb",
49
+ "spec/dummy/config/initializers/secret_token.rb",
50
+ "spec/dummy/config/initializers/session_store.rb",
51
+ "spec/dummy/config/locales/en.yml",
52
+ "spec/dummy/config/routes.rb",
53
+ "spec/dummy/db/test.sqlite3",
54
+ "spec/dummy/log/development.log",
55
+ "spec/dummy/log/production.log",
56
+ "spec/dummy/log/server.log",
57
+ "spec/dummy/log/test.log",
58
+ "spec/dummy/public/404.html",
59
+ "spec/dummy/public/422.html",
60
+ "spec/dummy/public/500.html",
61
+ "spec/dummy/public/favicon.ico",
62
+ "spec/dummy/public/javascripts/application.js",
63
+ "spec/dummy/public/javascripts/controls.js",
64
+ "spec/dummy/public/javascripts/dragdrop.js",
65
+ "spec/dummy/public/javascripts/effects.js",
66
+ "spec/dummy/public/javascripts/prototype.js",
67
+ "spec/dummy/public/javascripts/rails.js",
68
+ "spec/dummy/public/stylesheets/.gitkeep",
69
+ "spec/dummy/script/rails",
70
+ "spec/format_validators_spec.rb",
71
+ "spec/spec_helper.rb",
72
+ "spec/validators/ssn_format_validator_spec.rb"
73
+ ]
74
+ s.homepage = "http://github.com/jeremiahishere/format_validators"
75
+ s.licenses = ["MIT"]
76
+ s.require_paths = ["lib"]
77
+ s.rubygems_version = "1.8.15"
78
+ s.summary = "Complex format validators"
79
+
80
+ if s.respond_to? :specification_version then
81
+ s.specification_version = 3
82
+
83
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
84
+ s.add_runtime_dependency(%q<rails>, ["~> 3.0.7"])
85
+ s.add_development_dependency(%q<capybara>, [">= 0.4.0"])
86
+ s.add_development_dependency(%q<sqlite3>, [">= 0"])
87
+ s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
88
+ s.add_development_dependency(%q<jeweler>, ["~> 1.6.4"])
89
+ s.add_development_dependency(%q<ruby-debug19>, [">= 0"])
90
+ s.add_development_dependency(%q<rspec>, ["~> 2.6.0"])
91
+ s.add_development_dependency(%q<rspec-rails>, ["~> 2.6.1"])
92
+ s.add_development_dependency(%q<shoulda>, ["~> 3.0.0"])
93
+ s.add_development_dependency(%q<ruby_parser>, ["~> 2.3.1"])
94
+ s.add_development_dependency(%q<ZenTest>, [">= 0"])
95
+ s.add_development_dependency(%q<autotest-rails>, [">= 0"])
96
+ else
97
+ s.add_dependency(%q<rails>, ["~> 3.0.7"])
98
+ s.add_dependency(%q<capybara>, [">= 0.4.0"])
99
+ s.add_dependency(%q<sqlite3>, [">= 0"])
100
+ s.add_dependency(%q<bundler>, ["~> 1.0.0"])
101
+ s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
102
+ s.add_dependency(%q<ruby-debug19>, [">= 0"])
103
+ s.add_dependency(%q<rspec>, ["~> 2.6.0"])
104
+ s.add_dependency(%q<rspec-rails>, ["~> 2.6.1"])
105
+ s.add_dependency(%q<shoulda>, ["~> 3.0.0"])
106
+ s.add_dependency(%q<ruby_parser>, ["~> 2.3.1"])
107
+ s.add_dependency(%q<ZenTest>, [">= 0"])
108
+ s.add_dependency(%q<autotest-rails>, [">= 0"])
109
+ end
110
+ else
111
+ s.add_dependency(%q<rails>, ["~> 3.0.7"])
112
+ s.add_dependency(%q<capybara>, [">= 0.4.0"])
113
+ s.add_dependency(%q<sqlite3>, [">= 0"])
114
+ s.add_dependency(%q<bundler>, ["~> 1.0.0"])
115
+ s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
116
+ s.add_dependency(%q<ruby-debug19>, [">= 0"])
117
+ s.add_dependency(%q<rspec>, ["~> 2.6.0"])
118
+ s.add_dependency(%q<rspec-rails>, ["~> 2.6.1"])
119
+ s.add_dependency(%q<shoulda>, ["~> 3.0.0"])
120
+ s.add_dependency(%q<ruby_parser>, ["~> 2.3.1"])
121
+ s.add_dependency(%q<ZenTest>, [">= 0"])
122
+ s.add_dependency(%q<autotest-rails>, [">= 0"])
123
+ end
124
+ end
125
+
@@ -1,6 +1,6 @@
1
1
  require 'rails'
2
2
 
3
- require 'dynamic_fieldsets/config'
3
+ # require 'dynamic_fieldsets/config'
4
4
 
5
5
  module FormatValidators
6
6
  class Railtie < ::Rails::Railtie
@@ -0,0 +1,7 @@
1
+ # Add your own tasks in files placed in lib/tasks ending in .rake,
2
+ # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
3
+
4
+ require File.expand_path('../config/application', __FILE__)
5
+ require 'rake'
6
+
7
+ Dummy::Application.load_tasks
@@ -0,0 +1,3 @@
1
+ class ApplicationController < ActionController::Base
2
+ protect_from_forgery
3
+ end
@@ -0,0 +1,2 @@
1
+ module ApplicationHelper
2
+ end
@@ -0,0 +1,14 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>Dummy</title>
5
+ <%= stylesheet_link_tag :all %>
6
+ <%= javascript_include_tag :defaults %>
7
+ <%= csrf_meta_tag %>
8
+ </head>
9
+ <body>
10
+
11
+ <%= yield %>
12
+
13
+ </body>
14
+ </html>
@@ -0,0 +1,4 @@
1
+ # This file is used by Rack-based servers to start the application.
2
+
3
+ require ::File.expand_path('../config/environment', __FILE__)
4
+ run Dummy::Application
@@ -0,0 +1,45 @@
1
+ require File.expand_path('../boot', __FILE__)
2
+
3
+ require "active_model/railtie"
4
+ require "active_record/railtie"
5
+ require "action_controller/railtie"
6
+ require "action_view/railtie"
7
+ require "action_mailer/railtie"
8
+
9
+ Bundler.require
10
+ require "format_validators"
11
+
12
+ module Dummy
13
+ class Application < Rails::Application
14
+ # Settings in config/environments/* take precedence over those specified here.
15
+ # Application configuration should go into files in config/initializers
16
+ # -- all .rb files in that directory are automatically loaded.
17
+
18
+ # Custom directories with classes and modules you want to be autoloadable.
19
+ # config.autoload_paths += %W(#{config.root}/extras)
20
+
21
+ # Only load the plugins named here, in the order given (default is alphabetical).
22
+ # :all can be used as a placeholder for all plugins not explicitly named.
23
+ # config.plugins = [ :exception_notification, :ssl_requirement, :all ]
24
+
25
+ # Activate observers that should always be running.
26
+ # config.active_record.observers = :cacher, :garbage_collector, :forum_observer
27
+
28
+ # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
29
+ # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
30
+ # config.time_zone = 'Central Time (US & Canada)'
31
+
32
+ # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
33
+ # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
34
+ # config.i18n.default_locale = :de
35
+
36
+ # JavaScript files you want as :defaults (application.js is always included).
37
+ # config.action_view.javascript_expansions[:defaults] = %w(jquery rails)
38
+
39
+ # Configure the default encoding used in templates for Ruby 1.9.
40
+ config.encoding = "utf-8"
41
+
42
+ # Configure sensitive parameters which will be filtered from the log file.
43
+ config.filter_parameters += [:password]
44
+ end
45
+ end
@@ -0,0 +1,10 @@
1
+ require 'rubygems'
2
+ gemfile = File.expand_path('../../../../Gemfile', __FILE__)
3
+
4
+ if File.exist?(gemfile)
5
+ ENV['BUNDLE_GEMFILE'] = gemfile
6
+ require 'bundler'
7
+ Bundler.setup
8
+ end
9
+
10
+ $:.unshift File.expand_path('../../../../lib', __FILE__)
@@ -0,0 +1,22 @@
1
+ # SQLite version 3.x
2
+ # gem install sqlite3
3
+ development:
4
+ adapter: sqlite3
5
+ database: db/development.sqlite3
6
+ pool: 5
7
+ timeout: 5000
8
+
9
+ # Warning: The database defined as "test" will be erased and
10
+ # re-generated from your development database when you run "rake".
11
+ # Do not set this db to the same as development or production.
12
+ test:
13
+ adapter: sqlite3
14
+ database: db/test.sqlite3
15
+ pool: 5
16
+ timeout: 5000
17
+
18
+ production:
19
+ adapter: sqlite3
20
+ database: db/production.sqlite3
21
+ pool: 5
22
+ timeout: 5000