Class: Apex

Inherits:
IRB::HelperMethod::Base
  • Object
show all
Defined in:
lib/alet/irb/helper_methods.rb

Instance Method Summary collapse

Instance Method Details

#execute(apex_code = nil, verbose: false) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/alet/irb/helper_methods.rb', line 25

def execute(apex_code = nil, verbose: false)
  result =
    if apex_code
      sf.apex.run target_org: Alet.config.conn.alias, file: StringIO.new(apex_code)
    else
      sf.apex.run target_org: Alet.config.conn.alias
    end

  IRB.conf[:INSPECT_MODE] = false
  if verbose
    result.logs.each{|line| puts line }
  else
    pastel = Pastel.new
    result.logs.select{|line| line.include? "USER_DEBUG"}.each do |line|
      match_result = /USER_DEBUG\|.+DEBUG\|(.+)\Z/.match(line)
      puts pastel.cyan(match_result[1])
    end
  end
  IRB.conf[:INSPECT_MODE] = true
end