validates_im 1.0.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2009 Tim Morgan
1
+ Copyright (c) 2010 Tim Morgan
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
data/README.textile CHANGED
@@ -1,7 +1,7 @@
1
1
  h1. validates_im -- Instant messenger account validations for ActiveRecord
2
2
 
3
3
  | *Author* | Tim Morgan |
4
- | *Version* | 1.0 (Oct 30, 2010) |
4
+ | *Version* | 1.1 (Aug 31, 2011) |
5
5
  | *License* | Released under the MIT license. |
6
6
 
7
7
  h2. About
@@ -55,7 +55,7 @@
55
55
  # validations.
56
56
 
57
57
  class AccountNameValidator < ActiveModel::EachValidator
58
- class_inheritable_array :validations
58
+ class_attribute :validations
59
59
  self.validations = Array.new
60
60
 
61
61
  # @private
@@ -94,7 +94,7 @@ class AccountNameValidator < ActiveModel::EachValidator
94
94
 
95
95
  def self.add_validation(key, &block)
96
96
  return unless block_given?
97
- self.validations << [ block, key ]
97
+ self.validations += [[ block, key ]]
98
98
  end
99
99
 
100
100
  # Enforces a minimum length on account names. Uses the "too_short" error
data/validates_im.gemspec CHANGED
@@ -1,62 +1,62 @@
1
1
  # Generated by jeweler
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{validates_im}
8
- s.version = "1.0.0"
8
+ s.version = "1.1.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
- s.authors = ["Tim Morgan"]
12
- s.date = %q{2010-10-30}
13
- s.description = %q{Adds ActiveModel validators for common instant messenging services like Skype and AIM.}
11
+ s.authors = [%q{Tim Morgan}]
12
+ s.date = %q{2011-08-31}
13
+ s.description = %q{Adds ActiveModel validators for common instant messaging services like Skype and AIM.}
14
14
  s.email = %q{git@timothymorgan.info}
15
15
  s.extra_rdoc_files = [
16
16
  "LICENSE",
17
- "README.textile"
17
+ "README.textile"
18
18
  ]
19
19
  s.files = [
20
- ".document",
21
- ".gitignore",
22
- ".rspec",
23
- "Gemfile",
24
- "Gemfile.lock",
25
- "LICENSE",
26
- "README.textile",
27
- "Rakefile",
28
- "VERSION",
29
- "lib/account_name_validator.rb",
30
- "lib/aim_validator.rb",
31
- "lib/skype_validator.rb",
32
- "lib/steam_validator.rb",
33
- "lib/validates_im.rb",
34
- "lib/xbox_live_validator.rb",
35
- "lib/yahoo_im_validator.rb",
36
- "spec/account_name_validator_spec.rb",
37
- "spec/spec_helper.rb",
38
- "validates_im.gemspec"
20
+ "LICENSE",
21
+ "README.textile",
22
+ "lib/account_name_validator.rb",
23
+ "lib/aim_validator.rb",
24
+ "lib/skype_validator.rb",
25
+ "lib/steam_validator.rb",
26
+ "lib/validates_im.rb",
27
+ "lib/xbox_live_validator.rb",
28
+ "lib/yahoo_im_validator.rb",
29
+ "validates_im.gemspec"
39
30
  ]
40
31
  s.homepage = %q{http://github.com/riscfuture/validates_im}
41
- s.rdoc_options = ["--charset=UTF-8"]
42
- s.require_paths = ["lib"]
43
- s.rubygems_version = %q{1.3.7}
44
- s.summary = %q{A set of Rails validators for common instant messenging services}
45
- s.test_files = [
46
- "spec/account_name_validator_spec.rb",
47
- "spec/spec_helper.rb"
48
- ]
32
+ s.require_paths = [%q{lib}]
33
+ s.rubygems_version = %q{1.8.9}
34
+ s.summary = %q{A set of Rails validators for common instant messaging services}
49
35
 
50
36
  if s.respond_to? :specification_version then
51
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
52
37
  s.specification_version = 3
53
38
 
54
39
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
40
+ s.add_runtime_dependency(%q<activerecord>, [">= 3.1"])
41
+ s.add_development_dependency(%q<jeweler>, [">= 0"])
42
+ s.add_development_dependency(%q<yard>, [">= 0"])
43
+ s.add_development_dependency(%q<RedCloth>, [">= 0"])
44
+ s.add_development_dependency(%q<rspec>, [">= 0"])
55
45
  s.add_runtime_dependency(%q<activerecord>, [">= 3.0"])
56
46
  else
47
+ s.add_dependency(%q<activerecord>, [">= 3.1"])
48
+ s.add_dependency(%q<jeweler>, [">= 0"])
49
+ s.add_dependency(%q<yard>, [">= 0"])
50
+ s.add_dependency(%q<RedCloth>, [">= 0"])
51
+ s.add_dependency(%q<rspec>, [">= 0"])
57
52
  s.add_dependency(%q<activerecord>, [">= 3.0"])
58
53
  end
59
54
  else
55
+ s.add_dependency(%q<activerecord>, [">= 3.1"])
56
+ s.add_dependency(%q<jeweler>, [">= 0"])
57
+ s.add_dependency(%q<yard>, [">= 0"])
58
+ s.add_dependency(%q<RedCloth>, [">= 0"])
59
+ s.add_dependency(%q<rspec>, [">= 0"])
60
60
  s.add_dependency(%q<activerecord>, [">= 3.0"])
61
61
  end
62
62
  end
metadata CHANGED
@@ -1,55 +1,93 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: validates_im
3
- version: !ruby/object:Gem::Version
4
- prerelease: false
5
- segments:
6
- - 1
7
- - 0
8
- - 0
9
- version: 1.0.0
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.1.0
5
+ prerelease:
10
6
  platform: ruby
11
- authors:
7
+ authors:
12
8
  - Tim Morgan
13
9
  autorequire:
14
10
  bindir: bin
15
11
  cert_chain: []
16
-
17
- date: 2010-10-30 00:00:00 -07:00
18
- default_executable:
19
- dependencies:
20
- - !ruby/object:Gem::Dependency
12
+ date: 2011-08-31 00:00:00.000000000Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: activerecord
16
+ requirement: &2167709520 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '3.1'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *2167709520
25
+ - !ruby/object:Gem::Dependency
26
+ name: jeweler
27
+ requirement: &2167708860 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ type: :development
34
+ prerelease: false
35
+ version_requirements: *2167708860
36
+ - !ruby/object:Gem::Dependency
37
+ name: yard
38
+ requirement: &2167708280 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
44
+ type: :development
45
+ prerelease: false
46
+ version_requirements: *2167708280
47
+ - !ruby/object:Gem::Dependency
48
+ name: RedCloth
49
+ requirement: &2167707660 !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ type: :development
56
+ prerelease: false
57
+ version_requirements: *2167707660
58
+ - !ruby/object:Gem::Dependency
59
+ name: rspec
60
+ requirement: &2167707060 !ruby/object:Gem::Requirement
61
+ none: false
62
+ requirements:
63
+ - - ! '>='
64
+ - !ruby/object:Gem::Version
65
+ version: '0'
66
+ type: :development
67
+ prerelease: false
68
+ version_requirements: *2167707060
69
+ - !ruby/object:Gem::Dependency
21
70
  name: activerecord
22
- requirement: &id001 !ruby/object:Gem::Requirement
71
+ requirement: &2167706460 !ruby/object:Gem::Requirement
23
72
  none: false
24
- requirements:
25
- - - ">="
26
- - !ruby/object:Gem::Version
27
- segments:
28
- - 3
29
- - 0
30
- version: "3.0"
73
+ requirements:
74
+ - - ! '>='
75
+ - !ruby/object:Gem::Version
76
+ version: '3.0'
31
77
  type: :runtime
32
78
  prerelease: false
33
- version_requirements: *id001
34
- description: Adds ActiveModel validators for common instant messenging services like Skype and AIM.
79
+ version_requirements: *2167706460
80
+ description: Adds ActiveModel validators for common instant messaging services like
81
+ Skype and AIM.
35
82
  email: git@timothymorgan.info
36
83
  executables: []
37
-
38
84
  extensions: []
39
-
40
- extra_rdoc_files:
85
+ extra_rdoc_files:
41
86
  - LICENSE
42
87
  - README.textile
43
- files:
44
- - .document
45
- - .gitignore
46
- - .rspec
47
- - Gemfile
48
- - Gemfile.lock
88
+ files:
49
89
  - LICENSE
50
90
  - README.textile
51
- - Rakefile
52
- - VERSION
53
91
  - lib/account_name_validator.rb
54
92
  - lib/aim_validator.rb
55
93
  - lib/skype_validator.rb
@@ -57,42 +95,32 @@ files:
57
95
  - lib/validates_im.rb
58
96
  - lib/xbox_live_validator.rb
59
97
  - lib/yahoo_im_validator.rb
60
- - spec/account_name_validator_spec.rb
61
- - spec/spec_helper.rb
62
98
  - validates_im.gemspec
63
- has_rdoc: true
64
99
  homepage: http://github.com/riscfuture/validates_im
65
100
  licenses: []
66
-
67
101
  post_install_message:
68
- rdoc_options:
69
- - --charset=UTF-8
70
- require_paths:
102
+ rdoc_options: []
103
+ require_paths:
71
104
  - lib
72
- required_ruby_version: !ruby/object:Gem::Requirement
105
+ required_ruby_version: !ruby/object:Gem::Requirement
73
106
  none: false
74
- requirements:
75
- - - ">="
76
- - !ruby/object:Gem::Version
77
- hash: -3410244154363929374
78
- segments:
107
+ requirements:
108
+ - - ! '>='
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ segments:
79
112
  - 0
80
- version: "0"
81
- required_rubygems_version: !ruby/object:Gem::Requirement
113
+ hash: 221433530893937633
114
+ required_rubygems_version: !ruby/object:Gem::Requirement
82
115
  none: false
83
- requirements:
84
- - - ">="
85
- - !ruby/object:Gem::Version
86
- segments:
87
- - 0
88
- version: "0"
116
+ requirements:
117
+ - - ! '>='
118
+ - !ruby/object:Gem::Version
119
+ version: '0'
89
120
  requirements: []
90
-
91
121
  rubyforge_project:
92
- rubygems_version: 1.3.7
122
+ rubygems_version: 1.8.9
93
123
  signing_key:
94
124
  specification_version: 3
95
- summary: A set of Rails validators for common instant messenging services
96
- test_files:
97
- - spec/account_name_validator_spec.rb
98
- - spec/spec_helper.rb
125
+ summary: A set of Rails validators for common instant messaging services
126
+ test_files: []
data/.document DELETED
@@ -1,5 +0,0 @@
1
- README.rdoc
2
- lib/**/*.rb
3
- bin/*
4
- features/**/*.feature
5
- LICENSE
data/.gitignore DELETED
@@ -1,25 +0,0 @@
1
- ## MAC OS
2
- .DS_Store
3
-
4
- ## TEXTMATE
5
- *.tmproj
6
- tmtags
7
-
8
- ## EMACS
9
- *~
10
- \#*
11
- .\#*
12
-
13
- ## VIM
14
- *.swp
15
-
16
- ## PROJECT::GENERAL
17
- coverage
18
- rdoc
19
- pkg
20
- .rvmrc
21
- .bundle
22
-
23
- ## PROJECT::DOCUMENTATION
24
- .yardoc
25
- doc
data/.rspec DELETED
@@ -1 +0,0 @@
1
- -cfs
data/Gemfile DELETED
@@ -1,12 +0,0 @@
1
- source :rubygems
2
-
3
- # DEPENDENCIES
4
- gem 'activerecord', require: 'active_record'
5
-
6
- # DEVELOPMENT
7
- gem 'jeweler'
8
- gem 'yard'
9
- gem 'RedCloth', require: 'redcloth'
10
-
11
- # TEST
12
- gem 'rspec'
data/Gemfile.lock DELETED
@@ -1,50 +0,0 @@
1
- GEM
2
- remote: http://rubygems.org/
3
- specs:
4
- RedCloth (4.2.3)
5
- activemodel (3.0.1)
6
- activesupport (= 3.0.1)
7
- builder (~> 2.1.2)
8
- i18n (~> 0.4.1)
9
- activerecord (3.0.1)
10
- activemodel (= 3.0.1)
11
- activesupport (= 3.0.1)
12
- arel (~> 1.0.0)
13
- tzinfo (~> 0.3.23)
14
- activesupport (3.0.1)
15
- arel (1.0.1)
16
- activesupport (~> 3.0.0)
17
- builder (2.1.2)
18
- diff-lcs (1.1.2)
19
- gemcutter (0.6.1)
20
- git (1.2.5)
21
- i18n (0.4.2)
22
- jeweler (1.4.0)
23
- gemcutter (>= 0.1.0)
24
- git (>= 1.2.5)
25
- rubyforge (>= 2.0.0)
26
- json_pure (1.4.6)
27
- rspec (2.0.1)
28
- rspec-core (~> 2.0.1)
29
- rspec-expectations (~> 2.0.1)
30
- rspec-mocks (~> 2.0.1)
31
- rspec-core (2.0.1)
32
- rspec-expectations (2.0.1)
33
- diff-lcs (>= 1.1.2)
34
- rspec-mocks (2.0.1)
35
- rspec-core (~> 2.0.1)
36
- rspec-expectations (~> 2.0.1)
37
- rubyforge (2.0.4)
38
- json_pure (>= 1.1.7)
39
- tzinfo (0.3.23)
40
- yard (0.6.1)
41
-
42
- PLATFORMS
43
- ruby
44
-
45
- DEPENDENCIES
46
- RedCloth
47
- activerecord
48
- jeweler
49
- rspec
50
- yard
data/Rakefile DELETED
@@ -1,35 +0,0 @@
1
- require 'rake'
2
- begin
3
- require 'bundler'
4
- rescue LoadError
5
- puts "Bundler is not installed; install with `gem install bundler`."
6
- exit 1
7
- end
8
-
9
- Bundler.require :default
10
-
11
- Jeweler::Tasks.new do |gem|
12
- gem.name = "validates_im"
13
- gem.summary = %Q{A set of Rails validators for common instant messenging services}
14
- gem.description = %Q{Adds ActiveModel validators for common instant messenging services like Skype and AIM.}
15
- gem.email = "git@timothymorgan.info"
16
- gem.homepage = "http://github.com/riscfuture/validates_im"
17
- gem.authors = [ "Tim Morgan" ]
18
- gem.add_dependency 'activerecord', '>= 3.0'
19
- end
20
- Jeweler::GemcutterTasks.new
21
-
22
- require 'rspec/core/rake_task'
23
- RSpec::Core::RakeTask.new
24
-
25
- YARD::Rake::YardocTask.new('doc') do |doc|
26
- doc.options << "-m" << "textile"
27
- doc.options << "--protected"
28
- doc.options << "-r" << "README.textile"
29
- doc.options << "-o" << "doc"
30
- doc.options << "--title" << "validates_im Documentation".inspect
31
-
32
- doc.files = [ 'lib/*_validator.rb', 'README.textile' ]
33
- end
34
-
35
- task(default: :spec)
data/VERSION DELETED
@@ -1 +0,0 @@
1
- 1.0.0
@@ -1,115 +0,0 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
-
3
- module SpecSupport
4
- class TestAccountNameValidator < AccountNameValidator; end
5
- class FakeModel
6
- extend ActiveModel::Translation
7
- def errors() @errors ||= ActiveModel::Errors.new(self) end
8
- def self.lookup_ancestors() [ self ] end
9
- def read_attribute_for_validation(_) "mock" end
10
- end
11
- end
12
-
13
- describe AccountNameValidator do
14
- before :each do
15
- SpecSupport::TestAccountNameValidator.validations.clear
16
- @model = SpecSupport::FakeModel.new
17
- end
18
-
19
- describe ".error_key_prefix" do
20
- it "should be the downcased name of the validator by default" do
21
- SpecSupport::TestAccountNameValidator.error_key_prefix.should eql(:test_account_name)
22
- end
23
-
24
- it "should be able to be set" do
25
- SpecSupport::TestAccountNameValidator.error_key_prefix(:foo)
26
- SpecSupport::TestAccountNameValidator.error_key_prefix.should eql(:foo)
27
- SpecSupport::TestAccountNameValidator.instance_variable_set :@error_key_prefix, nil
28
- end
29
- end
30
-
31
- describe "#validate_each" do
32
- it "should do nothing if given nil and :allow_nil is set" do
33
- SpecSupport::TestAccountNameValidator.new(attributes: :field, allow_nil: true).validate_each(@model, :field, nil)
34
- @model.errors.should be_empty
35
- end
36
-
37
- it "should do nothing if given a blank value and :allow_blank is set" do
38
- SpecSupport::TestAccountNameValidator.new(attributes: :field, allow_blank: true).validate_each(@model, :field, "")
39
- @model.errors.should be_empty
40
- end
41
-
42
- it "should add an error to the record if any validation fails" do
43
- SpecSupport::TestAccountNameValidator.add_validation(:not_foo) { |value| value == 'foo' }
44
- SpecSupport::TestAccountNameValidator.new(attributes: :field).validate_each(@model, :field, 'bar')
45
- @model.errors[:field].should_not be_empty
46
- @model.errors[:field].first.should include('test_account_name_not_foo')
47
- end
48
-
49
- it "should use a :message option for the message" do
50
- SpecSupport::TestAccountNameValidator.add_validation(:not_foo) { |value| value == 'foo' }
51
- SpecSupport::TestAccountNameValidator.new(attributes: :field, message: 'bar').validate_each(@model, :field, 'bar')
52
- @model.errors[:field].should eql([ 'bar' ])
53
- end
54
-
55
- it "should typecast the value to a string" do
56
- SpecSupport::TestAccountNameValidator.add_validation(:not_foo) { |value| value == 'foo' }
57
- SpecSupport::TestAccountNameValidator.new(attributes: :field).validate_each(@model, :field, :foo)
58
- @model.errors.should be_empty
59
- end
60
- end
61
-
62
- describe ".add_validation" do
63
- before :each do
64
- @validator = SpecSupport::TestAccountNameValidator.new(attributes: :field)
65
- end
66
-
67
- it "should add a validation block" do
68
- SpecSupport::TestAccountNameValidator.add_validation(:not_foo) { |value| value == 'foo' }
69
- @validator.validate_each(@model, :field, 'bar')
70
- @model.errors[:field].should_not be_empty
71
- end
72
-
73
- it "should do nothing if no block is given" do
74
- SpecSupport::TestAccountNameValidator.add_validation(:not_foo)
75
- @validator.validate_each(@model, :field, 'bar')
76
- @model.errors[:field].should be_empty
77
- end
78
- end
79
-
80
- describe ".min_length" do
81
- it "should ensure a minimum length" do
82
- SpecSupport::TestAccountNameValidator.min_length 5
83
- SpecSupport::TestAccountNameValidator.new(attributes: :field).validate_each(@model, :field, '1234')
84
- @model.errors[:field].should_not be_empty
85
- @model.errors[:field].first.should include('too_short')
86
- end
87
- end
88
-
89
- describe ".max_length" do
90
- it "should ensure a maximum length" do
91
- SpecSupport::TestAccountNameValidator.max_length 5
92
- SpecSupport::TestAccountNameValidator.new(attributes: :field).validate_each(@model, :field, '123456')
93
- @model.errors[:field].should_not be_empty
94
- @model.errors[:field].first.should include('too_long')
95
- end
96
- end
97
-
98
- describe ".valid_chars" do
99
- it "should check for invalid chars" do
100
- SpecSupport::TestAccountNameValidator.valid_chars '[A-Z]'
101
- SpecSupport::TestAccountNameValidator.new(attributes: :field).validate_each(@model, :field, 'A!Z')
102
- @model.errors[:field].should_not be_empty
103
- @model.errors[:field].first.should include('invalid_chars')
104
- end
105
- end
106
-
107
- describe ".first_char" do
108
- it "should check for an invalid first character" do
109
- SpecSupport::TestAccountNameValidator.first_char '[A-Z]'
110
- SpecSupport::TestAccountNameValidator.new(attributes: :field).validate_each(@model, :field, 'abc')
111
- @model.errors[:field].should_not be_empty
112
- @model.errors[:field].first.should include('invalid_first_char')
113
- end
114
- end
115
- end
data/spec/spec_helper.rb DELETED
@@ -1,10 +0,0 @@
1
- Bundler.require :default, :test
2
-
3
- $LOAD_PATH.unshift(File.dirname(__FILE__))
4
- $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
5
-
6
- require 'validates_im'
7
-
8
- RSpec.configure do |config|
9
-
10
- end