dm-constraints 0.9.7 → 0.9.8

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt CHANGED
@@ -1 +1,5 @@
1
+ === 0.9.8 / 2008-12-07
1
2
 
3
+ * 1 bug fix:
4
+
5
+ * Only extend defined adapter classes [#610 state:resolved]
data/Manifest.txt CHANGED
@@ -12,9 +12,5 @@ lib/dm-constraints/version.rb
12
12
  spec/integration/constraints_spec.rb
13
13
  spec/spec.opts
14
14
  spec/spec_helper.rb
15
- tasks/ci.rb
16
- tasks/dm.rb
17
- tasks/doc.rb
18
- tasks/gemspec.rb
19
- tasks/hoe.rb
20
15
  tasks/install.rb
16
+ tasks/spec.rb
data/Rakefile CHANGED
@@ -1,26 +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-constraints/version'
8
10
 
9
- AUTHOR = "Dirkjan Bussink"
10
- EMAIL = "d.bussink@gmail.com"
11
- GEM_NAME = "dm-constraints"
11
+ AUTHOR = 'Dirkjan Bussink'
12
+ EMAIL = 'd.bussink [a] gmail [d] com'
13
+ GEM_NAME = 'dm-constraints'
12
14
  GEM_VERSION = DataMapper::Constraints::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 ] }
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 ] }
16
18
 
17
- PROJECT_NAME = "datamapper"
18
- PROJECT_URL = "http://github.com/sam/dm-more/tree/master/dm-constraints"
19
- PROJECT_DESCRIPTION = PROJECT_SUMMARY = "DataMapper plugin for performing validations on data models"
19
+ PROJECT_NAME = 'datamapper'
20
+ PROJECT_URL = "http://github.com/sam/dm-more/tree/master/#{GEM_NAME}"
21
+ PROJECT_DESCRIPTION = PROJECT_SUMMARY = 'DataMapper plugin constraining relationships'
20
22
 
21
- require ROOT + 'tasks/hoe'
22
- require ROOT + 'tasks/gemspec'
23
- require ROOT + 'tasks/install'
24
- require ROOT + 'tasks/dm'
25
- require ROOT + 'tasks/doc'
26
- require ROOT + 'tasks/ci'
23
+ [ ROOT, ROOT.parent ].each do |dir|
24
+ Pathname.glob(dir.join('tasks/**/*.rb').to_s).each { |f| require f }
25
+ end
data/TODO CHANGED
@@ -1,3 +0,0 @@
1
- TODO
2
- ====
3
- Everything :)
@@ -69,6 +69,7 @@ module DataMapper
69
69
  descendants.each do |model|
70
70
  if model.storage_exists?(repository_name)
71
71
  adapter = model.repository(repository_name).adapter
72
+ next unless adapter.respond_to?(:destroy_constraints_statements)
72
73
  statements = adapter.destroy_constraints_statements(repository_name, model)
73
74
  statements.each {|stmt| adapter.execute(stmt) }
74
75
  end
@@ -79,6 +80,7 @@ module DataMapper
79
80
  descendants = DataMapper::Resource.descendants.to_a if descendants.empty?
80
81
  descendants.each do |model|
81
82
  adapter = model.repository(repository_name).adapter
83
+ next unless adapter.respond_to?(:create_constraints_statements)
82
84
  statements = adapter.create_constraints_statements(repository_name, model)
83
85
  statements.each {|stmt| adapter.execute(stmt) }
84
86
  end
@@ -1,5 +1,5 @@
1
1
  module DataMapper
2
2
  module Constraints
3
- VERSION = "0.9.7"
3
+ VERSION = '0.9.8'
4
4
  end
5
5
  end
@@ -3,7 +3,7 @@ require 'rubygems'
3
3
  require 'pathname'
4
4
 
5
5
  # Add all external dependencies for the plugin here
6
- gem 'dm-core', '~>0.9.7'
6
+ gem 'dm-core', '~>0.9.8'
7
7
  require 'dm-core'
8
8
 
9
9
  # Require plugin-files
@@ -18,12 +18,12 @@ module DataMapper
18
18
  end
19
19
 
20
20
  module Adapters
21
- class MysqlAdapter
22
- include DataMapper::Constraints::MysqlAdapter::SQL
21
+ if defined?(MysqlAdapter)
22
+ MysqlAdapter.send :include, DataMapper::Constraints::MysqlAdapter::SQL
23
23
  end
24
24
 
25
- class PostgresAdapter
26
- include DataMapper::Constraints::PostgresAdapter::SQL
25
+ if defined?(PostgresAdapter)
26
+ PostgresAdapter.send :include, DataMapper::Constraints::PostgresAdapter::SQL
27
27
  end
28
28
  end
29
29
  end
@@ -1,7 +1,7 @@
1
1
  require 'pathname'
2
2
  require Pathname(__FILE__).dirname.expand_path.parent + 'spec_helper'
3
3
 
4
- [HAS_MYSQL, HAS_POSTGRES].each do |adapter|
4
+ ADAPTERS.each do |adapter|
5
5
 
6
6
  describe 'DataMapper::Constraints' do
7
7
 
@@ -57,7 +57,7 @@ require Pathname(__FILE__).dirname.expand_path.parent + 'spec_helper'
57
57
  end
58
58
 
59
59
  it "should not be able to create related objects with a failing foreign key constraint" do
60
- s = Stable.first(:order => [:id.desc])
60
+ s = Stable.create
61
61
  lambda { @c1 = Cow.create(:name => "Bea", :stable_id => s.id + 1) }.should raise_error
62
62
  end
63
63
 
data/spec/spec.opts CHANGED
@@ -1,2 +1 @@
1
- --format specdoc
2
1
  --colour
data/spec/spec_helper.rb CHANGED
@@ -1,27 +1,25 @@
1
+ require 'pathname'
1
2
  require 'rubygems'
2
- gem 'rspec', '>=1.1.3'
3
+
4
+ gem 'rspec', '~>1.1.11'
3
5
  require 'spec'
4
- require 'pathname'
5
6
 
6
- gem 'dm-core', '~>0.9.7'
7
+ gem 'dm-core', '~>0.9.8'
7
8
  require 'dm-core'
8
9
 
10
+ ADAPTERS = []
9
11
  def load_driver(name, default_uri)
10
-
11
- lib = "do_#{name}"
12
12
  begin
13
- gem lib, '~>0.9.7'
14
- require lib
15
13
  DataMapper.setup(name, ENV["#{name.to_s.upcase}_SPEC_URI"] || default_uri)
16
- DataMapper::Repository.adapters[:default] = DataMapper::Repository.adapters[name]
17
- name
18
- rescue Gem::LoadError => e
19
- warn "Could not load #{lib}: #{e}"
14
+ DataMapper::Repository.adapters[:default] = DataMapper::Repository.adapters[name]
15
+ ADAPTERS << name
16
+ rescue LoadError => e
17
+ warn "Could not load do_#{name}: #{e}"
20
18
  false
21
19
  end
22
20
  end
23
21
 
24
- HAS_POSTGRES = load_driver(:postgres, 'postgres://postgres@localhost/dm_core_test')
25
- HAS_MYSQL = load_driver(:mysql, 'mysql://localhost/dm_core_test')
22
+ load_driver(:postgres, 'postgres://postgres@localhost/dm_core_test')
23
+ load_driver(:mysql, 'mysql://localhost/dm_core_test')
26
24
 
27
25
  require Pathname(__FILE__).dirname.expand_path.parent + 'lib/dm-constraints'
data/tasks/install.rb CHANGED
@@ -1,20 +1,13 @@
1
- WIN32 = (RUBY_PLATFORM =~ /win32|mingw|bccwin|cygwin/) rescue nil
2
- SUDO = WIN32 ? '' : ('sudo' unless ENV['SUDOLESS'])
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
3
9
 
4
- desc "Install #{GEM_NAME}"
5
- if WIN32
6
- task :install => :gem do
7
- system %{gem install --no-rdoc --no-ri -l pkg/#{GEM_NAME}-#{GEM_VERSION}.gem}
8
- end
9
- namespace :dev do
10
- desc 'Install for development (for windows)'
11
- task :winstall => :gem do
12
- warn "You can now call 'rake install' instead of 'rake dev:winstall'."
13
- system %{gem install --no-rdoc --no-ri -l pkg/#{GEM_NAME}-#{GEM_VERSION}.gem}
14
- end
15
- end
16
- else
17
- task :install => :package do
18
- sh %{#{SUDO} gem install --local pkg/#{GEM_NAME}-#{GEM_VERSION}.gem}
19
- end
10
+ desc "Uninstall #{GEM_NAME} #{GEM_VERSION}"
11
+ task :uninstall => [ :clobber ] do
12
+ sudo_gem "uninstall #{GEM_NAME} -v#{GEM_VERSION} -Ix"
20
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-constraints
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
  - Dirkjan Bussink
@@ -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,21 +18,22 @@ 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
23
+ version: 0.9.8
24
24
  version:
25
- description: DataMapper plugin for performing validations on data models
25
+ description: DataMapper plugin constraining relationships
26
26
  email:
27
- - d.bussink@gmail.com
27
+ - d.bussink [a] gmail [d] com
28
28
  executables: []
29
29
 
30
30
  extensions: []
31
31
 
32
32
  extra_rdoc_files:
33
- - History.txt
34
- - Manifest.txt
35
33
  - README.txt
34
+ - LICENSE
35
+ - TODO
36
+ - History.txt
36
37
  files:
37
38
  - History.txt
38
39
  - LICENSE
@@ -48,12 +49,8 @@ files:
48
49
  - spec/integration/constraints_spec.rb
49
50
  - spec/spec.opts
50
51
  - spec/spec_helper.rb
51
- - tasks/ci.rb
52
- - tasks/dm.rb
53
- - tasks/doc.rb
54
- - tasks/gemspec.rb
55
- - tasks/hoe.rb
56
52
  - tasks/install.rb
53
+ - tasks/spec.rb
57
54
  has_rdoc: true
58
55
  homepage: http://github.com/sam/dm-more/tree/master/dm-constraints
59
56
  post_install_message:
@@ -80,6 +77,6 @@ rubyforge_project: datamapper
80
77
  rubygems_version: 1.3.1
81
78
  signing_key:
82
79
  specification_version: 2
83
- summary: DataMapper plugin for performing validations on data models
80
+ summary: DataMapper plugin constraining relationships
84
81
  test_files: []
85
82
 
data/tasks/ci.rb DELETED
@@ -1,68 +0,0 @@
1
- task 'ci:doc' => :doc
2
-
3
- namespace :ci do
4
-
5
- task :prepare do
6
- rm_rf ROOT + "ci"
7
- mkdir_p ROOT + "ci"
8
- mkdir_p ROOT + "ci/doc"
9
- mkdir_p ROOT + "ci/cyclomatic"
10
- mkdir_p ROOT + "ci/token"
11
- end
12
-
13
- Spec::Rake::SpecTask.new("spec:unit" => :prepare) do |t|
14
- t.spec_opts = ["--format", "specdoc", "--format", "html:#{ROOT}/ci/unit_rspec_report.html", "--diff"]
15
- t.spec_files = Pathname.glob((ROOT + 'spec/unit/**/*_spec.rb').to_s)
16
- unless ENV['NO_RCOV']
17
- t.rcov = true
18
- t.rcov_opts << '--exclude' << "spec,gems"
19
- t.rcov_opts << '--text-summary'
20
- t.rcov_opts << '--sort' << 'coverage' << '--sort-reverse'
21
- t.rcov_opts << '--only-uncovered'
22
- end
23
- end
24
-
25
- Spec::Rake::SpecTask.new("spec:integration" => :prepare) do |t|
26
- t.spec_opts = ["--format", "specdoc", "--format", "html:#{ROOT}/ci/integration_rspec_report.html", "--diff"]
27
- t.spec_files = Pathname.glob((ROOT + 'spec/integration/**/*_spec.rb').to_s)
28
- unless ENV['NO_RCOV']
29
- t.rcov = true
30
- t.rcov_opts << '--exclude' << "spec,gems"
31
- t.rcov_opts << '--text-summary'
32
- t.rcov_opts << '--sort' << 'coverage' << '--sort-reverse'
33
- t.rcov_opts << '--only-uncovered'
34
- end
35
- end
36
-
37
- task :spec do
38
- Rake::Task["ci:spec:unit"].invoke
39
- mv ROOT + "coverage", ROOT + "ci/unit_coverage"
40
-
41
- Rake::Task["ci:spec:integration"].invoke
42
- mv ROOT + "coverage", ROOT + "ci/integration_coverage"
43
- end
44
-
45
- task :saikuro => :prepare do
46
- system "saikuro -c -i lib -y 0 -w 10 -e 15 -o ci/cyclomatic"
47
- mv 'ci/cyclomatic/index_cyclo.html', 'ci/cyclomatic/index.html'
48
-
49
- system "saikuro -t -i lib -y 0 -w 20 -e 30 -o ci/token"
50
- mv 'ci/token/index_token.html', 'ci/token/index.html'
51
- end
52
-
53
- task :publish do
54
- out = ENV['CC_BUILD_ARTIFACTS'] || "out"
55
- mkdir_p out unless File.directory? out
56
-
57
- mv "ci/unit_rspec_report.html", "#{out}/unit_rspec_report.html"
58
- mv "ci/unit_coverage", "#{out}/unit_coverage"
59
- mv "ci/integration_rspec_report.html", "#{out}/integration_rspec_report.html"
60
- mv "ci/integration_coverage", "#{out}/integration_coverage"
61
- mv "ci/doc", "#{out}/doc"
62
- mv "ci/cyclomatic", "#{out}/cyclomatic_complexity"
63
- mv "ci/token", "#{out}/token_complexity"
64
- end
65
- end
66
-
67
- #task :ci => %w[ ci:spec ci:doc ci:saikuro install ci:publish ] # yard-related tasks do not work yet
68
- task :ci => %w[ ci:spec ci:saikuro install ]
data/tasks/dm.rb DELETED
@@ -1,63 +0,0 @@
1
- task :default => 'dm:spec'
2
- task :spec => 'dm:spec'
3
- task :rcov => 'dm:rcov'
4
-
5
- namespace :spec do
6
- task :unit => 'dm:spec:unit'
7
- task :integration => 'dm:spec:integration'
8
- end
9
-
10
- namespace :rcov do
11
- task :unit => 'dm:rcov:unit'
12
- task :integration => 'dm:rcov:integration'
13
- end
14
-
15
- namespace :dm do
16
- def run_spec(name, files, rcov)
17
- Spec::Rake::SpecTask.new(name) do |t|
18
- t.spec_opts << '--colour' << '--loadby' << 'random'
19
- t.spec_files = Pathname.glob(ENV['FILES'] || files.to_s)
20
- t.rcov = rcov
21
- t.rcov_opts << '--exclude' << 'spec,environment.rb'
22
- t.rcov_opts << '--text-summary'
23
- t.rcov_opts << '--sort' << 'coverage' << '--sort-reverse'
24
- t.rcov_opts << '--only-uncovered'
25
- end
26
- end
27
-
28
- unit_specs = ROOT + 'spec/unit/**/*_spec.rb'
29
- integration_specs = ROOT + 'spec/integration/**/*_spec.rb'
30
- all_specs = ROOT + 'spec/**/*_spec.rb'
31
-
32
- desc "Run all specifications"
33
- run_spec('spec', all_specs, false)
34
-
35
- desc "Run all specifications with rcov"
36
- run_spec('rcov', all_specs, true)
37
-
38
- namespace :spec do
39
- desc "Run unit specifications"
40
- run_spec('unit', unit_specs, false)
41
-
42
- desc "Run integration specifications"
43
- run_spec('integration', integration_specs, false)
44
- end
45
-
46
- namespace :rcov do
47
- desc "Run unit specifications with rcov"
48
- run_spec('unit', unit_specs, true)
49
-
50
- desc "Run integration specifications with rcov"
51
- run_spec('integration', integration_specs, true)
52
- end
53
-
54
- desc "Run all comparisons with ActiveRecord"
55
- task :perf do
56
- sh ROOT + 'script/performance.rb'
57
- end
58
-
59
- desc "Profile DataMapper"
60
- task :profile do
61
- sh ROOT + 'script/profile.rb'
62
- end
63
- end
data/tasks/doc.rb DELETED
@@ -1,20 +0,0 @@
1
- # when yard's ready, it'll have to come back, but for now...
2
- Rake::RDocTask.new("doc") do |t|
3
- t.rdoc_dir = 'doc'
4
- t.title = "DataMapper - Ruby Object Relational Mapper"
5
- t.options = ['--line-numbers', '--inline-source', '--all']
6
- t.rdoc_files.include("README.txt", "QUICKLINKS", "FAQ", "lib/**/**/*.rb")
7
- end
8
-
9
- begin
10
- gem 'yard', '>=0.2.1'
11
- require 'yard'
12
-
13
- YARD::Rake::YardocTask.new("yardoc") do |t|
14
- t.options << '--protected'
15
- # t.options << '-q'
16
- # t.files << '...anyglobshere...'
17
- end
18
- rescue Exception
19
- # yard not installed
20
- end
data/tasks/gemspec.rb DELETED
@@ -1,23 +0,0 @@
1
- desc "Generate gemspec"
2
- task :gemspec do |x|
3
- # Clean up extraneous files before checking manifest
4
- %x[rake clean]
5
-
6
- # Check the manifest before generating the gemspec
7
- manifest = %x[rake check_manifest]
8
- manifest.gsub!("(in /usr/local/projects/dm/dm-core)\n", "")
9
-
10
- unless manifest.empty?
11
- print "\n", "#"*68, "\n"
12
- print <<-EOS
13
- Manifest.txt is not up-to-date. Please review the changes below.
14
- If the changes are correct, run 'rake check_manifest | patch'
15
- and then run this command again.
16
- EOS
17
- print "#"*68, "\n\n"
18
- puts manifest
19
- else
20
- %x[rake debug_gem > #{GEM_NAME}.gemspec]
21
- puts "Successfully created gemspec for #{GEM_NAME}!"
22
- end
23
- end
data/tasks/hoe.rb DELETED
@@ -1,46 +0,0 @@
1
- require 'hoe'
2
-
3
- @config_file = "~/.rubyforge/user-config.yml"
4
- @config = nil
5
- RUBYFORGE_USERNAME = "unknown"
6
- def rubyforge_username
7
- unless @config
8
- begin
9
- @config = YAML.load(File.read(File.expand_path(@config_file)))
10
- rescue
11
- puts <<-EOS
12
- ERROR: No rubyforge config file found: #{@config_file}
13
- Run 'rubyforge setup' to prepare your env for access to Rubyforge
14
- - See http://newgem.rubyforge.org/rubyforge.html for more details
15
- EOS
16
- exit
17
- end
18
- end
19
- RUBYFORGE_USERNAME.replace @config["username"]
20
- end
21
-
22
- # Remove hoe dependency
23
- class Hoe
24
- def extra_dev_deps
25
- @extra_dev_deps.reject! { |dep| dep[0] == "hoe" }
26
- @extra_dev_deps
27
- end
28
- end
29
-
30
- hoe = Hoe.new(GEM_NAME, GEM_VERSION) do |p|
31
-
32
- p.developer(AUTHOR, EMAIL)
33
-
34
- p.description = PROJECT_DESCRIPTION
35
- p.summary = PROJECT_SUMMARY
36
- p.url = PROJECT_URL
37
-
38
- p.rubyforge_name = PROJECT_NAME if PROJECT_NAME
39
-
40
- p.clean_globs |= ["{coverage,doc,log,tmp}", "**/*.{log,db}", "profile_results.*", "**/.DS_Store"]
41
-
42
- GEM_DEPENDENCIES.each do |dep|
43
- p.extra_deps << dep
44
- end
45
-
46
- end