dtk-dsl 1.0.2 → 1.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/dsl/input_output_common/canonical/hash_key.rb +1 -0
- data/lib/dsl/input_output_common/semantic_parse/hash.rb +5 -0
- data/lib/dsl/input_output_common/semantic_parse/mixin.rb +1 -1
- data/lib/dsl/service_and_component_info/info/input_files.rb +58 -0
- data/lib/dsl/service_and_component_info/info.rb +64 -0
- data/lib/dsl/service_and_component_info/module_ref.rb +56 -0
- data/lib/dsl/service_and_component_info/parser.rb +58 -0
- data/lib/dsl/service_and_component_info/transform_from/info/component.rb +42 -0
- data/lib/dsl/service_and_component_info/transform_from/info/input_files.rb +27 -0
- data/lib/dsl/service_and_component_info/transform_from/info/service.rb +43 -0
- data/lib/dsl/service_and_component_info/transform_from/info.rb +64 -0
- data/lib/dsl/service_and_component_info/transform_from/parser/top_dsl/assemblies/node_bindings.rb +81 -0
- data/lib/dsl/service_and_component_info/transform_from/parser/top_dsl/assemblies/workflows.rb +37 -0
- data/lib/dsl/service_and_component_info/transform_from/parser/top_dsl/assemblies.rb +52 -0
- data/lib/dsl/service_and_component_info/transform_from/parser/top_dsl/components.rb +33 -0
- data/lib/dsl/service_and_component_info/transform_from/parser/top_dsl/dependencies.rb +74 -0
- data/lib/dsl/service_and_component_info/transform_from/parser/top_dsl/module_info.rb +31 -0
- data/lib/dsl/service_and_component_info/transform_from/parser/top_dsl.rb +36 -0
- data/lib/dsl/service_and_component_info/transform_from/parser.rb +24 -0
- data/lib/dsl/service_and_component_info/transform_from.rb +25 -0
- data/lib/dsl/service_and_component_info/transform_to/info/component.rb +70 -0
- data/lib/dsl/service_and_component_info/transform_to/info/input_files.rb +36 -0
- data/lib/dsl/service_and_component_info/transform_to/info/service.rb +72 -0
- data/lib/dsl/service_and_component_info/transform_to/info.rb +51 -0
- data/lib/dsl/service_and_component_info/transform_to/parser/component_module/module_refs.rb +27 -0
- data/lib/dsl/service_and_component_info/transform_to/parser/component_module/top_dsl.rb +47 -0
- data/lib/dsl/service_and_component_info/transform_to/parser/component_module.rb +28 -0
- data/lib/dsl/service_and_component_info/transform_to/parser/module_refs.rb +54 -0
- data/lib/dsl/service_and_component_info/transform_to/parser/service_module/module_refs.rb +27 -0
- data/lib/dsl/service_and_component_info/transform_to/parser/service_module/top_dsl.rb +73 -0
- data/lib/dsl/service_and_component_info/transform_to/parser/service_module.rb +28 -0
- data/lib/dsl/service_and_component_info/transform_to/parser/top_dsl.rb +36 -0
- data/lib/dsl/service_and_component_info/transform_to/parser.rb +39 -0
- data/lib/dsl/service_and_component_info/transform_to.rb +25 -0
- data/lib/dsl/service_and_component_info.rb +55 -0
- data/lib/dsl/template/parsing/mixin.rb +6 -5
- data/lib/dsl/template/parsing/parsing_error/subclasses.rb +13 -13
- data/lib/dsl/template/v1/common_module.rb +4 -2
- data/lib/dsl/template/v1/component.rb +11 -2
- data/lib/dsl/template/v1/component_def/semantic_parse.rb +26 -0
- data/lib/dsl/template/v1/component_def.rb +52 -0
- data/lib/dsl/template/v1/workflow.rb +0 -1
- data/lib/dsl/template/v1.rb +1 -0
- data/lib/dsl/version.rb +1 -1
- data/lib/dsl/yaml_helper.rb +1 -0
- data/lib/dtk_dsl.rb +2 -0
- metadata +41 -7
@@ -0,0 +1,74 @@
|
|
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 ServiceAndComponentInfo
|
20
|
+
class TransformFrom::Parser::TopDSL
|
21
|
+
class Dependencies < self
|
22
|
+
def update_output_hash?
|
23
|
+
module_refs_input_hash = input_file_hash?(:module_refs) || {}
|
24
|
+
unless module_refs_input_hash.empty?
|
25
|
+
existing_module_refs = output_hash['dependencies'] ||= {}
|
26
|
+
merge_in_new_module_refs!(existing_module_refs, module_refs_input_hash)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
private
|
31
|
+
|
32
|
+
def merge_in_new_module_refs!(module_refs_hash, input_module_refs_hash)
|
33
|
+
ndx_existing_modules = ndx_existing_modules(module_refs_hash)
|
34
|
+
component_module_refs(input_module_refs_hash).each do |module_ref|
|
35
|
+
raise_error_if_conflict(module_ref, ndx_existing_modules)
|
36
|
+
module_refs_hash.merge!(combined_module_form(module_ref))
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def component_module_refs(input_module_refs_hash)
|
41
|
+
(input_module_refs_hash['component_modules'] || {}).inject([]) do |a, (name, info)|
|
42
|
+
a + [ModuleRef.new(info['namespace'], name, info['version'])]
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
|
47
|
+
NAMESPACE_NAME_DELIM = '/'
|
48
|
+
# indexed by module_name
|
49
|
+
def ndx_existing_modules(module_refs_hash)
|
50
|
+
module_refs_hash.inject({}) do |h, (namespace_name, version)|
|
51
|
+
namespace, name = namespace_name.split(NAMESPACE_NAME_DELIM)
|
52
|
+
h.merge(name => ModuleRef.new(namespace, name, version))
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def combined_module_form(module_ref)
|
57
|
+
{ "#{module_ref.namespace}#{NAMESPACE_NAME_DELIM}#{module_ref.module_name}" => module_ref.version }
|
58
|
+
end
|
59
|
+
|
60
|
+
def raise_error_if_conflict(module_ref, ndx_existing_modules)
|
61
|
+
if matching_module_ref = ndx_existing_modules[@module_name]
|
62
|
+
fail Error::Usage, conflict_error_msg(module_ref, matching_module_ref) unless module_ref.match?(matching_module_ref)
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
|
67
|
+
def conflict_error_msg(module_ref, matching_module_ref)
|
68
|
+
"Conflicting versions of module '#{module_ref.module_name}': '#{module_ref.print_form}' vs '#{matching_module_ref.print_form}'"
|
69
|
+
end
|
70
|
+
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
@@ -0,0 +1,31 @@
|
|
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 ServiceAndComponentInfo::TransformFrom::Parser
|
20
|
+
class TopDSL
|
21
|
+
class ModuleInfo < self
|
22
|
+
def update_output_hash?
|
23
|
+
# if these attributes are in output_hash, already, they will match
|
24
|
+
output_hash['module'] ||= "#{module_ref.namespace}/#{module_ref.module_name}"
|
25
|
+
output_hash['version'] ||= module_ref.version
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,36 @@
|
|
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 ServiceAndComponentInfo::TransformFrom
|
20
|
+
class Parser
|
21
|
+
class TopDSL < self
|
22
|
+
require_relative('top_dsl/module_info')
|
23
|
+
require_relative('top_dsl/assemblies')
|
24
|
+
require_relative('top_dsl/components')
|
25
|
+
require_relative('top_dsl/dependencies')
|
26
|
+
end
|
27
|
+
|
28
|
+
private
|
29
|
+
|
30
|
+
def module_ref
|
31
|
+
info_object.module_ref
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,24 @@
|
|
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 ServiceAndComponentInfo::TransformFrom
|
20
|
+
class Parser < ServiceAndComponentInfo::Parser
|
21
|
+
require_relative('parser/top_dsl')
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -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
|
+
module DTK::DSL
|
19
|
+
class ServiceAndComponentInfo
|
20
|
+
class TransformFrom < self
|
21
|
+
require_relative('transform_from/info')
|
22
|
+
require_relative('transform_from/parser')
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,70 @@
|
|
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 ServiceAndComponentInfo::TransformTo
|
20
|
+
class Info
|
21
|
+
class Component < self
|
22
|
+
def compute_outputs!
|
23
|
+
set_top_level_dsl_output_hash!
|
24
|
+
set_module_refs_output_hash!
|
25
|
+
end
|
26
|
+
|
27
|
+
private
|
28
|
+
|
29
|
+
def info_type
|
30
|
+
:component_info
|
31
|
+
end
|
32
|
+
|
33
|
+
def set_top_level_dsl_output_hash!
|
34
|
+
path = ComponentModulePath.top_level_dsl
|
35
|
+
parser = component_module_dsl_parser::TopDSL
|
36
|
+
set_output_hash?(parser, path)
|
37
|
+
end
|
38
|
+
|
39
|
+
def set_module_refs_output_hash!
|
40
|
+
path = ComponentModulePath.module_refs
|
41
|
+
parser = component_module_dsl_parser::ModuleRefs
|
42
|
+
set_output_hash?(parser, path)
|
43
|
+
end
|
44
|
+
|
45
|
+
def set_output_hash?(parser, path)
|
46
|
+
output_hash = output_file_hash(path)
|
47
|
+
if parser.update_output_hash?(output_hash, self) # This conditionally updates output_hash
|
48
|
+
update_or_add_output_hash!(path, output_hash)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
def component_module_dsl_parser
|
53
|
+
@component_module_dsl_parser ||= Parser::ComponentModule
|
54
|
+
end
|
55
|
+
|
56
|
+
module ComponentModulePath
|
57
|
+
TOP_LEVEL_DSL = 'dtk.model.yaml'
|
58
|
+
MODULE_REFS = 'module_refs.yaml'
|
59
|
+
def self.top_level_dsl
|
60
|
+
TOP_LEVEL_DSL
|
61
|
+
end
|
62
|
+
def self.module_refs
|
63
|
+
MODULE_REFS
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
@@ -0,0 +1,36 @@
|
|
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 ServiceAndComponentInfo::TransformTo::Info
|
20
|
+
class InputFiles < ServiceAndComponentInfo::Info::InputFiles
|
21
|
+
def add_canonical_hash_content!(path, canonical_hash_content)
|
22
|
+
raise_error_if_not_canonical_hash(canonical_hash_content)
|
23
|
+
add_hash_content!(path, canonical_hash_content)
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
def raise_error_if_not_canonical_hash(obj)
|
29
|
+
unless obj.kind_of?(InputOutputCommon::Canonical::Hash)
|
30
|
+
raise Error, "Expecting input of type 'InputOutputCommon::Canonical::Hash', but '#{obj.class}' was given"
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -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
|
+
module DTK::DSL
|
19
|
+
class ServiceAndComponentInfo::TransformTo
|
20
|
+
class Info
|
21
|
+
class Service < self
|
22
|
+
def compute_outputs!
|
23
|
+
set_top_level_dsl_output_hash!
|
24
|
+
set_module_refs_output_hash!
|
25
|
+
end
|
26
|
+
|
27
|
+
private
|
28
|
+
|
29
|
+
def info_type
|
30
|
+
:service_info
|
31
|
+
end
|
32
|
+
|
33
|
+
def set_top_level_dsl_output_hash!
|
34
|
+
parser = service_module_dsl_parser::TopDSL
|
35
|
+
set_output_hash?(parser)
|
36
|
+
end
|
37
|
+
|
38
|
+
def set_module_refs_output_hash!
|
39
|
+
path = ServiceModulePath.module_refs
|
40
|
+
parser = service_module_dsl_parser::ModuleRefs
|
41
|
+
output_hash = output_file_hash(path)
|
42
|
+
update_or_add_output_hash!(path, output_hash) if parser.update_output_hash?(output_hash, self)
|
43
|
+
end
|
44
|
+
|
45
|
+
def set_output_hash?(parser)
|
46
|
+
output_hash = {}
|
47
|
+
if parser.update_output_hash?(output_hash, self)
|
48
|
+
if assemblies = output_hash['assemblies'] || output_hash[:assemblies]
|
49
|
+
assemblies.each { |assembly| update_or_add_output_hash!(ServiceModulePath.top_level_dsl(assembly['name']||assembly[:name]), assembly) }
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
def service_module_dsl_parser
|
55
|
+
@service_module_dsl_parser ||= Parser::ServiceModule
|
56
|
+
end
|
57
|
+
|
58
|
+
module ServiceModulePath
|
59
|
+
TOP_LEVEL_DSL = 'dtk.assembly.yaml'
|
60
|
+
MODULE_REFS = 'module_refs.yaml'
|
61
|
+
def self.top_level_dsl(assembly_name)
|
62
|
+
"assemblies/#{assembly_name}.#{TOP_LEVEL_DSL}"
|
63
|
+
end
|
64
|
+
def self.module_refs
|
65
|
+
MODULE_REFS
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
@@ -0,0 +1,51 @@
|
|
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 ServiceAndComponentInfo::TransformTo
|
20
|
+
class Info < ServiceAndComponentInfo::Info
|
21
|
+
require_relative('info/input_files')
|
22
|
+
require_relative('info/service')
|
23
|
+
require_relative('info/component')
|
24
|
+
|
25
|
+
# This is for mapping to module directories (not service instance directories)
|
26
|
+
INFO_HASH = {
|
27
|
+
:service_info => {
|
28
|
+
:input_files => {
|
29
|
+
:module => {
|
30
|
+
:regexps => [Regexp.new("dtk\.module\.yaml$")]
|
31
|
+
},
|
32
|
+
:assemblies => {
|
33
|
+
:regexps => [Regexp.new("assemblies/(.*)\.dtk\.assembly\.(yml|yaml)$"), ]
|
34
|
+
},
|
35
|
+
:legacy_assemblies => {
|
36
|
+
:regexps => [Regexp.new("assemblies/([^/]+)/assembly\.(yml|yaml)$")]
|
37
|
+
}
|
38
|
+
}
|
39
|
+
},
|
40
|
+
:component_info => {
|
41
|
+
:input_files => {
|
42
|
+
:module => {
|
43
|
+
:regexps => [Regexp.new("dtk\.module\.yaml$")]
|
44
|
+
}
|
45
|
+
}
|
46
|
+
}
|
47
|
+
}
|
48
|
+
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,27 @@
|
|
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 ServiceAndComponentInfo::TransformTo
|
20
|
+
class Parser
|
21
|
+
module ComponentModule
|
22
|
+
class ModuleRefs < Parser::ModuleRefs
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,47 @@
|
|
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; class ServiceAndComponentInfo::TransformTo
|
19
|
+
class Parser
|
20
|
+
module ComponentModule
|
21
|
+
class TopDSL < Parser
|
22
|
+
def update_output_hash?
|
23
|
+
if module_dsl_canonical_hash = input_file_hash?(:module)
|
24
|
+
if component_defs = module_dsl_canonical_hash.val(:ComponentDefs)
|
25
|
+
add_module_info_to_output_hash!
|
26
|
+
add_components_to_output_hash!(component_defs)
|
27
|
+
output_hash
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
private
|
33
|
+
|
34
|
+
COMPONENT_MODULE_DSL_VERSION = '1.0.0'
|
35
|
+
def add_module_info_to_output_hash!
|
36
|
+
output_hash['module'] = info_object.module_ref.module_name
|
37
|
+
output_hash['dsl_version'] = COMPONENT_MODULE_DSL_VERSION
|
38
|
+
end
|
39
|
+
|
40
|
+
def add_components_to_output_hash!(component_defs)
|
41
|
+
output_hash['components'] = component_defs
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end; end
|
@@ -0,0 +1,28 @@
|
|
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 ServiceAndComponentInfo::TransformTo
|
20
|
+
class Parser
|
21
|
+
# parse to form component module files
|
22
|
+
module ComponentModule
|
23
|
+
require_relative('component_module/top_dsl')
|
24
|
+
require_relative('component_module/module_refs')
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,54 @@
|
|
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 ServiceAndComponentInfo::TransformTo::Parser
|
20
|
+
class ModuleRefs < self
|
21
|
+
def update_output_hash?
|
22
|
+
if module_dsl_canonical_hash = input_file_hash?(:module)
|
23
|
+
if dependencies = module_dsl_canonical_hash.val(:DependentModules)
|
24
|
+
add_dependencies_to_output_hash!(dependencies)
|
25
|
+
output_hash
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
private
|
31
|
+
|
32
|
+
def add_dependencies_to_output_hash!(dependencies_canonical_array)
|
33
|
+
component_modules = dependencies_canonical_array.inject({}) do |h, dependency_canonical_hash|
|
34
|
+
module_name = dependency_canonical_hash.val(:ModuleName)
|
35
|
+
namespace = dependency_canonical_hash.val(:Namespace)
|
36
|
+
version = version?(dependency_canonical_hash)
|
37
|
+
|
38
|
+
module_info = { 'namespace' => namespace }
|
39
|
+
module_info.merge!('version' => version) if version
|
40
|
+
h.merge(module_name => module_info)
|
41
|
+
end
|
42
|
+
|
43
|
+
output_hash.merge!('component_modules' => component_modules) unless component_modules.empty?
|
44
|
+
end
|
45
|
+
|
46
|
+
def version?(dependency_canonical_hash)
|
47
|
+
if version = dependency_canonical_hash.val(:ModuleVersion)
|
48
|
+
version == 'master' ? nil : version
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,27 @@
|
|
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 ServiceAndComponentInfo::TransformTo
|
20
|
+
class Parser
|
21
|
+
module ServiceModule
|
22
|
+
class ModuleRefs < Parser::ModuleRefs
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,73 @@
|
|
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; class ServiceAndComponentInfo::TransformTo
|
19
|
+
class Parser
|
20
|
+
module ServiceModule
|
21
|
+
class TopDSL < Parser
|
22
|
+
def update_output_hash?
|
23
|
+
if module_dsl_canonical_hash = input_file_hash?(:module)
|
24
|
+
if assemblies = module_dsl_canonical_hash.val(:Assemblies)
|
25
|
+
add_module_info_to_output_hash!
|
26
|
+
add_assemblies_to_output_hash!(assemblies)
|
27
|
+
output_hash
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
private
|
33
|
+
|
34
|
+
DSL_VERSION = '1.0.0'
|
35
|
+
def add_module_info_to_output_hash!
|
36
|
+
output_hash['module'] = info_object.module_ref.module_name
|
37
|
+
output_hash['dsl_version'] = DSL_VERSION
|
38
|
+
end
|
39
|
+
|
40
|
+
def add_assemblies_to_output_hash!(assemblies)
|
41
|
+
assemblies_yaml_object_array = assemblies.map do |assembly_canonical_hash|
|
42
|
+
parsed_assembly = FileGenerator.generate_yaml_object(:assembly, assembly_canonical_hash, DSL_VERSION)
|
43
|
+
assembly_content = {}
|
44
|
+
|
45
|
+
if name = parsed_assembly.delete('name') || assembly_canonical_hash[:name]
|
46
|
+
assembly_content['name'] = name
|
47
|
+
end
|
48
|
+
|
49
|
+
if description = parsed_assembly.delete('description')
|
50
|
+
assembly_content['description'] = description
|
51
|
+
end
|
52
|
+
|
53
|
+
assembly_content['dsl_version'] = DSL_VERSION
|
54
|
+
workflows = parsed_assembly.delete('workflows')
|
55
|
+
|
56
|
+
if parsed_assembly && !parsed_assembly.empty?
|
57
|
+
assembly_content['assembly'] = parsed_assembly
|
58
|
+
end
|
59
|
+
|
60
|
+
if workflows
|
61
|
+
assembly_content['workflows'] = workflows
|
62
|
+
end
|
63
|
+
|
64
|
+
assembly_content
|
65
|
+
end
|
66
|
+
|
67
|
+
output_hash['assemblies'] = assemblies_yaml_object_array
|
68
|
+
end
|
69
|
+
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end; end
|