specjour 0.1.8 → 0.1.9

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.8
1
+ 0.1.9
@@ -1,34 +1,43 @@
1
1
  module Specjour
2
2
  module DbScrub
3
+ load 'Rakefile'
3
4
  extend self
4
5
 
5
6
  def scrub
6
- load 'Rakefile'
7
- begin
8
- ActiveRecord::Base.connection
9
- rescue # assume the database doesn't exist
10
- Rake::Task['db:create'].invoke
7
+ connect_to_database
8
+ if pending_migrations?
11
9
  Rake::Task['db:schema:load'].invoke
12
10
  else
13
- if pending_migrations?
14
- Rake::Task['db:migrate'].invoke
15
- end
16
-
17
11
  purge_tables
18
12
  end
19
13
  end
20
14
 
21
15
  protected
22
16
 
17
+ def connect_to_database
18
+ connection
19
+ rescue # assume the database doesn't exist
20
+ Rake::Task['db:create'].invoke
21
+ end
22
+
23
+ def connection
24
+ ActiveRecord::Base.connection
25
+ end
26
+
23
27
  def purge_tables
24
- tables = ActiveRecord::Base.connection.tables - ['schema_migrations']
25
- tables.each do |table|
26
- ActiveRecord::Base.connection.delete "delete from #{table}"
28
+ connection.disable_referential_integrity do
29
+ tables_to_purge.each do |table|
30
+ connection.delete "delete from #{table}"
31
+ end
27
32
  end
28
33
  end
29
34
 
30
35
  def pending_migrations?
31
36
  ActiveRecord::Migrator.new(:up, 'db/migrate').pending_migrations.any?
32
37
  end
38
+
39
+ def tables_to_purge
40
+ connection.tables - ['schema_migrations']
41
+ end
33
42
  end
34
43
  end
data/lib/specjour.rb CHANGED
@@ -18,5 +18,5 @@ module Specjour
18
18
  autoload :RsyncDaemon, 'specjour/rsync_daemon'
19
19
  autoload :Worker, 'specjour/worker'
20
20
 
21
- VERSION = "0.1.8".freeze
21
+ VERSION = "0.1.9".freeze
22
22
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 1
8
- - 8
9
- version: 0.1.8
8
+ - 9
9
+ version: 0.1.9
10
10
  platform: ruby
11
11
  authors:
12
12
  - Sandro Turriate
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-03-24 00:00:00 -04:00
17
+ date: 2010-03-26 00:00:00 -04:00
18
18
  default_executable: specjour
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency