dtk-dsl 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.byebug_history +70 -0
- data/.gitignore +2 -0
- data/Gemfile +2 -0
- data/README.md +2 -0
- data/dtk-dsl.gemspec +16 -0
- data/lib/dsl/directory_generator.rb +27 -0
- data/lib/dsl/directory_parser/path_info.rb +62 -0
- data/lib/dsl/directory_parser.rb +33 -0
- data/lib/dsl/dsl_version.rb +36 -0
- data/lib/dsl/error/subclasses.rb +38 -0
- data/lib/dsl/error.rb +24 -0
- data/lib/dsl/file_generator/content_input/array.rb +31 -0
- data/lib/dsl/file_generator/content_input/hash.rb +53 -0
- data/lib/dsl/file_generator/content_input/mixin.rb +68 -0
- data/lib/dsl/file_generator/content_input/string.rb +31 -0
- data/lib/dsl/file_generator/content_input/tags.rb +87 -0
- data/lib/dsl/file_generator/content_input.rb +29 -0
- data/lib/dsl/file_generator/yaml_object.rb +24 -0
- data/lib/dsl/file_generator.rb +39 -0
- data/lib/dsl/file_obj.rb +119 -0
- data/lib/dsl/file_parser/input/array.rb +27 -0
- data/lib/dsl/file_parser/input/hash.rb +40 -0
- data/lib/dsl/file_parser/input.rb +29 -0
- data/lib/dsl/file_parser/output.rb +24 -0
- data/lib/dsl/file_parser.rb +71 -0
- data/lib/dsl/file_type.rb +79 -0
- data/lib/dsl/input_output_common/array.rb +43 -0
- data/lib/dsl/input_output_common/canonical/array.rb +27 -0
- data/lib/dsl/input_output_common/canonical/hash.rb +69 -0
- data/lib/dsl/input_output_common/canonical/hash_key.rb +54 -0
- data/lib/dsl/input_output_common/canonical.rb +28 -0
- data/lib/dsl/input_output_common/hash.rb +44 -0
- data/lib/dsl/input_output_common/output_class_mixin.rb +34 -0
- data/lib/dsl/input_output_common/semantic_parse/hash.rb +33 -0
- data/lib/dsl/input_output_common/semantic_parse/mixin.rb +44 -0
- data/lib/dsl/input_output_common/semantic_parse.rb +26 -0
- data/lib/dsl/input_output_common.rb +60 -0
- data/lib/dsl/qualified_key.rb +55 -0
- data/lib/dsl/template/constant_class_mixin.rb +91 -0
- data/lib/dsl/template/generation/class_mixin.rb +40 -0
- data/lib/dsl/template/generation/mixin.rb +134 -0
- data/lib/dsl/template/generation.rb +26 -0
- data/lib/dsl/template/loader.rb +66 -0
- data/lib/dsl/template/parsing/class_mixin.rb +67 -0
- data/lib/dsl/template/parsing/mixin.rb +214 -0
- data/lib/dsl/template/parsing/parent_key.rb +82 -0
- data/lib/dsl/template/parsing/parsing_error/subclasses.rb +62 -0
- data/lib/dsl/template/parsing/parsing_error.rb +52 -0
- data/lib/dsl/template/parsing.rb +29 -0
- data/lib/dsl/template/v1/assembly.rb +82 -0
- data/lib/dsl/template/v1/attribute/semantic_parse.rb +26 -0
- data/lib/dsl/template/v1/attribute.rb +75 -0
- data/lib/dsl/template/v1/common_module.rb +38 -0
- data/lib/dsl/template/v1/common_module_summary.rb +42 -0
- data/lib/dsl/template/v1/component/semantic_parse.rb +26 -0
- data/lib/dsl/template/v1/component.rb +121 -0
- data/lib/dsl/template/v1/dependency.rb +63 -0
- data/lib/dsl/template/v1/module_ref.rb +62 -0
- data/lib/dsl/template/v1/node/semantic_parse.rb +62 -0
- data/lib/dsl/template/v1/node.rb +72 -0
- data/lib/dsl/template/v1/node_attribute/semantic_parse.rb +26 -0
- data/lib/dsl/template/v1/node_attribute.rb +25 -0
- data/lib/dsl/template/v1/service_instance.rb +50 -0
- data/lib/dsl/template/v1/service_module_summary.rb +37 -0
- data/lib/dsl/template/v1/workflow/semantic_parse.rb +26 -0
- data/lib/dsl/template/v1/workflow.rb +65 -0
- data/lib/dsl/template/v1.rb +43 -0
- data/lib/dsl/template.rb +110 -0
- data/lib/dsl/version.rb +6 -0
- data/lib/dsl/yaml_helper.rb +56 -0
- data/lib/dtk_dsl.rb +36 -0
- metadata +114 -0
@@ -0,0 +1,38 @@
|
|
1
|
+
#
|
2
|
+
# Copyright (C) 2010-2016 dtk contributors
|
3
|
+
#
|
4
|
+
# This file is part of the dtk project.
|
5
|
+
#
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
+
# you may not use this file except in compliance with the License.
|
8
|
+
# You may obtain a copy of the License at
|
9
|
+
#
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
#
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
+
# See the License for the specific language governing permissions and
|
16
|
+
# limitations under the License.
|
17
|
+
#
|
18
|
+
class DTK::DSL::Template
|
19
|
+
class V1
|
20
|
+
class CommonModule < CommonModuleSummary
|
21
|
+
module Constant
|
22
|
+
include CommonModuleSummary::Constant
|
23
|
+
|
24
|
+
module Variations
|
25
|
+
include CommonModuleSummary::Constant::Variations
|
26
|
+
end
|
27
|
+
|
28
|
+
extend ClassMixin::Constant
|
29
|
+
Assemblies = 'assemblies'
|
30
|
+
end
|
31
|
+
|
32
|
+
def parse!
|
33
|
+
super
|
34
|
+
set :Assemblies, parse_child_elements(:assembly, :Assemblies)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
#
|
2
|
+
# Copyright (C) 2010-2016 dtk contributors
|
3
|
+
#
|
4
|
+
# This file is part of the dtk project.
|
5
|
+
#
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
+
# you may not use this file except in compliance with the License.
|
8
|
+
# You may obtain a copy of the License at
|
9
|
+
#
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
#
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
+
# See the License for the specific language governing permissions and
|
16
|
+
# limitations under the License.
|
17
|
+
#
|
18
|
+
class DTK::DSL::Template
|
19
|
+
class V1
|
20
|
+
class CommonModuleSummary < self
|
21
|
+
module Constant
|
22
|
+
module Variations
|
23
|
+
end
|
24
|
+
extend ClassMixin::Constant
|
25
|
+
|
26
|
+
DSLVersion = 'dsl_version'
|
27
|
+
ModuleVersion = 'version'
|
28
|
+
DependentModules = 'dependencies'
|
29
|
+
|
30
|
+
Module = 'module'
|
31
|
+
Variations::Module = ['module', 'module_name']
|
32
|
+
end
|
33
|
+
|
34
|
+
def parse!
|
35
|
+
set :DSLVersion, input_key_value(:DSLVersion)
|
36
|
+
set :ModuleVersion, input_key_value(:ModuleVersion)
|
37
|
+
merge parse_child(:module_ref, input_key_value(:Module), :parent_key => Constant::Module)
|
38
|
+
set? :DependentModules, parse_child_elements?(:dependency, :DependentModules)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
#
|
2
|
+
# Copyright (C) 2010-2016 dtk contributors
|
3
|
+
#
|
4
|
+
# This file is part of the dtk project.
|
5
|
+
#
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
+
# you may not use this file except in compliance with the License.
|
8
|
+
# You may obtain a copy of the License at
|
9
|
+
#
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
#
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
+
# See the License for the specific language governing permissions and
|
16
|
+
# limitations under the License.
|
17
|
+
#
|
18
|
+
module DTK::DSL
|
19
|
+
class Template::V1
|
20
|
+
class Component
|
21
|
+
class SemanticParse < InputOutputCommon::SemanticParse::Hash
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
@@ -0,0 +1,121 @@
|
|
1
|
+
#
|
2
|
+
# Copyright (C) 2010-2016 dtk contributors
|
3
|
+
#
|
4
|
+
# This file is part of the dtk project.
|
5
|
+
#
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
+
# you may not use this file except in compliance with the License.
|
8
|
+
# You may obtain a copy of the License at
|
9
|
+
#
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
#
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
+
# See the License for the specific language governing permissions and
|
16
|
+
# limitations under the License.
|
17
|
+
#
|
18
|
+
module DTK::DSL
|
19
|
+
class Template
|
20
|
+
class V1
|
21
|
+
class Component < self
|
22
|
+
require_relative('component/semantic_parse')
|
23
|
+
|
24
|
+
module Constant
|
25
|
+
module Variations
|
26
|
+
end
|
27
|
+
|
28
|
+
extend ClassMixin::Constant
|
29
|
+
|
30
|
+
Attributes = 'attributes'
|
31
|
+
ComponentLinks = 'component_links'
|
32
|
+
end
|
33
|
+
|
34
|
+
### For parsing
|
35
|
+
def parser_output_type
|
36
|
+
:hash
|
37
|
+
end
|
38
|
+
|
39
|
+
def self.elements_collection_type
|
40
|
+
:array
|
41
|
+
end
|
42
|
+
|
43
|
+
def self.parse_elements(input_array, parent_info)
|
44
|
+
input_array.inject(file_parser_output_hash) do |h, component|
|
45
|
+
name = name(component)
|
46
|
+
h.merge(name => parse_element(component, parent_info, :index => name))
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
def parse!
|
51
|
+
# TODO: This is a catchall that removes ones we so far are parsing and then has catch all
|
52
|
+
if input_string?
|
53
|
+
parse_when_string!
|
54
|
+
elsif input_hash = input_hash?
|
55
|
+
parse_when_hash!
|
56
|
+
else
|
57
|
+
raise parsing_error(:WrongObjectType, @input, [::String, ::Hash])
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
### For generation
|
62
|
+
def self.generate_elements(components_content, parent)
|
63
|
+
components_content.map do |name, component|
|
64
|
+
if component_hash = generate_element?(component, parent)
|
65
|
+
component_hash.empty? ? name : { name => component_hash }
|
66
|
+
end
|
67
|
+
end.compact
|
68
|
+
end
|
69
|
+
|
70
|
+
def generate!
|
71
|
+
merge(generate_component_hash)
|
72
|
+
end
|
73
|
+
|
74
|
+
# Ovewritting this function because dont want to return nil when empty content
|
75
|
+
def generate_yaml_object?
|
76
|
+
generate! unless skip_for_generation?
|
77
|
+
end
|
78
|
+
|
79
|
+
private
|
80
|
+
|
81
|
+
def generate_component_hash
|
82
|
+
ret = {}
|
83
|
+
set_generation_hash(ret, :Attributes, generate_child_elements(:attribute, val(:Attributes)))
|
84
|
+
#TODO: set component_links
|
85
|
+
ret
|
86
|
+
end
|
87
|
+
|
88
|
+
def self.name(input)
|
89
|
+
if input.kind_of?(::String)
|
90
|
+
input
|
91
|
+
elsif input.kind_of?(::Hash) and input.size > 0
|
92
|
+
input.keys.first
|
93
|
+
else
|
94
|
+
raise parsing_error(:WrongObjectType, input, [::String, ::Hash])
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
def name
|
99
|
+
self.class.name(@input)
|
100
|
+
end
|
101
|
+
|
102
|
+
def parse_when_string!
|
103
|
+
end
|
104
|
+
|
105
|
+
def parse_when_hash!
|
106
|
+
unless input_hash.size == 1 and input_hash.values.first.kind_of?(::Hash)
|
107
|
+
raise parsing_error("Component is ill-formed; it must be string or hash with has value")
|
108
|
+
end
|
109
|
+
properties = input_hash.values.first
|
110
|
+
set? :Attributes, parse_child_elements?(:attribute, :Attributes, :input_hash => properties)
|
111
|
+
|
112
|
+
# TODO: This is a catchall that removes ones we so far are parsing and then has catch all
|
113
|
+
properties.delete('attributes')
|
114
|
+
merge properties
|
115
|
+
end
|
116
|
+
|
117
|
+
end
|
118
|
+
end
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
@@ -0,0 +1,63 @@
|
|
1
|
+
#
|
2
|
+
# Copyright (C) 2010-2016 dtk contributors
|
3
|
+
#
|
4
|
+
# This file is part of the dtk project.
|
5
|
+
#
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
+
# you may not use this file except in compliance with the License.
|
8
|
+
# You may obtain a copy of the License at
|
9
|
+
#
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
#
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
+
# See the License for the specific language governing permissions and
|
16
|
+
# limitations under the License.
|
17
|
+
#
|
18
|
+
class DTK::DSL::Template
|
19
|
+
class V1
|
20
|
+
class Dependency < self
|
21
|
+
|
22
|
+
MODULE_NAMESPACE_DELIMS = ['/', ':']
|
23
|
+
|
24
|
+
def parser_output_type
|
25
|
+
:hash
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.parse_elements(input_hash, parent_info)
|
29
|
+
ret = file_parser_output_array
|
30
|
+
input_hash.each do |name, version|
|
31
|
+
ret << parse_element({ 'name' => name, 'version' => version }, parent_info, :index => name)
|
32
|
+
end
|
33
|
+
ret
|
34
|
+
end
|
35
|
+
|
36
|
+
def parse!
|
37
|
+
name = input_hash['name']
|
38
|
+
version = input_hash['version']
|
39
|
+
|
40
|
+
split = split_by_delim(name)
|
41
|
+
unless split.size == 2
|
42
|
+
raise parsing_error("The term '#{input_string}' is an ill-formed module reference")
|
43
|
+
end
|
44
|
+
namespace, module_name = split
|
45
|
+
|
46
|
+
set :Namespace, namespace
|
47
|
+
set :ModuleName, module_name
|
48
|
+
set :ModuleVersion, version
|
49
|
+
end
|
50
|
+
|
51
|
+
private
|
52
|
+
|
53
|
+
def split_by_delim(str)
|
54
|
+
if matching_delim = MODULE_NAMESPACE_DELIMS.find { |delim| str =~ Regexp.new(delim) }
|
55
|
+
str.split(matching_delim)
|
56
|
+
else
|
57
|
+
[str]
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
@@ -0,0 +1,62 @@
|
|
1
|
+
#
|
2
|
+
# Copyright (C) 2010-2016 dtk contributors
|
3
|
+
#
|
4
|
+
# This file is part of the dtk project.
|
5
|
+
#
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
+
# you may not use this file except in compliance with the License.
|
8
|
+
# You may obtain a copy of the License at
|
9
|
+
#
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
#
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
+
# See the License for the specific language governing permissions and
|
16
|
+
# limitations under the License.
|
17
|
+
#
|
18
|
+
class DTK::DSL::Template
|
19
|
+
class V1
|
20
|
+
class ModuleRef < self
|
21
|
+
|
22
|
+
MODULE_NAMESPACE_DELIMS = ['/', ':']
|
23
|
+
|
24
|
+
def parser_output_type
|
25
|
+
:hash
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.elements_collection_type
|
29
|
+
:array
|
30
|
+
end
|
31
|
+
|
32
|
+
def self.parse_elements(input_array, parent_info)
|
33
|
+
ret = file_parser_output_array
|
34
|
+
input_array.each_with_index do |module_ref, i|
|
35
|
+
ret << parse_element(module_ref, parent_info, :index => i)
|
36
|
+
end
|
37
|
+
ret
|
38
|
+
end
|
39
|
+
|
40
|
+
def parse!
|
41
|
+
split = split_by_delim(input_string)
|
42
|
+
unless split.size == 2
|
43
|
+
raise parsing_error("The term '#{input_string}' is an ill-formed module reference")
|
44
|
+
end
|
45
|
+
namespace, module_name = split
|
46
|
+
set :Namespace, namespace
|
47
|
+
set :ModuleName, module_name
|
48
|
+
end
|
49
|
+
|
50
|
+
private
|
51
|
+
|
52
|
+
def split_by_delim(str)
|
53
|
+
if matching_delim = MODULE_NAMESPACE_DELIMS.find { |delim| str =~ Regexp.new(delim) }
|
54
|
+
str.split(matching_delim)
|
55
|
+
else
|
56
|
+
[str]
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
@@ -0,0 +1,62 @@
|
|
1
|
+
#
|
2
|
+
# Copyright (C) 2010-2016 dtk contributors
|
3
|
+
#
|
4
|
+
# This file is part of the dtk project.
|
5
|
+
#
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
+
# you may not use this file except in compliance with the License.
|
8
|
+
# You may obtain a copy of the License at
|
9
|
+
#
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
#
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
+
# See the License for the specific language governing permissions and
|
16
|
+
# limitations under the License.
|
17
|
+
#
|
18
|
+
module DTK::DSL
|
19
|
+
class Template::V1
|
20
|
+
class Node
|
21
|
+
class SemanticParse < InputOutputCommon::SemanticParse::Hash
|
22
|
+
def attribute_value(attr_name)
|
23
|
+
if attribute = attribute?(attr_name)
|
24
|
+
value_from_attribute_object(attribute)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
# possible values of type are :node or :node_group
|
29
|
+
def type
|
30
|
+
type_value = attribute_value(:type)
|
31
|
+
if type_value.nil?
|
32
|
+
:node
|
33
|
+
elsif type_value == 'group'
|
34
|
+
:node_group
|
35
|
+
else
|
36
|
+
type_attribute = attribute(:type)
|
37
|
+
fail Error::Usage, "The value '#{type_value}' assigned to attribute '#{type_attribute.qualified_name}' is not a legal node type"
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
private
|
42
|
+
|
43
|
+
def attribute(attr_name)
|
44
|
+
attribute?(attr_name) || fail(Error, "Unexpected that attribute?(attr_name) is nil")
|
45
|
+
end
|
46
|
+
|
47
|
+
def attribute?(attr_name)
|
48
|
+
attributes[attr_name.to_s]
|
49
|
+
end
|
50
|
+
|
51
|
+
def attributes
|
52
|
+
@attributes ||= val(:Attributes) || {}
|
53
|
+
end
|
54
|
+
|
55
|
+
def value_from_attribute_object(attribute)
|
56
|
+
attribute.req(:Value)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
@@ -0,0 +1,72 @@
|
|
1
|
+
#
|
2
|
+
# Copyright (C) 2010-2016 dtk contributors
|
3
|
+
#
|
4
|
+
# This file is part of the dtk project.
|
5
|
+
#
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
+
# you may not use this file except in compliance with the License.
|
8
|
+
# You may obtain a copy of the License at
|
9
|
+
#
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
#
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
+
# See the License for the specific language governing permissions and
|
16
|
+
# limitations under the License.
|
17
|
+
#
|
18
|
+
class DTK::DSL::Template
|
19
|
+
class V1
|
20
|
+
class Node < self
|
21
|
+
require_relative('node/semantic_parse')
|
22
|
+
module Constant
|
23
|
+
module Variations
|
24
|
+
end
|
25
|
+
|
26
|
+
extend ClassMixin::Constant
|
27
|
+
Name = 'name'
|
28
|
+
Attributes = 'attributes'
|
29
|
+
Components = 'components'
|
30
|
+
end
|
31
|
+
|
32
|
+
### For parsing
|
33
|
+
def self.elements_collection_type
|
34
|
+
:hash
|
35
|
+
end
|
36
|
+
|
37
|
+
def self.parse_elements(input_hash, parent_info)
|
38
|
+
input_hash.inject(file_parser_output_hash) do |h, (name, content)|
|
39
|
+
h.merge(name => parse_element(content, parent_info, :index => name))
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def parse!
|
44
|
+
set? :Attributes, parse_child_elements?(:node_attribute, :Attributes)
|
45
|
+
set? :Components, parse_child_elements?(:component, :Components)
|
46
|
+
end
|
47
|
+
|
48
|
+
### For generation
|
49
|
+
def self.generate_elements(nodes_content, parent)
|
50
|
+
nodes_content.inject({}) do |h, (name, node)|
|
51
|
+
node_hash = generate_element?(node, parent)
|
52
|
+
node_hash ? h.merge(name => node_hash) : h
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def generate!
|
57
|
+
merge(generate_node_hash)
|
58
|
+
end
|
59
|
+
|
60
|
+
private
|
61
|
+
|
62
|
+
def generate_node_hash
|
63
|
+
ret = {}
|
64
|
+
set_generation_hash(ret, :Attributes, generate_child_elements(:node_attribute, val(:Attributes)))
|
65
|
+
set_generation_hash(ret, :Components, generate_child_elements(:component, val(:Components)))
|
66
|
+
ret
|
67
|
+
end
|
68
|
+
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
@@ -0,0 +1,26 @@
|
|
1
|
+
#
|
2
|
+
# Copyright (C) 2010-2016 dtk contributors
|
3
|
+
#
|
4
|
+
# This file is part of the dtk project.
|
5
|
+
#
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
+
# you may not use this file except in compliance with the License.
|
8
|
+
# You may obtain a copy of the License at
|
9
|
+
#
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
#
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
+
# See the License for the specific language governing permissions and
|
16
|
+
# limitations under the License.
|
17
|
+
#
|
18
|
+
module DTK::DSL
|
19
|
+
class Template::V1
|
20
|
+
class NodeAttribute
|
21
|
+
class SemanticParse < Attribute::SemanticParse
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
@@ -0,0 +1,25 @@
|
|
1
|
+
#
|
2
|
+
# Copyright (C) 2010-2016 dtk contributors
|
3
|
+
#
|
4
|
+
# This file is part of the dtk project.
|
5
|
+
#
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
+
# you may not use this file except in compliance with the License.
|
8
|
+
# You may obtain a copy of the License at
|
9
|
+
#
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
#
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
+
# See the License for the specific language governing permissions and
|
16
|
+
# limitations under the License.
|
17
|
+
#
|
18
|
+
class DTK::DSL::Template
|
19
|
+
class V1
|
20
|
+
class NodeAttribute < Attribute
|
21
|
+
require_relative('node_attribute/semantic_parse')
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
@@ -0,0 +1,50 @@
|
|
1
|
+
#
|
2
|
+
# Copyright (C) 2010-2016 dtk contributors
|
3
|
+
#
|
4
|
+
# This file is part of the dtk project.
|
5
|
+
#
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
+
# you may not use this file except in compliance with the License.
|
8
|
+
# You may obtain a copy of the License at
|
9
|
+
#
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
#
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
+
# See the License for the specific language governing permissions and
|
16
|
+
# limitations under the License.
|
17
|
+
#
|
18
|
+
class DTK::DSL::Template
|
19
|
+
class V1
|
20
|
+
class ServiceInstance < self
|
21
|
+
module Constant
|
22
|
+
module Variations
|
23
|
+
end
|
24
|
+
extend ClassMixin::Constant
|
25
|
+
|
26
|
+
DSLVersion = 'dsl_version'
|
27
|
+
Name = 'name'
|
28
|
+
Variations::Name = ['name', 'service_name']
|
29
|
+
DependentModules = 'dependencies'
|
30
|
+
end
|
31
|
+
|
32
|
+
### For parsing
|
33
|
+
def parse!
|
34
|
+
set :DSLVersion, input_key_value(:DSLVersion)
|
35
|
+
set :Name, input_key_value(:DSLVersion)
|
36
|
+
set? :DependentModules, input_key_value?(:DependentModules)
|
37
|
+
merge parse_child(:assembly, input_hash)
|
38
|
+
end
|
39
|
+
|
40
|
+
### For generation
|
41
|
+
def generate!
|
42
|
+
set :DSLVersion, req(:DSLVersion)
|
43
|
+
set :Name, req(:Name)
|
44
|
+
set? :DependentModules, val(:DependentModules)
|
45
|
+
merge generate_child(:assembly, req(:Assembly))
|
46
|
+
end
|
47
|
+
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
#
|
2
|
+
# Copyright (C) 2010-2016 dtk contributors
|
3
|
+
#
|
4
|
+
# This file is part of the dtk project.
|
5
|
+
#
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
+
# you may not use this file except in compliance with the License.
|
8
|
+
# You may obtain a copy of the License at
|
9
|
+
#
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
#
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
+
# See the License for the specific language governing permissions and
|
16
|
+
# limitations under the License.
|
17
|
+
#
|
18
|
+
class DTK::DSL::Template
|
19
|
+
class V1
|
20
|
+
class ServiceModuleSummary < self
|
21
|
+
module Constant
|
22
|
+
module Variations
|
23
|
+
end
|
24
|
+
extend ClassMixin::Constant
|
25
|
+
|
26
|
+
DSLVersion = 'dsl_version'
|
27
|
+
Module = 'module'
|
28
|
+
Variations::Module = ['module', 'module_name', 'name']
|
29
|
+
end
|
30
|
+
|
31
|
+
def parse!
|
32
|
+
set :DSLVersion, input_key_value(:DSLVersion)
|
33
|
+
set :Name, input_key_value(:Module)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
#
|
2
|
+
# Copyright (C) 2010-2016 dtk contributors
|
3
|
+
#
|
4
|
+
# This file is part of the dtk project.
|
5
|
+
#
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
+
# you may not use this file except in compliance with the License.
|
8
|
+
# You may obtain a copy of the License at
|
9
|
+
#
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
#
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
+
# See the License for the specific language governing permissions and
|
16
|
+
# limitations under the License.
|
17
|
+
#
|
18
|
+
module DTK::DSL
|
19
|
+
class Template::V1
|
20
|
+
class Workflow
|
21
|
+
class SemanticParse < InputOutputCommon::SemanticParse::Hash
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|