tdc 0.3.0 → 0.3.5
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/.rubocop.yml +51 -5
- data/CHANGELOG.md +28 -2
- data/lib/tdc.rb +1 -0
- data/lib/tdc/definition_resolvers/definition_resolver.rb +2 -0
- data/lib/tdc/generators/catalog_entries.rb +10 -0
- data/lib/tdc/generators/configurable_generator.rb +4 -1
- data/lib/tdc/generators/definition_resolvable.rb +6 -17
- data/lib/tdc/generators/generation_context.rb +15 -0
- data/lib/tdc/generators/generator_base.rb +6 -4
- data/lib/tdc/generators/singular_generator.rb +1 -11
- data/lib/tdc/version.rb +1 -1
- data/tdc.gemspec +3 -2
- metadata +9 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2f0fa7ec99a40148ff1ca3fccaaa4ffeee29cc12034dc688b0957deeeb5df9a1
|
4
|
+
data.tar.gz: 2bcd19c81b665611f4f7abbfc8d23fb79db098b84eb837de5e6e6a67a69d7cf7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7cc7b66e9a063bd23e6ccfc482f187b1c8b1a8b2950e16984785c2f9c5c40615e2fb0375e59afd2d374ca3d782719d5f164ac4a2d177d746f0858551b0804061
|
7
|
+
data.tar.gz: dd2476bd5f82a387b89353e790661263d1c28b5c65f901ec01d0f50c3efcf1e716904eacab039f2c39fd44c91f97aeb4dd386dc884a3de07029354c8549acd43
|
data/.rubocop.yml
CHANGED
@@ -10,6 +10,9 @@ AllCops:
|
|
10
10
|
Layout/EmptyLinesAroundAttributeAccessor:
|
11
11
|
Enabled: true
|
12
12
|
|
13
|
+
Metrics/LineLength:
|
14
|
+
Max: 120
|
15
|
+
|
13
16
|
# Rubocop and I cannot agree.
|
14
17
|
Layout/MultilineMethodCallBraceLayout:
|
15
18
|
Enabled: false
|
@@ -17,6 +20,15 @@ Layout/MultilineMethodCallBraceLayout:
|
|
17
20
|
Layout/SpaceAroundMethodCallOperator:
|
18
21
|
Enabled: true
|
19
22
|
|
23
|
+
Lint/DeprecatedOpenSSLConstant:
|
24
|
+
Enabled: true
|
25
|
+
|
26
|
+
Lint/DuplicateElsifCondition:
|
27
|
+
Enabled: true
|
28
|
+
|
29
|
+
Lint/MixedRegexpCaptureTypes:
|
30
|
+
Enabled: true
|
31
|
+
|
20
32
|
Lint/RaiseException:
|
21
33
|
Enabled: true
|
22
34
|
|
@@ -35,9 +47,6 @@ RSpec/AnyInstance:
|
|
35
47
|
RSpec/ExampleLength:
|
36
48
|
Max: 15
|
37
49
|
|
38
|
-
Metrics/LineLength:
|
39
|
-
Max: 120
|
40
|
-
|
41
50
|
RSpec/DescribeClass:
|
42
51
|
Enabled: false
|
43
52
|
|
@@ -59,6 +68,15 @@ RSpec/MultipleExpectations:
|
|
59
68
|
RSpec/SubjectStub:
|
60
69
|
Enabled: false
|
61
70
|
|
71
|
+
Style/AccessorGrouping:
|
72
|
+
Enabled: true
|
73
|
+
|
74
|
+
Style/ArrayCoercion:
|
75
|
+
Enabled: true
|
76
|
+
|
77
|
+
Style/BisectedAttrAccessor:
|
78
|
+
Enabled: true
|
79
|
+
|
62
80
|
Style/BlockDelimiters:
|
63
81
|
Enabled: true
|
64
82
|
EnforcedStyle: line_count_based
|
@@ -66,6 +84,9 @@ Style/BlockDelimiters:
|
|
66
84
|
- 'let'
|
67
85
|
- 'subject'
|
68
86
|
|
87
|
+
Style/CaseLikeIf:
|
88
|
+
Enabled: true
|
89
|
+
|
69
90
|
Style/Documentation:
|
70
91
|
Enabled: false
|
71
92
|
|
@@ -79,9 +100,15 @@ Style/ExponentialNotation:
|
|
79
100
|
Style/FrozenStringLiteralComment:
|
80
101
|
Enabled: false
|
81
102
|
|
103
|
+
Style/HashAsLastArrayItem:
|
104
|
+
Enabled: true
|
105
|
+
|
82
106
|
Style/HashEachMethods:
|
83
107
|
Enabled: true
|
84
108
|
|
109
|
+
Style/HashLikeCase:
|
110
|
+
Enabled: true
|
111
|
+
|
85
112
|
Style/HashTransformKeys:
|
86
113
|
Enabled: true
|
87
114
|
|
@@ -93,6 +120,25 @@ Style/HashSyntax:
|
|
93
120
|
Exclude:
|
94
121
|
- 'Rakefile'
|
95
122
|
|
123
|
+
# We are not going to optimize by freezing strings.
|
124
|
+
Style/MutableConstant:
|
125
|
+
Enabled: false
|
126
|
+
|
127
|
+
Style/RedundantAssignment:
|
128
|
+
Enabled: true
|
129
|
+
|
130
|
+
Style/RedundantFetchBlock:
|
131
|
+
Enabled: true
|
132
|
+
|
133
|
+
Style/RedundantFileExtensionInRequire:
|
134
|
+
Enabled: true
|
135
|
+
|
136
|
+
Style/RedundantRegexpCharacterClass:
|
137
|
+
Enabled: true
|
138
|
+
|
139
|
+
Style/RedundantRegexpEscape:
|
140
|
+
Enabled: true
|
141
|
+
|
96
142
|
# No need to mention StandardError.
|
97
143
|
Style/RescueStandardError:
|
98
144
|
EnforcedStyle: implicit
|
@@ -108,6 +154,6 @@ Style/StringLiterals:
|
|
108
154
|
Style/SymbolArray:
|
109
155
|
Enabled: false
|
110
156
|
|
111
|
-
#
|
112
|
-
Style/
|
157
|
+
# I prefer not to use %w or %W for an array of words.
|
158
|
+
Style/WordArray:
|
113
159
|
Enabled: false
|
data/CHANGELOG.md
CHANGED
@@ -6,6 +6,34 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
6
6
|
|
7
7
|
## [Unreleased]
|
8
8
|
|
9
|
+
## [0.3.5] - 2020-08-06
|
10
|
+
|
11
|
+
- Add the `single_entry` method to `CatalogEntries`
|
12
|
+
|
13
|
+
#### Breaking Changes
|
14
|
+
|
15
|
+
- Drop the `with_definition` method from `SingularGenerator`
|
16
|
+
|
17
|
+
## [0.3.4] - 2020-08-05
|
18
|
+
|
19
|
+
#### Breaking Changes
|
20
|
+
|
21
|
+
- Introduce the `GenerationContext` abstraction
|
22
|
+
- All generators are initialized with an instance of `Tdc::Generators::GenerationContext`
|
23
|
+
|
24
|
+
## [0.3.3] - 2020-08-04
|
25
|
+
|
26
|
+
- Add the `empty?` method to `CatalogEntries`
|
27
|
+
- Evaluate `_atx` attribute values against a `Time.zone` instance
|
28
|
+
|
29
|
+
## [0.3.2] - 2020-07-27
|
30
|
+
|
31
|
+
- Return `self` from `DefinitionResolver#configure_current_catalog` to make it chainable
|
32
|
+
|
33
|
+
## [0.3.1] - 2020-07-25
|
34
|
+
|
35
|
+
- Support DefinitionResolver instance registration
|
36
|
+
|
9
37
|
## [0.3.0] - 2020-07-19
|
10
38
|
|
11
39
|
- Introduce the DefinitionResolver abstraction
|
@@ -42,5 +70,3 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
42
70
|
#### New Features
|
43
71
|
|
44
72
|
- Avoid all PackManager dependencies
|
45
|
-
|
46
|
-
|
data/lib/tdc.rb
CHANGED
@@ -8,6 +8,16 @@ module Tdc
|
|
8
8
|
def add_catalog_entry(tag, entry)
|
9
9
|
send("#{tag}=", entry)
|
10
10
|
end
|
11
|
+
|
12
|
+
def empty?
|
13
|
+
to_h.empty?
|
14
|
+
end
|
15
|
+
|
16
|
+
def single_entry
|
17
|
+
raise Tdc::FatalError, "There is more than one entry" if to_h.many?
|
18
|
+
|
19
|
+
to_h.first.second
|
20
|
+
end
|
11
21
|
end
|
12
22
|
end
|
13
23
|
end
|
@@ -44,12 +44,15 @@ module Tdc
|
|
44
44
|
def run_atx_resolvers(instance_definition)
|
45
45
|
atx_definitions = instance_definition.select { |k, _v| /_atx$/ =~ k }
|
46
46
|
|
47
|
+
# ARM (2020-08-04): Move all the way out so that all generators use the same atx_context.
|
48
|
+
atx_context = Time.zone
|
49
|
+
|
47
50
|
atx_definitions.each do |k, v|
|
48
51
|
# Remove the original _atx attribute.
|
49
52
|
instance_definition.delete(k)
|
50
53
|
|
51
54
|
# Add a standard _at attribute.
|
52
|
-
instance_definition[k.delete_suffix("x")] =
|
55
|
+
instance_definition[k.delete_suffix("x")] = atx_context.instance_eval(v)
|
53
56
|
end
|
54
57
|
end
|
55
58
|
end
|
@@ -2,7 +2,7 @@ module Tdc
|
|
2
2
|
module Generators
|
3
3
|
#
|
4
4
|
# Knows how to resolve attribute values in an instance definition. The attribute value will be replaced
|
5
|
-
# by the result of invoking the
|
5
|
+
# by the result of invoking the registered resolver.
|
6
6
|
#
|
7
7
|
# The resolve_tag class macro is provided for generators to define tag resolution. The test data definition
|
8
8
|
# YAML file has attribute values than contain a catalog entry tag.
|
@@ -14,18 +14,9 @@ module Tdc
|
|
14
14
|
#
|
15
15
|
# resolve_tag key: :subcomponent, source: "item_master.items"
|
16
16
|
#
|
17
|
-
# The
|
18
|
-
# definition YAML file has attribute values than contain an arbitrary
|
19
|
-
# an instance of an object returned by the specified resolver.
|
20
|
-
#
|
21
|
-
# Example:
|
22
|
-
#
|
23
|
-
# Suppose a particular instance definition contained { pallet_number: P0001 } then a generator could resolve
|
24
|
-
# the pallet_number to a pallet instance by defining:
|
25
|
-
#
|
26
|
-
# resolve_definition :pallet_number, to: :pallet_id, resolver: "TestDataCatalog::Resolvers::PalletNumberResolver"
|
27
|
-
#
|
28
|
-
# The PalletNumberResolver class inherits from Tdc::DefinitionResolvers::DefinitionResolver.
|
17
|
+
# The register_definition_resolver class macro is provided for generators to define and register their own
|
18
|
+
# definition resolvers. The test data definition YAML file has attribute values than contain an arbitrary
|
19
|
+
# value that will typically be replaced by an instance of an object returned by the specified resolver.
|
29
20
|
#
|
30
21
|
module DefinitionResolvable
|
31
22
|
extend ActiveSupport::Concern
|
@@ -37,14 +28,12 @@ module Tdc
|
|
37
28
|
end
|
38
29
|
|
39
30
|
class_methods do
|
40
|
-
def
|
41
|
-
resolver_instance = resolver.constantize.new(key: key, to: to || key)
|
42
|
-
|
31
|
+
def register_definition_resolver(resolver_instance)
|
43
32
|
_definition_resolvers << resolver_instance
|
44
33
|
end
|
45
34
|
|
46
35
|
def resolve_tag(key:, source:)
|
47
|
-
|
36
|
+
register_definition_resolver(Tdc::DefinitionResolvers::TagResolver.new(key: key, source: source))
|
48
37
|
end
|
49
38
|
end
|
50
39
|
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module Tdc
|
2
|
+
module Generators
|
3
|
+
#
|
4
|
+
# Knows all the parameters that define the context for generation.
|
5
|
+
#
|
6
|
+
class GenerationContext
|
7
|
+
attr_reader :current_catalog, :data_definition
|
8
|
+
|
9
|
+
def initialize(current_catalog:, data_definition:)
|
10
|
+
@current_catalog = current_catalog
|
11
|
+
@data_definition = data_definition
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -4,11 +4,13 @@ module Tdc
|
|
4
4
|
# Abstract base class for all Test Data Catalog generators.
|
5
5
|
#
|
6
6
|
class GeneratorBase
|
7
|
-
attr_reader :
|
7
|
+
attr_reader :generation_context
|
8
8
|
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
# ARM (2020-08-05): For backwards compatibility. Consider removing.
|
10
|
+
delegate :current_catalog, :data_definition, to: :generation_context
|
11
|
+
|
12
|
+
def initialize(generation_context)
|
13
|
+
@generation_context = generation_context
|
12
14
|
end
|
13
15
|
|
14
16
|
def generate
|
@@ -6,24 +6,14 @@ module Tdc
|
|
6
6
|
# See also StandardGenerator.
|
7
7
|
#
|
8
8
|
class SingularGenerator < Tdc::Generators::ConfigurableGenerator
|
9
|
-
def with_definition(additional_definitions)
|
10
|
-
@additional_definitions = additional_definitions.stringify_keys.reject { |_, v| v == :missing_definition }
|
11
|
-
|
12
|
-
self
|
13
|
-
end
|
14
|
-
|
15
9
|
def generate
|
16
|
-
configure_instance_definition(singular_instance_definition
|
10
|
+
configure_instance_definition(singular_instance_definition)
|
17
11
|
|
18
12
|
run_resolvers_and_generate_instance
|
19
13
|
end
|
20
14
|
|
21
15
|
private
|
22
16
|
|
23
|
-
def additional_definitions
|
24
|
-
@additional_definitions || {}
|
25
|
-
end
|
26
|
-
|
27
17
|
def singular_instance_definition
|
28
18
|
all_instance_definitions = instance_definitions
|
29
19
|
|
data/lib/tdc/version.rb
CHANGED
data/tdc.gemspec
CHANGED
@@ -8,6 +8,7 @@ Gem::Specification.new do |spec|
|
|
8
8
|
|
9
9
|
spec.summary = "A simple framework for creating a Test Data Catalog"
|
10
10
|
spec.homepage = "https://github.com/nulogy/tdc"
|
11
|
+
spec.license = "MIT"
|
11
12
|
|
12
13
|
spec.required_ruby_version = Gem::Requirement.new(">= 2.5.0")
|
13
14
|
|
@@ -31,7 +32,7 @@ Gem::Specification.new do |spec|
|
|
31
32
|
|
32
33
|
spec.add_development_dependency "rake", ">= 12.1", "< 13.1"
|
33
34
|
spec.add_development_dependency "rspec", ">= 3.9", "< 4.0"
|
34
|
-
spec.add_development_dependency "rubocop", "~> 0.
|
35
|
-
spec.add_development_dependency "rubocop-rspec", "~> 1.
|
35
|
+
spec.add_development_dependency "rubocop", "~> 0.88"
|
36
|
+
spec.add_development_dependency "rubocop-rspec", "~> 1.42"
|
36
37
|
spec.add_development_dependency "simplecov", "~> 0.17"
|
37
38
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tdc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alistair McKinnell
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-07
|
11
|
+
date: 2020-08-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -70,28 +70,28 @@ dependencies:
|
|
70
70
|
requirements:
|
71
71
|
- - "~>"
|
72
72
|
- !ruby/object:Gem::Version
|
73
|
-
version: '0.
|
73
|
+
version: '0.88'
|
74
74
|
type: :development
|
75
75
|
prerelease: false
|
76
76
|
version_requirements: !ruby/object:Gem::Requirement
|
77
77
|
requirements:
|
78
78
|
- - "~>"
|
79
79
|
- !ruby/object:Gem::Version
|
80
|
-
version: '0.
|
80
|
+
version: '0.88'
|
81
81
|
- !ruby/object:Gem::Dependency
|
82
82
|
name: rubocop-rspec
|
83
83
|
requirement: !ruby/object:Gem::Requirement
|
84
84
|
requirements:
|
85
85
|
- - "~>"
|
86
86
|
- !ruby/object:Gem::Version
|
87
|
-
version: '1.
|
87
|
+
version: '1.42'
|
88
88
|
type: :development
|
89
89
|
prerelease: false
|
90
90
|
version_requirements: !ruby/object:Gem::Requirement
|
91
91
|
requirements:
|
92
92
|
- - "~>"
|
93
93
|
- !ruby/object:Gem::Version
|
94
|
-
version: '1.
|
94
|
+
version: '1.42'
|
95
95
|
- !ruby/object:Gem::Dependency
|
96
96
|
name: simplecov
|
97
97
|
requirement: !ruby/object:Gem::Requirement
|
@@ -137,6 +137,7 @@ files:
|
|
137
137
|
- lib/tdc/generators/configurable_generator.rb
|
138
138
|
- lib/tdc/generators/definition_resolvable.rb
|
139
139
|
- lib/tdc/generators/definition_sourcable.rb
|
140
|
+
- lib/tdc/generators/generation_context.rb
|
140
141
|
- lib/tdc/generators/generator_base.rb
|
141
142
|
- lib/tdc/generators/singular_generator.rb
|
142
143
|
- lib/tdc/generators/standard_generator.rb
|
@@ -146,7 +147,8 @@ files:
|
|
146
147
|
- lib/tdc/with_indifferent_access_decorator.rb
|
147
148
|
- tdc.gemspec
|
148
149
|
homepage: https://github.com/nulogy/tdc
|
149
|
-
licenses:
|
150
|
+
licenses:
|
151
|
+
- MIT
|
150
152
|
metadata:
|
151
153
|
homepage_uri: https://github.com/nulogy/tdc
|
152
154
|
changelog_uri: https://github.com/nulogy/tdc/blob/master/CHANGELOG.md
|