fixture_background 0.9.3 → 0.9.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -9,8 +9,12 @@ module FixtureBackground
9
9
 
10
10
  transaction_with_rollback do
11
11
  (ActiveRecord::Base.connection.tables - ["schema_migrations"]).each do |table_name|
12
- klass = table_name.classify.constantize
13
- klass.delete_all
12
+ begin
13
+ klass = table_name.classify.constantize
14
+ klass.delete_all
15
+ rescue NameError # do not die on tables that have no model
16
+ puts "cannot delete from #{table_name} as no model exists"
17
+ end
14
18
  end
15
19
 
16
20
  bm = Benchmark.realtime do
@@ -70,17 +74,21 @@ module FixtureBackground
70
74
 
71
75
  def dump_fixtures
72
76
  (ActiveRecord::Base.connection.tables - ["schema_migrations"]).each do |table_name|
73
- klass = table_name.classify.constantize
77
+ begin
78
+ klass = table_name.classify.constantize
74
79
 
75
- records = klass.all
80
+ records = klass.all
76
81
 
77
- fixtures = {}
78
- records.each do |record|
79
- fixtures[table_name + record.id.to_s] = record.instance_variable_get(:@attributes)
80
- end
82
+ fixtures = {}
83
+ records.each do |record|
84
+ fixtures[table_name + record.id.to_s] = record.instance_variable_get(:@attributes)
85
+ end
81
86
 
82
- File.open("#{@background_dir}/#{table_name}.yml", 'w+') do |f|
83
- YAML.dump(fixtures, f)
87
+ File.open("#{@background_dir}/#{table_name}.yml", 'w+') do |f|
88
+ YAML.dump(fixtures, f)
89
+ end
90
+ rescue NameError # do not die on tables that have no model
91
+ puts "cannot dump from #{table_name} as no model exists"
84
92
  end
85
93
  end
86
94
  end
@@ -1,4 +1,4 @@
1
1
  module FixtureBackground
2
- VERSION = "0.9.3"
2
+ VERSION = "0.9.4"
3
3
  end
4
4
 
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 9
8
- - 3
9
- version: 0.9.3
8
+ - 4
9
+ version: 0.9.4
10
10
  platform: ruby
11
11
  authors:
12
12
  - Thies C. Arntzen
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-02-04 00:00:00 +01:00
18
+ date: 2011-03-31 00:00:00 +02:00
19
19
  default_executable:
20
20
  dependencies: []
21
21