dm-validations 0.9.7 → 0.9.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/History.txt CHANGED
@@ -1 +1,5 @@
1
+ === 0.9.8 / 2008-12-07
1
2
 
3
+ * 1 bug fix:
4
+
5
+ * Updated specs to test valididity of RFC2822 email addresses
data/Manifest.txt CHANGED
@@ -46,3 +46,5 @@ spec/integration/validation_spec.rb
46
46
  spec/integration/within_validator_spec.rb
47
47
  spec/spec.opts
48
48
  spec/spec_helper.rb
49
+ tasks/install.rb
50
+ tasks/spec.rb
data/Rakefile CHANGED
@@ -1,66 +1,25 @@
1
- require 'rubygems'
2
- require 'spec'
3
- require 'spec/rake/spectask'
4
1
  require 'pathname'
2
+ require 'rubygems'
3
+
4
+ ROOT = Pathname(__FILE__).dirname.expand_path
5
+ JRUBY = RUBY_PLATFORM =~ /java/
6
+ WINDOWS = Gem.win_platform?
7
+ SUDO = (WINDOWS || JRUBY) ? '' : ('sudo' unless ENV['SUDOLESS'])
5
8
 
6
- ROOT = Pathname(__FILE__).dirname.expand_path
7
9
  require ROOT + 'lib/dm-validations/version'
8
10
 
9
- AUTHOR = "Guy van den Berg"
10
- EMAIL = "vandenberg.guy@gmail.com"
11
- GEM_NAME = "dm-validations"
11
+ AUTHOR = 'Guy van den Berg'
12
+ EMAIL = 'vandenberg.guy [a] gmail [d] com'
13
+ GEM_NAME = 'dm-validations'
12
14
  GEM_VERSION = DataMapper::Validations::VERSION
13
- GEM_DEPENDENCIES = [["dm-core", GEM_VERSION]]
14
- GEM_CLEAN = ["log", "pkg", "coverage"]
15
- GEM_EXTRAS = { :has_rdoc => true, :extra_rdoc_files => %w[ README.txt LICENSE TODO ] }
16
-
17
- PROJECT_NAME = "datamapper"
18
- PROJECT_URL = "http://github.com/sam/dm-more/tree/master/dm-validations"
19
- PROJECT_DESCRIPTION = PROJECT_SUMMARY = "DataMapper plugin for performing validations on data models"
20
-
21
- require ROOT.parent + 'tasks/hoe'
22
-
23
- desc "Generate Documentation"
24
- rd = Rake::RDocTask.new do |rdoc|
25
- rdoc.rdoc_dir = 'doc'
26
- rdoc.title = "DataMapper Validations"
27
- rdoc.options << '--line-numbers' << '--inline-source' << '--main' << 'README'
28
- rdoc.rdoc_files.include(FileList[ 'lib/**/*.rb', 'README', 'LICENSE'])
29
- end
30
-
31
- task :default => [ :spec ]
32
-
33
- WIN32 = (RUBY_PLATFORM =~ /win32|mingw|cygwin/) rescue nil
34
- SUDO = WIN32 ? '' : ('sudo' unless ENV['SUDOLESS'])
35
-
36
- desc "Install #{GEM_NAME} #{GEM_VERSION} (default ruby)"
37
- task :install => [ :package ] do
38
- sh "#{SUDO} gem install --local pkg/#{GEM_NAME}-#{GEM_VERSION} --no-update-sources", :verbose => false
39
- end
40
-
41
- desc "Uninstall #{GEM_NAME} #{GEM_VERSION} (default ruby)"
42
- task :uninstall => [ :clobber ] do
43
- sh "#{SUDO} gem uninstall #{GEM_NAME} -v#{GEM_VERSION} -I -x", :verbose => false
44
- end
45
-
46
- namespace :jruby do
47
- desc "Install #{GEM_NAME} #{GEM_VERSION} with JRuby"
48
- task :install => [ :package ] do
49
- sh %{#{SUDO} jruby -S gem install --local pkg/#{GEM_NAME}-#{GEM_VERSION} --no-update-sources}, :verbose => false
50
- end
51
- end
15
+ GEM_DEPENDENCIES = [['dm-core', "~>#{GEM_VERSION}"]]
16
+ GEM_CLEAN = %w[ log pkg coverage ]
17
+ GEM_EXTRAS = { :has_rdoc => true, :extra_rdoc_files => %w[ README.txt LICENSE TODO History.txt ] }
52
18
 
53
- desc 'Run specifications'
54
- Spec::Rake::SpecTask.new(:spec) do |t|
55
- t.spec_opts << '--options' << 'spec/spec.opts' if File.exists?('spec/spec.opts')
56
- t.spec_files = Pathname.glob((ROOT + 'spec/**/*_spec.rb').to_s)
19
+ PROJECT_NAME = 'datamapper'
20
+ PROJECT_URL = "http://github.com/sam/dm-more/tree/master/#{GEM_NAME}"
21
+ PROJECT_DESCRIPTION = PROJECT_SUMMARY = 'DataMapper plugin for performing validations on data models'
57
22
 
58
- begin
59
- t.rcov = ENV.has_key?('NO_RCOV') ? ENV['NO_RCOV'] != 'true' : true
60
- t.rcov_opts << '--exclude' << 'spec'
61
- t.rcov_opts << '--text-summary'
62
- t.rcov_opts << '--sort' << 'coverage' << '--sort-reverse'
63
- rescue Exception
64
- # rcov not installed
65
- end
23
+ [ ROOT, ROOT.parent ].each do |dir|
24
+ Pathname.glob(dir.join('tasks/**/*.rb').to_s).each { |f| require f }
66
25
  end
data/TODO CHANGED
@@ -13,4 +13,4 @@
13
13
 
14
14
  ---
15
15
  TODO tickets may also be found in the DataMapper Issue Tracker:
16
- http://wm.lighthouseapp.com/projects/4819-datamapper/overview
16
+ http://datamapper.lighthouseapp.com/
@@ -1,7 +1,7 @@
1
1
  require 'rubygems'
2
2
  require 'pathname'
3
3
 
4
- gem 'dm-core', '~>0.9.7'
4
+ gem 'dm-core', '~>0.9.8'
5
5
  require 'dm-core'
6
6
 
7
7
  dir = Pathname(__FILE__).dirname.expand_path / 'dm-validations'
@@ -9,6 +9,7 @@ module DataMapper
9
9
  )
10
10
  end
11
11
 
12
+ # RFC2822 (No attribution reference available)
12
13
  EmailAddress = begin
13
14
  alpha = "a-zA-Z"
14
15
  digit = "0-9"
@@ -1,5 +1,5 @@
1
1
  module DataMapper
2
2
  module Validations
3
- VERSION = "0.9.7"
3
+ VERSION = '0.9.8'
4
4
  end
5
5
  end
@@ -43,42 +43,45 @@ describe DataMapper::Validate::FormatValidator do
43
43
  bol.should be_valid
44
44
  end
45
45
 
46
- it 'should have a pre-defined e-mail format' do
47
- bad = [ '-- guy --@example.com', # spaces are invalid unless quoted
48
- '[guy]@example.com', # square brackets are invalid unless quoted
49
- '.guy@example.com', # local part cannot start with .
50
- 'guy@example 10:10',
51
- 'guy@ example dot com',
52
- 'guy'
53
- ]
54
-
55
- good = [
56
- '+1~1+@example.com',
57
- '{_guy_}@example.com',
58
- '"[[ guy ]]"@example.com',
59
- 'guy."guy"@example.com',
60
- 'guy@localhost',
61
- 'guy@example.com',
62
- 'guy@example.co.uk',
63
- 'guy@example.co.za',
64
- 'guy@[187.223.45.119]',
65
- 'guy@123.com'
66
- ]
67
-
68
- bol = BillOfLading.new(valid_attributes.except(:email))
69
- bol.should_not be_valid
70
- bol.errors.on(:email).should include('Email has an invalid format')
46
+ describe "RFC2822 compatible email addresses" do
47
+ before do
48
+ @bol = BillOfLading.new(valid_attributes.except(:email))
49
+
50
+ @valid_email_addresses = [
51
+ '+1~1+@example.com',
52
+ '{_dave_}@example.com',
53
+ '"[[ dave ]]"@example.com',
54
+ 'dave."dave"@example.com',
55
+ 'test@localhost',
56
+ 'test@example.com',
57
+ 'test@example.co.uk',
58
+ 'test@example.com.br',
59
+ '"J. P. \'s-Gravezande, a.k.a. The Hacker!"@example.com',
60
+ 'me@[187.223.45.119]',
61
+ 'someone@123.com',
62
+ 'simon&garfunkel@songs.com'
63
+ ]
64
+
65
+ @invalid_email_addresses = [
66
+ '-- dave --@example.com',
67
+ '[dave]@example.com',
68
+ '.dave@example.com',
69
+ 'Max@Job 3:14',
70
+ 'Job@Book of Job',
71
+ 'J. P. \'s-Gravezande, a.k.a. The Hacker!@example.com'
72
+ ]
73
+ end
71
74
 
72
- bad.map do |e|
73
- bol.email = e
74
- bol.valid?
75
- bol.errors.on(:email).should include('Email has an invalid format')
75
+ it "should match the RFC reference addresses" do
76
+ @valid_email_addresses.each do |email|
77
+ email.should =~ DataMapper::Validate::Format::Email::EmailAddress
78
+ end
76
79
  end
77
80
 
78
- good.map do |e|
79
- bol.email = e
80
- bol.valid?
81
- bol.errors.on(:email).should be_nil
81
+ it "should not be valid" do
82
+ @invalid_email_addresses.each do |email|
83
+ email.should_not =~ DataMapper::Validate::Format::Email::EmailAddress
84
+ end
82
85
  end
83
86
 
84
87
  end
data/spec/spec.opts CHANGED
@@ -1,2 +1 @@
1
- --format specdoc
2
1
  --colour
data/spec/spec_helper.rb CHANGED
@@ -1,21 +1,20 @@
1
+ require 'pathname'
1
2
  require 'rubygems'
3
+
4
+ gem 'rspec', '~>1.1.11'
2
5
  require 'spec'
3
- require 'pathname'
6
+
4
7
  require Pathname(__FILE__).dirname.expand_path.parent + 'lib/dm-validations'
5
8
 
6
9
  def load_driver(name, default_uri)
7
10
  return false if ENV['ADAPTER'] != name.to_s
8
11
 
9
- lib = "do_#{name}"
10
-
11
12
  begin
12
- gem lib, '~>0.9.7'
13
- require lib
14
13
  DataMapper.setup(name, ENV["#{name.to_s.upcase}_SPEC_URI"] || default_uri)
15
14
  DataMapper::Repository.adapters[:default] = DataMapper::Repository.adapters[name]
16
15
  true
17
- rescue Gem::LoadError => e
18
- warn "Could not load #{lib}: #{e}"
16
+ rescue LoadError => e
17
+ warn "Could not load do_#{name}: #{e}"
19
18
  false
20
19
  end
21
20
  end
data/tasks/install.rb ADDED
@@ -0,0 +1,13 @@
1
+ def sudo_gem(cmd)
2
+ sh "#{SUDO} #{RUBY} -S gem #{cmd}", :verbose => false
3
+ end
4
+
5
+ desc "Install #{GEM_NAME} #{GEM_VERSION}"
6
+ task :install => [ :package ] do
7
+ sudo_gem "install --local pkg/#{GEM_NAME}-#{GEM_VERSION} --no-update-sources"
8
+ end
9
+
10
+ desc "Uninstall #{GEM_NAME} #{GEM_VERSION}"
11
+ task :uninstall => [ :clobber ] do
12
+ sudo_gem "uninstall #{GEM_NAME} -v#{GEM_VERSION} -Ix"
13
+ end
data/tasks/spec.rb ADDED
@@ -0,0 +1,25 @@
1
+ begin
2
+ gem 'rspec', '~>1.1.11'
3
+ require 'spec'
4
+ require 'spec/rake/spectask'
5
+
6
+ task :default => [ :spec ]
7
+
8
+ desc 'Run specifications'
9
+ Spec::Rake::SpecTask.new(:spec) do |t|
10
+ t.spec_opts << '--options' << 'spec/spec.opts' if File.exists?('spec/spec.opts')
11
+ t.spec_files = Pathname.glob((ROOT + 'spec/**/*_spec.rb').to_s)
12
+
13
+ begin
14
+ gem 'rcov', '~>0.8'
15
+ t.rcov = JRUBY ? false : (ENV.has_key?('NO_RCOV') ? ENV['NO_RCOV'] != 'true' : true)
16
+ t.rcov_opts << '--exclude' << 'spec'
17
+ t.rcov_opts << '--text-summary'
18
+ t.rcov_opts << '--sort' << 'coverage' << '--sort-reverse'
19
+ rescue LoadError
20
+ # rcov not installed
21
+ end
22
+ end
23
+ rescue LoadError
24
+ # rspec not installed
25
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dm-validations
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.7
4
+ version: 0.9.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Guy van den Berg
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-11-18 00:00:00 -08:00
12
+ date: 2008-12-07 00:00:00 -08:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -18,23 +18,13 @@ dependencies:
18
18
  version_requirement:
19
19
  version_requirements: !ruby/object:Gem::Requirement
20
20
  requirements:
21
- - - "="
21
+ - - ~>
22
22
  - !ruby/object:Gem::Version
23
- version: 0.9.7
24
- version:
25
- - !ruby/object:Gem::Dependency
26
- name: hoe
27
- type: :development
28
- version_requirement:
29
- version_requirements: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - ">="
32
- - !ruby/object:Gem::Version
33
- version: 1.8.2
23
+ version: 0.9.8
34
24
  version:
35
25
  description: DataMapper plugin for performing validations on data models
36
26
  email:
37
- - vandenberg.guy@gmail.com
27
+ - vandenberg.guy [a] gmail [d] com
38
28
  executables: []
39
29
 
40
30
  extensions: []
@@ -43,6 +33,7 @@ extra_rdoc_files:
43
33
  - README.txt
44
34
  - LICENSE
45
35
  - TODO
36
+ - History.txt
46
37
  files:
47
38
  - History.txt
48
39
  - LICENSE
@@ -92,6 +83,8 @@ files:
92
83
  - spec/integration/within_validator_spec.rb
93
84
  - spec/spec.opts
94
85
  - spec/spec_helper.rb
86
+ - tasks/install.rb
87
+ - tasks/spec.rb
95
88
  has_rdoc: true
96
89
  homepage: http://github.com/sam/dm-more/tree/master/dm-validations
97
90
  post_install_message: