Class: Fastlane::Actions::UpdateUrbanAirshipConfigurationAction

Inherits:
Fastlane::Action
  • Object
show all
Defined in:
lib/fastlane/actions/update_urban_airship_configuration.rb

Class Method Summary collapse

Methods inherited from Fastlane::Action

action_name, author, method_missing, other_action, output, return_value, sh, step_text

Class Method Details

.authorsObject



63
64
65
# File 'lib/fastlane/actions/update_urban_airship_configuration.rb', line 63

def self.authors
  ["kcharwood"]
end

.available_optionsObject



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/fastlane/actions/update_urban_airship_configuration.rb', line 31

def self.available_options
  [
    FastlaneCore::ConfigItem.new(key: :plist_path,
                                 env_name: "URBAN_AIRSHIP_PLIST_PATH",
                                 description: "Path to Urban Airship configuration Plist",
                                 verify_block: proc do |value|
                                   raise "Could not find Urban Airship plist file".red unless File.exist?(value)
                                 end),
    FastlaneCore::ConfigItem.new(key: :development_app_key,
                                 optional: true,
                                 env_name: "URBAN_AIRSHIP_DEVELOPMENT_APP_KEY",
                                 description: "The development app key"),
    FastlaneCore::ConfigItem.new(key: :development_app_secret,
                                 optional: true,
                                 env_name: "URBAN_AIRSHIP_DEVELOPMENT_APP_SECRET",
                                 description: "The development app secret"),
    FastlaneCore::ConfigItem.new(key: :production_app_key,
                                 optional: true,
                                 env_name: "URBAN_AIRSHIP_PRODUCTION_APP_KEY",
                                 description: "The production app key"),
    FastlaneCore::ConfigItem.new(key: :production_app_secret,
                                 optional: true,
                                 env_name: "URBAN_AIRSHIP_PRODUCTION_APP_SECRET",
                                 description: "The production app secret"),
    FastlaneCore::ConfigItem.new(key: :detect_provisioning_mode,
                                 env_name: "URBAN_AIRSHIP_DETECT_PROVISIONING_MODE",
                                 is_string: false,
                                 optional: true,
                                 description: "Automatically detect provisioning mode")
  ]
end

.descriptionObject



23
24
25
# File 'lib/fastlane/actions/update_urban_airship_configuration.rb', line 23

def self.description
  "Set the Urban Airship plist configuration values"
end

.detailsObject



27
28
29
# File 'lib/fastlane/actions/update_urban_airship_configuration.rb', line 27

def self.details
  "This action updates the AirshipConfig.plist need to configure the Urban Airship SDK at runtime, allowing keys and secrets to easily be set for Enterprise and Production versions of the application."
end

.is_supported?(platform) ⇒ Boolean

Returns:

  • (Boolean)


67
68
69
# File 'lib/fastlane/actions/update_urban_airship_configuration.rb', line 67

def self.is_supported?(platform)
  platform == :ios
end

.run(params) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/fastlane/actions/update_urban_airship_configuration.rb', line 4

def self.run(params)
  require "plist"

  begin
    path = File.expand_path(params[:plist_path])
    plist = Plist.parse_xml(path)
    plist['developmentAppKey'] = params[:development_app_key] unless params[:development_app_key].nil?
    plist['developmentAppSecret'] = params[:development_app_secret] unless params[:development_app_secret].nil?
    plist['productionAppKey'] = params[:production_app_key] unless params[:production_app_key].nil?
    plist['productionAppSecret'] = params[:production_app_secret] unless params[:production_app_secret].nil?
    plist['detectProvisioningMode'] = params[:detect_provisioning_mode] unless params[:detect_provisioning_mode].nil?
    new_plist = plist.to_plist
    File.write(path, new_plist)
  rescue => ex
    UI.error(ex)
    UI.error("Unable to update Urban Airship configuration for plist file at '#{path}'")
  end
end