Class: Fastlane::Actions::GetXcconfigValueAction

Inherits:
Action
  • Object
show all
Defined in:
lib/fastlane/plugin/xcconfig/actions/get_xcconfig_value_action.rb

Class Method Summary collapse

Class Method Details

.authorsObject



21
22
23
# File 'lib/fastlane/plugin/xcconfig/actions/get_xcconfig_value_action.rb', line 21

def self.authors
  ['Sergii Ovcharenko']
end

.available_optionsObject



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/fastlane/plugin/xcconfig/actions/get_xcconfig_value_action.rb', line 33

def self.available_options
  [
    FastlaneCore::ConfigItem.new(key: :name,
                                 env_name: "XCCP_GET_VALUE_PARAM_NAME",
                                 description: "Name of key in xcconfig file",
                                 type: String,
                                 optional: false),
    FastlaneCore::ConfigItem.new(key: :path,
                                 env_name: "XCCP_GET_VALUE_PARAM_PATH",
                                 description: "Path to plist file you want to update",
                                 type: String,
                                 optional: false,
                                 verify_block: proc do |value|
                                   UI.user_error!("Couldn't find xcconfig file at path '#{value}'") unless File.exist?(File.expand_path(value))
                                 end)
  ]
end

.descriptionObject



17
18
19
# File 'lib/fastlane/plugin/xcconfig/actions/get_xcconfig_value_action.rb', line 17

def self.description
  'Reads a value of a setting from xcconfig file.'
end

.detailsObject



29
30
31
# File 'lib/fastlane/plugin/xcconfig/actions/get_xcconfig_value_action.rb', line 29

def self.details
  'This action reads the value of a given setting from a given xcconfig file. Will throw an error if specified setting doesn\'t exist'
end

.is_supported?(platform) ⇒ Boolean

Returns:

  • (Boolean)


51
52
53
# File 'lib/fastlane/plugin/xcconfig/actions/get_xcconfig_value_action.rb', line 51

def self.is_supported?(platform)
  true
end

.return_valueObject



25
26
27
# File 'lib/fastlane/plugin/xcconfig/actions/get_xcconfig_value_action.rb', line 25

def self.return_value
  'Value of a setting.'
end

.run(params) ⇒ Object



7
8
9
10
11
12
13
14
15
# File 'lib/fastlane/plugin/xcconfig/actions/get_xcconfig_value_action.rb', line 7

def self.run(params)
  path = File.expand_path(params[:path])
  File.read(path).lines.each do |line|
    name, value = Helper::XcconfigHelper.parse_xcconfig_name_value_line(line)
    return value if name == params[:name]
  end

  Fastlane::UI.user_error!("Couldn't read '#{params[:name]}' from #{params[:path]}.")
end