preciousss 0.0.6 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -8,4 +8,9 @@ View Helpers
8
8
  body_id
9
9
  errors_for
10
10
  flash_messages
11
- is_bot?
11
+ is_bot?
12
+
13
+ Validators
14
+ ----------
15
+
16
+ email_format
@@ -0,0 +1,22 @@
1
+ class CollectionLengthValidator < ActiveModel::Validations::LengthValidator
2
+
3
+ def validate_each(record, attribute, value)
4
+ CHECKS.each do |key, validity_check|
5
+ next unless check_value = options[key]
6
+
7
+ value ||= [] if key == :maximum
8
+
9
+ # Changed value.size to value.length here
10
+ next if value && value.length.send(validity_check, check_value)
11
+
12
+ errors_options = options.except(*RESERVED_OPTIONS)
13
+ errors_options[:count] = check_value
14
+
15
+ default_message = options[MESSAGES[key]]
16
+ errors_options[:message] ||= default_message if default_message
17
+
18
+ record.errors.add(attribute, MESSAGES[key], errors_options)
19
+ end
20
+ end
21
+
22
+ end
@@ -3,7 +3,7 @@ require 'mail'
3
3
  # http://my.rails-royce.org/2010/07/21/email-validation-in-ruby-on-rails-without-regexp/
4
4
  class EmailFormatValidator < ActiveModel::EachValidator
5
5
 
6
- def validate_each(record,attribute,value)
6
+ def validate_each(record, attribute, value)
7
7
  begin
8
8
  m = Mail::Address.new(value)
9
9
  # We must check that value contains a domain and that value is an email address
@@ -1,3 +1,3 @@
1
1
  module Preciousss
2
- VERSION = '0.0.6'
2
+ VERSION = '0.0.7'
3
3
  end
data/lib/preciousss.rb CHANGED
@@ -16,6 +16,7 @@ module Preciousss
16
16
  end
17
17
 
18
18
  require 'preciousss/validators/email_format_validator'
19
+ require 'preciousss/validators/collection_length_validator'
19
20
  end
20
21
 
21
22
  end
metadata CHANGED
@@ -1,40 +1,31 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: preciousss
3
- version: !ruby/object:Gem::Version
4
- hash: 19
5
- prerelease:
6
- segments:
7
- - 0
8
- - 0
9
- - 6
10
- version: 0.0.6
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.7
5
+ prerelease: !!null
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - sodercober
14
- autorequire:
9
+ autorequire: !!null
15
10
  bindir: bin
16
11
  cert_chain: []
17
-
18
- date: 2011-03-07 00:00:00 +00:00
19
- default_executable:
12
+ date: 2011-03-08 00:00:00.000000000 +00:00
13
+ default_executable: !!null
20
14
  dependencies: []
21
-
22
15
  description: Several helpers for Ruby on Rails 3
23
- email:
16
+ email:
24
17
  - sodercober@gmail.com
25
18
  executables: []
26
-
27
19
  extensions: []
28
-
29
20
  extra_rdoc_files: []
30
-
31
- files:
21
+ files:
32
22
  - .gitignore
33
23
  - Gemfile
34
24
  - README.md
35
25
  - Rakefile
36
26
  - lib/preciousss.rb
37
27
  - lib/preciousss/controllers/helpers.rb
28
+ - lib/preciousss/validators/collection_length_validator.rb
38
29
  - lib/preciousss/validators/email_format_validator.rb
39
30
  - lib/preciousss/version.rb
40
31
  - lib/preciousss/view_helpers/action_view.rb
@@ -42,36 +33,26 @@ files:
42
33
  has_rdoc: true
43
34
  homepage: https://github.com/sodercober/preciousss
44
35
  licenses: []
45
-
46
- post_install_message:
36
+ post_install_message: !!null
47
37
  rdoc_options: []
48
-
49
- require_paths:
38
+ require_paths:
50
39
  - lib
51
- required_ruby_version: !ruby/object:Gem::Requirement
40
+ required_ruby_version: !ruby/object:Gem::Requirement
52
41
  none: false
53
- requirements:
54
- - - ">="
55
- - !ruby/object:Gem::Version
56
- hash: 3
57
- segments:
58
- - 0
59
- version: "0"
60
- required_rubygems_version: !ruby/object:Gem::Requirement
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ required_rubygems_version: !ruby/object:Gem::Requirement
61
47
  none: false
62
- requirements:
63
- - - ">="
64
- - !ruby/object:Gem::Version
65
- hash: 3
66
- segments:
67
- - 0
68
- version: "0"
48
+ requirements:
49
+ - - ! '>='
50
+ - !ruby/object:Gem::Version
51
+ version: '0'
69
52
  requirements: []
70
-
71
53
  rubyforge_project: preciousss
72
- rubygems_version: 1.6.1
73
- signing_key:
54
+ rubygems_version: 1.5.0
55
+ signing_key: !!null
74
56
  specification_version: 3
75
57
  summary: Several helpers for Ruby on Rails 3
76
58
  test_files: []
77
-