Class: Kubes::Compiler::Dsl::Core::Blocks
- Inherits:
-
Base
- Object
- Base
- Kubes::Compiler::Dsl::Core::Blocks
show all
- Defined in:
- lib/kubes/compiler/dsl/core/blocks.rb
Constant Summary
collapse
- @@syntax_instances =
{}
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Base
#initialize
Methods included from Fields
#field, #fields
#base_class_for_helper, #load_custom_helpers, #load_custom_variables, #load_plugin_helpers, #load_runtime_helpers, #show_variable_layer_path
#pretty_path
#decode64, #encode64, #generic_secret_data, #parse_env_like_line
#extra, #with_extra
#built_image, #built_image_helper, #docker_image
#config_map_files
Methods included from Helpers
#dockerfile_port
Instance Attribute Details
#results ⇒ Object
Returns the value of attribute results.
3
4
5
|
# File 'lib/kubes/compiler/dsl/core/blocks.rb', line 3
def results
@results
end
|
Class Method Details
.block_method(meth) ⇒ Object
39
40
41
42
43
44
45
46
47
|
# File 'lib/kubes/compiler/dsl/core/blocks.rb', line 39
def block_method(meth)
meth = meth.to_s
define_method meth do |name, &block|
syntax = syntax_instance(meth, name)
syntax.instance_eval(&block) if block
lookup = lookup_key(meth, name)
@results[lookup] = syntax.result
end
end
|
.discovered_methods ⇒ Object
31
32
33
34
35
36
37
|
# File 'lib/kubes/compiler/dsl/core/blocks.rb', line 31
def discovered_methods
syntax = File.expand_path("../syntax", __dir__)
expr = "#{syntax}/*.rb"
Dir.glob(expr).map do |path|
File.basename(path).sub('.rb','')
end
end
|
.syntax_instances ⇒ Object
50
51
52
|
# File 'lib/kubes/compiler/dsl/core/blocks.rb', line 50
def syntax_instances
@@syntax_instances
end
|
Instance Method Details
#lookup_key(meth, name) ⇒ Object
26
27
28
|
# File 'lib/kubes/compiler/dsl/core/blocks.rb', line 26
def lookup_key(meth, name)
[meth, name].join('-')
end
|
#result ⇒ Object
11
12
13
|
# File 'lib/kubes/compiler/dsl/core/blocks.rb', line 11
def result
@results.values end
|
#run ⇒ Object
4
5
6
7
8
9
|
# File 'lib/kubes/compiler/dsl/core/blocks.rb', line 4
def run
@results = {} @block_form = true super result end
|
#syntax_instance(meth, name) ⇒ Object
15
16
17
18
19
20
21
22
23
24
|
# File 'lib/kubes/compiler/dsl/core/blocks.rb', line 15
def syntax_instance(meth, name)
lookup = lookup_key(meth, name)
klass = "Kubes::Compiler::Dsl::Syntax::#{meth.camelize}".constantize
syntax = self.class.syntax_instances[lookup]
return syntax if syntax
syntax = klass.new(@options.merge(name: name))
syntax.kind_from_block = meth.camelize
self.class.syntax_instances[lookup] = syntax
end
|