fixturex 0.1.0 → 0.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4ea06be8bc96efed28b5178afcb2067df1f62e33ffcbab770b4e9f8981d7c4c7
4
- data.tar.gz: bdf4a376118d64737bd158430543dfa8cd4f072f5b47f22aee79f9d5faf316c5
3
+ metadata.gz: 517987007a6e6ca80e06f5f2159c45ebdd81e6824c223219cfd55f6a1a07ebec
4
+ data.tar.gz: 0ae40367ec829d9adb8292ad32d61da2344c3afd8928696298764f33a219368e
5
5
  SHA512:
6
- metadata.gz: a84ac2f32931c6302e3fe0f7d51e7857faf55ed82c84d333b6c9f5989737367859574e1c53a70a296bda588073e8233ad9f8b4e29b8a726b372957d75d7bdcb7
7
- data.tar.gz: df1e9d6e317c08ffb17d1d657220486d499b78a3ac3630290ff9834787b4b1c598e58f29f9fdf8e661bb0a7a5aa23b2abc7cc9b41fadbdfbc6be4967de4d3ae0
6
+ metadata.gz: 165341e0beb555401e373a8c3314cfd5bfd5020aaf4cab69ed27726a8ee1aa2ce73bbdc98b6235c8d428e1fb70b8dd382a0e0b3f832fefc1005d3c2db714ed6e
7
+ data.tar.gz: 00a86359a92354f61caeacf69cdc1b7cccc800df9141a27aed9903d83152555824b60a76c77b3b7ec28bc25e0c0d4603bcef4534485255244dcdf338576e27e1
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # Fixturex [![Ruby](https://github.com/artemave/fixturex/actions/workflows/ruby.yml/badge.svg)](https://github.com/artemave/fixturex/actions/workflows/ruby.yml)
1
+ # Fixturex [![Ruby](https://github.com/artemave/fixturex/actions/workflows/ruby.yml/badge.svg)](https://github.com/artemave/fixturex/actions/workflows/ruby.yml) [![Gem Version](https://badge.fury.io/rb/fixturex.svg)](https://badge.fury.io/rb/fixturex)
2
2
 
3
3
  Rails fixtures explorer.
4
4
 
@@ -10,7 +10,7 @@ module Fixturex
10
10
 
11
11
  def line
12
12
  @line ||= File.readlines(path).index do |line|
13
- line.match?(/^#{name}:/)
13
+ line.match?(/^#{Regexp.escape(name)}:/)
14
14
  end + 1
15
15
  end
16
16
 
@@ -55,6 +55,10 @@ module Fixturex
55
55
  end
56
56
 
57
57
  class TreeBuilder
58
+ def self.cache
59
+ @cache ||= {}
60
+ end
61
+
58
62
  def build_dependency_tree(fixture_path, fixture_name)
59
63
  TreeEntry.new(
60
64
  FixtureLocation.new(fixture_path, fixture_name),
@@ -67,7 +71,7 @@ module Fixturex
67
71
  def nested_fixtures_locations(parent_fixture_model_class, parent_fixture_name)
68
72
  associations_for_nested_models(parent_fixture_model_class).each_with_object([]) do |association, acc|
69
73
  belongs_to_attribute = belongs_to_attribute_for_association(association)
70
- model_fixtures = ModelFixtures.load(association.class_name)
74
+ model_fixtures = self.class.cache[association.class_name] ||= ModelFixtures.load(association.class_name)
71
75
 
72
76
  model_fixtures.each do |fixture|
73
77
  next if fixture.attributes.fetch(belongs_to_attribute, '').to_s.sub(/ .*/, '') != parent_fixture_name
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Fixturex
4
- VERSION = '0.1.0'
4
+ VERSION = '0.1.1'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fixturex
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - artemave
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-10-01 00:00:00.000000000 Z
11
+ date: 2022-07-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails