rggen-core 0.13.0 → 0.14.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: 7b863029dea0e5088f792bad82e185bf15bd22de39578f7e1d368851ab9d7549
4
- data.tar.gz: 5e8714a42f5b385f2373e01bcf7395b0139359c2a6dde6aa22889759edda12d0
3
+ metadata.gz: 2ad3c3965e2c0ac0bea5b0ef6d96ee5edeabb686d6eef675a9331e2754e26ffc
4
+ data.tar.gz: 56a3a6ceae64abc9d4f7f0398b3b3cbeb79c80350aef7dfb094c04989497830a
5
5
  SHA512:
6
- metadata.gz: 953bf54d406360b11bf39a2d5be9be50dffbb139ec9a55b2d0cc8e5405f58e05e047e938bb92cbee866dada08e57000e2675aa3055dfde881d63fbe570e1d24f
7
- data.tar.gz: 5ccbf66f592401e5fd3bd3bacf9dcdd883a5744eb7ba684eb6efb70332042efa8b692d2c2e7d07cc3dbbb4b7c95cadc2234d8a6125789ffbb42b8580fa0b4a2e
6
+ metadata.gz: 4a7bf7db44471e1d49fcec8f9e68d3619a0b63224854332255f4a4f8b0dc6e9f66be4142a25c374dd50d988401c9042fc7610d3ea0d2eaf3c34d83c9b6228f95
7
+ data.tar.gz: fea70cddb6c3b99904a7d0bdb20e9f71d112684bf52ebd847314b1368370863a2f05d878b153e638339c0de2bc6e64d9f90aa9a800c493a51eff47dcbe916016
@@ -4,7 +4,7 @@ module RgGen
4
4
  module Core
5
5
  module Base
6
6
  class Feature
7
- include InternalStruct
7
+ extend InternalStruct
8
8
  extend SharedContext
9
9
  extend Forwardable
10
10
 
@@ -4,10 +4,6 @@ module RgGen
4
4
  module Core
5
5
  module Base
6
6
  module InternalStruct
7
- def self.included(klass)
8
- klass.extend(self)
9
- end
10
-
11
7
  private
12
8
 
13
9
  def define_struct(name, members, &body)
@@ -90,8 +90,8 @@ module RgGen
90
90
  RegisterMap.setup(self)
91
91
  end
92
92
 
93
- def setup(name, plugin_module, &block)
94
- plugins.add(name, plugin_module, block)
93
+ def setup(name, module_or_version = nil, &block)
94
+ plugins.add(name, module_or_version, &block)
95
95
  end
96
96
 
97
97
  def activate_plugins
@@ -4,23 +4,37 @@ module RgGen
4
4
  module Core
5
5
  module Builder
6
6
  class Plugin
7
- def initialize(name, plugin_module, block)
7
+ DEFAULT_PLUGIN_VERSION = '0.0.0'
8
+
9
+ def initialize(name, module_or_version, &block)
8
10
  @name = name
9
- @version = extract_version(plugin_module)
10
- @plugin_module = plugin_module
11
11
  @block = block
12
+ @version, @plugin_module =
13
+ if module_or_version.is_a?(Module)
14
+ [extract_version(module_or_version), module_or_version]
15
+ else
16
+ [module_or_version || DEFAULT_PLUGIN_VERSION]
17
+ end
12
18
  end
13
19
 
14
20
  attr_reader :name
15
21
  attr_reader :version
16
22
 
17
23
  def default_setup(builder)
18
- @plugin_module.respond_to?(:default_setup) &&
19
- @plugin_module.default_setup(builder)
24
+ @plugin_module &&
25
+ begin
26
+ @plugin_module.respond_to?(:default_setup) &&
27
+ @plugin_module.default_setup(builder)
28
+ end
20
29
  end
21
30
 
22
31
  def optional_setup(builder)
23
- @block && @plugin_module.instance_exec(builder, &@block)
32
+ @block &&
33
+ if @plugin_module
34
+ @plugin_module.instance_exec(builder, &@block)
35
+ else
36
+ @block.call(builder)
37
+ end
24
38
  end
25
39
 
26
40
  private
@@ -31,7 +45,7 @@ module RgGen
31
45
  elsif plugin_module.respond_to?(:version)
32
46
  plugin_module.version
33
47
  else
34
- '0.0.0'
48
+ DEFAULT_PLUGIN_VERSION
35
49
  end
36
50
  end
37
51
  end
@@ -41,8 +55,8 @@ module RgGen
41
55
  @plugins = []
42
56
  end
43
57
 
44
- def add(name, plugin_module, block)
45
- @plugins << Plugin.new(name, plugin_module, block)
58
+ def add(name, module_or_version, &block)
59
+ @plugins << Plugin.new(name, module_or_version, &block)
46
60
  end
47
61
 
48
62
  def activate(builder)
@@ -7,16 +7,23 @@ module RgGen
7
7
  private
8
8
 
9
9
  def load_yaml(file)
10
- yaml = File.binread(file)
11
- result =
12
- if Psych::VERSION >= '3.1.0'
13
- YAML.safe_load(yaml, aliases: true, filename: file)
14
- else
15
- YAML.safe_load(yaml, [], [], true, file)
16
- end
10
+ result = yaml_safe_load(File.binread(file), file)
17
11
  symbolize_key(result)
18
12
  end
19
13
 
14
+ if Psych::VERSION >= '3.1.0'
15
+ def yaml_safe_load(yaml, file)
16
+ YAML.safe_load(
17
+ yaml,
18
+ permitted_classes: [Symbol], aliases: true, filename: file
19
+ )
20
+ end
21
+ else
22
+ def yaml_safe_load(yaml, file)
23
+ YAML.safe_load(yaml, [Symbol], [], true, file)
24
+ end
25
+ end
26
+
20
27
  def symbolize_key(result)
21
28
  case result
22
29
  when Hash
@@ -3,7 +3,7 @@
3
3
  module RgGen
4
4
  module Core
5
5
  MAJOR = 0
6
- MINOR = 13
6
+ MINOR = 14
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.13.0
4
+ version: 0.14.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-08-28 00:00:00.000000000 Z
11
+ date: 2019-09-03 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.13.0
190
+ summary: rggen-core-0.14.0
191
191
  test_files: []