tdc 0.3.2 → 0.3.6.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 +4 -4
- data/.rubocop.yml +9 -71
- data/CHANGELOG.md +30 -2
- data/README.md +1 -1
- data/images/Tdc.png +0 -0
- data/lib/tdc.rb +2 -1
- data/lib/tdc/data_definition_file_reader.rb +2 -0
- data/lib/tdc/definition_resolvers/tag_resolver.rb +2 -0
- data/lib/tdc/generators/atx_context_factory.rb +16 -0
- data/lib/tdc/generators/catalog_entries.rb +10 -0
- data/lib/tdc/generators/configurable_generator.rb +5 -3
- data/lib/tdc/generators/definition_sourcable.rb +1 -1
- data/lib/tdc/generators/generation_context.rb +15 -0
- data/lib/tdc/generators/generator_base.rb +6 -4
- data/lib/tdc/in_memory_data_definition.rb +2 -0
- data/lib/tdc/version.rb +1 -1
- data/tdc.gemspec +2 -1
- metadata +8 -6
- data/lib/tdc/generators/singular_generator.rb +0 -39
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4a9bab09cb1cb215daa94f3e53b950fd09f1baa059a3c6c8cddf47abd3fd95a7
|
4
|
+
data.tar.gz: 2bfccac38422fc897d0c2208e0d5853f0a4adf13074c9da93262476d09007cf1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 41e0866b7801d672791f6ea28d6878072f009aa31281d06889a2782c38464d79e2e2f3fd175d45cc9dbe9867491e07811fc58d1dffa0c1a1cd3c37d15f77c004
|
7
|
+
data.tar.gz: 63588b60c890b674dd4541e10b848f97108d7244f63cce86fcbb26f7daf5b25689791f436fa10aa3545604cfdbca1422d1c61cf90d4cff7804ec726b1c50aec0
|
data/.rubocop.yml
CHANGED
@@ -2,37 +2,19 @@ require:
|
|
2
2
|
- rubocop-rspec
|
3
3
|
|
4
4
|
AllCops:
|
5
|
-
|
5
|
+
NewCops: enable
|
6
|
+
TargetRubyVersion: 2.6
|
6
7
|
|
7
8
|
Exclude:
|
8
9
|
- 'bin/**/*'
|
9
10
|
|
10
|
-
Layout/
|
11
|
-
|
11
|
+
Layout/LineLength:
|
12
|
+
Max: 120
|
12
13
|
|
13
14
|
# Rubocop and I cannot agree.
|
14
15
|
Layout/MultilineMethodCallBraceLayout:
|
15
16
|
Enabled: false
|
16
17
|
|
17
|
-
Layout/SpaceAroundMethodCallOperator:
|
18
|
-
Enabled: true
|
19
|
-
|
20
|
-
Lint/DeprecatedOpenSSLConstant:
|
21
|
-
Enabled: true
|
22
|
-
|
23
|
-
Lint/DuplicateElsifCondition:
|
24
|
-
Enabled: true
|
25
|
-
|
26
|
-
Lint/MixedRegexpCaptureTypes:
|
27
|
-
Enabled: true
|
28
|
-
|
29
|
-
|
30
|
-
Lint/RaiseException:
|
31
|
-
Enabled: true
|
32
|
-
|
33
|
-
Lint/StructNewOverride:
|
34
|
-
Enabled: true
|
35
|
-
|
36
18
|
Metrics/BlockLength:
|
37
19
|
Enabled: false
|
38
20
|
|
@@ -45,9 +27,6 @@ RSpec/AnyInstance:
|
|
45
27
|
RSpec/ExampleLength:
|
46
28
|
Max: 15
|
47
29
|
|
48
|
-
Metrics/LineLength:
|
49
|
-
Max: 120
|
50
|
-
|
51
30
|
RSpec/DescribeClass:
|
52
31
|
Enabled: false
|
53
32
|
|
@@ -69,15 +48,6 @@ RSpec/MultipleExpectations:
|
|
69
48
|
RSpec/SubjectStub:
|
70
49
|
Enabled: false
|
71
50
|
|
72
|
-
Style/AccessorGrouping:
|
73
|
-
Enabled: true
|
74
|
-
|
75
|
-
Style/ArrayCoercion:
|
76
|
-
Enabled: true
|
77
|
-
|
78
|
-
Style/BisectedAttrAccessor:
|
79
|
-
Enabled: true
|
80
|
-
|
81
51
|
Style/BlockDelimiters:
|
82
52
|
Enabled: true
|
83
53
|
EnforcedStyle: line_count_based
|
@@ -85,56 +55,24 @@ Style/BlockDelimiters:
|
|
85
55
|
- 'let'
|
86
56
|
- 'subject'
|
87
57
|
|
88
|
-
Style/CaseLikeIf:
|
89
|
-
Enabled: true
|
90
|
-
|
91
58
|
Style/Documentation:
|
92
59
|
Enabled: false
|
93
60
|
|
94
61
|
Style/EmptyMethod:
|
95
62
|
EnforcedStyle: expanded
|
96
63
|
|
97
|
-
Style/ExponentialNotation:
|
98
|
-
Enabled: true
|
99
|
-
|
100
64
|
# We can ignore this small performance improvement.
|
101
65
|
Style/FrozenStringLiteralComment:
|
102
66
|
Enabled: false
|
103
67
|
|
104
|
-
Style/HashAsLastArrayItem:
|
105
|
-
Enabled: true
|
106
|
-
|
107
|
-
Style/HashEachMethods:
|
108
|
-
Enabled: true
|
109
|
-
|
110
|
-
Style/HashLikeCase:
|
111
|
-
Enabled: true
|
112
|
-
|
113
|
-
Style/HashTransformKeys:
|
114
|
-
Enabled: true
|
115
|
-
|
116
|
-
Style/HashTransformValues:
|
117
|
-
Enabled: true
|
118
|
-
|
119
68
|
# We like to use the hash rocket in rake files.
|
120
69
|
Style/HashSyntax:
|
121
70
|
Exclude:
|
122
71
|
- 'Rakefile'
|
123
72
|
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
Style/RedundantFetchBlock:
|
128
|
-
Enabled: true
|
129
|
-
|
130
|
-
Style/RedundantFileExtensionInRequire:
|
131
|
-
Enabled: true
|
132
|
-
|
133
|
-
Style/RedundantRegexpCharacterClass:
|
134
|
-
Enabled: true
|
135
|
-
|
136
|
-
Style/RedundantRegexpEscape:
|
137
|
-
Enabled: true
|
73
|
+
# We are not going to optimize by freezing strings.
|
74
|
+
Style/MutableConstant:
|
75
|
+
Enabled: false
|
138
76
|
|
139
77
|
# No need to mention StandardError.
|
140
78
|
Style/RescueStandardError:
|
@@ -151,6 +89,6 @@ Style/StringLiterals:
|
|
151
89
|
Style/SymbolArray:
|
152
90
|
Enabled: false
|
153
91
|
|
154
|
-
#
|
155
|
-
Style/
|
92
|
+
# I prefer not to use %w or %W for an array of words.
|
93
|
+
Style/WordArray:
|
156
94
|
Enabled: false
|
data/CHANGELOG.md
CHANGED
@@ -6,6 +6,36 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
6
6
|
|
7
7
|
## [Unreleased]
|
8
8
|
|
9
|
+
## [0.3.6.1] - 2020-08-10
|
10
|
+
|
11
|
+
- Add the AtxContextFactory abstraction
|
12
|
+
|
13
|
+
## [0.3.6] - 2020-08-06
|
14
|
+
|
15
|
+
#### Breaking Changes
|
16
|
+
|
17
|
+
- Drop the `SingularGenerator` abstraction
|
18
|
+
|
19
|
+
## [0.3.5] - 2020-08-06
|
20
|
+
|
21
|
+
- Add the `single_entry` method to `CatalogEntries`
|
22
|
+
|
23
|
+
#### Breaking Changes
|
24
|
+
|
25
|
+
- Drop the `with_definition` method from `SingularGenerator`
|
26
|
+
|
27
|
+
## [0.3.4] - 2020-08-05
|
28
|
+
|
29
|
+
#### Breaking Changes
|
30
|
+
|
31
|
+
- Introduce the `GenerationContext` abstraction
|
32
|
+
- All generators are initialized with an instance of `Tdc::Generators::GenerationContext`
|
33
|
+
|
34
|
+
## [0.3.3] - 2020-08-04
|
35
|
+
|
36
|
+
- Add the `empty?` method to `CatalogEntries`
|
37
|
+
- Evaluate `_atx` attribute values against a `Time.zone` instance
|
38
|
+
|
9
39
|
## [0.3.2] - 2020-07-27
|
10
40
|
|
11
41
|
- Return `self` from `DefinitionResolver#configure_current_catalog` to make it chainable
|
@@ -50,5 +80,3 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
50
80
|
#### New Features
|
51
81
|
|
52
82
|
- Avoid all PackManager dependencies
|
53
|
-
|
54
|
-
|
data/README.md
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
|
5
5
|
**Extension Points**
|
6
6
|
|
7
|
-
Define your own test data generators by inheriting from ```StandardGenerator
|
7
|
+
Define your own test data generators by inheriting from ```StandardGenerator```. Best practice is to define an ```ApplicationStandardGenerator``` and have all other generators inherit from it.
|
8
8
|
|
9
9
|
Define your own definition resolvers by inheriting from ```DefinitionResolver```. Best practice is to define an ```ApplicationDefinitionResolver``` and all other definition resolvers inherit from it.
|
10
10
|
|
data/images/Tdc.png
CHANGED
Binary file
|
data/lib/tdc.rb
CHANGED
@@ -19,6 +19,8 @@ require "tdc/with_indifferent_access_decorator"
|
|
19
19
|
|
20
20
|
# Generators
|
21
21
|
require "tdc/generators"
|
22
|
+
require "tdc/generators/atx_context_factory"
|
23
|
+
require "tdc/generators/generation_context"
|
22
24
|
|
23
25
|
# Current Catalog
|
24
26
|
require "tdc/generators/catalog_entries"
|
@@ -30,7 +32,6 @@ require "tdc/generators/definition_sourcable"
|
|
30
32
|
# Generator Hierarchy
|
31
33
|
require "tdc/generators/generator_base"
|
32
34
|
require "tdc/generators/configurable_generator"
|
33
|
-
require "tdc/generators/singular_generator"
|
34
35
|
require "tdc/generators/standard_generator"
|
35
36
|
|
36
37
|
# Definition Resolvers
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Tdc
|
2
|
+
module Generators
|
3
|
+
#
|
4
|
+
# Knows a class instance that supplies the instance_eval context for interpreting _atx attribute values.
|
5
|
+
#
|
6
|
+
class AtxContextFactory
|
7
|
+
include Singleton
|
8
|
+
|
9
|
+
attr_reader :context
|
10
|
+
|
11
|
+
def initialize
|
12
|
+
@context = Time.zone
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -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
|
@@ -3,8 +3,6 @@ module Tdc
|
|
3
3
|
#
|
4
4
|
# Knows how to provide a configurable instance definition.
|
5
5
|
#
|
6
|
-
# Shared implementation between the StandardGenerator and the SingularGenerator abstract classes.
|
7
|
-
#
|
8
6
|
class ConfigurableGenerator < Tdc::Generators::GeneratorBase
|
9
7
|
include Tdc::Generators::DefinitionSourcable
|
10
8
|
|
@@ -49,9 +47,13 @@ module Tdc
|
|
49
47
|
instance_definition.delete(k)
|
50
48
|
|
51
49
|
# Add a standard _at attribute.
|
52
|
-
instance_definition[k.delete_suffix("x")] =
|
50
|
+
instance_definition[k.delete_suffix("x")] = atx_context.instance_eval(v)
|
53
51
|
end
|
54
52
|
end
|
53
|
+
|
54
|
+
def atx_context
|
55
|
+
Tdc::Generators::AtxContextFactory.instance.context
|
56
|
+
end
|
55
57
|
end
|
56
58
|
end
|
57
59
|
end
|
@@ -38,7 +38,7 @@ module Tdc
|
|
38
38
|
definition_source&.key?(key) ? definition_source.fetch(key) : super
|
39
39
|
end
|
40
40
|
|
41
|
-
def respond_to_missing?(method, include_all = false)
|
41
|
+
def respond_to_missing?(method, include_all = false) # rubocop:disable Style/OptionalBooleanParameter
|
42
42
|
key = transform_method_to_definition_source_key(method)
|
43
43
|
|
44
44
|
definition_source&.key?(key) ? true : super
|
@@ -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
|
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", "~> 0.89"
|
35
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.6.1
|
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-
|
11
|
+
date: 2020-08-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -70,14 +70,14 @@ dependencies:
|
|
70
70
|
requirements:
|
71
71
|
- - "~>"
|
72
72
|
- !ruby/object:Gem::Version
|
73
|
-
version: '0.
|
73
|
+
version: '0.89'
|
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.89'
|
81
81
|
- !ruby/object:Gem::Dependency
|
82
82
|
name: rubocop-rspec
|
83
83
|
requirement: !ruby/object:Gem::Requirement
|
@@ -133,12 +133,13 @@ files:
|
|
133
133
|
- lib/tdc/definition_resolvers/tag_resolver.rb
|
134
134
|
- lib/tdc/fatal_error.rb
|
135
135
|
- lib/tdc/generators.rb
|
136
|
+
- lib/tdc/generators/atx_context_factory.rb
|
136
137
|
- lib/tdc/generators/catalog_entries.rb
|
137
138
|
- lib/tdc/generators/configurable_generator.rb
|
138
139
|
- lib/tdc/generators/definition_resolvable.rb
|
139
140
|
- lib/tdc/generators/definition_sourcable.rb
|
141
|
+
- lib/tdc/generators/generation_context.rb
|
140
142
|
- lib/tdc/generators/generator_base.rb
|
141
|
-
- lib/tdc/generators/singular_generator.rb
|
142
143
|
- lib/tdc/generators/standard_generator.rb
|
143
144
|
- lib/tdc/in_memory_data_definition.rb
|
144
145
|
- lib/tdc/missing_override_error.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
|
@@ -1,39 +0,0 @@
|
|
1
|
-
module Tdc
|
2
|
-
module Generators
|
3
|
-
#
|
4
|
-
# Abstract class for defining generators that define a single model instance.
|
5
|
-
#
|
6
|
-
# See also StandardGenerator.
|
7
|
-
#
|
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
|
-
def generate
|
16
|
-
configure_instance_definition(singular_instance_definition.merge(additional_definitions))
|
17
|
-
|
18
|
-
run_resolvers_and_generate_instance
|
19
|
-
end
|
20
|
-
|
21
|
-
private
|
22
|
-
|
23
|
-
def additional_definitions
|
24
|
-
@additional_definitions || {}
|
25
|
-
end
|
26
|
-
|
27
|
-
def singular_instance_definition
|
28
|
-
all_instance_definitions = instance_definitions
|
29
|
-
|
30
|
-
if all_instance_definitions.many?
|
31
|
-
raise Tdc::FatalError, "A singular generator only generates a single model instance"
|
32
|
-
end
|
33
|
-
|
34
|
-
# Delete the tag so that the models do not need to filter it out.
|
35
|
-
all_instance_definitions.first.except("tag")
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|