fixtury 1.0.0.beta4 → 1.0.0.beta5
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/Gemfile.lock +1 -1
- data/lib/fixtury/configuration.rb +2 -1
- data/lib/fixtury/dependency_store.rb +18 -7
- data/lib/fixtury/store.rb +1 -1
- data/lib/fixtury/version.rb +1 -1
- data/lib/fixtury.rb +10 -4
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 297aa8d54ad35f629cfb75dc8c7599660dc24393ad87b03de039ad8f4dfd691a
|
4
|
+
data.tar.gz: c89efb954c5bebe6751628d22b29ecc4fb1fd61020d53d321b7e782e93608007
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9af1d90c107d075bfdf89c50ed59b59b0ae264a7799058bab495ae66f0e0451876c90d119e24219880d193f6dc6a869798cb7f568885a5b85e5f676f9871221d
|
7
|
+
data.tar.gz: de852c51ecd2a53fa9ae050deea5d150fef75819c287330c831c99c9307b00ea98854e6c13df3dc9b03e5dd5119bf6805cee69a139199c22a0867b0a848d25ad
|
data/Gemfile.lock
CHANGED
@@ -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
|
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(
|
23
|
-
dep = definition.dependencies.
|
24
|
-
|
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.
|
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
|
data/lib/fixtury/version.rb
CHANGED
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
|
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
|
|