tdc 0.2.2 → 0.2.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +3 -0
- data/CHANGELOG.md +4 -0
- data/images/Tdc.png +0 -0
- data/lib/tdc.rb +17 -5
- data/lib/tdc/generators/{instance_definition_configurable.rb → configurable_generator.rb} +12 -15
- data/lib/tdc/generators/definition_sourcable.rb +2 -2
- data/lib/tdc/generators/singular_generator.rb +2 -4
- data/lib/tdc/generators/standard_generator.rb +1 -3
- data/lib/tdc/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3ea4c40daa383ebc80a1109132a3a8ded7bb6f89a77cb49b928bed2db838fbf6
|
4
|
+
data.tar.gz: fda5f7f22c87bcb36a7b4c072ad85809bb1f1f78e7bb621396fa746511c34dd0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d085e28662d3038b7609fb58d7e8b50fceca95a624cc9d0192b27d803f31bbaa1fff87996a93500a91557a8c45fc1b5adad26f4f6b6fe4dbf7bffafb11782640
|
7
|
+
data.tar.gz: 1ae1baacafb85ec5fbc8ed58d7f2de790cf68b75fa84461712f0b7e3cbf7f361335005cfdb8c23dd8e3c39576bdc496aa27b9272ef059f54ef2fb8f6f9638a73
|
data/.rubocop.yml
CHANGED
data/CHANGELOG.md
CHANGED
data/images/Tdc.png
CHANGED
Binary file
|
data/lib/tdc.rb
CHANGED
@@ -1,23 +1,35 @@
|
|
1
1
|
require "ostruct"
|
2
2
|
require "yaml"
|
3
3
|
|
4
|
+
require "active_support"
|
4
5
|
require "active_support/concern"
|
5
|
-
require "active_support/core_ext
|
6
|
+
require "active_support/core_ext"
|
6
7
|
|
8
|
+
require "tdc/version"
|
9
|
+
|
10
|
+
# Errors
|
11
|
+
require "tdc/fatal_error"
|
12
|
+
require "tdc/missing_override_error"
|
13
|
+
|
14
|
+
# Data Definition Hierarchy
|
7
15
|
require "tdc/data_definition"
|
8
16
|
require "tdc/data_definition_file_reader"
|
9
|
-
require "tdc/fatal_error"
|
10
17
|
require "tdc/in_memory_data_definition"
|
11
|
-
require "tdc/missing_override_error"
|
12
|
-
require "tdc/version"
|
13
18
|
require "tdc/with_indifferent_access_decorator"
|
14
19
|
|
20
|
+
# Generators
|
15
21
|
require "tdc/generators"
|
22
|
+
|
23
|
+
# Current Catalog
|
16
24
|
require "tdc/generators/catalog_entries"
|
25
|
+
|
26
|
+
# Concerns
|
17
27
|
require "tdc/generators/definition_resolvable"
|
18
28
|
require "tdc/generators/definition_sourcable"
|
29
|
+
|
30
|
+
# Generator Hierarchy
|
19
31
|
require "tdc/generators/generator_base"
|
20
|
-
require "tdc/generators/
|
32
|
+
require "tdc/generators/configurable_generator"
|
21
33
|
require "tdc/generators/singular_generator"
|
22
34
|
require "tdc/generators/standard_generator"
|
23
35
|
|
@@ -5,23 +5,12 @@ module Tdc
|
|
5
5
|
#
|
6
6
|
# Shared implementation between the StandardGenerator and the SingularGenerator abstract classes.
|
7
7
|
#
|
8
|
-
|
9
|
-
|
8
|
+
class ConfigurableGenerator < Tdc::Generators::GeneratorBase
|
9
|
+
include Tdc::Generators::DefinitionSourcable
|
10
10
|
|
11
|
-
|
12
|
-
include Tdc::Generators::DefinitionSourcable
|
11
|
+
attr_reader :instance_definition
|
13
12
|
|
14
|
-
|
15
|
-
|
16
|
-
source_definition_from :instance_definition
|
17
|
-
end
|
18
|
-
|
19
|
-
private
|
20
|
-
|
21
|
-
def configure_instance_definition(instance_definition)
|
22
|
-
@instance_definition = instance_definition
|
23
|
-
configure_definition_source(instance_definition)
|
24
|
-
end
|
13
|
+
source_definition_from :instance_definition
|
25
14
|
|
26
15
|
def run_resolvers_and_generate_instance
|
27
16
|
run_atx_resolvers(instance_definition)
|
@@ -44,6 +33,14 @@ module Tdc
|
|
44
33
|
# Do nothing
|
45
34
|
end
|
46
35
|
|
36
|
+
private
|
37
|
+
|
38
|
+
def configure_instance_definition(instance_definition)
|
39
|
+
@instance_definition = instance_definition
|
40
|
+
|
41
|
+
configure_definition_source(instance_definition)
|
42
|
+
end
|
43
|
+
|
47
44
|
def run_atx_resolvers(instance_definition)
|
48
45
|
atx_definitions = instance_definition.select { |k, _v| /_atx$/ =~ k }
|
49
46
|
|
@@ -35,13 +35,13 @@ module Tdc
|
|
35
35
|
def method_missing(method, *args)
|
36
36
|
key = transform_method_to_definition_source_key(method)
|
37
37
|
|
38
|
-
definition_source
|
38
|
+
definition_source&.key?(key) ? definition_source.fetch(key) : super
|
39
39
|
end
|
40
40
|
|
41
41
|
def respond_to_missing?(method, include_all = false)
|
42
42
|
key = transform_method_to_definition_source_key(method)
|
43
43
|
|
44
|
-
definition_source
|
44
|
+
definition_source&.key?(key) ? true : super
|
45
45
|
end
|
46
46
|
|
47
47
|
def transform_method_to_definition_source_key(method)
|
@@ -5,9 +5,7 @@ module Tdc
|
|
5
5
|
#
|
6
6
|
# See also StandardGenerator.
|
7
7
|
#
|
8
|
-
class SingularGenerator < Tdc::Generators::
|
9
|
-
include Tdc::Generators::InstanceDefinitionConfigurable
|
10
|
-
|
8
|
+
class SingularGenerator < Tdc::Generators::ConfigurableGenerator
|
11
9
|
def initialize(data_definition, current_catalog)
|
12
10
|
super
|
13
11
|
|
@@ -32,7 +30,7 @@ module Tdc
|
|
32
30
|
all_instance_definitions = instance_definitions
|
33
31
|
|
34
32
|
if all_instance_definitions.many?
|
35
|
-
raise Tdc::FatalError, "
|
33
|
+
raise Tdc::FatalError, "A singular generator only generates a single model instance"
|
36
34
|
end
|
37
35
|
|
38
36
|
# Delete the tag so that the models do not need to filter it out.
|
@@ -5,9 +5,7 @@ module Tdc
|
|
5
5
|
#
|
6
6
|
# See also SingularGenerator.
|
7
7
|
#
|
8
|
-
class StandardGenerator < Tdc::Generators::
|
9
|
-
include Tdc::Generators::InstanceDefinitionConfigurable
|
10
|
-
|
8
|
+
class StandardGenerator < Tdc::Generators::ConfigurableGenerator
|
11
9
|
def generate
|
12
10
|
CatalogEntries.new.tap do |catalog_entries|
|
13
11
|
instance_definitions.each do |instance_definition|
|
data/lib/tdc/version.rb
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.2.
|
4
|
+
version: 0.2.3
|
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-05-
|
11
|
+
date: 2020-05-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -131,10 +131,10 @@ files:
|
|
131
131
|
- lib/tdc/fatal_error.rb
|
132
132
|
- lib/tdc/generators.rb
|
133
133
|
- lib/tdc/generators/catalog_entries.rb
|
134
|
+
- lib/tdc/generators/configurable_generator.rb
|
134
135
|
- lib/tdc/generators/definition_resolvable.rb
|
135
136
|
- lib/tdc/generators/definition_sourcable.rb
|
136
137
|
- lib/tdc/generators/generator_base.rb
|
137
|
-
- lib/tdc/generators/instance_definition_configurable.rb
|
138
138
|
- lib/tdc/generators/singular_generator.rb
|
139
139
|
- lib/tdc/generators/standard_generator.rb
|
140
140
|
- lib/tdc/in_memory_data_definition.rb
|