fixtury 1.0.0.beta4 → 1.0.0.beta5

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
  SHA256:
3
- metadata.gz: 40d7b20a26b6cd75ff04db4f5208a5386dd941a3ee7b36bccf9533c0737ae159
4
- data.tar.gz: b0adbfcdfb0b7b33e80e4d5e27d69c0660858492fbe6e2a06212c8c857d4210d
3
+ metadata.gz: 297aa8d54ad35f629cfb75dc8c7599660dc24393ad87b03de039ad8f4dfd691a
4
+ data.tar.gz: c89efb954c5bebe6751628d22b29ecc4fb1fd61020d53d321b7e782e93608007
5
5
  SHA512:
6
- metadata.gz: 6c931673f51c04fb39d486a33b9d0ff29040d32fe09907520ddf0d82a65db1fdaa7312b8e1841c99c927048b8650377b70736f098071e49a2cf4cacc5f8325a1
7
- data.tar.gz: b6873bea9e6fbe6dd32e97a87d41073b6167087805d8646b78f10b4324c07baf229bd0735ac084e9c06476eb10bc9210ddf10bb8270293156b3911f61703337e
6
+ metadata.gz: 9af1d90c107d075bfdf89c50ed59b59b0ae264a7799058bab495ae66f0e0451876c90d119e24219880d193f6dc6a869798cb7f568885a5b85e5f676f9871221d
7
+ data.tar.gz: de852c51ecd2a53fa9ae050deea5d150fef75819c287330c831c99c9307b00ea98854e6c13df3dc9b03e5dd5119bf6805cee69a139199c22a0867b0a848d25ad
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- fixtury (1.0.0.beta4)
4
+ fixtury (1.0.0.beta5)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -6,12 +6,13 @@ module Fixtury
6
6
  class Configuration
7
7
 
8
8
  attr_reader :fixture_files, :dependency_files, :locator_backend
9
- attr_accessor :filepath, :reference_ttl
9
+ attr_accessor :filepath, :reference_ttl, :strict_dependencies
10
10
 
11
11
  def initialize
12
12
  @fixture_files = Set.new
13
13
  @dependency_files = Set.new
14
14
  @locator_backend = :memory
15
+ @strict_dependencies = true
15
16
  end
16
17
 
17
18
  def log_level
@@ -14,16 +14,27 @@ module Fixtury
14
14
  "#{self.class}(definition: #{definition.pathname.inspect}, dependencies: #{definition.dependencies.keys.inspect})"
15
15
  end
16
16
 
17
- # Returns the value of the dependency with the given key
17
+ # Returns the value of the dependency with the given key. If the key is not present in the dependencies
18
+ # and strict_dependencies is enabled, an error will be raised. If strict_dependencies is not enabled
19
+ # the store will receive the search term directly.
18
20
  #
19
- # @param key [String, Symbol] the accessor of the dependency
21
+ # @param search [String, Symbol] the accessor of the dependency
20
22
  # @return [Object] the value of the dependency
21
- # @raise [Fixtury::Errors::UnknownDependencyError] if the definition does not contain the provided dependency
22
- def get(key)
23
- dep = definition.dependencies.fetch(key.to_s) do
24
- raise Errors::UnknownDependencyError.new(definition, key)
23
+ # @raise [Fixtury::Errors::UnknownDependencyError] if the definition does not contain the provided dependency and strict_dependencies is enabled
24
+ def get(search)
25
+ dep = definition.dependencies[search.to_s]
26
+
27
+ if dep.nil? && Fixtury.configuration.strict_dependencies
28
+ raise Errors::UnknownDependencyError.new(definition, search)
29
+ end
30
+
31
+ if dep
32
+ store.get(dep.definition.pathname)
33
+ else
34
+ store.with_relative_schema(definition.parent) do
35
+ store.get(search)
36
+ end
25
37
  end
26
- store.get(dep.definition.pathname)
27
38
  end
28
39
  alias [] get
29
40
 
data/lib/fixtury/store.rb CHANGED
@@ -72,7 +72,7 @@ module Fixtury
72
72
  # @return [void]
73
73
  def load_all(schema = self.schema)
74
74
  schema.children.each_value do |item|
75
- get(item.name) if item.acts_like?(:fixtury_definition)
75
+ get(item.pathname) if item.acts_like?(:fixtury_definition)
76
76
  load_all(item) if item.acts_like?(:fixtury_schema)
77
77
  end
78
78
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Fixtury
4
4
 
5
- VERSION = "1.0.0.beta4"
5
+ VERSION = "1.0.0.beta5"
6
6
 
7
7
  end
data/lib/fixtury.rb CHANGED
@@ -80,15 +80,21 @@ module Fixtury
80
80
  end
81
81
 
82
82
  # Require each schema file to ensure that all definitions are loaded.
83
- def self.load_all_schemas
83
+ def self.load_all_schemas(mechanism = :require)
84
84
  configuration.fixture_files.each do |filepath|
85
- require filepath
85
+ if mechanism == :require
86
+ require filepath
87
+ elsif mechanism == :load
88
+ load filepath
89
+ else
90
+ raise ArgumentError, "unknown load mechanism: #{mechanism}"
91
+ end
86
92
  end
87
93
  end
88
94
 
89
95
  # Ensure all definitions are loaded and then load all known fixtures.
90
- def self.load_all_fixtures
91
- load_all_schemas
96
+ def self.load_all_fixtures(...)
97
+ load_all_schemas(...)
92
98
  store.load_all
93
99
  end
94
100
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fixtury
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0.beta4
4
+ version: 1.0.0.beta5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike Nelson