dtk-client 0.6.8 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (39) hide show
  1. checksums.yaml +8 -8
  2. data/bin/dtk +5 -1
  3. data/lib/auxiliary.rb +0 -1
  4. data/lib/commands/common/thor/assembly_workspace.rb +20 -1
  5. data/lib/commands/common/thor/inventory_parser.rb +1 -1
  6. data/lib/commands/common/thor/module/import.rb +41 -106
  7. data/lib/commands/common/thor/module.rb +13 -226
  8. data/lib/commands/common/thor/poller.rb +48 -0
  9. data/lib/commands/common/thor/puppet_forge.rb +7 -1
  10. data/lib/commands/common/thor/purge_clone.rb +2 -1
  11. data/lib/commands/common/thor/task_status.rb +15 -14
  12. data/lib/commands/common/thor/test_action_agent.rb +39 -0
  13. data/lib/commands/thor/component_module.rb +2 -2
  14. data/lib/commands/thor/node.rb +55 -14
  15. data/lib/commands/thor/node_group.rb +2 -26
  16. data/lib/commands/thor/service.rb +31 -11
  17. data/lib/commands/thor/service_module.rb +3 -1
  18. data/lib/commands/thor/workspace.rb +13 -3
  19. data/lib/core.rb +16 -6
  20. data/lib/domain/git_adapter.rb +0 -3
  21. data/lib/domain/response.rb +25 -13
  22. data/lib/dtk-client/version.rb +1 -1
  23. data/lib/parser/adapters/thor.rb +8 -5
  24. data/lib/shell/context.rb +8 -19
  25. data/lib/shell/domain/active_context.rb +169 -0
  26. data/lib/shell/domain/context_entity.rb +72 -0
  27. data/lib/shell/domain/context_params.rb +202 -0
  28. data/lib/shell/domain/override_tasks.rb +71 -0
  29. data/lib/shell/domain/shadow_entity.rb +59 -0
  30. data/lib/shell/help_monkey_patch.rb +76 -71
  31. data/lib/shell/message_queue.rb +2 -0
  32. data/lib/shell/status_monitor.rb +5 -3
  33. data/lib/shell.rb +4 -2
  34. data/lib/util/dtk_puppet.rb +8 -6
  35. data/lib/util/os_util.rb +5 -1
  36. data/lib/view_processor/table_print.rb +67 -12
  37. data/spec/lib/spec_thor.rb +5 -2
  38. metadata +9 -3
  39. data/lib/shell/domain.rb +0 -492
@@ -0,0 +1,59 @@
1
+ ##
2
+ # This is temporary workaround to faciliate concept we are introducing
3
+ #
4
+ # Entity / Double Entity Identifier
5
+ #
6
+
7
+ module DTK
8
+ module Shell
9
+ class ShadowEntity
10
+
11
+ def self.resolve(context_entity)
12
+ entity, shadow_entity = context_entity.entity, context_entity.shadow_entity
13
+
14
+ return nil if shadow_entity.nil? || entity.nil?
15
+ entity_mapping = @shadow_mapping.fetch(entity.to_sym)
16
+
17
+ return entity_mapping ? entity_mapping.fetch(shadow_entity.to_sym) : nil
18
+ end
19
+
20
+ def self.resolve_tasks(context_entity)
21
+ entity, shadow_entity = context_entity.entity, context_entity.shadow_entity
22
+ entity_mapping = @shadow_mapping.fetch(entity.to_sym)
23
+
24
+ raise DTK::Client::DtkError, "You are missing mapping for shadow entity #{entity} / #{shadow_entity} you need to specify it" if entity_mapping.nil?
25
+
26
+ shadow_entity_mapping = entity_mapping.fetch(shadow_entity.to_sym)
27
+
28
+ # return just task names
29
+ return shadow_entity_mapping.collect { |se_map| se_map.first.split(' ').first }
30
+ end
31
+
32
+ private
33
+
34
+ @shadow_mapping = {
35
+ :node => {
36
+ :node_group => [
37
+ ["add-component COMPONENT", "# Add a component to the node."],
38
+ ["list-attributes", "# List attributes associated with service's node."],
39
+ ["list-components", "# List components associated with service's node."],
40
+ ["delete-component COMPONENT-NAME [-y]", "# Delete component from service's node"],
41
+ ["set-attribute ATTRIBUTE-NAME [VALUE] [-u]", "# (Un)Set attribute value. The option -u will unset the attribute's value."]
42
+ ],
43
+ :node_group_node => [
44
+ ["info", "# Return info about node instance belonging to given workspace."],
45
+ ["start", "# Start node instance."],
46
+ ["stop", "# Stop node instance."],
47
+ ["ssh REMOTE-USER [-i PATH-TO-PEM]", "# SSH into node, optional parameters are path to identity file."]
48
+ ]
49
+ }
50
+ }
51
+
52
+ if ::DTK::Configuration.get(:development_mode)
53
+ @shadow_mapping[:node][:node_group_node] << ["test-action-agent BASH-COMMAND-LINE", "# Run bash command on test action agent"]
54
+ end
55
+
56
+
57
+ end
58
+ end
59
+ end
@@ -97,102 +97,107 @@ class Thor
97
97
  #
98
98
  override_tasks_obj = self.respond_to?(:override_allowed_methods) ? self.override_allowed_methods.dup : nil
99
99
 
100
+ shadow_list = ::DTK::Shell::ShadowEntity.resolve(active_context.last_context)
100
101
  # N-LEVEL-CONTEXT - context that has at least 2 commands and 1 or more identifiers
101
102
  # e.g. dtk:\assembly\assembly1\node> THIS IS N-LEVEL CONTEXT
102
103
  # e.g. dtk:\assembly\assembly1\node\node123> THIS IS N-LEVEL CONTEXT
103
104
  # e.g. dtk:\assembly\assembly1> THIS IS NOT N-LEVEL CONTEXT
104
105
  #
105
- if (!active_context.is_n_context? || active_context.current_identifier?)
106
-
107
- list.each do |help_item|
108
- help_item.first.gsub!("^^", '') if help_item.first.include?("^^")
109
-
110
- # this will match entity_name (command) and alternative identifiers
111
- identifers = [command] + alt_identifiers
112
-
113
- # matches identifiers for ID/NAME
114
- matched_data = help_item.first.match(/^\s\[?(#{identifers.join('|')}).?(NAME\/ID|ID\/NAME)\]?\s/)
115
- alt_matched_data = help_item.first.match(/^\s\[?(#{alt_identifiers.join('|')}).?(NAME\/ID|ID\/NAME)\]?\s/)
116
-
117
- if matched_data.nil?
118
- # not found and tier 1 we add it to help list
119
- filtered_list << overriden_help(override_tasks_obj, help_item, true) if @@shell_context.current_command?
120
- else
121
- # for help we only care about first context name / identifier
122
- if !is_there_identifier
123
- # if it contains [] it is optional and will be available on both tiers
124
- if matched_data[0].include?('[')
125
- # we remove it, since there is no need to use it
126
- help_item.first.gsub!(matched_data[0],' ') unless help_item.nil?
127
- filtered_list << overriden_help(override_tasks_obj, help_item, true)
128
- end
106
+ unless shadow_list
107
+ if (!active_context.is_n_context? || active_context.current_identifier?)
108
+
109
+ list.each do |help_item|
110
+ help_item.first.gsub!("^^", '') if help_item.first.include?("^^")
111
+
112
+ # this will match entity_name (command) and alternative identifiers
113
+ identifers = [command] + alt_identifiers
114
+
115
+ # matches identifiers for ID/NAME
116
+ matched_data = help_item.first.match(/^\s\[?(#{identifers.join('|')}).?(NAME\/ID|ID\/NAME)\]?\s/)
117
+ alt_matched_data = help_item.first.match(/^\s\[?(#{alt_identifiers.join('|')}).?(NAME\/ID|ID\/NAME)\]?\s/)
118
+
119
+ if matched_data.nil?
120
+ # not found and tier 1 we add it to help list
121
+ filtered_list << overriden_help(override_tasks_obj, help_item, true) if @@shell_context.current_command?
129
122
  else
130
- # Adding alt identifiers here
131
- if alt_matched_data
132
- if active_context.current_alt_identifier?
133
- help_item.first.gsub!(matched_data[0],'') unless help_item.nil?
134
- filtered_list << overriden_help(override_tasks_obj, help_item, false)
123
+ # for help we only care about first context name / identifier
124
+ if !is_there_identifier
125
+ # if it contains [] it is optional and will be available on both tiers
126
+ if matched_data[0].include?('[')
127
+ # we remove it, since there is no need to use it
128
+ help_item.first.gsub!(matched_data[0],' ') unless help_item.nil?
129
+ filtered_list << overriden_help(override_tasks_obj, help_item, true)
135
130
  end
136
131
  else
137
- unless active_context.current_alt_identifier?
138
- help_item.first.gsub!(matched_data[0],'') unless help_item.nil?
139
- filtered_list << overriden_help(override_tasks_obj, help_item, false)
132
+ # Adding alt identifiers here
133
+ if alt_matched_data
134
+ if active_context.current_alt_identifier?
135
+ help_item.first.gsub!(matched_data[0],'') unless help_item.nil?
136
+ filtered_list << overriden_help(override_tasks_obj, help_item, false)
137
+ end
138
+ else
139
+ unless active_context.current_alt_identifier?
140
+ help_item.first.gsub!(matched_data[0],'') unless help_item.nil?
141
+ filtered_list << overriden_help(override_tasks_obj, help_item, false)
142
+ end
140
143
  end
141
144
  end
142
145
  end
143
146
  end
144
147
  end
145
- end
146
148
 
147
- # This will return commands that have identifiers
148
- # e.g. dtk:\assembly\assembly1\node\node123> => ['assembly','node']
149
- commands_that_have_identifiers = active_context.commands_that_have_identifiers()
150
- is_n_level_context = active_context.command_list.size > 1
151
-
152
- # first one does not count
153
- if is_n_level_context
154
- # additional filter list for n-context
155
- n_filter_list = []
156
- # we do not need first one, since above code takes care of that one
157
- filtered_list = filtered_list.select do |filtered_help_item|
158
- #next unless filtered_help_item
159
- unless commands_that_have_identifiers.empty?
160
- commands_that_have_identifiers[1..-1].each_with_index do |entity,i|
161
- matched = match_help_item_changes(filtered_help_item, entity)
162
- filtered_help_item = replace_if_matched!(filtered_help_item, matched)
163
-
164
- # if it is last command, and there were changes
165
- if (i == (commands_that_have_identifiers.size - 2) && matched)
166
- n_filter_list << filtered_help_item
149
+ # This will return commands that have identifiers
150
+ # e.g. dtk:\assembly\assembly1\node\node123> => ['assembly','node']
151
+ commands_that_have_identifiers = active_context.commands_that_have_identifiers()
152
+ is_n_level_context = active_context.command_list.size > 1
153
+
154
+ # first one does not count
155
+ if is_n_level_context
156
+ # additional filter list for n-context
157
+ n_filter_list = []
158
+ # we do not need first one, since above code takes care of that one
159
+ filtered_list = filtered_list.select do |filtered_help_item|
160
+ #next unless filtered_help_item
161
+ unless commands_that_have_identifiers.empty?
162
+ commands_that_have_identifiers[1..-1].each_with_index do |entity,i|
163
+ matched = match_help_item_changes(filtered_help_item, entity)
164
+ filtered_help_item = replace_if_matched!(filtered_help_item, matched)
165
+
166
+ # if it is last command, and there were changes
167
+ if (i == (commands_that_have_identifiers.size - 2) && matched)
168
+ n_filter_list << filtered_help_item
169
+ end
167
170
  end
168
171
  end
169
172
  end
170
- end
171
173
 
172
- if override_tasks_obj && is_n_level_context
173
- last_entity_name = active_context.last_context_entity_name.to_sym
174
+ if override_tasks_obj && is_n_level_context
175
+ last_entity_name = active_context.last_context_entity_name.to_sym
174
176
 
175
- # we get commands task, and identifier tasks for given entity (e.g. :assembly)
176
- command_o_tasks, identifier_o_tasks = override_tasks_obj.get_all_tasks(last_entity_name)
177
+ # we get commands task, and identifier tasks for given entity (e.g. :assembly)
178
+ command_o_tasks, identifier_o_tasks = override_tasks_obj.get_all_tasks(last_entity_name)
177
179
 
178
- if active_context.current_identifier?
179
- identifier_o_tasks.each do |o_task|
180
- n_filter_list << [o_task[1],o_task[2]]
181
- end
182
- else
183
- command_o_tasks.each do |o_task|
184
- n_filter_list << [o_task[1],o_task[2]]
180
+ if active_context.current_identifier?
181
+ identifier_o_tasks.each do |o_task|
182
+ n_filter_list << [o_task[1],o_task[2]]
183
+ end
184
+ else
185
+ command_o_tasks.each do |o_task|
186
+ n_filter_list << [o_task[1],o_task[2]]
187
+ end
185
188
  end
186
189
  end
190
+
191
+ # we have just filtered those methods that have attribute for given entity
192
+ # and also are last in the list
193
+ filtered_list = n_filter_list
187
194
  end
188
195
 
189
- # we have just filtered those methods that have attribute for given entity
190
- # and also are last in the list
191
- filtered_list = n_filter_list
196
+ # remove double spaces
197
+ list = filtered_list.each { |e| e.first.gsub!(/ /,' ') }
198
+ else
199
+ list = shadow_list
192
200
  end
193
-
194
- # remove double spaces
195
- list = filtered_list.each { |e| e.first.gsub!(/ /,' ') }
196
201
  end
197
202
  else
198
203
  # no dtk-shell just dtk, we make sure that underscore is not used '_'
@@ -1,3 +1,5 @@
1
+ # TODO-REMOVE: Check if we need this anymore
2
+
1
3
  dtk_require_from_base('util/os_util')
2
4
 
3
5
  module DTK
@@ -1,3 +1,5 @@
1
+ # TODO-REMOVE: Check if we need this anymore
2
+
1
3
  require 'thread'
2
4
  require 'singleton'
3
5
  require 'colorize'
@@ -5,7 +7,7 @@ require 'colorize'
5
7
 
6
8
  # This singleton is used to check status on running processes on the server side
7
9
  # Once certain task is complete it will give notice to user da certain task has been completed
8
- # At the moment this only
10
+ # At the moment this only
9
11
 
10
12
  module DTK
11
13
  module Shell
@@ -71,12 +73,12 @@ module DTK
71
73
  # we break if there is error in response
72
74
  break unless response.ok?
73
75
  end
74
-
76
+
75
77
  DTK::Shell::TaskStatusThread.current.finished = true
76
78
 
77
79
  if response.ok?
78
80
  DTK::Shell::TaskStatusThread.current.status = response.data['status'].upcase
79
- else
81
+ else
80
82
  DTK::Shell::TaskStatusThread.current.status = "RESPONSE NOT OK, RESPONSE: #{response}"
81
83
  end
82
84
 
data/lib/shell.rb CHANGED
@@ -4,7 +4,7 @@ require File.expand_path('commands/thor/dtk', File.dirname(__FILE__))
4
4
  require File.expand_path('error', File.dirname(__FILE__))
5
5
 
6
6
  # load all from shell directory since those are required
7
- Dir[File.expand_path('shell/*.rb', File.dirname(__FILE__))].each { |file| require file }
7
+ Dir[File.expand_path('shell/**/*.rb', File.dirname(__FILE__))].each { |file| require file }
8
8
 
9
9
  require 'shellwords'
10
10
  require 'readline'
@@ -94,7 +94,9 @@ end
94
94
  def execute_shell_command(line, prompt)
95
95
  begin
96
96
  # remove single/double quotes from string because shellwords module is not able to parse it
97
- line.gsub!(/['"]/, '')
97
+ if matched = line.scan(/['"]/)
98
+ line.gsub!(/['"]/, '') if matched.size.odd?
99
+ end
98
100
 
99
101
  # some special cases
100
102
  raise DTK::Shell::ExitSignal if line == 'exit'
@@ -1,8 +1,10 @@
1
+ # TODO-REMOVE: Check if we need this anymore
2
+
1
3
  module DTK
2
4
  module Client
3
5
  #
4
6
  # Class is used as puppet wrapper, at the moment it will use console comamnds, later
5
- # to be replaced with direct usage of puppet code, or re-implentation of their direct calls
7
+ # to be replaced with direct usage of puppet code, or re-implentation of their direct calls
6
8
  #
7
9
  class DtkPuppet
8
10
 
@@ -14,16 +16,16 @@ module DTK
14
16
  # Returns: Name of directory where module is saved
15
17
  def self.install_module(module_name)
16
18
  output = nil
17
-
19
+
18
20
  OsUtil.suspend_output do
19
21
  output = `puppet module install #{module_name} --modulepath #{MODULE_PATH} --force --render-as json`
20
22
  end
21
-
23
+
22
24
  # extract json from output, regex will match json in string
23
25
  matched = output.match(/\{.+\}/)
24
26
 
25
27
  raise DTK::Client::DtkError, "Puppet module '#{module_name}' not found." unless matched
26
-
28
+
27
29
  # parse matched json
28
30
  result = JSON.parse(matched[0])
29
31
 
@@ -34,13 +36,13 @@ module DTK
34
36
  filtered = filtered.split(/\n/).map(&:strip).join(', ')
35
37
  raise DTK::Client::DtkError, filtered
36
38
  end
37
-
39
+
38
40
  # puppet uses last part of the module name, as dir for location
39
41
  dir_name = module_name.split('-').last
40
42
  puts "Successfully installed '#{module_name}' from puppet forge, location: '#{MODULE_PATH}/#{dir_name}'"
41
43
  return dir_name
42
44
  end
43
-
45
+
44
46
  end
45
47
  end
46
48
  end
data/lib/util/os_util.rb CHANGED
@@ -282,7 +282,11 @@ module DTK
282
282
  load File.expand_path('../../lib/util/ssh_util.rb', File.dirname(__FILE__))
283
283
  load File.expand_path('../../lib/util/remote_dependency_util.rb', File.dirname(__FILE__))
284
284
  load File.expand_path('../../lib/shell/help_monkey_patch.rb', File.dirname(__FILE__))
285
- load File.expand_path('../../lib/shell/domain.rb', File.dirname(__FILE__))
285
+ load File.expand_path('../../lib/shell/domain/context_entity.rb', File.dirname(__FILE__))
286
+ load File.expand_path('../../lib/shell/domain/active_context.rb', File.dirname(__FILE__))
287
+ load File.expand_path('../../lib/shell/domain/context_params.rb', File.dirname(__FILE__))
288
+ load File.expand_path('../../lib/shell/domain/override_tasks.rb', File.dirname(__FILE__))
289
+ load File.expand_path('../../lib/shell/context.rb', File.dirname(__FILE__))
286
290
  load File.expand_path('../../lib/domain/git_adapter.rb', File.dirname(__FILE__))
287
291
  load File.expand_path('../../lib/command_helpers/git_repo.rb', File.dirname(__FILE__))
288
292
  load File.expand_path('../../lib/command_helpers/service_importer.rb', File.dirname(__FILE__))
@@ -70,12 +70,16 @@ module DTK
70
70
  data = [data] unless data.kind_of?(Array)
71
71
 
72
72
  data.each do |data_element|
73
+ # special flag to filter out data not needed here
74
+ next if data_element['dtk_client_hidden']
75
+
73
76
  structured_data << to_ostruct(data_element)
74
77
  end
75
78
 
76
79
  # we use array of OpenStruct to hold our evaluated values
77
80
  @evaluated_data = []
78
81
  @error_data = []
82
+ @action_data = []
79
83
  structured_data.each do |structured_element|
80
84
  evaluated_element = DtkOpenStruct.new
81
85
  error_element = DtkOpenStruct.new
@@ -88,7 +92,8 @@ module DTK
88
92
 
89
93
  if print_error_table && k.include?('error')
90
94
  error_message = value_of(structured_element, v)
91
-
95
+ server_error = nil
96
+
92
97
  # here we see if there was an error if not we will skip this
93
98
  # if so we add it to @error_data
94
99
 
@@ -99,25 +104,58 @@ module DTK
99
104
  error_index = ""
100
105
  error_type = value_of(structured_element,'errors.dtk_type') || ""
101
106
 
107
+ if error_type.empty?
108
+ val = value_of(structured_element,'dtk_type')||''
109
+ # extract e.g. 3.1.1.1 from '3.1.1.1 action' etc.
110
+ error_type = val.scan( /\d+[,.]\d?[,.]?\d?[,.]?\d?[,.]?\d?/ ).first
111
+ end
112
+
102
113
  # we set index for each message first => [ 1 ], second => [ 2 ], etc.
103
114
  if error_type == "user_error" || error_type == "test_error"
104
115
  error_index = "[ #{@error_data.size + 1} ]"
116
+ else
117
+ server_error = true
118
+ error_index = error_type
105
119
  end
106
120
 
107
121
  # original table takes that index
108
122
  evaluated_element.send("#{k}=", error_index)
109
123
  # we set new error element
110
124
  error_element.id = error_index
111
- if error_index.empty?
112
- error_element.message = "[SERVER ERROR] " + error_message
125
+ # if error_index.empty?
126
+ if server_error
127
+ error_element.message = "[SERVER ERROR] " + error_message
113
128
  else
114
129
  error_element.message = "[USER ERROR] " + error_message if error_type == "user_error"
115
- error_element.message = "[TEST ERROR] " + error_message if error_type == "test_error"
130
+ error_element.message = "[TEST ERROR] " + error_message if error_type == "test_error"
116
131
  end
117
132
 
118
133
  # add it with other
119
134
  @error_data << error_element
120
135
  end
136
+ elsif k.include?('action')
137
+ error_message = value_of(structured_element, v)
138
+
139
+ # here we see if there was an error if not we will skip this
140
+ # if so we add it to @error_data
141
+
142
+ if error_message.empty?
143
+ # no error message just add it as regular element
144
+ evaluated_element.send("#{k}=",value_of(structured_element, v))
145
+ else
146
+ error_index = "[ #{value_of(structured_element,'logs.label')} ]" || ""
147
+ error_type = value_of(structured_element,'logs.dtk_type') || ""
148
+
149
+ # original table takes that index
150
+ evaluated_element.send("#{k}=", error_index)
151
+
152
+ # we set new error element
153
+ error_element.id = error_index
154
+ error_element.message = error_message
155
+
156
+ # add it with other
157
+ @action_data << error_element
158
+ end
121
159
  else
122
160
  evaluated_element.send("#{k}=", value_of(structured_element, v))
123
161
  # eval "evaluated_element.#{k}=structured_element.#{v}"
@@ -129,8 +167,12 @@ module DTK
129
167
  # make sure when in development to disable this TODO: better solution needed
130
168
  raise DTK::Client::DtkError,"Error with missing metadata occurred. There is a mistake in table metadata or unexpected data presented to table view."
131
169
  end
132
- end
170
+ end
133
171
  end
172
+
173
+ @order_definition.delete('action')
174
+ @order_definition.delete('errors')
175
+
134
176
  @evaluated_data << evaluated_element
135
177
  end
136
178
  end
@@ -178,12 +220,12 @@ module DTK
178
220
  unless (forced_metadata['order'].nil? || forced_metadata['mapping'].nil?)
179
221
  return if (forced_metadata['order'].class.eql?(Array) && forced_metadata['mapping'].class.eql?(Hash))
180
222
  end
181
-
223
+
182
224
  raise DTK::Client::DtkError,"Provided table definition is not valid. Please review your order and mapping for provided definition: \n #{forced_metadata.inspect}"
183
225
  end
184
226
 
185
227
  def filter_remove_underscore(field)
186
-
228
+
187
229
  end
188
230
 
189
231
  def print
@@ -196,10 +238,23 @@ module DTK
196
238
  unless @error_data.empty?
197
239
  printf "\nERRORS: \n\n"
198
240
  #table(@error_data,{:fields => [ :id, :message ]})
199
- @error_data.each do |error_row|
241
+ @error_data.each do |error_row|
200
242
  printf "%15s %s\n", error_row.id.colorize(:yellow), error_row.message.colorize(:red)
201
243
  end
202
244
  end
245
+
246
+ unless @action_data.empty?
247
+ printf " \n"
248
+ #table(@error_data,{:fields => [ :id, :message ]})
249
+ printed = []
250
+ @action_data.each do |action_row|
251
+ # printf "%15s\n"
252
+ # printf(" INFO: #{action_row.message.colorize(:yellow)} \n") #, action_row.id.colorize(:yellow), action_row.message.colorize(:yellow)
253
+ message = action_row.message
254
+ printf "%15s %s\n", "INFO:".colorize(:yellow), message.colorize(:yellow) unless printed.include?(message)
255
+ printed << message
256
+ end
257
+ end
203
258
  end
204
259
 
205
260
  private
@@ -223,7 +278,7 @@ module DTK
223
278
  case
224
279
  when command.include?('map{')
225
280
  matched_data = command.match(/\['(.+)'\]/)
226
-
281
+
227
282
  my_lambda = lambda{|_x| _x.map{|r|r["#{matched_data[1]}"]||[]}}
228
283
  value = my_lambda.call(value)
229
284
 
@@ -242,19 +297,19 @@ module DTK
242
297
  value = value.send('[]',params)
243
298
  when command.start_with?("list_")
244
299
  matched_data = command.match(/list_(.+)/)
245
-
300
+
246
301
  my_lambda = lambda{|_x| _x.map{|r|r["#{matched_data[1]}"]||[]}}
247
302
  value = my_lambda.call(value)
248
303
 
249
304
  raise DTK::Client::DtkError,"There is a mistake in table metadata: #{command.inspect}" if value.nil?
250
305
  when command.start_with?("count_")
251
306
  matched_data = command.match(/count_(.+)/)
252
-
307
+
253
308
  my_lambda = lambda{|_x| _x.map{|r|r["#{matched_data[1]}"]||[]}.flatten.size}
254
309
  value = my_lambda.call(value)
255
310
 
256
311
  raise DTK::Client::DtkError,"There is a mistake in table metadata: #{command.inspect}" if value.nil?
257
- else
312
+ else
258
313
  value = value.send(command)
259
314
  end
260
315
  return value
@@ -1,7 +1,10 @@
1
1
  require File.expand_path('../../lib/client', File.dirname(__FILE__))
2
2
  require File.expand_path('../../lib/parser/adapters/thor', File.dirname(__FILE__))
3
3
  require File.expand_path('../../lib/shell/context', File.dirname(__FILE__))
4
- require File.expand_path('../../lib/shell/domain', File.dirname(__FILE__))
4
+ require File.expand_path('../../lib/shell/domain/context_entity', File.dirname(__FILE__))
5
+ require File.expand_path('../../lib/shell/domain/active_context', File.dirname(__FILE__))
6
+ require File.expand_path('../../lib/shell/domain/context_params', File.dirname(__FILE__))
7
+ require File.expand_path('../../lib/shell/domain/override_tasks', File.dirname(__FILE__))
5
8
  Dir[File.expand_path('../../lib/shell/parse_monkey_patch.rb', File.dirname(__FILE__))].each {|file| require file }
6
9
 
7
10
  require 'shellwords'
@@ -92,7 +95,7 @@ module SpecThor
92
95
  gsub(regex, '').chomp
93
96
  end
94
97
 
95
- private
98
+ private
96
99
 
97
100
  ##
98
101
  # Method will take task name from class name
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dtk-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.8
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rich PELAVIN
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-01-19 00:00:00.000000000 Z
11
+ date: 2015-02-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -219,6 +219,7 @@ files:
219
219
  - lib/commands/common/thor/list_diffs.rb
220
220
  - lib/commands/common/thor/module.rb
221
221
  - lib/commands/common/thor/module/import.rb
222
+ - lib/commands/common/thor/poller.rb
222
223
  - lib/commands/common/thor/pull_clone_changes.rb
223
224
  - lib/commands/common/thor/pull_from_remote.rb
224
225
  - lib/commands/common/thor/puppet_forge.rb
@@ -228,6 +229,7 @@ files:
228
229
  - lib/commands/common/thor/reparse.rb
229
230
  - lib/commands/common/thor/set_required_params.rb
230
231
  - lib/commands/common/thor/task_status.rb
232
+ - lib/commands/common/thor/test_action_agent.rb
231
233
  - lib/commands/thor/account.rb
232
234
  - lib/commands/thor/assembly.rb
233
235
  - lib/commands/thor/attribute.rb
@@ -276,7 +278,11 @@ files:
276
278
  - lib/shell.rb
277
279
  - lib/shell/context.rb
278
280
  - lib/shell/context_aux.rb
279
- - lib/shell/domain.rb
281
+ - lib/shell/domain/active_context.rb
282
+ - lib/shell/domain/context_entity.rb
283
+ - lib/shell/domain/context_params.rb
284
+ - lib/shell/domain/override_tasks.rb
285
+ - lib/shell/domain/shadow_entity.rb
280
286
  - lib/shell/header_shell.rb
281
287
  - lib/shell/help_monkey_patch.rb
282
288
  - lib/shell/interactive_wizard.rb