dtk-shell 0.10.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Gemfile +5 -0
- data/Gemfile_dev +13 -0
- data/README.md +121 -0
- data/bin/dtk-execute +32 -0
- data/bin/dtk-run +92 -0
- data/bin/dtk-shell +31 -0
- data/dtk-shell.gemspec +50 -0
- data/lib/auxiliary.rb +61 -0
- data/lib/bundler_monkey_patch.rb +26 -0
- data/lib/client.rb +58 -0
- data/lib/command_helper.rb +33 -0
- data/lib/command_helpers/git_repo.rb +589 -0
- data/lib/command_helpers/git_repo/merge.rb +153 -0
- data/lib/command_helpers/jenkins_client.rb +106 -0
- data/lib/command_helpers/jenkins_client/config_xml.rb +288 -0
- data/lib/command_helpers/service_importer.rb +251 -0
- data/lib/command_helpers/service_link.rb +33 -0
- data/lib/command_helpers/test_module_creator.rb +69 -0
- data/lib/command_helpers/test_module_templates/dtk.model.yaml.eruby +10 -0
- data/lib/command_helpers/test_module_templates/spec_helper.rb.eruby +10 -0
- data/lib/command_helpers/test_module_templates/temp_component_spec.rb.eruby +5 -0
- data/lib/commands.rb +57 -0
- data/lib/commands/common/thor/access_control.rb +133 -0
- data/lib/commands/common/thor/action_result_handler.rb +74 -0
- data/lib/commands/common/thor/assembly_template.rb +92 -0
- data/lib/commands/common/thor/assembly_workspace.rb +1801 -0
- data/lib/commands/common/thor/base_command_helper.rb +59 -0
- data/lib/commands/common/thor/clone.rb +82 -0
- data/lib/commands/common/thor/common.rb +88 -0
- data/lib/commands/common/thor/common_base.rb +49 -0
- data/lib/commands/common/thor/create_target.rb +70 -0
- data/lib/commands/common/thor/edit.rb +255 -0
- data/lib/commands/common/thor/inventory_parser.rb +98 -0
- data/lib/commands/common/thor/list_diffs.rb +128 -0
- data/lib/commands/common/thor/module.rb +1011 -0
- data/lib/commands/common/thor/module/import.rb +210 -0
- data/lib/commands/common/thor/node.rb +53 -0
- data/lib/commands/common/thor/poller.rb +65 -0
- data/lib/commands/common/thor/pull_clone_changes.rb +28 -0
- data/lib/commands/common/thor/pull_from_remote.rb +152 -0
- data/lib/commands/common/thor/puppet_forge.rb +72 -0
- data/lib/commands/common/thor/purge_clone.rb +101 -0
- data/lib/commands/common/thor/push_clone_changes.rb +162 -0
- data/lib/commands/common/thor/push_to_remote.rb +94 -0
- data/lib/commands/common/thor/remotes.rb +71 -0
- data/lib/commands/common/thor/reparse.rb +40 -0
- data/lib/commands/common/thor/set_required_attributes.rb +46 -0
- data/lib/commands/thor/account.rb +239 -0
- data/lib/commands/thor/assembly.rb +356 -0
- data/lib/commands/thor/attribute.rb +79 -0
- data/lib/commands/thor/component.rb +70 -0
- data/lib/commands/thor/component_module.rb +501 -0
- data/lib/commands/thor/component_template.rb +174 -0
- data/lib/commands/thor/dependency.rb +34 -0
- data/lib/commands/thor/developer.rb +144 -0
- data/lib/commands/thor/dtk.rb +152 -0
- data/lib/commands/thor/library.rb +125 -0
- data/lib/commands/thor/node.rb +504 -0
- data/lib/commands/thor/node_template.rb +94 -0
- data/lib/commands/thor/project.rb +34 -0
- data/lib/commands/thor/provider.rb +233 -0
- data/lib/commands/thor/remotes.rb +49 -0
- data/lib/commands/thor/service.rb +941 -0
- data/lib/commands/thor/service_module.rb +914 -0
- data/lib/commands/thor/state_change.rb +25 -0
- data/lib/commands/thor/target.rb +250 -0
- data/lib/commands/thor/task.rb +116 -0
- data/lib/commands/thor/test_module.rb +310 -0
- data/lib/commands/thor/utils.rb +21 -0
- data/lib/commands/thor/workspace.rb +685 -0
- data/lib/config/cacert.pem +3785 -0
- data/lib/config/client.conf.header +20 -0
- data/lib/config/configuration.rb +99 -0
- data/lib/config/default.conf +16 -0
- data/lib/config/disk_cacher.rb +80 -0
- data/lib/configurator.rb +176 -0
- data/lib/context_router.rb +44 -0
- data/lib/core.rb +497 -0
- data/lib/domain/git_adapter.rb +412 -0
- data/lib/domain/git_error_handler.rb +64 -0
- data/lib/domain/response.rb +285 -0
- data/lib/domain/response/error_handler.rb +86 -0
- data/lib/dtk-shell/version.rb +20 -0
- data/lib/dtk_constants.rb +40 -0
- data/lib/dtk_error.rb +114 -0
- data/lib/dtk_logger.rb +126 -0
- data/lib/dtk_shell.rb +31 -0
- data/lib/error.rb +85 -0
- data/lib/execute.rb +29 -0
- data/lib/execute/cli_pure/cli_rerouter.rb +102 -0
- data/lib/execute/command.rb +40 -0
- data/lib/execute/command/api_call.rb +60 -0
- data/lib/execute/command/api_call/map.rb +60 -0
- data/lib/execute/command/api_call/service.rb +91 -0
- data/lib/execute/command/api_call/translation_term.rb +119 -0
- data/lib/execute/command/rest_call.rb +37 -0
- data/lib/execute/command_processor.rb +30 -0
- data/lib/execute/command_processor/rest_call.rb +59 -0
- data/lib/execute/error_usage.rb +21 -0
- data/lib/execute/execute_context.rb +86 -0
- data/lib/execute/execute_context/result_store.rb +37 -0
- data/lib/execute/script.rb +64 -0
- data/lib/execute/script/add_tenant.rb +121 -0
- data/lib/git-logs/git.log +0 -0
- data/lib/parser/adapters/option_parser.rb +70 -0
- data/lib/parser/adapters/thor.rb +555 -0
- data/lib/parser/adapters/thor/common_option_defs.rb +40 -0
- data/lib/require_first.rb +104 -0
- data/lib/search_hash.rb +44 -0
- data/lib/shell.rb +261 -0
- data/lib/shell/context.rb +1065 -0
- data/lib/shell/context_aux.rb +46 -0
- data/lib/shell/domain/active_context.rb +186 -0
- data/lib/shell/domain/context_entity.rb +89 -0
- data/lib/shell/domain/context_params.rb +223 -0
- data/lib/shell/domain/override_tasks.rb +88 -0
- data/lib/shell/domain/shadow_entity.rb +76 -0
- data/lib/shell/header_shell.rb +44 -0
- data/lib/shell/help_monkey_patch.rb +283 -0
- data/lib/shell/interactive_wizard.rb +225 -0
- data/lib/shell/message_queue.rb +63 -0
- data/lib/shell/parse_monkey_patch.rb +39 -0
- data/lib/shell/status_monitor.rb +124 -0
- data/lib/task_status.rb +83 -0
- data/lib/task_status/refresh_mode.rb +77 -0
- data/lib/task_status/snapshot_mode.rb +28 -0
- data/lib/task_status/stream_mode.rb +48 -0
- data/lib/task_status/stream_mode/element.rb +101 -0
- data/lib/task_status/stream_mode/element/format.rb +101 -0
- data/lib/task_status/stream_mode/element/hierarchical_task.rb +100 -0
- data/lib/task_status/stream_mode/element/hierarchical_task/result.rb +72 -0
- data/lib/task_status/stream_mode/element/hierarchical_task/result/action.rb +93 -0
- data/lib/task_status/stream_mode/element/hierarchical_task/result/components.rb +26 -0
- data/lib/task_status/stream_mode/element/hierarchical_task/result/node_level.rb +26 -0
- data/lib/task_status/stream_mode/element/hierarchical_task/steps.rb +34 -0
- data/lib/task_status/stream_mode/element/hierarchical_task/steps/action.rb +53 -0
- data/lib/task_status/stream_mode/element/hierarchical_task/steps/components.rb +53 -0
- data/lib/task_status/stream_mode/element/hierarchical_task/steps/node_level.rb +42 -0
- data/lib/task_status/stream_mode/element/no_results.rb +26 -0
- data/lib/task_status/stream_mode/element/render.rb +59 -0
- data/lib/task_status/stream_mode/element/stage.rb +84 -0
- data/lib/task_status/stream_mode/element/stage/render.rb +76 -0
- data/lib/task_status/stream_mode/element/task_end.rb +35 -0
- data/lib/task_status/stream_mode/element/task_start.rb +37 -0
- data/lib/util/common_util.rb +37 -0
- data/lib/util/console.rb +235 -0
- data/lib/util/dtk_puppet.rb +65 -0
- data/lib/util/module_util.rb +66 -0
- data/lib/util/os_util.rb +385 -0
- data/lib/util/permission_util.rb +31 -0
- data/lib/util/remote_dependency_util.rb +84 -0
- data/lib/util/ssh_util.rb +94 -0
- data/lib/view_processor.rb +129 -0
- data/lib/view_processor/augmented_simple_list.rb +44 -0
- data/lib/view_processor/hash_pretty_print.rb +123 -0
- data/lib/view_processor/simple_list.rb +156 -0
- data/lib/view_processor/table_print.rb +309 -0
- data/lib/violation.rb +86 -0
- data/lib/violation/attribute.rb +76 -0
- data/lib/violation/fix.rb +26 -0
- data/lib/violation/fix/result.rb +73 -0
- data/lib/violation/fix/result/error.rb +34 -0
- data/lib/violation/fix/set_attribute.rb +41 -0
- data/lib/violation/sub_classes.rb +60 -0
- data/puppet/manifests/init.pp +72 -0
- data/puppet/manifests/params.pp +16 -0
- data/puppet/r8meta.puppet.yml +35 -0
- data/puppet/templates/bash_profile.erb +2 -0
- data/puppet/templates/client.conf.erb +1 -0
- data/puppet/templates/dtkclient.erb +2 -0
- data/spec/component_module_spec.rb +34 -0
- data/spec/dependency_spec.rb +6 -0
- data/spec/dtk_shell_spec.rb +13 -0
- data/spec/dtk_spec.rb +33 -0
- data/spec/lib/spec_helper.rb +10 -0
- data/spec/lib/spec_thor.rb +108 -0
- data/spec/node_template_spec.rb +24 -0
- data/spec/project_spec.rb +6 -0
- data/spec/repo_spec.rb +7 -0
- data/spec/response_spec.rb +52 -0
- data/spec/service_module_spec.rb +38 -0
- data/spec/service_spec.rb +50 -0
- data/spec/state_change_spec.rb +7 -0
- data/spec/table_print_spec.rb +48 -0
- data/spec/target_spec.rb +57 -0
- data/spec/task_spec.rb +28 -0
- data/views/assembly/augmented_simple_list.rb +12 -0
- data/views/assembly_template/augmented_simple_list.rb +12 -0
- data/views/list_task/augmented_simple_list.rb +12 -0
- metadata +421 -0
@@ -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::Client; class TaskStatus::StreamMode::Element
|
19
|
+
class HierarchicalTask
|
20
|
+
class Results < self
|
21
|
+
require File.expand_path('result/action', File.dirname(__FILE__))
|
22
|
+
require File.expand_path('result/components', File.dirname(__FILE__))
|
23
|
+
require File.expand_path('result/node_level', File.dirname(__FILE__))
|
24
|
+
|
25
|
+
def initialize(element, hash)
|
26
|
+
super
|
27
|
+
@errors = hash['errors'] || []
|
28
|
+
end
|
29
|
+
|
30
|
+
|
31
|
+
def self.render(element, stage_subtasks)
|
32
|
+
results_per_node = base_subtasks(element, stage_subtasks)
|
33
|
+
return if results_per_node.empty?
|
34
|
+
# assumption is that if multipe results_per_node they are same type
|
35
|
+
results_per_node.first.render_results(results_per_node)
|
36
|
+
end
|
37
|
+
|
38
|
+
protected
|
39
|
+
|
40
|
+
attr_reader :errors
|
41
|
+
|
42
|
+
def render_errors(results_per_node)
|
43
|
+
return unless results_per_node.find { |result| not result.errors.empty?}
|
44
|
+
first_time = true
|
45
|
+
results_per_node.each do |result|
|
46
|
+
if first_time
|
47
|
+
render_line 'ERRORS:'
|
48
|
+
first_time = false
|
49
|
+
end
|
50
|
+
result.render_node_errors
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
def render_node_errors
|
55
|
+
return if @errors.empty?
|
56
|
+
render_node_term
|
57
|
+
@errors.each do |error|
|
58
|
+
if err_msg = error['message']
|
59
|
+
render_error_line err_msg
|
60
|
+
render_empty_line
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
def render_error_line(line, opts = {})
|
66
|
+
render_line(line, ErrorRenderOpts.merge(opts))
|
67
|
+
end
|
68
|
+
ErrorRenderOpts = { :tabs => 1}
|
69
|
+
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end; end
|
@@ -0,0 +1,93 @@
|
|
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::Client; class TaskStatus::StreamMode::Element::HierarchicalTask
|
19
|
+
class Results
|
20
|
+
class Action < self
|
21
|
+
def initialize(element, hash)
|
22
|
+
super
|
23
|
+
@action_results = hash['action_results'] || []
|
24
|
+
end
|
25
|
+
|
26
|
+
attr_reader :action_results
|
27
|
+
|
28
|
+
def render_results(results_per_node)
|
29
|
+
if any_results?(results_per_node)
|
30
|
+
render_line 'RESULTS:'
|
31
|
+
render_empty_line
|
32
|
+
results_per_node.each { |result| result.render }
|
33
|
+
else
|
34
|
+
render_errors(results_per_node)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def render
|
39
|
+
not_first_time = nil
|
40
|
+
render_node_term
|
41
|
+
@action_results.each do |action_result|
|
42
|
+
render_action_result_lines(action_result, :first_time => not_first_time.nil?)
|
43
|
+
not_first_time ||= true
|
44
|
+
end
|
45
|
+
render_empty_line
|
46
|
+
end
|
47
|
+
|
48
|
+
private
|
49
|
+
|
50
|
+
def any_results?(results_per_node)
|
51
|
+
!!results_per_node.find { |results| !results.action_results.empty? }
|
52
|
+
end
|
53
|
+
|
54
|
+
def render_action_result_lines(action_result, opts = {})
|
55
|
+
stdout = action_result['stdout']
|
56
|
+
stderr = action_result['stderr']
|
57
|
+
unless opts[:first_time]
|
58
|
+
render_line '--'
|
59
|
+
end
|
60
|
+
if command = command?(action_result)
|
61
|
+
render_line command
|
62
|
+
end
|
63
|
+
if return_code = action_result['status']
|
64
|
+
render_line "RETURN CODE: #{return_code.to_s}"
|
65
|
+
end
|
66
|
+
if stdout && !stdout.empty?
|
67
|
+
render_line 'STDOUT:'
|
68
|
+
render_action_output stdout
|
69
|
+
end
|
70
|
+
if stderr && !stderr.empty?
|
71
|
+
render_line 'STDERR:'
|
72
|
+
render_action_output stderr
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
def render_action_output(line)
|
77
|
+
render_line line, RenderActionLineOpts
|
78
|
+
end
|
79
|
+
RenderActionLineOpts = { :tabs => 1 }
|
80
|
+
|
81
|
+
def command?(action_result)
|
82
|
+
if command = action_result['description']
|
83
|
+
if match = command.match(/^(create )(.*)/)
|
84
|
+
"ADD: #{match[2]}"
|
85
|
+
else
|
86
|
+
"RUN: #{command}"
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end; 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::Client; class TaskStatus::StreamMode::Element::HierarchicalTask
|
19
|
+
class Results
|
20
|
+
class Components < self
|
21
|
+
def render_results(results_per_node)
|
22
|
+
render_errors(results_per_node)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end; 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::Client; class TaskStatus::StreamMode::Element::HierarchicalTask
|
19
|
+
class Results
|
20
|
+
class NodeLevel < self
|
21
|
+
def render_results(results_per_node)
|
22
|
+
render_errors(results_per_node)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end; end
|
@@ -0,0 +1,34 @@
|
|
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::Client; class TaskStatus::StreamMode::Element
|
19
|
+
class HierarchicalTask
|
20
|
+
class Steps < self
|
21
|
+
require File.expand_path('steps/action', File.dirname(__FILE__))
|
22
|
+
require File.expand_path('steps/components', File.dirname(__FILE__))
|
23
|
+
require File.expand_path('steps/node_level', File.dirname(__FILE__))
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
def self.render(element, stage_subtasks)
|
28
|
+
steps = base_subtasks(element, stage_subtasks, :stop_at_node_group => true)
|
29
|
+
return if steps.empty?
|
30
|
+
steps.first.render_steps(steps)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end; end
|
@@ -0,0 +1,53 @@
|
|
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::Client; class TaskStatus::StreamMode::Element::HierarchicalTask
|
19
|
+
class Steps
|
20
|
+
class Action < self
|
21
|
+
def initialize(element, hash)
|
22
|
+
super
|
23
|
+
@action = hash['action'] || {}
|
24
|
+
end
|
25
|
+
|
26
|
+
def render_steps(steps)
|
27
|
+
steps.each { |step| step.render }
|
28
|
+
end
|
29
|
+
|
30
|
+
def render
|
31
|
+
if action_term = action_term?
|
32
|
+
render_line "ACTION: #{action_term}"
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
private
|
37
|
+
|
38
|
+
def action_term?
|
39
|
+
ret = ''
|
40
|
+
if node_term = node_term?
|
41
|
+
ret << "#{node_term}/"
|
42
|
+
end
|
43
|
+
if component_name = @action['component_name']
|
44
|
+
ret << component_name
|
45
|
+
end
|
46
|
+
if method_name = @action['method_name']
|
47
|
+
ret << ".#{method_name}"
|
48
|
+
end
|
49
|
+
ret.nil? ? nil : ret
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end; end
|
@@ -0,0 +1,53 @@
|
|
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::Client; class TaskStatus::StreamMode::Element::HierarchicalTask
|
19
|
+
class Steps
|
20
|
+
class Components < self
|
21
|
+
def initialize(element, hash)
|
22
|
+
super
|
23
|
+
@component_names = (hash['components'] || []).map { |cmp| cmp['name'] }.compact
|
24
|
+
end
|
25
|
+
|
26
|
+
attr_reader :component_names
|
27
|
+
|
28
|
+
def render_steps(steps)
|
29
|
+
step = steps.first
|
30
|
+
if steps.size == 1 and step.component_names.size == 1
|
31
|
+
render_line "COMPONENT: #{step.component_term(step.component_names.first)}"
|
32
|
+
else
|
33
|
+
render_line 'COMPONENTS:'
|
34
|
+
steps.each do |step|
|
35
|
+
step.component_names.each do |component_name|
|
36
|
+
render_line step.component_term(component_name), :tabs => 1
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def component_term(component_name)
|
43
|
+
ret = ''
|
44
|
+
if node_term = node_term?
|
45
|
+
ret << "#{node_term}/"
|
46
|
+
end
|
47
|
+
ret << component_name
|
48
|
+
ret
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
end; 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
|
+
module DTK::Client; class TaskStatus::StreamMode::Element::HierarchicalTask
|
19
|
+
class Steps
|
20
|
+
class NodeLevel < self
|
21
|
+
def render_steps(steps)
|
22
|
+
render_line node_operation_line(steps)
|
23
|
+
steps.each { |step| step.render }
|
24
|
+
end
|
25
|
+
|
26
|
+
def render
|
27
|
+
render_line node_term?, :tabs => 1
|
28
|
+
end
|
29
|
+
|
30
|
+
private
|
31
|
+
|
32
|
+
def node_operation_line(steps)
|
33
|
+
operation_term = @type
|
34
|
+
if steps.size > 1 and not operation_term =~ /s$/
|
35
|
+
operation_term += 's'
|
36
|
+
end
|
37
|
+
"OPERATION: #{operation_term}"
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end; 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::Client; class TaskStatus::StreamMode
|
19
|
+
class Element
|
20
|
+
class NoResults < self
|
21
|
+
def task_end?()
|
22
|
+
true
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end; end
|
@@ -0,0 +1,59 @@
|
|
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::Client::TaskStatus::StreamMode::Element
|
19
|
+
module RenderMixin
|
20
|
+
def render_line(msg, params = {})
|
21
|
+
if msg
|
22
|
+
print_to_console(@formatter.format(msg, params))
|
23
|
+
render_empty_line
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def render_start_time(started_at)
|
28
|
+
render_line(@formatter.start_time_msg?(started_at))
|
29
|
+
end
|
30
|
+
|
31
|
+
def formatted_duration?
|
32
|
+
@formatter.formatted_duration?(field?(:duration))
|
33
|
+
end
|
34
|
+
|
35
|
+
def render_duration_line
|
36
|
+
render_line(@formatter.duration_msg?(field?(:duration)))
|
37
|
+
end
|
38
|
+
|
39
|
+
def render_border
|
40
|
+
print_to_console(@formatter.border)
|
41
|
+
render_empty_line
|
42
|
+
end
|
43
|
+
|
44
|
+
def render_empty_line
|
45
|
+
render_empty_lines(1)
|
46
|
+
end
|
47
|
+
|
48
|
+
def render_empty_lines(num_empty_lines = 1)
|
49
|
+
print_to_console("\n" * num_empty_lines)
|
50
|
+
end
|
51
|
+
|
52
|
+
private
|
53
|
+
|
54
|
+
def print_to_console(string)
|
55
|
+
#TODO: stub
|
56
|
+
STDOUT << string
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|