class Fastlane::Actions::SlackTrainAction

Public Class Methods

authors() click to toggle source
# File lib/fastlane/plugin/slack_train/actions/slack_train_action.rb, line 31
def self.authors
  ["@KrauseFx"]
end
available_options() click to toggle source
# File lib/fastlane/plugin/slack_train/actions/slack_train_action.rb, line 39
def self.available_options
  []
end
description() click to toggle source
# File lib/fastlane/plugin/slack_train/actions/slack_train_action.rb, line 27
def self.description
  "Show a train of the fastlane progress"
end
is_supported?(platform) click to toggle source
# File lib/fastlane/plugin/slack_train/actions/slack_train_action.rb, line 43
def self.is_supported?(platform)
  true
end
return_value() click to toggle source
# File lib/fastlane/plugin/slack_train/actions/slack_train_action.rb, line 35
def self.return_value
  "A string that is being sent to slack"
end
run(params) click to toggle source
# File lib/fastlane/plugin/slack_train/actions/slack_train_action.rb, line 4
def self.run(params)
  train_emoji = lane_context[SharedValues::SLACK_TRAIN_EMOJI]
  rail_emoji = lane_context[SharedValues::SLACK_TRAIN_RAIL]
  total_distance = lane_context[SharedValues::SLACK_TRAIN_DISTANCE]
  current_position = lane_context[SharedValues::SLACK_TRAIN_CURRENT_TRAIN_POSITION]
  speed = lane_context[SharedValues::SLACK_TRAIN_DIRECTION]
  return if total_distance.nil? # train hasn't started yet

  UI.user_error!("train drove too far") if current_position < 0
  UI.user_error!("train drove too far") if total_distance == current_position

  before = rail_emoji * current_position
  after = rail_emoji * (total_distance - current_position - 1)
  lane_name = lane_context[SharedValues::LANE_NAME]

  message = ["`#{lane_name}` ", before, train_emoji, after].join("")
  other_action.slack(message: message,
            default_payloads: [])
  UI.message(message)

  lane_context[SharedValues::SLACK_TRAIN_CURRENT_TRAIN_POSITION] += speed
end