fixation 1.1.0 → 1.1.1
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.
- checksums.yaml +4 -4
- data/lib/fixation.rb +14 -12
- data/lib/fixation/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 658d4e159e9f4f2a40209757beeb8992e52099ad
|
|
4
|
+
data.tar.gz: 445b6032756c033604a8683d583e2a3100122daf
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 3a553d7eb6c23791c74c68bab53d6541e4254052e08525d62c6c658c702a363ebe358d86b8757a1de7952b3051bd1348dab721fd6b07da0a5f4558239a5c0abe
|
|
7
|
+
data.tar.gz: 5b858f89167561777658619076f3fb58c2dd87d91ee0a1ea247a1fb61b3a8fddc026a861ff3cc1d3ae151b2e3a49cf232a33bb650c6860c1448bf4d2cf59d74c
|
data/lib/fixation.rb
CHANGED
|
@@ -7,26 +7,28 @@ require "fixation/version"
|
|
|
7
7
|
|
|
8
8
|
module Fixation
|
|
9
9
|
class FixtureTable
|
|
10
|
-
attr_reader :filename, :table_name, :connection, :now
|
|
10
|
+
attr_reader :filename, :class_name, :table_name, :connection, :now
|
|
11
11
|
|
|
12
|
-
def initialize(filename,
|
|
12
|
+
def initialize(filename, basename, connection, now)
|
|
13
13
|
@filename = filename
|
|
14
|
-
@table_name = table_name
|
|
15
14
|
@connection = connection
|
|
16
15
|
@now = now
|
|
17
16
|
|
|
18
|
-
@
|
|
17
|
+
@class_name = basename.classify
|
|
19
18
|
begin
|
|
20
|
-
@klass = @
|
|
19
|
+
@klass = @class_name.constantize
|
|
21
20
|
@klass = nil unless @klass < ActiveRecord::Base
|
|
22
21
|
rescue NameError
|
|
23
|
-
ActiveRecord::Base.logger.warn "couldn't load #{
|
|
22
|
+
ActiveRecord::Base.logger.warn "couldn't load #{class_name} for fixture table #{table_name}: #{$!}"
|
|
24
23
|
end
|
|
25
24
|
|
|
26
25
|
if @klass
|
|
26
|
+
@table_name = @klass.table_name
|
|
27
27
|
@primary_key = @klass.primary_key
|
|
28
28
|
@record_timestamps = @klass.record_timestamps
|
|
29
29
|
@inheritance_column = @klass.inheritance_column
|
|
30
|
+
else
|
|
31
|
+
@table_name = basename.gsub('/', '_')
|
|
30
32
|
end
|
|
31
33
|
end
|
|
32
34
|
|
|
@@ -181,18 +183,18 @@ module Fixation
|
|
|
181
183
|
Fixation.paths.each do |path|
|
|
182
184
|
Dir["#{path}/{**,*}/*.yml"].each do |pathname|
|
|
183
185
|
basename = pathname[path.size + 1..-5]
|
|
184
|
-
compile_fixture_file(pathname, basename
|
|
186
|
+
compile_fixture_file(pathname, basename, connection, now) if ::File.file?(pathname)
|
|
185
187
|
end
|
|
186
188
|
end
|
|
187
189
|
|
|
188
190
|
puts "#{Time.now} built fixtures for #{@fixture_ids.size} tables" if Fixation.trace
|
|
189
191
|
end
|
|
190
192
|
|
|
191
|
-
def compile_fixture_file(filename,
|
|
192
|
-
fixture_table = FixtureTable.new(filename,
|
|
193
|
-
@fixture_ids[table_name] = fixture_table.fixture_ids
|
|
194
|
-
@statements[table_name] = fixture_table.statements
|
|
195
|
-
@class_names[table_name] = class_name
|
|
193
|
+
def compile_fixture_file(filename, basename, connection, now)
|
|
194
|
+
fixture_table = FixtureTable.new(filename, basename, connection, now)
|
|
195
|
+
@fixture_ids[fixture_table.table_name] = fixture_table.fixture_ids
|
|
196
|
+
@statements[fixture_table.table_name] = fixture_table.statements
|
|
197
|
+
@class_names[fixture_table.table_name] = fixture_table.class_name
|
|
196
198
|
end
|
|
197
199
|
|
|
198
200
|
def apply_fixtures(connection = ActiveRecord::Base.connection)
|
data/lib/fixation/version.rb
CHANGED