fixture_seed 0.4.1 → 0.4.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8d3cd5453c25f8d850aa253af3a3be318d4f321d67ac8d08a47894bcaebc762a
4
- data.tar.gz: 38f74d96fc45637798f95d0ab92948f9e399a6b447e96ea3d515862ebc61424a
3
+ metadata.gz: 3eac99125111c4643c61c6fb9a8437ff32efe5b5e695e241565078de54b46526
4
+ data.tar.gz: 3fc03ab1f49b6723ef304bbd7ea4a892150e474080c70d6182b069013b02eec7
5
5
  SHA512:
6
- metadata.gz: eecab5f96b32f9311b2c453c7cdff9a1fc6a0000f0295310022bf3279dec380cb8509d81bc53a9b88d4691d55bd1ecb0ebc34982169d3533f273da7b790a209f
7
- data.tar.gz: 3119f7c0827b348723a9534d9740802d47c35be613b4b883ac144837bae7d18983808d86eef1b361cde4d7fc745bdfa85e034d03e38a8823c6695f5824d1c6bc
6
+ metadata.gz: 248a11f90920c9fd60fc0e6931fd3adf29baa427eb9fd42a275e27e789cf58f35341786d93051e916409e765df6d341c0f3a6aeb6c8ec911816e6bcc7d491a34
7
+ data.tar.gz: cc63888523cab5b38d0fd4c4b72b5f03f1b478884895d6da29c4fee8b51c8f274bcc931d80f37bf65f3d986307b696b440080596a24e77c4444c98945d7f2659
@@ -9,43 +9,22 @@ module FixtureSeed
9
9
 
10
10
  class << self
11
11
  def load_fixtures(fixtures_path = nil)
12
- fixtures_path ||= ENV["FIXTURES_PATH"] || DEFAULT_FIXTURES_PATH
12
+ fixtures_path ||= ENV["FIXTURES_PATH"] || "db/fixtures"
13
13
  fixtures_dir = Rails.root.join(fixtures_path)
14
+ fixture_names = discover_fixture_names(fixtures_dir)
14
15
 
15
- return unless fixtures_directory_exists?(fixtures_dir, fixtures_path)
16
-
17
- load_fixture_files(fixtures_dir, fixtures_path)
16
+ ActiveRecord::Base.connection.disable_referential_integrity do
17
+ ActiveRecord::FixtureSet.create_fixtures(fixtures_dir.to_s, fixture_names)
18
+ end
18
19
  end
19
20
 
20
21
  private
21
22
 
22
- def fixtures_directory_exists?(fixtures_dir, fixtures_path)
23
- return true if Dir.exist?(fixtures_dir)
24
-
25
- Rails.logger&.info "[FixtureSeed] Fixtures directory not found: #{fixtures_path}"
26
- false
27
- end
28
-
29
- def load_fixture_files(fixtures_dir, fixtures_path)
30
- Rails.logger&.info "[FixtureSeed] Loading fixtures from #{fixtures_path}"
31
-
32
- fixture_files = Dir.glob("#{fixtures_dir}/*.yml")
33
- return if fixture_files.empty?
34
-
35
- table_names = fixture_files.map { |f| File.basename(f, ".yml") }
36
- Rails.logger&.info "[FixtureSeed] Found tables: #{table_names.join(', ')}"
37
-
38
- # Check if FixtureSet is available
39
- unless defined?(ActiveRecord::FixtureSet)
40
- Rails.logger&.error "[FixtureSeed] ActiveRecord::FixtureSet is not available. Please ensure you're using Rails 4.0+ or include 'active_record/fixtures'."
41
- return
42
- end
43
-
44
- ActiveRecord::Base.connection.disable_referential_integrity do
45
- ActiveRecord::FixtureSet.create_fixtures(fixtures_dir.to_s, table_names)
23
+ def discover_fixture_names(fixtures_dir)
24
+ fixture_files = Dir[File.join(fixtures_dir, "**/*.yml")]
25
+ fixture_files.map do |file|
26
+ file[fixtures_dir.to_s.size..-5].delete_prefix("/")
46
27
  end
47
-
48
- Rails.logger&.info "[FixtureSeed] Finished loading fixtures"
49
28
  end
50
29
  end
51
30
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module FixtureSeed
4
- VERSION = "0.4.1"
4
+ VERSION = "0.4.2"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fixture_seed
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Masaki Komagata