Class: CredentialsManager::AppfileConfig
- Inherits:
-
Object
- Object
- CredentialsManager::AppfileConfig
- Defined in:
- lib/credentials_manager/appfile_config.rb
Overview
Access the content of the app file (e.g. app identifier and Apple ID)
Class Method Summary collapse
Instance Method Summary collapse
-
#app_identifier(value) ⇒ Object
Setters.
- #apple_id(value) ⇒ Object
- #blocks ⇒ Object
- #data ⇒ Object
-
#for_lane(lane_name, &block) ⇒ Object
Override Appfile configuration for a specific lane.
-
#initialize(path = nil) ⇒ AppfileConfig
constructor
A new instance of AppfileConfig.
- #team_id(value) ⇒ Object
- #team_name(value) ⇒ Object
Constructor Details
#initialize(path = nil) ⇒ AppfileConfig
Returns a new instance of AppfileConfig.
19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/credentials_manager/appfile_config.rb', line 19 def initialize(path = nil) path ||= self.class.default_path raise "Could not find Appfile at path '#{path}'".red unless File.exists?(path) full_path = File.(path) Dir.chdir(File.('..', path)) do eval(File.read(full_path)) end # If necessary override per lane configuration blocks[ENV["FASTLANE_LANE_NAME"].to_s].call if (ENV["FASTLANE_LANE_NAME"] && blocks[ENV["FASTLANE_LANE_NAME"].to_s]) end |
Class Method Details
.default_path ⇒ Object
12 13 14 15 16 17 |
# File 'lib/credentials_manager/appfile_config.rb', line 12 def self.default_path ["./fastlane/Appfile", "./Appfile"].each do |current| return current if File.exists?current end nil end |
.try_fetch_value(key) ⇒ Object
5 6 7 8 9 10 |
# File 'lib/credentials_manager/appfile_config.rb', line 5 def self.try_fetch_value(key) if self.default_path return (self.new.data[key] rescue nil) end nil end |
Instance Method Details
#app_identifier(value) ⇒ Object
Setters
43 44 45 46 |
# File 'lib/credentials_manager/appfile_config.rb', line 43 def app_identifier(value) value ||= yield if block_given? data[:app_identifier] = value if value end |
#apple_id(value) ⇒ Object
48 49 50 51 |
# File 'lib/credentials_manager/appfile_config.rb', line 48 def apple_id(value) value ||= yield if block_given? data[:apple_id] = value if value end |
#blocks ⇒ Object
33 34 35 |
# File 'lib/credentials_manager/appfile_config.rb', line 33 def blocks @blocks ||= {} end |
#data ⇒ Object
37 38 39 |
# File 'lib/credentials_manager/appfile_config.rb', line 37 def data @data ||= {} end |
#for_lane(lane_name, &block) ⇒ Object
Override Appfile configuration for a specific lane.
lane_name - Symbol representing a lane name. block - Block to execute to override configuration values.
Discussion If received lane name does not match the lane name available as environment variable, no changes will
be applied.
70 71 72 73 |
# File 'lib/credentials_manager/appfile_config.rb', line 70 def for_lane(lane_name, &block) raise "Configuration for lane '#{lane_name}' was defined multiple times!".red if blocks[lane_name] blocks[lane_name] = block end |
#team_id(value) ⇒ Object
53 54 55 56 |
# File 'lib/credentials_manager/appfile_config.rb', line 53 def team_id(value) value ||= yield if block_given? data[:team_id] = value if value end |
#team_name(value) ⇒ Object
58 59 60 61 |
# File 'lib/credentials_manager/appfile_config.rb', line 58 def team_name(value) value ||= yield if block_given? data[:team_name] = value if value end |