rggen-core 0.15.0 → 0.16.0

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: ec4c2a7ada4a8af68c0969d9c13ef4b54ff80f176720a88fb52b03d2ad92fbba
4
- data.tar.gz: 807e8ca8ef6593a44de7f033ddb9ffdbf277715c94cda70ba65556842f39f55c
3
+ metadata.gz: 0510741051f873be7dc827047f0de66a99c8597f012c4115b856b5c33080a55d
4
+ data.tar.gz: 6acbc096d450278f19c03e4fad095d1a181fa8ae3dbe11e1fcd7e8bde0f11e16
5
5
  SHA512:
6
- metadata.gz: 400ddb69015ddc339db84803976e8bbf5e427bc76014288cfb577ef4f817b16dee8ccf529a89371562169d79582092e7a5b96ac1e9dec903c89877890d0fb6da
7
- data.tar.gz: 95e434257b80b8b27204e6fcb9f366413847f47b5fef71972fbe47fcf8e905f0006dab15a6e9729e1c6f198ca8b0ee3ef96c4e5fab71ad5b91c9618685d511fa
6
+ metadata.gz: caf9bacb6b71be870d48a03afc67ff9f35516289e331b4cc8231ee1ed94f9bb3444001b496f9a508de5c2e9700bbaa99cb9e9ab05e9628f6a73902d3d7d9d46b
7
+ data.tar.gz: e1863ab6134225fc653bb9dcf88dde4ae5e307f0d73ce88c1ab87669c26452a57f3852ee29c8821c42f79d83ca279047011eb5fef6d58c516699260ae4d837d2
@@ -4,7 +4,8 @@ module RgGen
4
4
  module Core
5
5
  module Base
6
6
  class Component
7
- def initialize(*args)
7
+ def initialize(base_name, *args)
8
+ @base_name = base_name
8
9
  @parent = args.first
9
10
  @children = []
10
11
  @need_children = true
@@ -18,6 +19,15 @@ module RgGen
18
19
  attr_reader :children
19
20
  attr_reader :level
20
21
 
22
+ def component_name
23
+ [hierarchy, @base_name].compact.join('@')
24
+ end
25
+
26
+ def hierarchy
27
+ end
28
+
29
+ alias_method :to_s, :component_name
30
+
21
31
  def need_children?
22
32
  @need_children
23
33
  end
@@ -4,7 +4,8 @@ module RgGen
4
4
  module Core
5
5
  module Base
6
6
  class ComponentFactory
7
- def initialize
7
+ def initialize(component_name)
8
+ @component_name = component_name
8
9
  @root_factory = false
9
10
  block_given? && yield(self)
10
11
  end
@@ -24,7 +25,7 @@ module RgGen
24
25
  else
25
26
  [args.first, preprocess(args[1..-1])]
26
27
  end
27
- create_component(parent, *sources) do |component|
28
+ create_component(parent, sources) do |component|
28
29
  build_component(parent, component, sources)
29
30
  root_factory? && finalize(component)
30
31
  end
@@ -36,6 +37,15 @@ module RgGen
36
37
  @root_factory
37
38
  end
38
39
 
40
+ def create_component(parent, sources, &block)
41
+ actual_sources = Array(select_actual_sources(*sources))
42
+ @target_component
43
+ .new(@component_name, parent, *actual_sources, &block)
44
+ end
45
+
46
+ def select_actual_sources(*sources)
47
+ end
48
+
39
49
  def build_component(parent, component, sources)
40
50
  do_create_features(component, sources)
41
51
  do_create_children(component, sources)
@@ -8,15 +8,28 @@ module RgGen
8
8
  extend SharedContext
9
9
  extend Forwardable
10
10
 
11
- def initialize(component, feature_name)
12
- @component = component
11
+ def initialize(feature_name, sub_feature_name, component)
13
12
  @feature_name = feature_name
13
+ @sub_feature_name = sub_feature_name
14
+ @component = component
14
15
  post_initialize
15
16
  block_given? && yield(self)
16
17
  end
17
18
 
18
19
  attr_reader :component
19
- attr_reader :feature_name
20
+
21
+ def feature_name(verbose: false)
22
+ if verbose
23
+ [@feature_name, @sub_feature_name]
24
+ .compact.reject(&:empty?).join(':')
25
+ else
26
+ @feature_name
27
+ end
28
+ end
29
+
30
+ def inspect
31
+ "#{feature_name(verbose: true)}(#{component})"
32
+ end
20
33
 
21
34
  class << self
22
35
  attr_reader :printables
@@ -15,8 +15,8 @@ module RgGen
15
15
  attr_setter :target_features
16
16
 
17
17
  def create_feature(component, *args)
18
- klass = select_target_feature(*args)
19
- klass.new(component, @feature_name) do |feature|
18
+ klass, sub_feature_name = select_feature(*args)
19
+ klass.new(@feature_name, sub_feature_name, component) do |feature|
20
20
  feature.available? || break
21
21
  block_given? && yield(feature)
22
22
  component.add_feature(feature)
@@ -25,11 +25,13 @@ module RgGen
25
25
 
26
26
  private
27
27
 
28
- def select_target_feature(*args)
29
- (@target_features && select_feature(*args)) || @target_feature
28
+ def select_feature(*args)
29
+ key = @target_features && target_feature_key(*args)
30
+ feature = (key && @target_features[key]) || @target_feature
31
+ [feature, key]
30
32
  end
31
33
 
32
- def select_feature(*args)
34
+ def target_feature_key(*args)
33
35
  end
34
36
  end
35
37
  end
@@ -6,6 +6,10 @@ module RgGen
6
6
  class ComponentEntry
7
7
  Entry = Struct.new(:target, :factory)
8
8
 
9
+ def initialize(component_name)
10
+ @component_name = component_name
11
+ end
12
+
9
13
  [:component, :feature].each do |entry_name|
10
14
  define_method(entry_name) do |target, factory|
11
15
  instance_variable_set("@#{__method__}", Entry.new(target, factory))
@@ -18,7 +22,7 @@ module RgGen
18
22
  end
19
23
 
20
24
  def build_factory
21
- @component.factory.new do |f|
25
+ @component.factory.new(@component_name) do |f|
22
26
  f.target_component(@component.target)
23
27
  f.feature_factories(feature_registry&.build_factories)
24
28
  end
@@ -4,8 +4,8 @@ module RgGen
4
4
  module Core
5
5
  module Builder
6
6
  class ComponentRegistry
7
- def initialize(name, builder)
8
- @name = name
7
+ def initialize(component_name, builder)
8
+ @component_name = component_name
9
9
  @builder = builder
10
10
  @entries = []
11
11
  end
@@ -31,7 +31,7 @@ module RgGen
31
31
  private
32
32
 
33
33
  def create_new_entry(category, block)
34
- entry = ComponentEntry.new
34
+ entry = ComponentEntry.new(@component_name)
35
35
  Docile.dsl_eval(entry, category, &block)
36
36
  add_feature_registry(category, entry.feature_registry)
37
37
  entry
@@ -39,7 +39,8 @@ module RgGen
39
39
 
40
40
  def add_feature_registry(category, feature_registry)
41
41
  feature_registry || return
42
- @builder.add_feature_registry(@name, category, feature_registry)
42
+ @builder
43
+ .add_feature_registry(@component_name, category, feature_registry)
43
44
  end
44
45
  end
45
46
  end
@@ -6,10 +6,6 @@ module RgGen
6
6
  class ComponentFactory < InputBase::ComponentFactory
7
7
  private
8
8
 
9
- def create_component(*_, &block)
10
- @target_component.new(&block)
11
- end
12
-
13
9
  def create_input_data(&block)
14
10
  InputBase::InputData.new(valid_value_lists, &block)
15
11
  end
@@ -105,6 +105,12 @@ module RgGen
105
105
  !helper.printables.nil?
106
106
  end
107
107
 
108
+ def inspect
109
+ printable_values =
110
+ printables&.map { |name, value| "#{name}: #{value.inspect}" }
111
+ (printable_values && "#{super}[#{printable_values.join(', ')}]") || super
112
+ end
113
+
108
114
  private
109
115
 
110
116
  def do_build(args)
@@ -6,8 +6,8 @@ module RgGen
6
6
  class ComponentFactory < Base::ComponentFactory
7
7
  private
8
8
 
9
- def create_component(parent, configuration, register_map, &block)
10
- target_component.new(parent, configuration, register_map, &block)
9
+ def select_actual_sources(configuration, register_map)
10
+ [configuration, register_map]
11
11
  end
12
12
 
13
13
  def create_features(component, configuration, register_map)
@@ -6,8 +6,8 @@ module RgGen
6
6
  class ComponentFactory < InputBase::ComponentFactory
7
7
  private
8
8
 
9
- def create_component(parent, configuration, _, &block)
10
- @target_component.new(parent, configuration, &block)
9
+ def select_actual_sources(configuration, *_)
10
+ configuration
11
11
  end
12
12
 
13
13
  def create_input_data(&block)
@@ -3,7 +3,7 @@
3
3
  module RgGen
4
4
  module Core
5
5
  MAJOR = 0
6
- MINOR = 15
6
+ MINOR = 16
7
7
  PATCH = 0
8
8
  VERSION = "#{MAJOR}.#{MINOR}.#{PATCH}"
9
9
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rggen-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.15.0
4
+ version: 0.16.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Taichi Ishitani
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-09-18 00:00:00.000000000 Z
11
+ date: 2019-10-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: docile
@@ -187,5 +187,5 @@ requirements: []
187
187
  rubygems_version: 3.0.3
188
188
  signing_key:
189
189
  specification_version: 4
190
- summary: rggen-core-0.15.0
190
+ summary: rggen-core-0.16.0
191
191
  test_files: []