fixture_dependencies 1.8.0 → 1.9.0
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/README.md +14 -0
- data/lib/fixture_dependencies.rb +5 -2
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 877d9ca54c211da2669f1b1b3cab5a8e6d2a1392
|
4
|
+
data.tar.gz: fa0af29b417430076a9edf64a0b1446c27436960
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 99ecbc859a9d13abd029484a3b9bd70ed68951d81ca64f2157ba12827b10e30534d0520079d4934b73e5ae38cacd0942830ed9f107398b6fea31cbb465edf7f1
|
7
|
+
data.tar.gz: 91655d4afc2f5cd99e1e30e512a32d39c1a815cb152e172d207d8a4d70b555f5ac6395c412e9f7644a14316f6df09931ae5a0ff28db4d516838589fde618c271
|
data/README.md
CHANGED
@@ -371,6 +371,20 @@ override the default mapping:
|
|
371
371
|
and then use :bar__baz to load the fixture with name baz for the model
|
372
372
|
Foo::Bar.
|
373
373
|
|
374
|
+
## Custom Fixture Filenames
|
375
|
+
|
376
|
+
Fixture dependencies will look for a file that corresponds to the table name
|
377
|
+
for the model by default. You can override this by defining a fixtures_filename
|
378
|
+
class method in the model:
|
379
|
+
|
380
|
+
```
|
381
|
+
class Artist < Sequel::Model
|
382
|
+
def self.fixture_filename
|
383
|
+
:artists_custom_fixture_file
|
384
|
+
end
|
385
|
+
end
|
386
|
+
```
|
387
|
+
|
374
388
|
## Troubleshooting
|
375
389
|
|
376
390
|
If you run into problems with loading your fixtures, it can be difficult to see
|
data/lib/fixture_dependencies.rb
CHANGED
@@ -106,7 +106,8 @@ class << FixtureDependencies
|
|
106
106
|
def load_yaml(model_name)
|
107
107
|
raise(ArgumentError, "No fixture_path set. Use FixtureDependencies.fixture_path = ...") unless fixture_path
|
108
108
|
|
109
|
-
|
109
|
+
klass = model_class(model_name)
|
110
|
+
filename = klass.send(klass.respond_to?(:fixture_filename) ? :fixture_filename : :table_name)
|
110
111
|
yaml_path = File.join(fixture_path, "#{filename}.yml")
|
111
112
|
|
112
113
|
if File.exist?(yaml_path)
|
@@ -210,9 +211,11 @@ class << FixtureDependencies
|
|
210
211
|
if polymorphic_association?(value)
|
211
212
|
value, polymorphic_class = polymorphic_association(value)
|
212
213
|
reflection[:class_name] = polymorphic_class
|
214
|
+
dep_name = "#{polymorphic_class.to_s.underscore}__#{value}".to_sym
|
215
|
+
else
|
216
|
+
dep_name = "#{model_method(:reflection_class, mtype, reflection).name.underscore}__#{value}".to_sym
|
213
217
|
end
|
214
218
|
|
215
|
-
dep_name = "#{model_method(:reflection_class, mtype, reflection).name.underscore}__#{value}".to_sym
|
216
219
|
if dep_name == record
|
217
220
|
# Self referential record, use primary key
|
218
221
|
puts "#{spaces}#{record}.#{attr}: belongs_to self-referential" if verbose > 1
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fixture_dependencies
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.9.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jeremy Evans
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-04-07 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description:
|
14
14
|
email: code@jeremyevans.net
|
@@ -53,7 +53,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
53
53
|
version: '0'
|
54
54
|
requirements: []
|
55
55
|
rubyforge_project:
|
56
|
-
rubygems_version: 2.
|
56
|
+
rubygems_version: 2.6.11
|
57
57
|
signing_key:
|
58
58
|
specification_version: 4
|
59
59
|
summary: Sequel/ActiveRecord fixture loader that handles dependency graphs
|