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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: '047929ba6cb08c87ebab328779a9ad41c9860ad953ebe559f5d47bbc1d7ef53b'
4
- data.tar.gz: 83864de78f6680541319688a7a3e9a523dea3e87f5eeb6c2b234114c954842b3
3
+ metadata.gz: 3ea4c40daa383ebc80a1109132a3a8ded7bb6f89a77cb49b928bed2db838fbf6
4
+ data.tar.gz: fda5f7f22c87bcb36a7b4c072ad85809bb1f1f78e7bb621396fa746511c34dd0
5
5
  SHA512:
6
- metadata.gz: fd7913a43b6ca6c179b2b8b839db1f744a89bfe1cd563347290633e79bd46bb5ed58597da994ffd70e6245f68b8313490a1624769150561f80b359a93516255e
7
- data.tar.gz: 45d2f32e3030bd93bf1ddb3665bb1e6491849bcb3ebaf9b7bf32caddd4df3ec76f8289519a92abc83842ad86ea173d25d4d7aaa5709723011c566b2d4063748f
6
+ metadata.gz: d085e28662d3038b7609fb58d7e8b50fceca95a624cc9d0192b27d803f31bbaa1fff87996a93500a91557a8c45fc1b5adad26f4f6b6fe4dbf7bffafb11782640
7
+ data.tar.gz: 1ae1baacafb85ec5fbc8ed58d7f2de790cf68b75fa84461712f0b7e3cbf7f361335005cfdb8c23dd8e3c39576bdc496aa27b9272ef059f54ef2fb8f6f9638a73
data/.rubocop.yml CHANGED
@@ -68,6 +68,9 @@ Style/BlockDelimiters:
68
68
  Style/Documentation:
69
69
  Enabled: false
70
70
 
71
+ Style/EmptyMethod:
72
+ EnforcedStyle: expanded
73
+
71
74
  Style/ExponentialNotation:
72
75
  Enabled: true
73
76
 
data/CHANGELOG.md CHANGED
@@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
+ ## [0.2.3] - 2020-05-21
10
+
11
+ - Update the diagram in the README
12
+
9
13
  ## [0.2.2] - 2020-05-20
10
14
 
11
15
  - Adding specs
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/hash/indifferent_access"
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/instance_definition_configurable"
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
- module InstanceDefinitionConfigurable
9
- extend ActiveSupport::Concern
8
+ class ConfigurableGenerator < Tdc::Generators::GeneratorBase
9
+ include Tdc::Generators::DefinitionSourcable
10
10
 
11
- included do
12
- include Tdc::Generators::DefinitionSourcable
11
+ attr_reader :instance_definition
13
12
 
14
- attr_reader :instance_definition
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.key?(key) ? definition_source.fetch(key) : super
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.key?(key) ? true : super
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::GeneratorBase
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, "For the moment we only generate a single model instance"
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::GeneratorBase
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
@@ -1,3 +1,3 @@
1
1
  module Tdc
2
- VERSION = "0.2.2"
2
+ VERSION = "0.2.3"
3
3
  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.2.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-20 00:00:00.000000000 Z
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