database_cleaner 1.8.2 → 2.0.0.beta

Sign up to get free protection for your applications and to get access to all the features.
Files changed (91) hide show
  1. checksums.yaml +4 -4
  2. data/lib/database_cleaner.rb +1 -47
  3. metadata +14 -481
  4. data/CONTRIBUTE.markdown +0 -27
  5. data/Gemfile.lock +0 -325
  6. data/History.rdoc +0 -482
  7. data/LICENSE +0 -20
  8. data/README.markdown +0 -389
  9. data/Rakefile +0 -44
  10. data/TODO +0 -3
  11. data/adapters/database_cleaner-active_record/lib/database_cleaner-active_record.rb +0 -1
  12. data/adapters/database_cleaner-active_record/lib/database_cleaner/active_record.rb +0 -6
  13. data/adapters/database_cleaner-active_record/lib/database_cleaner/active_record/base.rb +0 -101
  14. data/adapters/database_cleaner-active_record/lib/database_cleaner/active_record/deletion.rb +0 -108
  15. data/adapters/database_cleaner-active_record/lib/database_cleaner/active_record/transaction.rb +0 -59
  16. data/adapters/database_cleaner-active_record/lib/database_cleaner/active_record/truncation.rb +0 -280
  17. data/adapters/database_cleaner-active_record/lib/database_cleaner/active_record/version.rb +0 -5
  18. data/adapters/database_cleaner-couch_potato/lib/database_cleaner-couch_potato.rb +0 -1
  19. data/adapters/database_cleaner-couch_potato/lib/database_cleaner/couch_potato.rb +0 -11
  20. data/adapters/database_cleaner-couch_potato/lib/database_cleaner/couch_potato/base.rb +0 -7
  21. data/adapters/database_cleaner-couch_potato/lib/database_cleaner/couch_potato/truncation.rb +0 -28
  22. data/adapters/database_cleaner-couch_potato/lib/database_cleaner/couch_potato/version.rb +0 -5
  23. data/adapters/database_cleaner-data_mapper/lib/database_cleaner-data_mapper.rb +0 -1
  24. data/adapters/database_cleaner-data_mapper/lib/database_cleaner/data_mapper.rb +0 -4
  25. data/adapters/database_cleaner-data_mapper/lib/database_cleaner/data_mapper/base.rb +0 -25
  26. data/adapters/database_cleaner-data_mapper/lib/database_cleaner/data_mapper/transaction.rb +0 -28
  27. data/adapters/database_cleaner-data_mapper/lib/database_cleaner/data_mapper/truncation.rb +0 -173
  28. data/adapters/database_cleaner-data_mapper/lib/database_cleaner/data_mapper/version.rb +0 -5
  29. data/adapters/database_cleaner-mongo/lib/database_cleaner-mongo.rb +0 -1
  30. data/adapters/database_cleaner-mongo/lib/database_cleaner/mongo.rb +0 -10
  31. data/adapters/database_cleaner-mongo/lib/database_cleaner/mongo/base.rb +0 -16
  32. data/adapters/database_cleaner-mongo/lib/database_cleaner/mongo/truncation.rb +0 -62
  33. data/adapters/database_cleaner-mongo/lib/database_cleaner/mongo/truncation_mixin.rb +0 -26
  34. data/adapters/database_cleaner-mongo/lib/database_cleaner/mongo/version.rb +0 -5
  35. data/adapters/database_cleaner-mongo_mapper/lib/database_cleaner-mongo_mapper.rb +0 -1
  36. data/adapters/database_cleaner-mongo_mapper/lib/database_cleaner/mongo_mapper.rb +0 -4
  37. data/adapters/database_cleaner-mongo_mapper/lib/database_cleaner/mongo_mapper/base.rb +0 -24
  38. data/adapters/database_cleaner-mongo_mapper/lib/database_cleaner/mongo_mapper/truncation.rb +0 -35
  39. data/adapters/database_cleaner-mongo_mapper/lib/database_cleaner/mongo_mapper/version.rb +0 -5
  40. data/adapters/database_cleaner-mongoid/lib/database_cleaner-mongoid.rb +0 -1
  41. data/adapters/database_cleaner-mongoid/lib/database_cleaner/mongoid.rb +0 -10
  42. data/adapters/database_cleaner-mongoid/lib/database_cleaner/mongoid/base.rb +0 -20
  43. data/adapters/database_cleaner-mongoid/lib/database_cleaner/mongoid/mongo1_truncation_mixin.rb +0 -26
  44. data/adapters/database_cleaner-mongoid/lib/database_cleaner/mongoid/mongo2_truncation_mixin.rb +0 -38
  45. data/adapters/database_cleaner-mongoid/lib/database_cleaner/mongoid/mongoid_truncation_mixin.rb +0 -65
  46. data/adapters/database_cleaner-mongoid/lib/database_cleaner/mongoid/truncation.rb +0 -49
  47. data/adapters/database_cleaner-mongoid/lib/database_cleaner/mongoid/version.rb +0 -5
  48. data/adapters/database_cleaner-moped/lib/database_cleaner-moped.rb +0 -1
  49. data/adapters/database_cleaner-moped/lib/database_cleaner/moped.rb +0 -10
  50. data/adapters/database_cleaner-moped/lib/database_cleaner/moped/base.rb +0 -39
  51. data/adapters/database_cleaner-moped/lib/database_cleaner/moped/truncation.rb +0 -9
  52. data/adapters/database_cleaner-moped/lib/database_cleaner/moped/truncation_base.rb +0 -44
  53. data/adapters/database_cleaner-moped/lib/database_cleaner/moped/version.rb +0 -5
  54. data/adapters/database_cleaner-neo4j/lib/database_cleaner-neo4j.rb +0 -1
  55. data/adapters/database_cleaner-neo4j/lib/database_cleaner/neo4j.rb +0 -6
  56. data/adapters/database_cleaner-neo4j/lib/database_cleaner/neo4j/base.rb +0 -66
  57. data/adapters/database_cleaner-neo4j/lib/database_cleaner/neo4j/deletion.rb +0 -16
  58. data/adapters/database_cleaner-neo4j/lib/database_cleaner/neo4j/transaction.rb +0 -35
  59. data/adapters/database_cleaner-neo4j/lib/database_cleaner/neo4j/truncation.rb +0 -9
  60. data/adapters/database_cleaner-neo4j/lib/database_cleaner/neo4j/version.rb +0 -5
  61. data/adapters/database_cleaner-ohm/lib/database_cleaner-ohm.rb +0 -1
  62. data/adapters/database_cleaner-ohm/lib/database_cleaner/ohm.rb +0 -12
  63. data/adapters/database_cleaner-ohm/lib/database_cleaner/ohm/truncation.rb +0 -24
  64. data/adapters/database_cleaner-ohm/lib/database_cleaner/ohm/version.rb +0 -5
  65. data/adapters/database_cleaner-redis/lib/database_cleaner-redis.rb +0 -1
  66. data/adapters/database_cleaner-redis/lib/database_cleaner/redis.rb +0 -4
  67. data/adapters/database_cleaner-redis/lib/database_cleaner/redis/base.rb +0 -41
  68. data/adapters/database_cleaner-redis/lib/database_cleaner/redis/truncation.rb +0 -26
  69. data/adapters/database_cleaner-redis/lib/database_cleaner/redis/version.rb +0 -5
  70. data/adapters/database_cleaner-sequel/lib/database_cleaner-sequel.rb +0 -1
  71. data/adapters/database_cleaner-sequel/lib/database_cleaner/sequel.rb +0 -6
  72. data/adapters/database_cleaner-sequel/lib/database_cleaner/sequel/base.rb +0 -26
  73. data/adapters/database_cleaner-sequel/lib/database_cleaner/sequel/deletion.rb +0 -47
  74. data/adapters/database_cleaner-sequel/lib/database_cleaner/sequel/transaction.rb +0 -40
  75. data/adapters/database_cleaner-sequel/lib/database_cleaner/sequel/truncation.rb +0 -79
  76. data/adapters/database_cleaner-sequel/lib/database_cleaner/sequel/version.rb +0 -5
  77. data/cucumber.yml +0 -1
  78. data/lib/database_cleaner/base.rb +0 -149
  79. data/lib/database_cleaner/configuration.rb +0 -141
  80. data/lib/database_cleaner/cucumber.rb +0 -3
  81. data/lib/database_cleaner/deprecation.rb +0 -21
  82. data/lib/database_cleaner/generic/base.rb +0 -29
  83. data/lib/database_cleaner/generic/transaction.rb +0 -11
  84. data/lib/database_cleaner/generic/truncation.rb +0 -40
  85. data/lib/database_cleaner/null_strategy.rb +0 -20
  86. data/lib/database_cleaner/orm_autodetector.rb +0 -40
  87. data/lib/database_cleaner/safeguard.rb +0 -107
  88. data/lib/database_cleaner/spec.rb +0 -2
  89. data/lib/database_cleaner/spec/database_helper.rb +0 -82
  90. data/lib/database_cleaner/spec/shared_examples.rb +0 -15
  91. data/lib/database_cleaner/version.rb +0 -3
@@ -1,24 +0,0 @@
1
- require 'database_cleaner/generic/base'
2
- module DatabaseCleaner
3
- module MongoMapper
4
- def self.available_strategies
5
- %w[truncation]
6
- end
7
-
8
- def self.default_strategy
9
- :truncation
10
- end
11
-
12
- module Base
13
- include ::DatabaseCleaner::Generic::Base
14
-
15
- def db=(desired_db)
16
- @db = desired_db
17
- end
18
-
19
- def db
20
- @db ||= :default
21
- end
22
- end
23
- end
24
- end
@@ -1,35 +0,0 @@
1
- require 'database_cleaner/mongo_mapper/base'
2
- require 'database_cleaner/generic/truncation'
3
-
4
- module DatabaseCleaner
5
- module MongoMapper
6
- class Truncation
7
- include ::DatabaseCleaner::MongoMapper::Base
8
- include ::DatabaseCleaner::Generic::Truncation
9
-
10
- def clean
11
- if @only
12
- collections.each { |c| c.send(truncate_method_name) if @only.include?(c.name) }
13
- else
14
- collections.each { |c| c.send(truncate_method_name) unless @tables_to_exclude.include?(c.name) }
15
- end
16
- true
17
- end
18
-
19
- private
20
-
21
- def collections
22
- database.collections.select { |c| c.name !~ /^system\./ }
23
- end
24
-
25
- def truncate_method_name
26
- # This constant only exists in the 2.x series.
27
- defined?(::Mongo::VERSION) ? :delete_many : :remove
28
- end
29
-
30
- def database
31
- ::MongoMapper.database
32
- end
33
- end
34
- end
35
- end
@@ -1,5 +0,0 @@
1
- module DatabaseCleaner
2
- module MongoMapper
3
- VERSION = "1.8.1"
4
- end
5
- end
@@ -1 +0,0 @@
1
- require "database_cleaner/mongoid"
@@ -1,10 +0,0 @@
1
- require "database_cleaner/mongoid/version"
2
- require "database_cleaner"
3
- require "database_cleaner/mongoid/truncation"
4
-
5
- module DatabaseCleaner::Mongoid
6
- def self.default_strategy
7
- :truncation
8
- end
9
- end
10
-
@@ -1,20 +0,0 @@
1
- require 'database_cleaner/generic/base'
2
- module DatabaseCleaner
3
- module Mongoid
4
- def self.available_strategies
5
- %w[truncation]
6
- end
7
-
8
- module Base
9
- include ::DatabaseCleaner::Generic::Base
10
-
11
- def db=(desired_db)
12
- @db = desired_db
13
- end
14
-
15
- def db
16
- @db || :default
17
- end
18
- end
19
- end
20
- end
@@ -1,26 +0,0 @@
1
- module DatabaseCleaner
2
- module Mongoid
3
- module Mongo1TruncationMixin
4
- def clean
5
- if @only
6
- collections.each { |c| c.send(truncate_method_name) if @only.include?(c.name) }
7
- else
8
- collections.each { |c| c.send(truncate_method_name) unless @tables_to_exclude.include?(c.name) }
9
- end
10
- true
11
- end
12
-
13
- private
14
-
15
- def collections
16
- database.collections.select { |c| c.name !~ /^system\./ }
17
- end
18
-
19
- def truncate_method_name
20
- # This constant only exists in the 2.x series.
21
- defined?(::Mongo::VERSION) ? :delete_many : :remove
22
- end
23
- end
24
- end
25
- end
26
-
@@ -1,38 +0,0 @@
1
- module DatabaseCleaner
2
- module Mongoid
3
- module Mongo2TruncationMixin
4
- def clean
5
- if @only
6
- collections.each { |c| database[c].find.delete_many if @only.include?(c) }
7
- else
8
- collections.each { |c| database[c].find.delete_many unless @tables_to_exclude.include?(c) }
9
- end
10
- true
11
- end
12
-
13
- private
14
-
15
- def database
16
- if @db.nil? || @db == :default
17
- ::Mongoid::Clients.default
18
- else
19
- ::Mongoid::Clients.with_name(@db)
20
- end
21
- end
22
-
23
- def collections
24
- if db != :default
25
- database.use(db)
26
- end
27
-
28
- database.collections.collect { |c| c.namespace.split('.',2)[1] }
29
-
30
- # database['system.namespaces'].find(:name => { '$not' => /\.system\.|\$/ }).to_a.map do |collection|
31
- # _, name = collection['name'].split('.', 2)
32
- # name
33
- # end
34
- end
35
- end
36
- end
37
- end
38
-
@@ -1,65 +0,0 @@
1
- require 'database_cleaner/generic/base'
2
- require 'database_cleaner/generic/truncation'
3
-
4
- module DatabaseCleaner
5
- module Mongoid
6
- module MongoidTruncationMixin
7
- include ::DatabaseCleaner::Generic::Base
8
- include ::DatabaseCleaner::Generic::Truncation
9
-
10
- def db=(desired_db)
11
- @db = desired_db
12
- end
13
-
14
- def db
15
- @db ||= :default
16
- end
17
-
18
- def host_port=(desired_host)
19
- @host = desired_host
20
- end
21
-
22
- def host
23
- @host ||= '127.0.0.1:27017'
24
- end
25
-
26
- def db_version
27
- @db_version ||= session.command('buildinfo' => 1)['version']
28
- end
29
-
30
- def clean
31
- if @only
32
- collections.each { |c| session[c].find.remove_all if @only.include?(c) }
33
- else
34
- collections.each { |c| session[c].find.remove_all unless @tables_to_exclude.include?(c) }
35
- end
36
- wait_for_removals_to_finish
37
- true
38
- end
39
-
40
- private
41
-
42
- def collections
43
- if db != :default
44
- session.use(db)
45
- end
46
-
47
- if db_version.split('.').first.to_i >= 3
48
- session.command(listCollections: 1, filter: { 'name' => { '$not' => /.?system\.|\$/ } })['cursor']['firstBatch'].map do |collection|
49
- collection['name']
50
- end
51
- else
52
- session['system.namespaces'].find(name: { '$not' => /\.system\.|\$/ }).to_a.map do |collection|
53
- _, name = collection['name'].split('.', 2)
54
- name
55
- end
56
- end
57
- end
58
-
59
- def wait_for_removals_to_finish
60
- session.command(getlasterror: 1)
61
- end
62
- end
63
- end
64
- end
65
-
@@ -1,49 +0,0 @@
1
- require 'database_cleaner/mongoid/base'
2
- require 'database_cleaner/generic/truncation'
3
- require 'database_cleaner/mongoid/mongo1_truncation_mixin'
4
- require 'database_cleaner/mongoid/mongo2_truncation_mixin'
5
- require 'database_cleaner/mongoid/mongoid_truncation_mixin'
6
- require 'mongoid/version'
7
-
8
- module DatabaseCleaner
9
- module Mongoid
10
- class Truncation
11
- include ::DatabaseCleaner::Mongoid::Base
12
- include ::DatabaseCleaner::Generic::Truncation
13
-
14
- if ::Mongoid::VERSION < '3'
15
-
16
- include ::DatabaseCleaner::Mongoid::Mongo1TruncationMixin
17
-
18
- private
19
-
20
- def database
21
- ::Mongoid.database
22
- end
23
-
24
- elsif ::Mongoid::VERSION < '5'
25
-
26
- include ::DatabaseCleaner::Mongoid::MongoidTruncationMixin
27
-
28
- private
29
-
30
- def session
31
- ::Mongoid::VERSION > "5.0.0" ? ::Mongoid.default_client : ::Mongoid.default_session
32
- end
33
-
34
- def database
35
- if not(@db.nil? or @db == :default)
36
- ::Mongoid.databases[@db]
37
- else
38
- ::Mongoid.database
39
- end
40
- end
41
-
42
- else
43
-
44
- include ::DatabaseCleaner::Mongoid::Mongo2TruncationMixin
45
-
46
- end
47
- end
48
- end
49
- end
@@ -1,5 +0,0 @@
1
- module DatabaseCleaner
2
- module Mongoid
3
- VERSION = "1.8.1"
4
- end
5
- end
@@ -1 +0,0 @@
1
- require "database_cleaner/moped"
@@ -1,10 +0,0 @@
1
- require "database_cleaner/moped/version"
2
- require "database_cleaner"
3
- require "database_cleaner/moped/truncation"
4
-
5
- module DatabaseCleaner::Moped
6
- def self.default_strategy
7
- :truncation
8
- end
9
- end
10
-
@@ -1,39 +0,0 @@
1
- require 'database_cleaner/generic/base'
2
-
3
- module DatabaseCleaner
4
- module Moped
5
- def self.available_strategies
6
- %w[truncation]
7
- end
8
-
9
- module Base
10
- include ::DatabaseCleaner::Generic::Base
11
-
12
- def db=(desired_db)
13
- @db = desired_db
14
- end
15
-
16
- def db
17
- @db ||= :default
18
- end
19
-
20
- def host_port=(desired_host)
21
- @host = desired_host
22
- end
23
-
24
- def host
25
- @host ||= '127.0.0.1:27017'
26
- end
27
-
28
- def db_version
29
- @db_version ||= session.command('buildinfo' => 1)['version']
30
- end
31
-
32
- private
33
-
34
- def session
35
- @session ||= ::Moped::Session.new([host], database: db)
36
- end
37
- end
38
- end
39
- end
@@ -1,9 +0,0 @@
1
- require 'database_cleaner/moped/truncation_base'
2
-
3
- module DatabaseCleaner
4
- module Moped
5
- class Truncation
6
- include ::DatabaseCleaner::Moped::TruncationBase
7
- end
8
- end
9
- end
@@ -1,44 +0,0 @@
1
- require 'database_cleaner/moped/base'
2
- require 'database_cleaner/generic/truncation'
3
-
4
- module DatabaseCleaner
5
- module Moped
6
- module TruncationBase
7
- include ::DatabaseCleaner::Moped::Base
8
- include ::DatabaseCleaner::Generic::Truncation
9
-
10
- def clean
11
- if @only
12
- collections.each { |c| session[c].find.remove_all if @only.include?(c) }
13
- else
14
- collections.each { |c| session[c].find.remove_all unless @tables_to_exclude.include?(c) }
15
- end
16
- wait_for_removals_to_finish
17
- true
18
- end
19
-
20
- private
21
-
22
- def collections
23
- if db != :default
24
- session.use(db)
25
- end
26
-
27
- if db_version.split('.').first.to_i >= 3
28
- session.command(listCollections: 1, filter: { 'name' => { '$not' => /.?system\.|\$/ } })['cursor']['firstBatch'].map do |collection|
29
- collection['name']
30
- end
31
- else
32
- session['system.namespaces'].find(name: { '$not' => /\.system\.|\$/ }).to_a.map do |collection|
33
- _, name = collection['name'].split('.', 2)
34
- name
35
- end
36
- end
37
- end
38
-
39
- def wait_for_removals_to_finish
40
- session.command(getlasterror: 1)
41
- end
42
- end
43
- end
44
- end
@@ -1,5 +0,0 @@
1
- module DatabaseCleaner
2
- module Moped
3
- VERSION = "1.8.0"
4
- end
5
- end
@@ -1 +0,0 @@
1
- require "database_cleaner/neo4j"
@@ -1,6 +0,0 @@
1
- require "database_cleaner/neo4j/version"
2
- require "database_cleaner"
3
- require "database_cleaner/neo4j/transaction"
4
- require "database_cleaner/neo4j/truncation"
5
- require "database_cleaner/neo4j/deletion"
6
-
@@ -1,66 +0,0 @@
1
- require 'database_cleaner/generic/base'
2
- module DatabaseCleaner
3
- module Neo4j
4
- def self.available_strategies
5
- %w[transaction truncation deletion]
6
- end
7
-
8
- def self.default_strategy
9
- :transaction
10
- end
11
-
12
- module Base
13
- include ::DatabaseCleaner::Generic::Base
14
-
15
- def db=(desired_db)
16
- @db = desired_db == :default ? nil : desired_db
17
- end
18
-
19
- def db
20
- @db ||= nil
21
- end
22
-
23
- def start
24
- if db_type == :embedded_db and not session.running?
25
- session.start
26
- else
27
- session
28
- end
29
- end
30
-
31
- def database
32
- db && default_db.merge(db) || default_db
33
- end
34
-
35
- private
36
-
37
- def default_db
38
- {:type => default_db_type, :path => default_db_path}
39
- end
40
-
41
- def default_db_type
42
- :server_db
43
- end
44
-
45
- def default_db_path(type = default_db_type)
46
- type == :server_db ? 'http://localhost:7475/' : './db/test'
47
- end
48
-
49
- def db_type
50
- database[:type]
51
- end
52
-
53
- def db_path
54
- database[:path]
55
- end
56
-
57
- def db_params
58
- database.reject!{|key, value| [:type, :path].include? key }
59
- end
60
-
61
- def session
62
- @session ||= ::Neo4j::Session.open(db_type, db_path, db_params)
63
- end
64
- end
65
- end
66
- end