tdc 0.1.2 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +7 -0
- data/README.md +12 -1
- data/images/Tdc.png +0 -0
- data/lib/tdc.rb +3 -9
- data/lib/tdc/data_definition.rb +14 -0
- data/lib/tdc/{test_data_definition_reader.rb → data_definition_file_reader.rb} +4 -8
- data/lib/tdc/fatal_error.rb +7 -0
- data/lib/tdc/generators/definition_resolvable.rb +1 -1
- data/lib/tdc/generators/generator_base.rb +2 -2
- data/lib/tdc/generators/instance_definition_configurable.rb +1 -1
- data/lib/tdc/generators/singular_generator.rb +1 -1
- data/lib/tdc/in_memory_data_definition.rb +5 -9
- data/lib/tdc/{missing_hook_override_error.rb → missing_override_error.rb} +1 -1
- data/lib/tdc/version.rb +1 -1
- data/lib/tdc/with_indifferent_access_decorator.rb +1 -1
- metadata +6 -9
- data/lib/tdc/decorator_error.rb +0 -3
- data/lib/tdc/missing_path_elements_error.rb +0 -3
- data/lib/tdc/missing_test_data_definition_error.rb +0 -3
- data/lib/tdc/non_singular_instance_error.rb +0 -3
- data/lib/tdc/unresolvable_tag_error.rb +0 -3
- data/lib/tdc/yaml_load_error.rb +0 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9c04de93f4bf48d68994ce4b8adab06f21ebd2f44e3d47ce6f221400cdc8495d
|
4
|
+
data.tar.gz: 93a7c7a9d9dc4ea4480cc464cf6dc7c6526b6e941a68d74de956572e3fe71864
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4986b573ecf8e32558cbfafddba2218a21896f7b01c6197b42bdab1b117cdee729dd3f0cc58fb8907e577223dad3fcd42890a8fedc937e1a9f4280a3be2be224
|
7
|
+
data.tar.gz: 25aad449a81724ff044343015835148683c540ba3080d298841152bca2b5ac79d29557f1b2de17d7e986d1556629c20a542e4360a7ece7c3c6998c3fc5971402
|
data/CHANGELOG.md
CHANGED
@@ -6,6 +6,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
6
6
|
|
7
7
|
## [Unreleased]
|
8
8
|
|
9
|
+
## [0.2.0] - 2020-05-19
|
10
|
+
|
11
|
+
#### Breaking Changes
|
12
|
+
|
13
|
+
- Renamed TestDataDefinitionReader to DataDefinitionFileReader
|
14
|
+
- All errors inherit from Tdc::FatalError
|
15
|
+
|
9
16
|
## [0.1.2] - 2020-05-18
|
10
17
|
|
11
18
|
- Complete the extraction from PackManager
|
data/README.md
CHANGED
@@ -1,2 +1,13 @@
|
|
1
|
-
# TDC: Test Data Catalog
|
1
|
+
# TDC: Test Data Catalog Generation
|
2
2
|
|
3
|
+
![TDC Framelet](/images/Tdc.png)
|
4
|
+
|
5
|
+
**Extension Points**
|
6
|
+
|
7
|
+
Define your own test data generators by inheriting from ```StandardGenerator``` or ```Singular Generator```.
|
8
|
+
|
9
|
+
During generation the test data catalog will be represented by ```CatalogEntries``` that are populated by reading from ```YAML``` files with a ```DataDefinitionReader``` or provided directly by an ```InMemoryDataDefinition```.
|
10
|
+
|
11
|
+
**Data Definition DSL**
|
12
|
+
|
13
|
+
```DefinitionResolvable``` and ```DefinitionSourcable``` provide a DSL that you may use in your generators to work more easily with a ```DataDefinition```.
|
data/images/Tdc.png
ADDED
Binary file
|
data/lib/tdc.rb
CHANGED
@@ -3,8 +3,10 @@ require "ostruct"
|
|
3
3
|
require "active_support/concern"
|
4
4
|
require "active_support/core_ext/hash/indifferent_access"
|
5
5
|
|
6
|
+
require "tdc/data_definition"
|
7
|
+
require "tdc/data_definition_file_reader"
|
8
|
+
require "tdc/fatal_error"
|
6
9
|
require "tdc/in_memory_data_definition"
|
7
|
-
require "tdc/test_data_definition_reader"
|
8
10
|
require "tdc/version"
|
9
11
|
require "tdc/with_indifferent_access_decorator"
|
10
12
|
|
@@ -17,14 +19,6 @@ require "tdc/generators/instance_definition_configurable"
|
|
17
19
|
require "tdc/generators/singular_generator"
|
18
20
|
require "tdc/generators/standard_generator"
|
19
21
|
|
20
|
-
require "tdc/decorator_error"
|
21
|
-
require "tdc/missing_hook_override_error"
|
22
|
-
require "tdc/missing_path_elements_error"
|
23
|
-
require "tdc/missing_test_data_definition_error"
|
24
|
-
require "tdc/non_singular_instance_error"
|
25
|
-
require "tdc/unresolvable_tag_error"
|
26
|
-
require "tdc/yaml_load_error"
|
27
|
-
|
28
22
|
#
|
29
23
|
# A framework for building a Test Data Catalog
|
30
24
|
#
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module Tdc
|
2
|
+
#
|
3
|
+
# Knows how to read data definitions from the specified path elements.
|
4
|
+
#
|
5
|
+
class DataDefinition
|
6
|
+
def read(*_path_elements)
|
7
|
+
raise MissingOverrideError
|
8
|
+
end
|
9
|
+
|
10
|
+
def with_indifferent_access
|
11
|
+
self.extend(Tdc::WithIndifferentAccessDecorator) # rubocop:disable Style/RedundantSelf
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -1,8 +1,8 @@
|
|
1
1
|
module Tdc
|
2
2
|
#
|
3
|
-
# Knows how to read
|
3
|
+
# Knows how to read data definitions from YAML files.
|
4
4
|
#
|
5
|
-
class
|
5
|
+
class DataDefinitionFileReader < Tdc::DataDefinition
|
6
6
|
EMPTY_DEFINITIONS = []
|
7
7
|
|
8
8
|
def initialize(catalog_root_directory)
|
@@ -13,10 +13,6 @@ module Tdc
|
|
13
13
|
data_definition_from(definitions_file(path_elements))
|
14
14
|
end
|
15
15
|
|
16
|
-
def with_indifferent_access
|
17
|
-
self.extend(Tdc::WithIndifferentAccessDecorator) # rubocop:disable Style/RedundantSelf
|
18
|
-
end
|
19
|
-
|
20
16
|
private
|
21
17
|
|
22
18
|
def definitions_file(path_elements)
|
@@ -38,7 +34,7 @@ module Tdc
|
|
38
34
|
def load_yaml(definitions_file)
|
39
35
|
YAML.load(expand_erb(definitions_file)) # rubocop:disable Security/YAMLLoad
|
40
36
|
rescue => e
|
41
|
-
raise Tdc::
|
37
|
+
raise Tdc::FatalError, <<~MSG
|
42
38
|
Unable to load YAML from #{definitions_file}
|
43
39
|
Cause: #{e.message}"
|
44
40
|
MSG
|
@@ -51,7 +47,7 @@ module Tdc
|
|
51
47
|
def missing_data_definition(definitions_file)
|
52
48
|
return EMPTY_DEFINITIONS if ENV.key?("TDC_IGNORE_MISSING_TEST_DATA_DEFINITION_ERROR")
|
53
49
|
|
54
|
-
raise
|
50
|
+
raise Tdc::FatalError, "Missing test definitions file: '#{definitions_file}'"
|
55
51
|
end
|
56
52
|
end
|
57
53
|
end
|
@@ -51,7 +51,7 @@ module Tdc
|
|
51
51
|
unless sourced_object
|
52
52
|
message = "Could not find a tag reference for '#{key}' in the catalog entries provided."
|
53
53
|
|
54
|
-
raise Tdc::
|
54
|
+
raise Tdc::FatalError, message
|
55
55
|
end
|
56
56
|
|
57
57
|
# Replace the tag value with the sourced object.
|
@@ -32,7 +32,7 @@ module Tdc
|
|
32
32
|
all_instance_definitions = instance_definitions
|
33
33
|
|
34
34
|
if all_instance_definitions.many?
|
35
|
-
raise Tdc::
|
35
|
+
raise Tdc::FatalError, "For the moment we only generate a single model instance"
|
36
36
|
end
|
37
37
|
|
38
38
|
# Delete the tag so that the models do not need to filter it out.
|
@@ -1,24 +1,20 @@
|
|
1
1
|
module Tdc
|
2
2
|
#
|
3
|
-
# Knows how to read
|
3
|
+
# Knows how to read data definitions from an in-memory representation.
|
4
4
|
#
|
5
|
-
class InMemoryDataDefinition
|
5
|
+
class InMemoryDataDefinition < Tdc::DataDefinition
|
6
6
|
def initialize(path_elements_data = {})
|
7
7
|
@store = path_elements_data
|
8
8
|
end
|
9
9
|
|
10
|
-
def store(path_elements, data)
|
11
|
-
@store[path_elements] = data
|
12
|
-
end
|
13
|
-
|
14
10
|
def read(*path_elements)
|
15
11
|
@store.fetch(path_elements) do
|
16
|
-
raise
|
12
|
+
raise Tdc::FatalError, "The path did not have any data associated with it: #{path_elements.inspect}"
|
17
13
|
end
|
18
14
|
end
|
19
15
|
|
20
|
-
def
|
21
|
-
|
16
|
+
def store(path_elements, data)
|
17
|
+
@store[path_elements] = data
|
22
18
|
end
|
23
19
|
end
|
24
20
|
end
|
data/lib/tdc/version.rb
CHANGED
@@ -7,7 +7,7 @@ module Tdc
|
|
7
7
|
def read(*path_elements)
|
8
8
|
definitions = super
|
9
9
|
|
10
|
-
raise
|
10
|
+
raise Tdc::FatalError, "Use 'with_indifferent_access' only for an Array" unless definitions.is_a?(Array)
|
11
11
|
|
12
12
|
definitions.map do |definition|
|
13
13
|
definition.is_a?(Hash) ? ActiveSupport::HashWithIndifferentAccess.new(definition) : definition
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tdc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alistair McKinnell
|
@@ -123,8 +123,11 @@ files:
|
|
123
123
|
- Rakefile
|
124
124
|
- bin/console
|
125
125
|
- bin/setup
|
126
|
+
- images/Tdc.png
|
126
127
|
- lib/tdc.rb
|
127
|
-
- lib/tdc/
|
128
|
+
- lib/tdc/data_definition.rb
|
129
|
+
- lib/tdc/data_definition_file_reader.rb
|
130
|
+
- lib/tdc/fatal_error.rb
|
128
131
|
- lib/tdc/generators.rb
|
129
132
|
- lib/tdc/generators/catalog_entries.rb
|
130
133
|
- lib/tdc/generators/definition_resolvable.rb
|
@@ -134,15 +137,9 @@ files:
|
|
134
137
|
- lib/tdc/generators/singular_generator.rb
|
135
138
|
- lib/tdc/generators/standard_generator.rb
|
136
139
|
- lib/tdc/in_memory_data_definition.rb
|
137
|
-
- lib/tdc/
|
138
|
-
- lib/tdc/missing_path_elements_error.rb
|
139
|
-
- lib/tdc/missing_test_data_definition_error.rb
|
140
|
-
- lib/tdc/non_singular_instance_error.rb
|
141
|
-
- lib/tdc/test_data_definition_reader.rb
|
142
|
-
- lib/tdc/unresolvable_tag_error.rb
|
140
|
+
- lib/tdc/missing_override_error.rb
|
143
141
|
- lib/tdc/version.rb
|
144
142
|
- lib/tdc/with_indifferent_access_decorator.rb
|
145
|
-
- lib/tdc/yaml_load_error.rb
|
146
143
|
- tdc.gemspec
|
147
144
|
homepage: https://github.com/nulogy/tdc
|
148
145
|
licenses: []
|
data/lib/tdc/decorator_error.rb
DELETED
data/lib/tdc/yaml_load_error.rb
DELETED