sbf-dm-constraints 1.3.0.beta
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +39 -0
- data/.rspec +5 -0
- data/.rubocop.yml +468 -0
- data/Gemfile +70 -0
- data/LICENSE +20 -0
- data/README.rdoc +58 -0
- data/Rakefile +4 -0
- data/dm-constraints.gemspec +21 -0
- data/lib/data_mapper/constraints/adapters/abstract_adapter.rb +33 -0
- data/lib/data_mapper/constraints/adapters/do_adapter.rb +192 -0
- data/lib/data_mapper/constraints/adapters/extension.rb +45 -0
- data/lib/data_mapper/constraints/adapters/mysql_adapter.rb +26 -0
- data/lib/data_mapper/constraints/adapters/oracle_adapter.rb +53 -0
- data/lib/data_mapper/constraints/adapters/postgres_adapter.rb +13 -0
- data/lib/data_mapper/constraints/adapters/sqlite_adapter.rb +22 -0
- data/lib/data_mapper/constraints/adapters/sqlserver_adapter.rb +11 -0
- data/lib/data_mapper/constraints/migrations/model.rb +34 -0
- data/lib/data_mapper/constraints/migrations/relationship.rb +41 -0
- data/lib/data_mapper/constraints/migrations/singleton_methods.rb +44 -0
- data/lib/data_mapper/constraints/relationship/many_to_many.rb +48 -0
- data/lib/data_mapper/constraints/relationship/one_to_many.rb +79 -0
- data/lib/data_mapper/constraints/resource.rb +30 -0
- data/lib/data_mapper/constraints/version.rb +5 -0
- data/lib/dm-constraints.rb +19 -0
- data/spec/integration/constraints_spec.rb +630 -0
- data/spec/isolated/require_after_setup_spec.rb +36 -0
- data/spec/isolated/require_before_setup_spec.rb +35 -0
- data/spec/isolated/require_spec.rb +15 -0
- data/spec/rcov.opts +6 -0
- data/spec/spec_helper.rb +26 -0
- data/tasks/spec.rake +21 -0
- data/tasks/yard.rake +9 -0
- data/tasks/yardstick.rake +19 -0
- metadata +94 -0
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'rspec'
|
2
|
+
|
3
|
+
require_relative 'require_spec'
|
4
|
+
require 'dm-core/spec/setup'
|
5
|
+
require 'dm-core/spec/lib/adapter_helpers'
|
6
|
+
|
7
|
+
# To really test this behavior, this spec needs to be run in isolation and not
|
8
|
+
# as part of the typical rake spec run, which requires dm-transactions upfront
|
9
|
+
|
10
|
+
RSpec.configure do |config|
|
11
|
+
config.extend(DataMapper::Spec::Adapters::Helpers)
|
12
|
+
end
|
13
|
+
|
14
|
+
describe "require 'dm-constraints' before calling DataMapper.setup" do
|
15
|
+
|
16
|
+
before(:all) do
|
17
|
+
require 'dm-constraints'
|
18
|
+
@adapter = DataMapper::Spec.adapter
|
19
|
+
|
20
|
+
class ::Person
|
21
|
+
include DataMapper::Resource
|
22
|
+
property :id, Serial
|
23
|
+
has n, :tasks
|
24
|
+
end
|
25
|
+
|
26
|
+
class ::Task
|
27
|
+
include DataMapper::Resource
|
28
|
+
property :id, Serial
|
29
|
+
belongs_to :person
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
|
34
|
+
it_behaves_like "require 'dm-constraints'"
|
35
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
shared_examples "require 'dm-constraints'" do
|
2
|
+
it 'extends Model descendants with the constraint API' do
|
3
|
+
expect(DataMapper::Model.descendants).not_to be_empty
|
4
|
+
DataMapper::Model.descendants.all? do |model|
|
5
|
+
expect(model.respond_to?(:auto_migrate_constraints_down, true)).to be(true)
|
6
|
+
expect(model.respond_to?(:auto_migrate_constraints_up, true)).to be(true)
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
it 'includes the constraint API into the adapter' do
|
11
|
+
expect(@adapter.respond_to?(:constraint_exists? )).to be(true)
|
12
|
+
expect(@adapter.respond_to?(:create_relationship_constraint )).to be(true)
|
13
|
+
expect(@adapter.respond_to?(:destroy_relationship_constraint)).to be(true)
|
14
|
+
end
|
15
|
+
end
|
data/spec/rcov.opts
ADDED
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
|
2
|
+
require 'dm-core/spec/setup'
|
3
|
+
require 'dm-core/spec/lib/spec_helper'
|
4
|
+
require 'dm-core/spec/lib/adapter_helpers'
|
5
|
+
require 'dm-core/spec/lib/pending_helpers'
|
6
|
+
|
7
|
+
require 'dm-constraints'
|
8
|
+
|
9
|
+
RSpec.configure do |config|
|
10
|
+
config.extend(DataMapper::Spec::Adapters::Helpers)
|
11
|
+
config.extend(DataMapper::Spec::Helpers)
|
12
|
+
config.include(DataMapper::Spec::PendingHelpers)
|
13
|
+
|
14
|
+
config.before(:each) do
|
15
|
+
DataMapper.finalize
|
16
|
+
DataMapper.auto_migrate!
|
17
|
+
end
|
18
|
+
|
19
|
+
config.after :each do
|
20
|
+
DataMapper.send(:auto_migrate_down!, DataMapper::Spec.adapter.name)
|
21
|
+
end
|
22
|
+
|
23
|
+
config.after :all do
|
24
|
+
DataMapper::Spec.cleanup_models
|
25
|
+
end
|
26
|
+
end
|
data/tasks/spec.rake
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'rspec/core/rake_task'
|
2
|
+
|
3
|
+
begin
|
4
|
+
task(:default).clear
|
5
|
+
task(:spec).clear
|
6
|
+
|
7
|
+
RSpec::Core::RakeTask.new(:spec) do |spec|
|
8
|
+
spec.pattern = 'spec/**/*_spec.rb'
|
9
|
+
|
10
|
+
require 'simplecov'
|
11
|
+
SimpleCov.start do
|
12
|
+
minimum_coverage 100
|
13
|
+
end
|
14
|
+
end
|
15
|
+
rescue LoadError
|
16
|
+
task :spec do
|
17
|
+
abort 'rspec is not available. In order to run spec, you must: gem install rspec'
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
task default: :spec
|
data/tasks/yard.rake
ADDED
@@ -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
ADDED
@@ -0,0 +1,94 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: sbf-dm-constraints
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.3.0.beta
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Dirkjan Bussink
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2024-10-04 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: sbf-dm-core
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 1.3.0.beta
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 1.3.0.beta
|
27
|
+
description: Plugin that adds foreign key constraints to associations. Currently supports
|
28
|
+
only PostgreSQL and MySQL All constraints are added to the underlying database,
|
29
|
+
but constraining is implemented in pure ruby.
|
30
|
+
email:
|
31
|
+
- d.bussink [a] gmail [d] com
|
32
|
+
executables: []
|
33
|
+
extensions: []
|
34
|
+
extra_rdoc_files:
|
35
|
+
- LICENSE
|
36
|
+
- README.rdoc
|
37
|
+
files:
|
38
|
+
- ".gitignore"
|
39
|
+
- ".rspec"
|
40
|
+
- ".rubocop.yml"
|
41
|
+
- Gemfile
|
42
|
+
- LICENSE
|
43
|
+
- README.rdoc
|
44
|
+
- Rakefile
|
45
|
+
- dm-constraints.gemspec
|
46
|
+
- lib/data_mapper/constraints/adapters/abstract_adapter.rb
|
47
|
+
- lib/data_mapper/constraints/adapters/do_adapter.rb
|
48
|
+
- lib/data_mapper/constraints/adapters/extension.rb
|
49
|
+
- lib/data_mapper/constraints/adapters/mysql_adapter.rb
|
50
|
+
- lib/data_mapper/constraints/adapters/oracle_adapter.rb
|
51
|
+
- lib/data_mapper/constraints/adapters/postgres_adapter.rb
|
52
|
+
- lib/data_mapper/constraints/adapters/sqlite_adapter.rb
|
53
|
+
- lib/data_mapper/constraints/adapters/sqlserver_adapter.rb
|
54
|
+
- lib/data_mapper/constraints/migrations/model.rb
|
55
|
+
- lib/data_mapper/constraints/migrations/relationship.rb
|
56
|
+
- lib/data_mapper/constraints/migrations/singleton_methods.rb
|
57
|
+
- lib/data_mapper/constraints/relationship/many_to_many.rb
|
58
|
+
- lib/data_mapper/constraints/relationship/one_to_many.rb
|
59
|
+
- lib/data_mapper/constraints/resource.rb
|
60
|
+
- lib/data_mapper/constraints/version.rb
|
61
|
+
- lib/dm-constraints.rb
|
62
|
+
- spec/integration/constraints_spec.rb
|
63
|
+
- spec/isolated/require_after_setup_spec.rb
|
64
|
+
- spec/isolated/require_before_setup_spec.rb
|
65
|
+
- spec/isolated/require_spec.rb
|
66
|
+
- spec/rcov.opts
|
67
|
+
- spec/spec_helper.rb
|
68
|
+
- tasks/spec.rake
|
69
|
+
- tasks/yard.rake
|
70
|
+
- tasks/yardstick.rake
|
71
|
+
homepage: https://datamapper.org
|
72
|
+
licenses:
|
73
|
+
- Nonstandard
|
74
|
+
metadata: {}
|
75
|
+
post_install_message:
|
76
|
+
rdoc_options: []
|
77
|
+
require_paths:
|
78
|
+
- lib
|
79
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - ">="
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: 2.7.8
|
84
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
85
|
+
requirements:
|
86
|
+
- - ">"
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: 1.3.1
|
89
|
+
requirements: []
|
90
|
+
rubygems_version: 3.4.10
|
91
|
+
signing_key:
|
92
|
+
specification_version: 4
|
93
|
+
summary: DataMapper plugin constraining relationships
|
94
|
+
test_files: []
|