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



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/alet/irb/helper_methods.rb', line 7

def execute(apex_code = nil, verbose: false)
  result =
    if apex_code
      sf.apex.run target_org: Alet.config.org.alias, file: StringIO.new(apex_code)
    else
      sf.apex.run target_org: Alet.config.org.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