Class: Fastlane::Runner

Inherits:
Object
  • Object
show all
Defined in:
lib/fastlane/runner.rb

Instance Method Summary collapse

Instance Method Details

#available_lanesObject



37
38
39
# File 'lib/fastlane/runner.rb', line 37

def available_lanes
  blocks.keys
end

#execute(key) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/fastlane/runner.rb', line 4

def execute(key)
  key = key.to_sym
  Helper.log.info "Driving the lane '#{key}'".green
  Actions.lane_context[Actions::SharedValues::LANE_NAME] = key
  ENV["FASTLANE_LANE_NAME"] = key.to_s

  return_val = nil

  path_to_use = Fastlane::FastlaneFolder.path || Dir.pwd
  Dir.chdir(path_to_use) do # the file is located in the fastlane folder
    @before_all.call(key) if @before_all
    
    return_val = nil

    if blocks[key]
      return_val = blocks[key].call
    else
      raise "Could not find lane for type '#{key}'. Available lanes: #{available_lanes.join(', ')}".red
    end

    @after_all.call(key) if @after_all # this is only called if no exception was raised before
  end

  return return_val
rescue => ex
  Dir.chdir(path_to_use) do
    # Provide error block exception without colour code
    error_ex = ex.exception(ex.message.gsub(/\033\[\d+m/, ''))
    @error.call(key, error_ex) if @error # notify the block
  end
  raise ex
end

#set_after_all(block) ⇒ Object



46
47
48
# File 'lib/fastlane/runner.rb', line 46

def set_after_all(block)
  @after_all = block
end

#set_before_all(block) ⇒ Object

Called internally



42
43
44
# File 'lib/fastlane/runner.rb', line 42

def set_before_all(block)
  @before_all = block
end

#set_block(key, block) ⇒ Object



54
55
56
57
# File 'lib/fastlane/runner.rb', line 54

def set_block(key, block)
  raise "Lane '#{key}' was defined multiple times!".red if blocks[key]
  blocks[key] = block
end

#set_error(block) ⇒ Object



50
51
52
# File 'lib/fastlane/runner.rb', line 50

def set_error(block)
  @error = block
end