dm-constraints 0.10.1 → 0.10.2

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) 2008 Dirkjan Bussink
1
+ Copyright (c) 2009 Dirkjan Bussink
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.rdoc CHANGED
@@ -42,10 +42,14 @@ end
42
42
  class Articles
43
43
  has n, :tags, :through => Resource, :constraint => :destroy
44
44
  end
45
+
45
46
  class Tags
46
47
  has n, :articles, :through => Resource, :constraint => :destroy
47
48
  end
48
49
 
50
+ # Intermediary constraints for relationships using :through => Resource
51
+ # are automatically inherited from the M:M relationship.
52
+
49
53
  # 1:1 Example
50
54
  class Farmer
51
55
  has 1, :beloved_sheep, :constraint => :protect
data/Rakefile CHANGED
@@ -1,24 +1,29 @@
1
- require 'pathname'
1
+ require 'rubygems'
2
+ require 'rake'
2
3
 
3
- ROOT = Pathname(__FILE__).dirname.expand_path
4
- JRUBY = RUBY_PLATFORM =~ /java/
5
- WINDOWS = Gem.win_platform?
6
- SUDO = (WINDOWS || JRUBY) ? '' : ('sudo' unless ENV['SUDOLESS'])
4
+ begin
5
+ gem 'jeweler', '~> 1.4'
6
+ require 'jeweler'
7
7
 
8
- require ROOT + 'lib/dm-constraints/version'
8
+ Jeweler::Tasks.new do |gem|
9
+ gem.name = 'dm-constraints'
10
+ gem.summary = 'DataMapper plugin constraining relationships'
11
+ gem.description = gem.summary
12
+ gem.email = 'd.bussink [a] gmail [d] com'
13
+ gem.homepage = 'http://github.com/datamapper/dm-more/tree/master/%s' % gem.name
14
+ gem.authors = [ 'Dirkjan Bussink' ]
9
15
 
10
- AUTHOR = 'Dirkjan Bussink'
11
- EMAIL = 'd.bussink [a] gmail [d] com'
12
- GEM_NAME = 'dm-constraints'
13
- GEM_VERSION = DataMapper::Constraints::VERSION
14
- GEM_DEPENDENCIES = [['dm-core', GEM_VERSION]]
15
- GEM_CLEAN = %w[ log pkg coverage ]
16
- GEM_EXTRAS = { :has_rdoc => true, :extra_rdoc_files => %w[ README.rdoc LICENSE TODO History.rdoc ] }
16
+ gem.rubyforge_project = 'datamapper'
17
17
 
18
- PROJECT_NAME = 'datamapper'
19
- PROJECT_URL = "http://github.com/datamapper/dm-more/tree/master/#{GEM_NAME}"
20
- PROJECT_DESCRIPTION = PROJECT_SUMMARY = 'DataMapper plugin constraining relationships'
18
+ gem.add_dependency 'dm-core', '~> 0.10.2'
21
19
 
22
- [ ROOT, ROOT.parent ].each do |dir|
23
- Pathname.glob(dir.join('tasks/**/*.rb').to_s).each { |f| require f }
20
+ gem.add_development_dependency 'rspec', '~> 1.2.9'
21
+ gem.add_development_dependency 'yard', '~> 0.4.0'
22
+ end
23
+
24
+ Jeweler::GemcutterTasks.new
25
+
26
+ FileList['tasks/**/*.rake'].each { |task| import task }
27
+ rescue LoadError
28
+ puts 'Jeweler (or a dependency) not available. Install it with: gem install jeweler'
24
29
  end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.10.2
@@ -0,0 +1,64 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{dm-constraints}
8
+ s.version = "0.10.2"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Dirkjan Bussink"]
12
+ s.date = %q{2009-12-11}
13
+ s.description = %q{DataMapper plugin constraining relationships}
14
+ s.email = %q{d.bussink [a] gmail [d] com}
15
+ s.extra_rdoc_files = [
16
+ "LICENSE",
17
+ "README.rdoc"
18
+ ]
19
+ s.files = [
20
+ "LICENSE",
21
+ "README.rdoc",
22
+ "Rakefile",
23
+ "VERSION",
24
+ "dm-constraints.gemspec",
25
+ "lib/dm-constraints.rb",
26
+ "lib/dm-constraints/delete_constraint.rb",
27
+ "lib/dm-constraints/migrations.rb",
28
+ "spec/integration/constraints_spec.rb",
29
+ "spec/rcov.opts",
30
+ "spec/spec.opts",
31
+ "spec/spec_helper.rb",
32
+ "tasks/ci.rake",
33
+ "tasks/metrics.rake",
34
+ "tasks/spec.rake",
35
+ "tasks/yard.rake",
36
+ "tasks/yardstick.rake"
37
+ ]
38
+ s.homepage = %q{http://github.com/datamapper/dm-more/tree/master/dm-constraints}
39
+ s.rdoc_options = ["--charset=UTF-8"]
40
+ s.require_paths = ["lib"]
41
+ s.rubyforge_project = %q{datamapper}
42
+ s.rubygems_version = %q{1.3.5}
43
+ s.summary = %q{DataMapper plugin constraining relationships}
44
+
45
+ if s.respond_to? :specification_version then
46
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
47
+ s.specification_version = 3
48
+
49
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
50
+ s.add_runtime_dependency(%q<dm-core>, ["~> 0.10.2"])
51
+ s.add_development_dependency(%q<rspec>, ["~> 1.2.9"])
52
+ s.add_development_dependency(%q<yard>, ["~> 0.4.0"])
53
+ else
54
+ s.add_dependency(%q<dm-core>, ["~> 0.10.2"])
55
+ s.add_dependency(%q<rspec>, ["~> 1.2.9"])
56
+ s.add_dependency(%q<yard>, ["~> 0.4.0"])
57
+ end
58
+ else
59
+ s.add_dependency(%q<dm-core>, ["~> 0.10.2"])
60
+ s.add_dependency(%q<rspec>, ["~> 1.2.9"])
61
+ s.add_dependency(%q<yard>, ["~> 0.4.0"])
62
+ end
63
+ end
64
+
@@ -100,7 +100,7 @@ module DataMapper
100
100
  when :protect
101
101
  Array(association).empty?
102
102
  when :destroy, :destroy!
103
- association.send(constraint)
103
+ association.__send__(constraint)
104
104
  when :set_nil
105
105
  Array(association).all? do |resource|
106
106
  resource.update(relationship.inverse => nil)
@@ -46,7 +46,7 @@ module DataMapper
46
46
  AND "constraint_name" = ?
47
47
  SQL
48
48
 
49
- query(statement, schema_name, storage_name, constraint_name).first > 0
49
+ select(statement, schema_name, storage_name, constraint_name).first > 0
50
50
  end
51
51
 
52
52
  ##
@@ -1,6 +1,5 @@
1
1
  require 'dm-constraints/delete_constraint'
2
2
  require 'dm-constraints/migrations'
3
- require 'dm-constraints/version'
4
3
 
5
4
  module DataMapper
6
5
  module Associations
@@ -57,6 +56,8 @@ module DataMapper
57
56
  end
58
57
  RUBY
59
58
  end
59
+
60
+ Model.append_inclusions self
60
61
  end
61
62
 
62
63
  module Migrations
@@ -8,10 +8,9 @@ ADAPTERS.each do |name, connection_uri|
8
8
 
9
9
  class ::Article
10
10
  include DataMapper::Resource
11
- include DataMapper::Constraints
12
11
 
13
12
  property :id, Serial
14
- property :title, String, :nullable => false
13
+ property :title, String, :required => true
15
14
  property :content, Text
16
15
 
17
16
  has 1, :revision
@@ -21,7 +20,6 @@ ADAPTERS.each do |name, connection_uri|
21
20
 
22
21
  class ::Author
23
22
  include DataMapper::Resource
24
- include DataMapper::Constraints
25
23
 
26
24
  property :first_name, String, :key => true
27
25
  property :last_name, String, :key => true
@@ -32,7 +30,6 @@ ADAPTERS.each do |name, connection_uri|
32
30
 
33
31
  class ::Comment
34
32
  include DataMapper::Resource
35
- include DataMapper::Constraints
36
33
 
37
34
  property :id, Serial
38
35
  property :body, Text
@@ -45,7 +42,6 @@ ADAPTERS.each do |name, connection_uri|
45
42
  # on the other end
46
43
  class ::Revision
47
44
  include DataMapper::Resource
48
- include DataMapper::Constraints
49
45
 
50
46
  property :id, Serial
51
47
  property :text, String
@@ -57,12 +53,12 @@ ADAPTERS.each do |name, connection_uri|
57
53
  describe 'create related objects' do
58
54
  before :all do
59
55
  class ::Comment
60
- belongs_to :article, :nullable => true
61
- belongs_to :author, :nullable => true
56
+ belongs_to :article, :required => false
57
+ belongs_to :author, :required => false
62
58
  end
63
59
 
64
60
  class ::Revision
65
- belongs_to :article, :nullable => true
61
+ belongs_to :article, :required => false
66
62
  end
67
63
  end
68
64
 
@@ -410,12 +406,12 @@ ADAPTERS.each do |name, connection_uri|
410
406
  end
411
407
 
412
408
  class ::Comment
413
- belongs_to :article, :nullable => true
414
- belongs_to :author, :nullable => true
409
+ belongs_to :article, :required => false
410
+ belongs_to :author, :required => false
415
411
  end
416
412
 
417
413
  class ::Revision
418
- belongs_to :article, :nullable => true
414
+ belongs_to :article, :required => false
419
415
  end
420
416
  end
421
417
 
@@ -559,7 +555,7 @@ ADAPTERS.each do |name, connection_uri|
559
555
  # M:M relationships results in a join table composed of composite (composed of two parts)
560
556
  # primary key.
561
557
  # Setting a portion of this primary key is not possible for two reasons:
562
- # 1. the columns are defined as :nullable => false
558
+ # 1. the columns are defined as :required => true
563
559
  # 2. there could be duplicate rows if more than one of either of the types
564
560
  # was deleted while being associated to the same type on the other side of the relationshp
565
561
  # Given
data/spec/rcov.opts ADDED
@@ -0,0 +1,6 @@
1
+ --exclude "spec"
2
+ --sort coverage
3
+ --callsites
4
+ --xrefs
5
+ --profile
6
+ --text-summary
data/spec/spec.opts CHANGED
@@ -1,2 +1,4 @@
1
1
  --colour
2
2
  --loadby random
3
+ --format profile
4
+ --backtrace
data/spec/spec_helper.rb CHANGED
@@ -18,7 +18,7 @@ def load_driver(name, default_uri)
18
18
 
19
19
  # test the connection if possible
20
20
  if adapter.respond_to?(:query)
21
- adapter.query('SELECT 1')
21
+ adapter.select('SELECT 1')
22
22
  end
23
23
 
24
24
  ADAPTERS[name] = connection_string
data/tasks/ci.rake ADDED
@@ -0,0 +1 @@
1
+ task :ci => [ :verify_measurements, 'metrics:all' ]
@@ -0,0 +1,36 @@
1
+ begin
2
+ require 'metric_fu'
3
+ rescue LoadError
4
+ namespace :metrics do
5
+ task :all do
6
+ abort 'metric_fu is not available. In order to run metrics:all, you must: gem install metric_fu'
7
+ end
8
+ end
9
+ end
10
+
11
+ begin
12
+ require 'reek/adapters/rake_task'
13
+
14
+ Reek::RakeTask.new do |t|
15
+ t.fail_on_error = true
16
+ t.verbose = false
17
+ t.source_files = 'lib/**/*.rb'
18
+ end
19
+ rescue LoadError
20
+ task :reek do
21
+ abort 'Reek is not available. In order to run reek, you must: gem install reek'
22
+ end
23
+ end
24
+
25
+ begin
26
+ require 'roodi'
27
+ require 'roodi_task'
28
+
29
+ RoodiTask.new do |t|
30
+ t.verbose = false
31
+ end
32
+ rescue LoadError
33
+ task :roodi do
34
+ abort 'Roodi is not available. In order to run roodi, you must: gem install roodi'
35
+ end
36
+ end
data/tasks/spec.rake ADDED
@@ -0,0 +1,41 @@
1
+ spec_defaults = lambda do |spec|
2
+ spec.pattern = 'spec/**/*_spec.rb'
3
+ spec.libs << 'lib' << 'spec'
4
+ spec.spec_opts << '--options' << 'spec/spec.opts'
5
+ end
6
+
7
+ begin
8
+ require 'spec/rake/spectask'
9
+
10
+ Spec::Rake::SpecTask.new(:spec, &spec_defaults)
11
+ rescue LoadError
12
+ task :spec do
13
+ abort 'rspec is not available. In order to run spec, you must: gem install rspec'
14
+ end
15
+ end
16
+
17
+ begin
18
+ require 'rcov'
19
+ require 'spec/rake/verify_rcov'
20
+
21
+ Spec::Rake::SpecTask.new(:rcov) do |rcov|
22
+ spec_defaults.call(rcov)
23
+ rcov.rcov = true
24
+ rcov.rcov_opts = File.read('spec/rcov.opts').split(/\s+/)
25
+ end
26
+
27
+ RCov::VerifyTask.new(:verify_rcov => :rcov) do |rcov|
28
+ rcov.threshold = 100
29
+ end
30
+ rescue LoadError
31
+ %w[ rcov verify_rcov ].each do |name|
32
+ task name do
33
+ abort "rcov is not available. In order to run #{name}, you must: gem install rcov"
34
+ end
35
+ end
36
+ end
37
+
38
+ task :spec => :check_dependencies
39
+ task :rcov => :check_dependencies
40
+
41
+ task :default => :spec
data/tasks/yard.rake ADDED
@@ -0,0 +1,9 @@
1
+ begin
2
+ require 'yard'
3
+
4
+ YARD::Rake::YardocTask.new
5
+ rescue LoadError
6
+ task :yard do
7
+ abort 'YARD is not available. In order to run yard, you must: gem install yard'
8
+ end
9
+ end
@@ -0,0 +1,19 @@
1
+ begin
2
+ require 'pathname'
3
+ require 'yardstick/rake/measurement'
4
+ require 'yardstick/rake/verify'
5
+
6
+ # yardstick_measure task
7
+ Yardstick::Rake::Measurement.new
8
+
9
+ # verify_measurements task
10
+ Yardstick::Rake::Verify.new do |verify|
11
+ verify.threshold = 100
12
+ end
13
+ rescue LoadError
14
+ %w[ yardstick_measure verify_measurements ].each do |name|
15
+ task name.to_s do
16
+ abort "Yardstick is not available. In order to run #{name}, you must: gem install yardstick"
17
+ end
18
+ end
19
+ 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.10.1
4
+ version: 0.10.2
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: 2009-09-30 00:00:00 -07:00
12
+ date: 2009-12-11 00:00:00 -08:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -18,46 +18,64 @@ 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.10.1
23
+ version: 0.10.2
24
+ version:
25
+ - !ruby/object:Gem::Dependency
26
+ name: rspec
27
+ type: :development
28
+ version_requirement:
29
+ version_requirements: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: 1.2.9
34
+ version:
35
+ - !ruby/object:Gem::Dependency
36
+ name: yard
37
+ type: :development
38
+ version_requirement:
39
+ version_requirements: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - ~>
42
+ - !ruby/object:Gem::Version
43
+ version: 0.4.0
24
44
  version:
25
45
  description: DataMapper plugin constraining relationships
26
- email:
27
- - d.bussink [a] gmail [d] com
46
+ email: d.bussink [a] gmail [d] com
28
47
  executables: []
29
48
 
30
49
  extensions: []
31
50
 
32
51
  extra_rdoc_files:
33
- - README.rdoc
34
52
  - LICENSE
35
- - TODO
36
- - History.rdoc
53
+ - README.rdoc
37
54
  files:
38
- - History.rdoc
39
55
  - LICENSE
40
- - Manifest.txt
41
56
  - README.rdoc
42
57
  - Rakefile
43
- - TODO
58
+ - VERSION
59
+ - dm-constraints.gemspec
44
60
  - lib/dm-constraints.rb
45
61
  - lib/dm-constraints/delete_constraint.rb
46
62
  - lib/dm-constraints/migrations.rb
47
- - lib/dm-constraints/version.rb
48
63
  - spec/integration/constraints_spec.rb
64
+ - spec/rcov.opts
49
65
  - spec/spec.opts
50
66
  - spec/spec_helper.rb
51
- - tasks/install.rb
52
- - tasks/spec.rb
67
+ - tasks/ci.rake
68
+ - tasks/metrics.rake
69
+ - tasks/spec.rake
70
+ - tasks/yard.rake
71
+ - tasks/yardstick.rake
53
72
  has_rdoc: true
54
73
  homepage: http://github.com/datamapper/dm-more/tree/master/dm-constraints
55
74
  licenses: []
56
75
 
57
76
  post_install_message:
58
77
  rdoc_options:
59
- - --main
60
- - README.rdoc
78
+ - --charset=UTF-8
61
79
  require_paths:
62
80
  - lib
63
81
  required_ruby_version: !ruby/object:Gem::Requirement
data/History.rdoc DELETED
@@ -1,31 +0,0 @@
1
- === 0.10.1 / 2009-09-30
2
-
3
- * No changes this version
4
-
5
- === 0.10.0 / 2009-09-15
6
-
7
- * Updated to work with dm-core 0.10.0
8
-
9
- === 0.9.11 / 2009-03-29
10
-
11
- * Added :destroy! constraints
12
- * Added support for 1:1 constraints
13
- * Added support for M:M constraints
14
- * Add'l rspecs
15
- * Updated readme.txt
16
-
17
- === 0.9.10 / 2009-01-19
18
-
19
- * 1 major enhancement:
20
-
21
- * Add :protect, :destroy, :set_nil and :skip constraints
22
-
23
- === 0.9.9 / 2009-01-04
24
-
25
- * No changes this version
26
-
27
- === 0.9.8 / 2008-12-07
28
-
29
- * 1 bug fix:
30
-
31
- * Only extend defined adapter classes [#610 state:resolved]
data/Manifest.txt DELETED
@@ -1,15 +0,0 @@
1
- History.rdoc
2
- LICENSE
3
- Manifest.txt
4
- README.rdoc
5
- Rakefile
6
- TODO
7
- lib/dm-constraints.rb
8
- lib/dm-constraints/delete_constraint.rb
9
- lib/dm-constraints/migrations.rb
10
- lib/dm-constraints/version.rb
11
- spec/integration/constraints_spec.rb
12
- spec/spec.opts
13
- spec/spec_helper.rb
14
- tasks/install.rb
15
- tasks/spec.rb
data/TODO DELETED
File without changes
@@ -1,5 +0,0 @@
1
- module DataMapper
2
- module Constraints
3
- VERSION = '0.10.1'.freeze
4
- end
5
- end
data/tasks/install.rb DELETED
@@ -1,13 +0,0 @@
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 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 DELETED
@@ -1,25 +0,0 @@
1
- begin
2
- require 'spec/rake/spectask'
3
-
4
- task :default => [ :spec ]
5
-
6
- desc 'Run specifications'
7
- Spec::Rake::SpecTask.new(:spec) do |t|
8
- t.spec_opts << '--options' << 'spec/spec.opts' if File.exists?('spec/spec.opts')
9
- t.libs << 'lib' << 'spec' # needed for CI rake spec task, duplicated in spec_helper
10
-
11
- begin
12
- require 'rcov'
13
- t.rcov = JRUBY ? false : (ENV.has_key?('NO_RCOV') ? ENV['NO_RCOV'] != 'true' : true)
14
- t.rcov_opts << '--exclude' << 'spec'
15
- t.rcov_opts << '--text-summary'
16
- t.rcov_opts << '--sort' << 'coverage' << '--sort-reverse'
17
- rescue LoadError
18
- # rcov not installed
19
- rescue SyntaxError
20
- # rcov syntax invalid
21
- end
22
- end
23
- rescue LoadError
24
- # rspec not installed
25
- end