Class: Fastlane::Lane
- Inherits:
-
Object
- Object
- Fastlane::Lane
- Defined in:
- fastlane/lib/fastlane/lane.rb
Overview
Represents a lane
Instance Attribute Summary collapse
-
#block ⇒ Object
Returns the value of attribute block.
-
#description ⇒ Array
An array containing the description of this lane Each item of the array is one line.
-
#is_private ⇒ Boolean
Is that a private lane that can’t be called from the CLI?.
-
#name ⇒ Object
Returns the value of attribute name.
-
#platform ⇒ Object
Returns the value of attribute platform.
Class Method Summary collapse
- .deny_list ⇒ Object
- .ensure_name_not_conflicts(name) ⇒ Object
- .gray_list ⇒ Object
-
.verify_lane_name(name) ⇒ Object
Makes sure the lane name is valid.
Instance Method Summary collapse
-
#call(parameters) ⇒ Object
Execute this lane.
-
#initialize(platform: nil, name: nil, description: nil, block: nil, is_private: false) ⇒ Lane
constructor
A new instance of Lane.
-
#pretty_name ⇒ String
The lane + name of the lane.
Constructor Details
#initialize(platform: nil, name: nil, description: nil, block: nil, is_private: false) ⇒ Lane
Returns a new instance of Lane.
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'fastlane/lib/fastlane/lane.rb', line 17 def initialize(platform: nil, name: nil, description: nil, block: nil, is_private: false) UI.user_error!("description must be an array") unless description.kind_of?(Array) UI.user_error!("lane name must not contain any spaces") if name.to_s.include?(" ") UI.user_error!("lane name must start with :") unless name.kind_of?(Symbol) self.class.verify_lane_name(name) self.platform = platform self.name = name self.description = description # We want to support _both_ lanes expecting a `Hash` (like `lane :foo do |options|`), and lanes expecting # keyword parameters (like `lane :foo do |param1:, param2:, param3: 'default value'|`) block_expects_keywords = !block.nil? && block.parameters.any? { |type, _| [:key, :keyreq].include?(type) } # Conversion of the `Hash` parameters (passed by `Lane#call`) into keywords has to be explicit in Ruby 3 # https://www.ruby-lang.org/en/news/2019/12/12/separation-of-positional-and-keyword-arguments-in-ruby-3-0/ self.block = block_expects_keywords ? proc { || block.call(**) } : block self.is_private = is_private end |
Instance Attribute Details
#block ⇒ Object
Returns the value of attribute block.
12 13 14 |
# File 'fastlane/lib/fastlane/lane.rb', line 12 def block @block end |
#description ⇒ Array
Returns An array containing the description of this lane Each item of the array is one line.
10 11 12 |
# File 'fastlane/lib/fastlane/lane.rb', line 10 def description @description end |
#is_private ⇒ Boolean
Returns Is that a private lane that can’t be called from the CLI?.
15 16 17 |
# File 'fastlane/lib/fastlane/lane.rb', line 15 def is_private @is_private end |
#name ⇒ Object
Returns the value of attribute name.
6 7 8 |
# File 'fastlane/lib/fastlane/lane.rb', line 6 def name @name end |
#platform ⇒ Object
Returns the value of attribute platform.
4 5 6 |
# File 'fastlane/lib/fastlane/lane.rb', line 4 def platform @platform end |
Class Method Details
.deny_list ⇒ Object
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'fastlane/lib/fastlane/lane.rb', line 70 def deny_list %w( run init new_action lanes list docs action actions enable_auto_complete new_plugin add_plugin install_plugins update_plugins search_plugins help env update_fastlane ) end |
.ensure_name_not_conflicts(name) ⇒ Object
96 97 98 99 100 101 102 |
# File 'fastlane/lib/fastlane/lane.rb', line 96 def ensure_name_not_conflicts(name) # First, check if there is a predefined method in the actions folder return unless Actions.action_class_ref(name) UI.error("------------------------------------------------") UI.error("Name of the lane '#{name}' is already taken by the action named '#{name}'") UI.error("------------------------------------------------") end |
.gray_list ⇒ Object
92 93 94 |
# File 'fastlane/lib/fastlane/lane.rb', line 92 def gray_list Fastlane::TOOLS end |
.verify_lane_name(name) ⇒ Object
Makes sure the lane name is valid
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'fastlane/lib/fastlane/lane.rb', line 51 def verify_lane_name(name) if self.deny_list.include?(name.to_s) UI.error("Lane name '#{name}' is invalid! Invalid names are #{self.deny_list.join(', ')}.") UI.user_error!("Lane name '#{name}' is invalid") end if self.gray_list.include?(name.to_sym) UI.error("------------------------------------------------") UI.error("Lane name '#{name}' should not be used because it is the name of a fastlane tool") UI.error("It is recommended to not use '#{name}' as the name of your lane") UI.error("------------------------------------------------") # We still allow it, because we're nice # Otherwise we might break existing setups return end self.ensure_name_not_conflicts(name.to_s) end |
Instance Method Details
#call(parameters) ⇒ Object
Execute this lane
40 41 42 |
# File 'fastlane/lib/fastlane/lane.rb', line 40 def call(parameters) block.call(parameters || {}) end |
#pretty_name ⇒ String
Returns The lane + name of the lane. If there is no platform, it will only be the lane name.
45 46 47 |
# File 'fastlane/lib/fastlane/lane.rb', line 45 def pretty_name [platform, name].reject(&:nil?).join(' ') end |