tdc 0.3.1 → 0.3.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +9 -6
- data/CHANGELOG.md +30 -2
- data/README.md +1 -1
- data/images/Tdc.png +0 -0
- data/lib/tdc.rb +1 -1
- 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/generation_context.rb +15 -0
- data/lib/tdc/generators/generator_base.rb +6 -4
- data/lib/tdc/version.rb +1 -1
- data/tdc.gemspec +1 -0
- metadata +5 -4
- 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: afd309b8d6f641f50856a6ab71c6557dceba91c43e97c6d23a54f526cc954570
|
4
|
+
data.tar.gz: c730e903a12d47f4a8dc452a212ae9f38f75a4d2b61a74dd72237e69f0005d47
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f699b62e54e48f3b42bb06215a8e783ca15797265292e988f70f4cbc82191aa55174ccfbcdf1bb50b58ccb1323716272d7d958283b49eac45dbb1c948208f616
|
7
|
+
data.tar.gz: 7496da7a34c508a1b132a5232f1c061eded18b8b5057192728be98b3faae095b3c3e1dd377b2563fde95f897861bcedb932bf867c8f20c4e3f09621af18cf52d
|
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
|
@@ -26,7 +29,6 @@ Lint/DuplicateElsifCondition:
|
|
26
29
|
Lint/MixedRegexpCaptureTypes:
|
27
30
|
Enabled: true
|
28
31
|
|
29
|
-
|
30
32
|
Lint/RaiseException:
|
31
33
|
Enabled: true
|
32
34
|
|
@@ -45,9 +47,6 @@ RSpec/AnyInstance:
|
|
45
47
|
RSpec/ExampleLength:
|
46
48
|
Max: 15
|
47
49
|
|
48
|
-
Metrics/LineLength:
|
49
|
-
Max: 120
|
50
|
-
|
51
50
|
RSpec/DescribeClass:
|
52
51
|
Enabled: false
|
53
52
|
|
@@ -121,6 +120,10 @@ Style/HashSyntax:
|
|
121
120
|
Exclude:
|
122
121
|
- 'Rakefile'
|
123
122
|
|
123
|
+
# We are not going to optimize by freezing strings.
|
124
|
+
Style/MutableConstant:
|
125
|
+
Enabled: false
|
126
|
+
|
124
127
|
Style/RedundantAssignment:
|
125
128
|
Enabled: true
|
126
129
|
|
@@ -151,6 +154,6 @@ Style/StringLiterals:
|
|
151
154
|
Style/SymbolArray:
|
152
155
|
Enabled: false
|
153
156
|
|
154
|
-
#
|
155
|
-
Style/
|
157
|
+
# I prefer not to use %w or %W for an array of words.
|
158
|
+
Style/WordArray:
|
156
159
|
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] - 2020-08-06
|
10
|
+
|
11
|
+
#### Breaking Changes
|
12
|
+
|
13
|
+
- Drop the `SingularGenerator` abstraction
|
14
|
+
|
15
|
+
## [0.3.5] - 2020-08-06
|
16
|
+
|
17
|
+
- Add the `single_entry` method to `CatalogEntries`
|
18
|
+
|
19
|
+
#### Breaking Changes
|
20
|
+
|
21
|
+
- Drop the `with_definition` method from `SingularGenerator`
|
22
|
+
|
23
|
+
## [0.3.4] - 2020-08-05
|
24
|
+
|
25
|
+
#### Breaking Changes
|
26
|
+
|
27
|
+
- Introduce the `GenerationContext` abstraction
|
28
|
+
- All generators are initialized with an instance of `Tdc::Generators::GenerationContext`
|
29
|
+
|
30
|
+
## [0.3.3] - 2020-08-04
|
31
|
+
|
32
|
+
- Add the `empty?` method to `CatalogEntries`
|
33
|
+
- Evaluate `_atx` attribute values against a `Time.zone` instance
|
34
|
+
|
35
|
+
## [0.3.2] - 2020-07-27
|
36
|
+
|
37
|
+
- Return `self` from `DefinitionResolver#configure_current_catalog` to make it chainable
|
38
|
+
|
9
39
|
## [0.3.1] - 2020-07-25
|
10
40
|
|
11
41
|
- Support DefinitionResolver instance registration
|
@@ -46,5 +76,3 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
46
76
|
#### New Features
|
47
77
|
|
48
78
|
- Avoid all PackManager dependencies
|
49
|
-
|
50
|
-
|
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,7 @@ require "tdc/with_indifferent_access_decorator"
|
|
19
19
|
|
20
20
|
# Generators
|
21
21
|
require "tdc/generators"
|
22
|
+
require "tdc/generators/generation_context"
|
22
23
|
|
23
24
|
# Current Catalog
|
24
25
|
require "tdc/generators/catalog_entries"
|
@@ -30,7 +31,6 @@ require "tdc/generators/definition_sourcable"
|
|
30
31
|
# Generator Hierarchy
|
31
32
|
require "tdc/generators/generator_base"
|
32
33
|
require "tdc/generators/configurable_generator"
|
33
|
-
require "tdc/generators/singular_generator"
|
34
34
|
require "tdc/generators/standard_generator"
|
35
35
|
|
36
36
|
# Definition Resolvers
|
@@ -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
|
@@ -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
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
|
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
|
@@ -137,8 +137,8 @@ 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
|
-
- lib/tdc/generators/singular_generator.rb
|
142
142
|
- lib/tdc/generators/standard_generator.rb
|
143
143
|
- lib/tdc/in_memory_data_definition.rb
|
144
144
|
- lib/tdc/missing_override_error.rb
|
@@ -146,7 +146,8 @@ files:
|
|
146
146
|
- lib/tdc/with_indifferent_access_decorator.rb
|
147
147
|
- tdc.gemspec
|
148
148
|
homepage: https://github.com/nulogy/tdc
|
149
|
-
licenses:
|
149
|
+
licenses:
|
150
|
+
- MIT
|
150
151
|
metadata:
|
151
152
|
homepage_uri: https://github.com/nulogy/tdc
|
152
153
|
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
|