inline_forms 1.1.18 → 1.1.19

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,30 @@
1
+ # == usage:
2
+ # in your model, add:
3
+ # validates :email, :presence => true, :is_email_address => true;
4
+ # taken from http://lindsaar.net/2010/1/31/validates_rails_3_awesome_is_true
5
+ # (It's probably a fake regex but hey, it looks legit.)
6
+ class IsEmailAddressValidator < ActiveModel::EachValidator
7
+ EmailAddress = begin
8
+ qtext = '[^\\x0d\\x22\\x5c\\x80-\\xff]'
9
+ dtext = '[^\\x0d\\x5b-\\x5d\\x80-\\xff]'
10
+ atom = '[^\\x00-\\x20\\x22\\x28\\x29\\x2c\\x2e\\x3a-' +
11
+ '\\x3c\\x3e\\x40\\x5b-\\x5d\\x7f-\\xff]+'
12
+ quoted_pair = '\\x5c[\\x00-\\x7f]'
13
+ domain_literal = "\\x5b(?:#{dtext}|#{quoted_pair})*\\x5d"
14
+ quoted_string = "\\x22(?:#{qtext}|#{quoted_pair})*\\x22"
15
+ domain_ref = atom
16
+ sub_domain = "(?:#{domain_ref}|#{domain_literal})"
17
+ word = "(?:#{atom}|#{quoted_string})"
18
+ domain = "#{sub_domain}(?:\\x2e#{sub_domain})*"
19
+ local_part = "#{word}(?:\\x2e#{word})*"
20
+ addr_spec = "#{local_part}\\x40#{domain}"
21
+ pattern = /\A#{addr_spec}\z/
22
+ end
23
+
24
+ def validate_each(record, attribute, value)
25
+ unless value =~ EmailAddress
26
+ record.errors[attribute] << (options[:message] || "is not a valid email address.")
27
+ end
28
+ end
29
+
30
+ end
@@ -1,3 +1,3 @@
1
1
  module InlineForms
2
- VERSION = "1.1.18"
2
+ VERSION = "1.1.19"
3
3
  end
data/lib/inline_forms.rb CHANGED
@@ -2,8 +2,6 @@ require ('inline_forms/version.rb')
2
2
  # InlineForms is a Rails Engine that let you setup an admin interface quick and
3
3
  # easy. Please install it as a gem or include it in your Gemfile.
4
4
  module InlineForms
5
- # load stuff in lib
6
- config.autoload_paths += Dir["lib", "lib/**/"]
7
5
  # DEFAULT_COLUMN_TYPES holds the standard ActiveRecord::Migration column types.
8
6
  # This list provides compatability with the standard types, but we add our own
9
7
  # later in 'Special Column Types'.
@@ -144,7 +142,6 @@ module InlineForms
144
142
  paths["app/models"] << "lib/app/models"
145
143
  paths["app/views"] << "lib/app/views"
146
144
  paths["app/assets"] << "lib/app/assets"
147
- paths["lib"] << "lib/validators"
148
145
  end
149
146
 
150
147
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: inline_forms
3
3
  version: !ruby/object:Gem::Version
4
- hash: 55
4
+ hash: 53
5
5
  prerelease:
6
6
  segments:
7
7
  - 1
8
8
  - 1
9
- - 18
10
- version: 1.1.18
9
+ - 19
10
+ version: 1.1.19
11
11
  platform: ruby
12
12
  authors:
13
13
  - Ace Suares
@@ -156,6 +156,7 @@ files:
156
156
  - lib/app/helpers/form_elements/text_field.rb
157
157
  - lib/app/helpers/inline_forms_helper.rb
158
158
  - lib/app/models/geo_code_curacao.rb
159
+ - lib/app/validators/is_email_address_validator.rb
159
160
  - lib/app/views/devise/confirmations/new.html.erb
160
161
  - lib/app/views/devise/mailer/confirmation_instructions.html.erb
161
162
  - lib/app/views/devise/mailer/reset_password_instructions.html.erb
@@ -197,7 +198,6 @@ files:
197
198
  - lib/otherstuff/diffie
198
199
  - lib/otherstuff/mkrole
199
200
  - lib/otherstuff/roles_users.sql
200
- - lib/validators/email_format_validator.rb
201
201
  - test/helper.rb
202
202
  - test/test_inline_forms.rb
203
203
  homepage: http://github.com/acesuares/inline_forms
@@ -1,8 +0,0 @@
1
- # http://railscasts.com/episodes/211-validations-in-rails-3
2
- class EmailFormatValidator < ActiveModel::EachValidator
3
- def validate_each(object, attribute, value)
4
- unless value =~ /^([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/i
5
- object.errors[attribute] << (options[:message] || "is not formatted properly")
6
- end
7
- end
8
- end