Class: WLST::Runner

Inherits:
Object
  • Object
show all
Defined in:
lib/rlogic.rb,
lib/rlogic.rb,
lib/wlst/wlst.rb

Instance Method Summary collapse

Constructor Details

#initialize(params = {}) ⇒ Runner

Returns a new instance of Runner.



179
180
181
182
183
184
# File 'lib/wlst/wlst.rb', line 179

def initialize params = {}
  @wl_home = params[:wl_home]
  @output_file = params[:output_file]
  @file = params[:script_file]
  @print = params[:print]
end

Instance Method Details

#clear_screenObject



33
34
35
# File 'lib/rlogic.rb', line 33

def clear_screen
  system("clear")
end

#commandObject



29
30
31
# File 'lib/rlogic.rb', line 29

def command
  ". #{@wl_home}/server/bin/setWLSEnv.sh && java weblogic.WLST #{@file}"
end

#process(params = {}) ⇒ Object



212
213
214
215
216
217
# File 'lib/wlst/wlst.rb', line 212

def process params = {}
  result = run_and_get_result
  clear_screen if params[:clear_screen] and @print
  puts result if @print
  File.open(@output_file, 'w') { |f| f.write result } if @output_file
end

#run(interval = nil) ⇒ Object



186
187
188
189
190
191
192
193
194
195
# File 'lib/wlst/wlst.rb', line 186

def run interval = nil
  if interval
    while true
      process :clear_screen => true
      sleep interval
    end
  else
    process
  end
end

#run_and_get_resultObject



197
198
199
200
201
202
203
204
205
206
207
208
209
210
# File 'lib/wlst/wlst.rb', line 197

def run_and_get_result
  result = `#{command}`
  truncated = ""
  flag = false
  result.each_line do |line|
    if line.strip == "Type help() for help on available commands"
      flag = true
      next
    end
    truncated << line if flag
  end
  return truncated.strip unless truncated.empty?
  result
end