fixturies 1.0.2 → 1.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/fixturies.rb +12 -1
  3. metadata +2 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 111de78ccf16d0722626b9a84398e602488be1c181c5aa2a8ebe6d8d6c8c2732
4
- data.tar.gz: 28175fa7dd4a3528e3e173037a1ef47cf01f5859f1f6be8d681d739bef324696
3
+ metadata.gz: 95b9e96f5a11eb6e20390fe38f5a786de44adf85930aa5218840d2e559144e7d
4
+ data.tar.gz: e83b5b488b24fdbe24f464bdff10d59e916e96a18bdf4e6d319e174f44310747
5
5
  SHA512:
6
- metadata.gz: a52d50c7c2cebe3a78fbdb361c589a5e755f277c2d90d8dd2d6904399b8a47f7887c722a50d2c5601cb4c55b2a50f1b05c8f9a0e017815c18ac9b20689336292
7
- data.tar.gz: e0fd102ca4656cd6ae621b48952fbbce36cd8cc434c05ddcfccd7cc2562b3964054d17b080cfb643dfefea09d5a9922506a75ada7ab9081dc58c7fb968123b28
6
+ metadata.gz: 33c08b5e3804540d938d019024e001c601e8f55f6320518e2573f9500dbe0ad56fe4bc57418d96c922a95e6a70057b19d3d2304e4eb87888414eeebc6fbacdfb
7
+ data.tar.gz: 4453b116af5b4ed500b78f0dc096c645a6709da2445770e00fe6cc23dbc684336d0279af8773a316140d894ce54b0d9a1ede02e26f5490ed53c5bb6d5e1dc6cd
@@ -2,7 +2,7 @@ class Fixturies
2
2
 
3
3
  class << self
4
4
 
5
- attr_reader :fixtures_directory
5
+ attr_reader :fixtures_directory, :fixture_class_names
6
6
 
7
7
  def build(&proc)
8
8
  meth_name = :"builder_#{rand}"
@@ -14,6 +14,11 @@ class Fixturies
14
14
  @fixtures_directory = dir
15
15
  end
16
16
 
17
+ def set_fixture_class(class_names = {})
18
+ @fixture_class_names ||= {}
19
+ @fixture_class_names = fixture_class_names.merge(class_names.stringify_keys)
20
+ end
21
+
17
22
  def create_fixtures
18
23
  self.new.create_fixtures
19
24
  end
@@ -115,6 +120,12 @@ class Fixturies
115
120
  end
116
121
 
117
122
  if hash.any?
123
+ # Rails allows baking the model_class into the YAML file, which
124
+ # can be useful if the class cannot be inferred from the table_name.
125
+ # See https://github.com/rails/rails/pull/20574/files
126
+ klass = self.class.fixture_class_names&.[](table_name)
127
+ hash['_fixture'] = {'model_class' => klass.to_s} if klass.present?
128
+
118
129
  File.open(filename, 'w+') do |f|
119
130
  f.write(hash.to_yaml)
120
131
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fixturies
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nate Brustein
@@ -36,8 +36,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
36
36
  - !ruby/object:Gem::Version
37
37
  version: '0'
38
38
  requirements: []
39
- rubyforge_project:
40
- rubygems_version: 2.7.6
39
+ rubygems_version: 3.0.8
41
40
  signing_key:
42
41
  specification_version: 4
43
42
  summary: The speed of fixtures meets the maintanability of factories