fixation 1.1.0 → 1.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a3b3168e7c5df3c31609251ba4a7c645d706e765
4
- data.tar.gz: f5bfe0e79605be818a4bf47096fc03a9f9ae74a3
3
+ metadata.gz: 658d4e159e9f4f2a40209757beeb8992e52099ad
4
+ data.tar.gz: 445b6032756c033604a8683d583e2a3100122daf
5
5
  SHA512:
6
- metadata.gz: 67670b4cb21db3794e855a7cd3b7cf504c241ae5af6f493ee4c638c59a5a5e0b905f575c8c1e9650775341f9c97c9f3c9ce2345e604e8ef712d64abf85962b4d
7
- data.tar.gz: 62086ce7f21c3c1c74d2f4329b63f8c4282ef0609378b2ac174a5f01c95d51c827ccfc562c9fa30aa04eaa79c568fd2e06e0be68d295ac9ddd103fef3e67f2aa
6
+ metadata.gz: 3a553d7eb6c23791c74c68bab53d6541e4254052e08525d62c6c658c702a363ebe358d86b8757a1de7952b3051bd1348dab721fd6b07da0a5f4558239a5c0abe
7
+ data.tar.gz: 5b858f89167561777658619076f3fb58c2dd87d91ee0a1ea247a1fb61b3a8fddc026a861ff3cc1d3ae151b2e3a49cf232a33bb650c6860c1448bf4d2cf59d74c
@@ -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, table_name, connection, now)
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
- @klass_name = @table_name.classify
17
+ @class_name = basename.classify
19
18
  begin
20
- @klass = @klass_name.constantize
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 #{@klass_name} for fixture table #{table_name}: #{$!}"
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.gsub('/', '_'), basename.classify, connection, now) if ::File.file?(pathname)
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, table_name, class_name, connection, now)
192
- fixture_table = FixtureTable.new(filename, table_name, connection, now)
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)
@@ -1,3 +1,3 @@
1
1
  module Fixation
2
- VERSION = "1.1.0"
2
+ VERSION = "1.1.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fixation
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Will Bryant