dtk-client 0.9.1 → 0.10.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +4 -0
- data/Gemfile +1 -3
- data/README.md +2 -121
- data/Rakefile +44 -0
- data/bin/dtk +10 -88
- data/dtk-client.gemspec +21 -44
- data/examples/simple/dtk.module.yaml +32 -0
- data/{lib/git-logs/git.log → examples/simple/test/README.md} +0 -0
- data/examples/spark/dtk.module.yaml +120 -0
- data/examples/with_repo_content/deploy/puppet/manifests/hostname.pp +54 -0
- data/examples/with_repo_content/dtk.module.yaml +49 -0
- data/examples/with_repo_content/test/README.txt +0 -0
- data/features/dtk.feature +8 -0
- data/features/step_definitions/dtk_steps.rb +6 -0
- data/features/support/env.rb +15 -0
- data/lib/cli/command/mixin.rb +101 -0
- data/lib/cli/command/module/clone.rb +42 -0
- data/lib/cli/command/module/install.rb +52 -0
- data/lib/cli/command/module/list.rb +31 -0
- data/lib/cli/command/module/list_assemblies.rb +39 -0
- data/lib/cli/command/module/push.rb +34 -0
- data/lib/cli/command/module/uninstall.rb +46 -0
- data/lib/cli/command/module.rb +33 -0
- data/lib/cli/command/options.rb +33 -0
- data/lib/cli/command/service/cancel_task.rb +33 -0
- data/lib/cli/command/service/converge.rb +37 -0
- data/lib/{parser/adapters/thor/common_option_defs.rb → cli/command/service/create_workspace.rb} +13 -17
- data/lib/cli/command/service/destroy.rb +47 -0
- data/lib/cli/command/service/edit.rb +47 -0
- data/lib/cli/command/service/exec.rb +42 -0
- data/lib/cli/command/service/exec_sync.rb +53 -0
- data/lib/cli/command/service/list.rb +30 -0
- data/lib/cli/command/service/list_actions.rb +39 -0
- data/lib/cli/command/service/list_attributes.rb +44 -0
- data/lib/cli/command/service/list_component_links.rb +33 -0
- data/lib/cli/command/service/list_components.rb +39 -0
- data/lib/cli/command/service/list_dependent_modules.rb +33 -0
- data/lib/cli/command/service/list_nodes.rb +33 -0
- data/lib/cli/command/service/list_violations.rb +33 -0
- data/lib/cli/command/service/pull.rb +32 -0
- data/lib/cli/command/service/push.rb +37 -0
- data/lib/{shell/parse_monkey_patch.rb → cli/command/service/set_default_target.rb} +9 -17
- data/lib/cli/command/service/set_required_attributes.rb +32 -0
- data/lib/cli/command/service/ssh.rb +42 -0
- data/lib/cli/command/service/stage.rb +55 -0
- data/lib/cli/command/service/start.rb +33 -0
- data/lib/{shell/context_aux.rb → cli/command/service/stop.rb} +10 -23
- data/lib/cli/command/service/task_status.rb +39 -0
- data/lib/cli/command/service.rb +55 -0
- data/lib/{commands.rb → cli/command/subcommand.rb} +22 -25
- data/lib/{bundler_monkey_patch.rb → cli/command/token/arg.rb} +6 -6
- data/lib/cli/command/token/class_mixin.rb +96 -0
- data/lib/cli/command/token/flag.rb +42 -0
- data/lib/{execute/command/rest_call.rb → cli/command/token/mixin.rb} +23 -14
- data/lib/cli/command/token/switch.rb +35 -0
- data/lib/cli/command/token.rb +76 -0
- data/lib/cli/command.rb +46 -0
- data/lib/cli/context/attributes.rb +50 -0
- data/lib/cli/context/type/module.rb +34 -0
- data/lib/{commands/thor/state_change.rb → cli/context/type/service.rb} +11 -5
- data/lib/cli/context/type/top.rb +32 -0
- data/lib/cli/context/type.rb +42 -0
- data/lib/cli/context.rb +174 -0
- data/lib/cli/directory_parser/file_system.rb +105 -0
- data/lib/{execute/command.rb → cli/directory_parser.rb} +14 -17
- data/lib/{execute.rb → cli/file_obj.rb} +13 -9
- data/lib/cli/processor/plugin/gli.rb +70 -0
- data/lib/cli/processor.rb +60 -0
- data/lib/cli/runner/dtkn_access.rb +75 -0
- data/lib/cli/runner.rb +58 -0
- data/lib/cli/version.rb +8 -0
- data/lib/{config → client/config}/cacert.pem +0 -0
- data/lib/client/config/default.conf +20 -0
- data/lib/client/config.rb +106 -0
- data/lib/client/configurator.rb +182 -0
- data/lib/client/conn.rb +197 -0
- data/lib/client/content_generator.rb +127 -0
- data/lib/client/error/subclasses.rb +105 -0
- data/lib/client/error.rb +98 -0
- data/lib/client/git_repo/adapter/git_gem/error_handler.rb +70 -0
- data/lib/client/git_repo/adapter/git_gem.rb +179 -0
- data/lib/client/git_repo.rb +122 -0
- data/lib/client/logger.rb +136 -0
- data/lib/client/operation/account.rb +66 -0
- data/lib/client/operation/client_module_dir/git_repo.rb +286 -0
- data/lib/client/operation/client_module_dir.rb +138 -0
- data/lib/client/operation/module/clone_module.rb +52 -0
- data/lib/client/operation/module/install/common_module.rb +58 -0
- data/lib/client/operation/module/install/external_module.rb +122 -0
- data/lib/client/operation/module/install.rb +91 -0
- data/lib/client/operation/module/install_from_catalog.rb +76 -0
- data/lib/client/operation/module/list.rb +34 -0
- data/lib/client/operation/module/list_assemblies.rb +35 -0
- data/lib/client/operation/module/push.rb +62 -0
- data/lib/client/operation/module/uninstall.rb +44 -0
- data/lib/client/operation/module.rb +58 -0
- data/lib/{commands/common/thor/reparse.rb → client/operation/module_service_common.rb} +27 -16
- data/lib/client/operation/service/cancel_task.rb +29 -0
- data/lib/client/operation/service/commit_and_push.rb +128 -0
- data/lib/client/operation/service/converge.rb +50 -0
- data/lib/{util/common_util.rb → client/operation/service/create_workspace.rb} +13 -13
- data/lib/client/operation/service/destroy.rb +42 -0
- data/lib/client/operation/service/edit.rb +54 -0
- data/lib/client/operation/service/exec.rb +73 -0
- data/lib/client/operation/service/list.rb +32 -0
- data/lib/client/operation/service/list_actions.rb +34 -0
- data/lib/{commands/thor/dependency.rb → client/operation/service/list_attributes.rb} +16 -12
- data/lib/client/operation/service/list_component_links.rb +29 -0
- data/lib/{commands/common/thor/pull_clone_changes.rb → client/operation/service/list_components.rb} +13 -7
- data/lib/client/operation/service/list_dependent_modules.rb +29 -0
- data/lib/client/operation/service/list_nodes.rb +29 -0
- data/lib/{commands/thor/project.rb → client/operation/service/list_violations.rb} +8 -13
- data/lib/client/operation/service/pull.rb +37 -0
- data/lib/client/operation/service/set_default_target.rb +31 -0
- data/lib/client/operation/service/set_required_attributes.rb +41 -0
- data/lib/client/operation/service/ssh.rb +118 -0
- data/lib/client/operation/service/stage.rb +54 -0
- data/lib/client/operation/service/start.rb +29 -0
- data/lib/client/operation/service/stop.rb +30 -0
- data/lib/{task_status → client/operation/service/task_status}/refresh_mode.rb +15 -25
- data/lib/{task_status → client/operation/service/task_status}/snapshot_mode.rb +4 -5
- data/lib/{task_status → client/operation/service/task_status}/stream_mode/element/format.rb +1 -1
- data/lib/{task_status → client/operation/service/task_status}/stream_mode/element/hierarchical_task/result/action.rb +1 -1
- data/lib/{task_status → client/operation/service/task_status}/stream_mode/element/hierarchical_task/result/components.rb +1 -1
- data/lib/{task_status → client/operation/service/task_status}/stream_mode/element/hierarchical_task/result/node_level.rb +1 -1
- data/lib/{task_status → client/operation/service/task_status}/stream_mode/element/hierarchical_task/result.rb +4 -4
- data/lib/{task_status → client/operation/service/task_status}/stream_mode/element/hierarchical_task/steps/action.rb +1 -1
- data/lib/{task_status → client/operation/service/task_status}/stream_mode/element/hierarchical_task/steps/components.rb +1 -1
- data/lib/{task_status → client/operation/service/task_status}/stream_mode/element/hierarchical_task/steps/node_level.rb +1 -1
- data/lib/{task_status → client/operation/service/task_status}/stream_mode/element/hierarchical_task/steps.rb +4 -4
- data/lib/{task_status → client/operation/service/task_status}/stream_mode/element/hierarchical_task.rb +3 -3
- data/lib/{task_status → client/operation/service/task_status}/stream_mode/element/no_results.rb +1 -1
- data/lib/{task_status → client/operation/service/task_status}/stream_mode/element/render.rb +1 -1
- data/lib/{task_status → client/operation/service/task_status}/stream_mode/element/stage/render.rb +1 -1
- data/lib/{task_status → client/operation/service/task_status}/stream_mode/element/stage.rb +3 -3
- data/lib/{task_status → client/operation/service/task_status}/stream_mode/element/task_end.rb +1 -1
- data/lib/{task_status → client/operation/service/task_status}/stream_mode/element/task_start.rb +1 -1
- data/lib/{task_status → client/operation/service/task_status}/stream_mode/element.rb +13 -13
- data/lib/{task_status → client/operation/service/task_status}/stream_mode.rb +5 -9
- data/lib/client/operation/service/task_status.rb +77 -0
- data/lib/client/operation/service.rb +54 -0
- data/lib/client/operation.rb +67 -0
- data/lib/client/operation_args.rb +40 -0
- data/lib/{execute/execute_context/result_store.rb → client/render/view/simple.rb} +15 -14
- data/lib/client/render/view/table/processor.rb +248 -0
- data/lib/client/render/view/table.rb +75 -0
- data/lib/client/render.rb +113 -0
- data/lib/client/response/error_handler.rb +97 -0
- data/lib/client/response/render_helper.rb +78 -0
- data/lib/client/response/subclasses.rb +62 -0
- data/lib/client/response.rb +83 -0
- data/lib/client/session.rb +62 -0
- data/lib/client/util/auxiliary.rb +34 -0
- data/lib/client/util/console.rb +81 -0
- data/lib/client/util/disk_cacher.rb +66 -0
- data/lib/client/util/dtk_path.rb +28 -0
- data/lib/{search_hash.rb → client/util/hash_with_optional_keys.rb} +29 -21
- data/lib/client/util/interactive_wizard.rb +84 -0
- data/lib/client/util/module_ref.rb +92 -0
- data/lib/client/util/os_util/print.rb +121 -0
- data/lib/client/util/os_util.rb +122 -0
- data/lib/{commands/thor/utils.rb → client/util/post_body.rb} +1 -1
- data/lib/{execute/error_usage.rb → client/util/query_string_hash.rb} +2 -2
- data/lib/client/util/remote_dependency.rb +67 -0
- data/lib/client/util/ssh_util.rb +89 -0
- data/lib/client/util/validation.rb +28 -0
- data/lib/client/util.rb +18 -0
- data/lib/{util/permission_util.rb → dtk_cli.rb} +10 -9
- data/lib/dtk_client.rb +18 -14
- data/test/default_test.rb +14 -0
- data/test/test_helper.rb +9 -0
- metadata +196 -307
- data/Gemfile_dev +0 -13
- data/bin/dtk-execute +0 -32
- data/bin/dtk-shell +0 -31
- data/lib/auxiliary.rb +0 -61
- data/lib/client.rb +0 -58
- data/lib/command_helper.rb +0 -33
- data/lib/command_helpers/git_repo/merge.rb +0 -153
- data/lib/command_helpers/git_repo.rb +0 -589
- data/lib/command_helpers/jenkins_client/config_xml.rb +0 -288
- data/lib/command_helpers/jenkins_client.rb +0 -106
- data/lib/command_helpers/service_importer.rb +0 -251
- data/lib/command_helpers/service_link.rb +0 -33
- data/lib/command_helpers/test_module_creator.rb +0 -69
- data/lib/command_helpers/test_module_templates/dtk.model.yaml.eruby +0 -10
- data/lib/command_helpers/test_module_templates/spec_helper.rb.eruby +0 -10
- data/lib/command_helpers/test_module_templates/temp_component_spec.rb.eruby +0 -5
- data/lib/commands/common/thor/access_control.rb +0 -133
- data/lib/commands/common/thor/action_result_handler.rb +0 -74
- data/lib/commands/common/thor/assembly_template.rb +0 -92
- data/lib/commands/common/thor/assembly_workspace.rb +0 -1638
- data/lib/commands/common/thor/base_command_helper.rb +0 -59
- data/lib/commands/common/thor/clone.rb +0 -82
- data/lib/commands/common/thor/common.rb +0 -88
- data/lib/commands/common/thor/common_base.rb +0 -49
- data/lib/commands/common/thor/create_target.rb +0 -70
- data/lib/commands/common/thor/edit.rb +0 -255
- data/lib/commands/common/thor/inventory_parser.rb +0 -98
- data/lib/commands/common/thor/list_diffs.rb +0 -128
- data/lib/commands/common/thor/module/import.rb +0 -215
- data/lib/commands/common/thor/module.rb +0 -1011
- data/lib/commands/common/thor/node.rb +0 -53
- data/lib/commands/common/thor/poller.rb +0 -65
- data/lib/commands/common/thor/pull_from_remote.rb +0 -152
- data/lib/commands/common/thor/puppet_forge.rb +0 -72
- data/lib/commands/common/thor/purge_clone.rb +0 -101
- data/lib/commands/common/thor/push_clone_changes.rb +0 -162
- data/lib/commands/common/thor/push_to_remote.rb +0 -94
- data/lib/commands/common/thor/remotes.rb +0 -71
- data/lib/commands/common/thor/set_required_attributes.rb +0 -46
- data/lib/commands/thor/account.rb +0 -239
- data/lib/commands/thor/assembly.rb +0 -361
- data/lib/commands/thor/attribute.rb +0 -79
- data/lib/commands/thor/component.rb +0 -70
- data/lib/commands/thor/component_module.rb +0 -501
- data/lib/commands/thor/component_template.rb +0 -174
- data/lib/commands/thor/developer.rb +0 -144
- data/lib/commands/thor/dtk.rb +0 -152
- data/lib/commands/thor/library.rb +0 -125
- data/lib/commands/thor/node.rb +0 -504
- data/lib/commands/thor/node_group.rb +0 -203
- data/lib/commands/thor/node_template.rb +0 -94
- data/lib/commands/thor/provider.rb +0 -233
- data/lib/commands/thor/remotes.rb +0 -49
- data/lib/commands/thor/service.rb +0 -932
- data/lib/commands/thor/service_module.rb +0 -900
- data/lib/commands/thor/target.rb +0 -250
- data/lib/commands/thor/task.rb +0 -116
- data/lib/commands/thor/test_module.rb +0 -310
- data/lib/commands/thor/workspace.rb +0 -698
- data/lib/config/client.conf.header +0 -20
- data/lib/config/configuration.rb +0 -99
- data/lib/config/default.conf +0 -16
- data/lib/config/disk_cacher.rb +0 -80
- data/lib/configurator.rb +0 -176
- data/lib/context_router.rb +0 -44
- data/lib/core.rb +0 -489
- data/lib/domain/git_adapter.rb +0 -412
- data/lib/domain/git_error_handler.rb +0 -64
- data/lib/domain/response/error_handler.rb +0 -86
- data/lib/domain/response.rb +0 -285
- data/lib/dtk-client/version.rb +0 -20
- data/lib/dtk_constants.rb +0 -40
- data/lib/dtk_error.rb +0 -114
- data/lib/dtk_logger.rb +0 -113
- data/lib/error.rb +0 -85
- data/lib/execute/cli_pure/cli_rerouter.rb +0 -102
- data/lib/execute/command/api_call/map.rb +0 -60
- data/lib/execute/command/api_call/service.rb +0 -91
- data/lib/execute/command/api_call/translation_term.rb +0 -119
- data/lib/execute/command/api_call.rb +0 -60
- data/lib/execute/command_processor/rest_call.rb +0 -59
- data/lib/execute/command_processor.rb +0 -30
- data/lib/execute/execute_context.rb +0 -86
- data/lib/execute/script/add_tenant.rb +0 -121
- data/lib/execute/script.rb +0 -64
- data/lib/parser/adapters/option_parser.rb +0 -70
- data/lib/parser/adapters/thor.rb +0 -555
- data/lib/require_first.rb +0 -104
- data/lib/shell/context.rb +0 -1064
- data/lib/shell/domain/active_context.rb +0 -186
- data/lib/shell/domain/context_entity.rb +0 -89
- data/lib/shell/domain/context_params.rb +0 -223
- data/lib/shell/domain/override_tasks.rb +0 -88
- data/lib/shell/domain/shadow_entity.rb +0 -76
- data/lib/shell/header_shell.rb +0 -44
- data/lib/shell/help_monkey_patch.rb +0 -283
- data/lib/shell/interactive_wizard.rb +0 -256
- data/lib/shell/message_queue.rb +0 -63
- data/lib/shell/status_monitor.rb +0 -124
- data/lib/shell.rb +0 -261
- data/lib/task_status.rb +0 -83
- data/lib/util/console.rb +0 -235
- data/lib/util/dtk_puppet.rb +0 -65
- data/lib/util/module_util.rb +0 -66
- data/lib/util/os_util.rb +0 -385
- data/lib/util/remote_dependency_util.rb +0 -84
- data/lib/util/ssh_util.rb +0 -94
- data/lib/view_processor/augmented_simple_list.rb +0 -44
- data/lib/view_processor/hash_pretty_print.rb +0 -123
- data/lib/view_processor/simple_list.rb +0 -156
- data/lib/view_processor/table_print.rb +0 -309
- data/lib/view_processor.rb +0 -129
- data/puppet/manifests/init.pp +0 -72
- data/puppet/manifests/params.pp +0 -16
- data/puppet/r8meta.puppet.yml +0 -35
- data/puppet/templates/bash_profile.erb +0 -2
- data/puppet/templates/client.conf.erb +0 -1
- data/puppet/templates/dtkclient.erb +0 -2
- data/spec/component_module_spec.rb +0 -34
- data/spec/dependency_spec.rb +0 -6
- data/spec/dtk_shell_spec.rb +0 -13
- data/spec/dtk_spec.rb +0 -33
- data/spec/lib/spec_helper.rb +0 -10
- data/spec/lib/spec_thor.rb +0 -108
- data/spec/node_template_spec.rb +0 -24
- data/spec/project_spec.rb +0 -6
- data/spec/repo_spec.rb +0 -7
- data/spec/response_spec.rb +0 -52
- data/spec/service_module_spec.rb +0 -38
- data/spec/service_spec.rb +0 -50
- data/spec/state_change_spec.rb +0 -7
- data/spec/table_print_spec.rb +0 -48
- data/spec/target_spec.rb +0 -57
- data/spec/task_spec.rb +0 -28
- data/views/assembly/augmented_simple_list.rb +0 -12
- data/views/assembly_template/augmented_simple_list.rb +0 -12
- data/views/list_task/augmented_simple_list.rb +0 -12
@@ -1,186 +0,0 @@
|
|
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::Shell
|
19
|
-
class ActiveContext
|
20
|
-
|
21
|
-
# special case when we are not able to provide valid identifier but we are
|
22
|
-
# using it as such
|
23
|
-
NO_IDENTIFIER_PROVIDED = -1
|
24
|
-
|
25
|
-
# TODO: Remove accessor for debug purpose only
|
26
|
-
attr_accessor :context_list
|
27
|
-
|
28
|
-
def clone_me()
|
29
|
-
inst = ActiveContext.new
|
30
|
-
inst.context_list = @context_list.clone
|
31
|
-
return inst
|
32
|
-
end
|
33
|
-
|
34
|
-
def initialize
|
35
|
-
@context_list = []
|
36
|
-
end
|
37
|
-
|
38
|
-
def push_new_context(context_name, entity_name, context_value=nil, shadow_entity=nil)
|
39
|
-
@context_list << ContextEntity.create_context(context_name, entity_name, context_value, :id, shadow_entity)
|
40
|
-
end
|
41
|
-
|
42
|
-
def push_new_name_context(context_name, entity_name, context_value=nil)
|
43
|
-
@context_list << ContextEntity.create_context(context_name, entity_name, context_value, :name)
|
44
|
-
end
|
45
|
-
|
46
|
-
def pop_context(n)
|
47
|
-
return @context_list.pop(n)
|
48
|
-
end
|
49
|
-
|
50
|
-
def find_identifier(entity_name)
|
51
|
-
results = @context_list.select { |e| (e.is_identifier? && (e.entity == entity_name.to_sym))}
|
52
|
-
return results.first
|
53
|
-
end
|
54
|
-
|
55
|
-
def find_command(entity_name)
|
56
|
-
results = @context_list.select { |e| (e.is_command? && (e.entity == entity_name.to_sym))}
|
57
|
-
return results.first
|
58
|
-
end
|
59
|
-
|
60
|
-
def name_list()
|
61
|
-
@context_list.collect { |e| e.is_alt_identifier? ? e.transform_alt_identifier_name : e.name }
|
62
|
-
end
|
63
|
-
|
64
|
-
def name_list_simple()
|
65
|
-
@context_list.collect { |e| e.name }
|
66
|
-
end
|
67
|
-
|
68
|
-
|
69
|
-
# returns list of entities that have identifier
|
70
|
-
def commands_that_have_identifiers()
|
71
|
-
filtered_entities = @context_list.select { |e| e.is_identifier? }
|
72
|
-
return filtered_entities.collect { |e| e.entity.to_s }
|
73
|
-
end
|
74
|
-
|
75
|
-
def command_list()
|
76
|
-
filtered_entities = @context_list.select { |e| e.is_command? }
|
77
|
-
return filtered_entities.collect { |e| e.entity.to_s }
|
78
|
-
end
|
79
|
-
|
80
|
-
# returns id to be used to retrive task list form the cache based on
|
81
|
-
# current active context
|
82
|
-
def get_task_cache_id()
|
83
|
-
identifier = command_list().join('_')
|
84
|
-
return 'dtk' if identifier.empty?
|
85
|
-
if current_alt_identifier?
|
86
|
-
return "#{identifier}_#{current_alt_identifier_name()}".to_sym()
|
87
|
-
end
|
88
|
-
|
89
|
-
return current_identifier? ? "#{identifier}_wid".to_sym : identifier.to_sym
|
90
|
-
end
|
91
|
-
|
92
|
-
def full_path()
|
93
|
-
path = name_list().join('/')
|
94
|
-
path = Context.enchance_path_with_alias(path, @context_list)
|
95
|
-
|
96
|
-
return "/#{path}"
|
97
|
-
end
|
98
|
-
|
99
|
-
def clear()
|
100
|
-
@context_list.clear
|
101
|
-
end
|
102
|
-
|
103
|
-
def empty?()
|
104
|
-
return @context_list.empty?
|
105
|
-
end
|
106
|
-
|
107
|
-
def is_n_context?
|
108
|
-
@context_list.size > 2
|
109
|
-
end
|
110
|
-
|
111
|
-
def is_base_context?
|
112
|
-
@context_list.size == 1
|
113
|
-
end
|
114
|
-
|
115
|
-
def is_root_context?
|
116
|
-
@context_list.size == 0
|
117
|
-
end
|
118
|
-
|
119
|
-
def current_command?
|
120
|
-
return @context_list.empty? ? true : @context_list.last.is_command?
|
121
|
-
end
|
122
|
-
|
123
|
-
def current_identifier?
|
124
|
-
return @context_list.empty? ? false : @context_list.last.is_identifier?
|
125
|
-
end
|
126
|
-
|
127
|
-
def current_alt_identifier?
|
128
|
-
return @context_list.empty? ? false : @context_list.last.is_alt_identifier?
|
129
|
-
end
|
130
|
-
|
131
|
-
def current_alt_identifier_name
|
132
|
-
@context_list.last.alt_identifier
|
133
|
-
end
|
134
|
-
|
135
|
-
def first_command_name()
|
136
|
-
@context_list.each do |e|
|
137
|
-
return e.name if e.is_command?
|
138
|
-
end
|
139
|
-
|
140
|
-
return nil
|
141
|
-
end
|
142
|
-
|
143
|
-
def is_there_identifier_for_first_context?
|
144
|
-
@context_list.each { |e| return true if e.is_identifier? }
|
145
|
-
return false
|
146
|
-
end
|
147
|
-
|
148
|
-
def last_command_name()
|
149
|
-
@context_list.reverse.each do |e|
|
150
|
-
return e.name if e.is_command?
|
151
|
-
end
|
152
|
-
|
153
|
-
return nil
|
154
|
-
end
|
155
|
-
|
156
|
-
def last_context_entity_name()
|
157
|
-
return @context_list.empty? ? nil : @context_list.last.entity
|
158
|
-
end
|
159
|
-
|
160
|
-
def last_context_name()
|
161
|
-
return @context_list.empty? ? nil : @context_list.last.name
|
162
|
-
end
|
163
|
-
|
164
|
-
def first_context_name()
|
165
|
-
return @context_list.empty? ? nil : @context_list.first.name
|
166
|
-
end
|
167
|
-
|
168
|
-
def first_context()
|
169
|
-
return @context_list.empty? ? nil : @context_list.first
|
170
|
-
end
|
171
|
-
|
172
|
-
def last_context()
|
173
|
-
return @context_list.empty? ? nil : @context_list.last
|
174
|
-
end
|
175
|
-
|
176
|
-
def last_context_is_shadow_entity?
|
177
|
-
return false if @context_list.empty?
|
178
|
-
!!last_context().shadow_entity
|
179
|
-
end
|
180
|
-
|
181
|
-
def shadow_entity()
|
182
|
-
return if @context_list.empty?
|
183
|
-
last_context().shadow_entity
|
184
|
-
end
|
185
|
-
end
|
186
|
-
end
|
@@ -1,89 +0,0 @@
|
|
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::Shell
|
19
|
-
class ContextEntity
|
20
|
-
attr_accessor :entity
|
21
|
-
attr_accessor :name
|
22
|
-
attr_accessor :identifier
|
23
|
-
attr_accessor :alt_identifier
|
24
|
-
attr_accessor :shadow_entity
|
25
|
-
|
26
|
-
SHELL_SEPARATOR = '/'
|
27
|
-
|
28
|
-
def self.create_context(context_name, entity_name, context_value=nil, type_id=:id, shadow_entity=nil)
|
29
|
-
if context_value
|
30
|
-
if :id.eql?(type_id)
|
31
|
-
return ContextEntity.create_identifier(context_name, entity_name, context_value, shadow_entity)
|
32
|
-
else
|
33
|
-
return ContextEntity.create_name_identifier(context_name, entity_name, context_value, shadow_entity)
|
34
|
-
end
|
35
|
-
else
|
36
|
-
return ContextEntity.create_command(context_name, entity_name, shadow_entity)
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
def is_identifier?
|
41
|
-
return !@identifier.nil?
|
42
|
-
end
|
43
|
-
|
44
|
-
def is_alt_identifier?
|
45
|
-
return !@alt_identifier.nil?
|
46
|
-
end
|
47
|
-
|
48
|
-
def is_command?
|
49
|
-
return @identifier.nil?
|
50
|
-
end
|
51
|
-
|
52
|
-
def get_identifier(type)
|
53
|
-
return (type == 'id' ? self.identifier : self.name)
|
54
|
-
end
|
55
|
-
|
56
|
-
def transform_alt_identifier_name()
|
57
|
-
@name.gsub(::DTK::Client::CommandBaseThor::ALT_IDENTIFIER_SEPARATOR, SHELL_SEPARATOR)
|
58
|
-
end
|
59
|
-
|
60
|
-
private
|
61
|
-
|
62
|
-
def self.create_command(name, entity_name, shadow_entity=nil)
|
63
|
-
instance = ContextEntity.new
|
64
|
-
instance.name = name
|
65
|
-
instance.entity = entity_name.to_sym
|
66
|
-
instance.shadow_entity = shadow_entity
|
67
|
-
return instance
|
68
|
-
end
|
69
|
-
|
70
|
-
def self.create_name_identifier(name, entity_name, value, shadow_entity=nil)
|
71
|
-
instance = self.create_command(name,entity_name)
|
72
|
-
instance.name = value
|
73
|
-
instance.identifier = value
|
74
|
-
instance.alt_identifier = value
|
75
|
-
instance.shadow_entity = shadow_entity
|
76
|
-
|
77
|
-
return instance
|
78
|
-
end
|
79
|
-
|
80
|
-
def self.create_identifier(name, entity_name, value, shadow_entity=nil)
|
81
|
-
instance = self.create_command(name,entity_name)
|
82
|
-
instance.identifier = value
|
83
|
-
alt_identifier_name = name.to_s.split(::DTK::Client::CommandBaseThor::ALT_IDENTIFIER_SEPARATOR)
|
84
|
-
instance.alt_identifier = alt_identifier_name.size > 1 ? alt_identifier_name.first : nil
|
85
|
-
instance.shadow_entity = shadow_entity
|
86
|
-
return instance
|
87
|
-
end
|
88
|
-
end
|
89
|
-
end
|
@@ -1,223 +0,0 @@
|
|
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::Shell
|
19
|
-
class ContextParams
|
20
|
-
|
21
|
-
attr_accessor :current_context
|
22
|
-
attr_accessor :method_arguments
|
23
|
-
attr_accessor :pure_cli_mode
|
24
|
-
|
25
|
-
def initialize(override_method_arguments = [])
|
26
|
-
@current_context = ActiveContext.new
|
27
|
-
@method_arguments = override_method_arguments
|
28
|
-
@thor_options = Hash.new
|
29
|
-
@pure_cli_mode = false
|
30
|
-
|
31
|
-
@method_arguments
|
32
|
-
end
|
33
|
-
|
34
|
-
def add_context_to_params(context_name, entity_name, context_value = nil)
|
35
|
-
@current_context.push_new_context(context_name, stand_name(entity_name), context_value)
|
36
|
-
end
|
37
|
-
|
38
|
-
def add_context_name_to_params(context_name, entity_name, context_value = nil)
|
39
|
-
@current_context.push_new_name_context(context_name, stand_name(entity_name), context_value)
|
40
|
-
end
|
41
|
-
|
42
|
-
def forward_options(options)
|
43
|
-
@thor_options = options
|
44
|
-
end
|
45
|
-
|
46
|
-
def get_forwarded_options()
|
47
|
-
@thor_options
|
48
|
-
end
|
49
|
-
|
50
|
-
def get_forwarded_thor_option(option_key)
|
51
|
-
return @thor_options ? @thor_options[option_key] : nil
|
52
|
-
end
|
53
|
-
|
54
|
-
def override_method_argument!(key, value)
|
55
|
-
id = match_argument_id(key)
|
56
|
-
raise DTK::Client::DtkImplementationError, "Wrong identifier used '#{key}', ID not matched!" unless id
|
57
|
-
@method_arguments[id] = value
|
58
|
-
end
|
59
|
-
|
60
|
-
# can be class methods but no need, since we have this instance available in each method
|
61
|
-
def retrieve_thor_options(mapping, options)
|
62
|
-
results = []
|
63
|
-
errors = []
|
64
|
-
|
65
|
-
mapping.each do |key|
|
66
|
-
required = key.to_s.match(/.+!$/)
|
67
|
-
thor_key = key.to_s.gsub('!','')
|
68
|
-
|
69
|
-
results << element = options[thor_key]
|
70
|
-
|
71
|
-
if required && element.nil?
|
72
|
-
errors << thor_key
|
73
|
-
end
|
74
|
-
end
|
75
|
-
|
76
|
-
unless errors.empty?
|
77
|
-
raise DTK::Client::DtkValidationError.new("Missing required option#{errors.size > 1 ? 's' : ''}: #{errors.join(', ')}", true)
|
78
|
-
end
|
79
|
-
|
80
|
-
return ((results.size == 1) ? results.first : results)
|
81
|
-
end
|
82
|
-
|
83
|
-
def retrieve_arguments(mapping, method_info = [])
|
84
|
-
results = []
|
85
|
-
errors = []
|
86
|
-
|
87
|
-
# using context_name when have array as key_mapping [:assembly_id, :workspace_id]
|
88
|
-
# to determine which context is used
|
89
|
-
context_name = method_info.first.split('-').first unless method_info.empty?
|
90
|
-
|
91
|
-
mapping.each do |key_mapping|
|
92
|
-
|
93
|
-
is_array = key_mapping.is_a?(Array)
|
94
|
-
|
95
|
-
selected_key = is_array ? key_mapping.first : key_mapping
|
96
|
-
|
97
|
-
required = selected_key.to_s.match(/.+!$/)
|
98
|
-
|
99
|
-
element = nil
|
100
|
-
matched = selected_key.to_s.match(/option_([0-9]+)/)
|
101
|
-
if matched
|
102
|
-
id = matched[1].to_i - 1
|
103
|
-
element = @method_arguments[id]
|
104
|
-
|
105
|
-
# used if last parameter has more than one word
|
106
|
-
# e.g. set-attribute attr_name "some value" (thor separates 'some value' as two parameters but we need it as one)
|
107
|
-
if(mapping.last.to_s.eql?(key_mapping.to_s))
|
108
|
-
new_id = id+1
|
109
|
-
while @method_arguments[new_id] do
|
110
|
-
element << " #{@method_arguments[new_id]}"
|
111
|
-
new_id += 1;
|
112
|
-
end
|
113
|
-
end
|
114
|
-
|
115
|
-
unless method_info.empty?
|
116
|
-
unless element
|
117
|
-
errors << method_info[id] if required
|
118
|
-
end
|
119
|
-
end
|
120
|
-
|
121
|
-
else
|
122
|
-
# More complex split regex for extracting entitiy name from mapping due to complex context names
|
123
|
-
# i.e. assembly-template will have assembly_template_id mapping
|
124
|
-
element = check_context_for_element(selected_key)
|
125
|
-
|
126
|
-
# if we are dealing with array we need to check rest of the keys since it is OR
|
127
|
-
# approach if first element not found take second
|
128
|
-
if element.nil? && is_array
|
129
|
-
key_mapping[1..-1].each do |alternative_key|
|
130
|
-
element = check_context_for_element(alternative_key)
|
131
|
-
break if element
|
132
|
-
if context_name
|
133
|
-
if alternative_key.to_s.include?(context_name.downcase)
|
134
|
-
required = alternative_key.to_s.match(/.+!$/)
|
135
|
-
selected_key = alternative_key
|
136
|
-
end
|
137
|
-
end
|
138
|
-
end
|
139
|
-
end
|
140
|
-
|
141
|
-
unless element
|
142
|
-
errors << "#{entity_name(selected_key).upcase} ID/NAME" if required
|
143
|
-
end
|
144
|
-
end
|
145
|
-
|
146
|
-
results << element
|
147
|
-
end
|
148
|
-
|
149
|
-
unless errors.empty?
|
150
|
-
raise DTK::Client::DtkValidationError.new("Missing required argument#{errors.size > 1 ? 's' : ''}: #{errors.join(', ')}", true)
|
151
|
-
end
|
152
|
-
|
153
|
-
return ((results.size == 1) ? results.first : results)
|
154
|
-
end
|
155
|
-
|
156
|
-
def is_last_command_eql_to?(command_name)
|
157
|
-
return @current_context.last_command_name() == command_name.to_s
|
158
|
-
end
|
159
|
-
|
160
|
-
def is_there_identifier?(entity_name)
|
161
|
-
return @current_context.find_identifier(entity_name) != nil
|
162
|
-
end
|
163
|
-
|
164
|
-
def is_there_command?(entity_name)
|
165
|
-
return @current_context.find_command(entity_name) != nil
|
166
|
-
end
|
167
|
-
def current_command?
|
168
|
-
return @current_context.current_command?
|
169
|
-
end
|
170
|
-
def root_command_name
|
171
|
-
@current_context.first_command_name
|
172
|
-
end
|
173
|
-
def last_entity_name
|
174
|
-
@current_context.last_context_entity_name
|
175
|
-
end
|
176
|
-
def shadow_entity_name()
|
177
|
-
@current_context.shadow_entity()
|
178
|
-
end
|
179
|
-
|
180
|
-
private
|
181
|
-
|
182
|
-
# matches argument id (integer) from used identifier (symbol)
|
183
|
-
#
|
184
|
-
# Returns: Integer as ID , or nil if not found
|
185
|
-
def match_argument_id(identifier)
|
186
|
-
matched = identifier.to_s.match(/option_([0-9]+)/)
|
187
|
-
(matched ? matched[1].to_i - 1 : nil)
|
188
|
-
end
|
189
|
-
|
190
|
-
# based on map key binding e.g. assembly_id, assembly_name we will extrace value
|
191
|
-
# from our ActiveContext
|
192
|
-
def check_context_for_element(key_mapping)
|
193
|
-
split_info = split_info(key_mapping)
|
194
|
-
entity_name = entity_name(key_mapping,split_info)
|
195
|
-
id_type = split_info[1].gsub(/!/,'') # for required elements we remove '!' required marker
|
196
|
-
context_identifier = @current_context.find_identifier(entity_name)
|
197
|
-
if context_identifier
|
198
|
-
return context_identifier.get_identifier(id_type)
|
199
|
-
else
|
200
|
-
return nil
|
201
|
-
end
|
202
|
-
end
|
203
|
-
|
204
|
-
def entity_name(key_mapping,split_info=nil)
|
205
|
-
split_info ||= split_info(key_mapping)
|
206
|
-
split_info[0].gsub(/_/,'-') # makes sure we are using entity names with '_'
|
207
|
-
end
|
208
|
-
|
209
|
-
#
|
210
|
-
# Standardize context name since we are in domain treating :component_module as :'component-module'
|
211
|
-
# and need to be careful about these changes
|
212
|
-
#
|
213
|
-
|
214
|
-
def stand_name(name)
|
215
|
-
name.to_s.gsub('_','-').to_sym
|
216
|
-
end
|
217
|
-
|
218
|
-
def split_info(key_mapping)
|
219
|
-
key_mapping.to_s.split(/_([a-z]+!?$)/)
|
220
|
-
end
|
221
|
-
|
222
|
-
end
|
223
|
-
end
|
@@ -1,88 +0,0 @@
|
|
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
|
19
|
-
module Shell
|
20
|
-
|
21
|
-
class CachedTasks < Hash
|
22
|
-
end
|
23
|
-
|
24
|
-
class OverrideTasks < Hash
|
25
|
-
|
26
|
-
attr_accessor :completed_tasks
|
27
|
-
attr_accessor :always_load_list
|
28
|
-
|
29
|
-
|
30
|
-
# help_item (Thor printable task), structure:
|
31
|
-
# [0] => task defintion
|
32
|
-
# [1] => task description
|
33
|
-
# [2] => task name
|
34
|
-
|
35
|
-
# overriden_task (DTK override task), structure:
|
36
|
-
# [0] => task name
|
37
|
-
# [1] => task defintion
|
38
|
-
# [2] => task description
|
39
|
-
|
40
|
-
# using 'always load listed' to skip adding task to completed tasks e.g load utils for workspace and workspace_node
|
41
|
-
def initialize(hash=nil, always_load_listed=[])
|
42
|
-
super(hash)
|
43
|
-
@completed_tasks = []
|
44
|
-
@always_load_list = always_load_listed
|
45
|
-
self.merge!(hash)
|
46
|
-
end
|
47
|
-
|
48
|
-
# returns true if there are overrides for tasks on first two levels.
|
49
|
-
def are_there_self_override_tasks?
|
50
|
-
return (self[:all][:self] || self[:command_only][:self] || self[:identifier_only][:self])
|
51
|
-
end
|
52
|
-
|
53
|
-
def check_help_item(help_item, is_command)
|
54
|
-
command_tasks, identifier_tasks = get_all_tasks(:self)
|
55
|
-
found = []
|
56
|
-
|
57
|
-
if is_command
|
58
|
-
found = command_tasks.select { |o_task| o_task[0].eql?(help_item[2]) }
|
59
|
-
else
|
60
|
-
found = identifier_tasks.select { |o_task| o_task[0].eql?(help_item[2]) }
|
61
|
-
end
|
62
|
-
|
63
|
-
# if we find self overriden task we remove it
|
64
|
-
# [found.first[1],found.first[2],found.first[0]] => we convert from o_task structure to thor help structure
|
65
|
-
return found.empty? ? help_item : [found.first[1],found.first[2],found.first[0]]
|
66
|
-
end
|
67
|
-
|
68
|
-
# returns 2 arrays one for commands and next one for identifiers
|
69
|
-
def get_all_tasks(child_name)
|
70
|
-
command_o_tasks, identifier_o_tasks = [], []
|
71
|
-
command_o_tasks = (self[:all][child_name]||[]) + (self[:command_only][child_name]||[])
|
72
|
-
identifier_o_tasks = (self[:all][child_name]||[]) + (self[:identifier_only][child_name]||[])
|
73
|
-
return command_o_tasks, identifier_o_tasks
|
74
|
-
end
|
75
|
-
|
76
|
-
def is_completed?(child_name)
|
77
|
-
# do not add task to completed if explicitly said to always load that task
|
78
|
-
return false if @always_load_list.include?(child_name)
|
79
|
-
@completed_tasks.include?(child_name)
|
80
|
-
end
|
81
|
-
|
82
|
-
def add_to_completed(child_name)
|
83
|
-
@completed_tasks << child_name
|
84
|
-
end
|
85
|
-
end
|
86
|
-
|
87
|
-
end
|
88
|
-
end
|
@@ -1,76 +0,0 @@
|
|
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
|
-
##
|
19
|
-
# This is temporary workaround to faciliate concept we are introducing
|
20
|
-
#
|
21
|
-
# Entity / Double Entity Identifier
|
22
|
-
#
|
23
|
-
|
24
|
-
module DTK
|
25
|
-
module Shell
|
26
|
-
class ShadowEntity
|
27
|
-
|
28
|
-
def self.resolve(context_entity)
|
29
|
-
entity, shadow_entity = context_entity.entity, context_entity.shadow_entity
|
30
|
-
|
31
|
-
return nil if shadow_entity.nil? || entity.nil?
|
32
|
-
entity_mapping = @shadow_mapping.fetch(entity.to_sym)
|
33
|
-
|
34
|
-
return entity_mapping ? entity_mapping.fetch(shadow_entity.to_sym) : nil
|
35
|
-
end
|
36
|
-
|
37
|
-
def self.resolve_tasks(context_entity)
|
38
|
-
entity, shadow_entity = context_entity.entity, context_entity.shadow_entity
|
39
|
-
entity_mapping = @shadow_mapping.fetch(entity.to_sym)
|
40
|
-
|
41
|
-
raise DTK::Client::DtkError, "You are missing mapping for shadow entity #{entity} / #{shadow_entity} you need to specify it" if entity_mapping.nil?
|
42
|
-
|
43
|
-
shadow_entity_mapping = entity_mapping.fetch(shadow_entity.to_sym)
|
44
|
-
|
45
|
-
# return just task names
|
46
|
-
return shadow_entity_mapping.collect { |se_map| se_map.first.split(' ').first }
|
47
|
-
end
|
48
|
-
|
49
|
-
private
|
50
|
-
|
51
|
-
@shadow_mapping = {
|
52
|
-
:node => {
|
53
|
-
:node_group => [
|
54
|
-
["add-component COMPONENT", "# Add a component to the node."],
|
55
|
-
["list-attributes", "# List attributes associated with service's node."],
|
56
|
-
["list-components", "# List components associated with service's node."],
|
57
|
-
["delete-component COMPONENT-NAME [-y]", "# Delete component from service's node"],
|
58
|
-
["set-attribute ATTRIBUTE-NAME [VALUE] [-u]", "# (Un)Set attribute value. The option -u will unset the attribute's value."]
|
59
|
-
],
|
60
|
-
:node_group_node => [
|
61
|
-
["info", "# Return info about node instance belonging to given workspace."],
|
62
|
-
["start", "# Start node instance."],
|
63
|
-
["stop", "# Stop node instance."],
|
64
|
-
["ssh REMOTE-USER [-i PATH-TO-PEM]", "# SSH into node, optional parameters are path to identity file."]
|
65
|
-
]
|
66
|
-
}
|
67
|
-
}
|
68
|
-
|
69
|
-
if ::DTK::Configuration.get(:development_mode)
|
70
|
-
@shadow_mapping[:node][:node_group_node] << ["test-action-agent BASH-COMMAND-LINE", "# Run bash command on test action agent"]
|
71
|
-
end
|
72
|
-
|
73
|
-
|
74
|
-
end
|
75
|
-
end
|
76
|
-
end
|
data/lib/shell/header_shell.rb
DELETED
@@ -1,44 +0,0 @@
|
|
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
|
-
require 'hirb'
|
19
|
-
|
20
|
-
module DTK
|
21
|
-
module Shell
|
22
|
-
|
23
|
-
# We will use this class to generate header for console which would be always present,
|
24
|
-
# when activated. Hirb implementation will be used to display status information.
|
25
|
-
|
26
|
-
class HeaderShell
|
27
|
-
|
28
|
-
attr_accessor :active
|
29
|
-
alias_method :is_active?, :active
|
30
|
-
|
31
|
-
def initialize
|
32
|
-
@active = true
|
33
|
-
end
|
34
|
-
|
35
|
-
def print_header
|
36
|
-
puts "*********************"
|
37
|
-
puts "********************* #{Time.now} "
|
38
|
-
puts "*********************"
|
39
|
-
end
|
40
|
-
|
41
|
-
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|