Class: UniversalPipeHandler::CmdletsHandler
- Inherits:
-
Base
- Object
- Base
- UniversalPipeHandler::CmdletsHandler
show all
- Defined in:
- lib/universal_pipe_handler/cmdlets_handler/cmdlets_handler.rb
Overview
UniversalPipeHandler::CmdletsHandler
Constant Summary
collapse
- NAMESPACE =
inspect
Class Method Summary
collapse
-
.[](i = '') ⇒ Object
# === UniversalPipeHandler::CmdletsHandler[] ========================================================================= #.
Instance Method Summary
collapse
Methods inherited from Base
#allowed_actions?, #chdir, #commandline_arguments?, #copy, #first_argument?, #mkdir, #register_sigint, #remove_quotes, #return_pwd, #set_commandline_arguments
Constructor Details
#initialize(commandline_arguments = nil, run_already = true) ⇒ CmdletsHandler
41
42
43
44
45
46
47
48
49
50
|
# File 'lib/universal_pipe_handler/cmdlets_handler/cmdlets_handler.rb', line 41
def initialize(
commandline_arguments = nil,
run_already = true
)
reset
set_commandline_arguments(
commandline_arguments
)
run if run_already
end
|
Class Method Details
.[](i = '') ⇒ Object
#
UniversalPipeHandler::CmdletsHandler[]
#
162
163
164
|
# File 'lib/universal_pipe_handler/cmdlets_handler/cmdlets_handler.rb', line 162
def self.[](i = '')
new(i)
end
|
Instance Method Details
#assign_pipe(i) ⇒ Object
Also known as:
set_pipe
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
|
# File 'lib/universal_pipe_handler/cmdlets_handler/cmdlets_handler.rb', line 70
def assign_pipe(i)
if i.is_a? Array
i = i.join(' ')
end
i.strip!
i.squeeze!(' ') if i.include? ' '
i = ConvertGlobalEnv.convert(i) if i.include? '$'
@pipe = i
end
|
#do_evaluate_the_pipe ⇒ Object
Also known as:
process_pipe
115
116
117
118
119
120
121
122
123
124
125
126
127
128
|
# File 'lib/universal_pipe_handler/cmdlets_handler/cmdlets_handler.rb', line 115
def do_evaluate_the_pipe
@splitted.each {|cmdlet|
cmdlet.strip!
e
ewarn 'DEBUGGING GOING ON, REMOVE ME AT A LATER TIME: processing pipe '+sfile(cmdlet)+' next.'
e
cmdlet.set_start_dir(@start_dir)
cmdlet.do_evaluate
ewarn 'DEBUGGING GOING ON, REMOVE ME AT A LATER TIME: the result is now:'
pp result?
pp result?.class
e
}
end
|
#ensure_that_the_log_directory_exists ⇒ Object
#
ensure_that_the_log_directory_exists
#
140
141
142
143
144
145
|
# File 'lib/universal_pipe_handler/cmdlets_handler/cmdlets_handler.rb', line 140
def ensure_that_the_log_directory_exists
_ = '/home/Temp/universal_pipe_handler/'
mkdir(_) unless File.directory? _
cd(_)
pp Dir.pwd
end
|
#map_the_splitted_components_onto_individual_cmdlets ⇒ Object
#
map_the_splitted_components_onto_individual_cmdlets
#
106
107
108
109
110
|
# File 'lib/universal_pipe_handler/cmdlets_handler/cmdlets_handler.rb', line 106
def map_the_splitted_components_onto_individual_cmdlets
@splitted.map! {|line|
Cmdlet.new(line, :do_not_run_yet)
}
end
|
#reset ⇒ Object
55
56
57
58
59
60
61
62
63
64
65
|
# File 'lib/universal_pipe_handler/cmdlets_handler/cmdlets_handler.rb', line 55
def reset
super()
@namespace = NAMESPACE
@start_dir = return_pwd
end
|
#run ⇒ Object
150
151
152
153
154
155
156
157
|
# File 'lib/universal_pipe_handler/cmdlets_handler/cmdlets_handler.rb', line 150
def run
_ = commandline_arguments?.join(' ').strip
ensure_that_the_log_directory_exists
assign_pipe(_)
split_into_individual_cmdlets
map_the_splitted_components_onto_individual_cmdlets
do_evaluate_the_pipe
end
|
#split_into_individual_cmdlets ⇒ Object
Also known as:
split_on_pipe_token, split_pipe
#
split_into_individual_cmdlets
This method will assign towards @splitted (an Array).
#
92
93
94
95
96
97
98
99
100
|
# File 'lib/universal_pipe_handler/cmdlets_handler/cmdlets_handler.rb', line 92
def split_into_individual_cmdlets
if @pipe.include? PIPE_TOKEN
@splitted = @pipe.split(PIPE_TOKEN)
else
@splitted = [@pipe]
end
@splitted.flatten!
@splitted.compact!
end
|