Class: Fastlane::Actions::AndroidChangeStringAppNameRevertAction

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

Class Method Summary collapse

Class Method Details

.authorsObject



105
106
107
# File 'lib/fastlane/plugin/android_change_string_app_name/actions/android_change_string_app_name_action.rb', line 105

def self.authors
  ["MaximusMcCann"]
end

.available_optionsObject



117
118
119
120
121
122
123
124
125
126
# File 'lib/fastlane/plugin/android_change_string_app_name/actions/android_change_string_app_name_action.rb', line 117

def self.available_options
  [
    FastlaneCore::ConfigItem.new(key: :stringsFile,
                            env_name: "",
                         description: "Optional custom location for strings.xml",
                            optional: false,
                                type: String,
                       default_value: "app/src/main/res/values/strings.xml")
  ]
end

.descriptionObject



101
102
103
# File 'lib/fastlane/plugin/android_change_string_app_name/actions/android_change_string_app_name_action.rb', line 101

def self.description
  "Revert strings.xml app_name using ANDROID_CHANGE_STRING_APP_NAME_ORIGINAL_NAME"
end

.detailsObject



113
114
115
# File 'lib/fastlane/plugin/android_change_string_app_name/actions/android_change_string_app_name_action.rb', line 113

def self.details
  "Revert strings.xml app_name using ANDROID_CHANGE_STRING_APP_NAME_ORIGINAL_NAME"
end

.is_supported?(platform) ⇒ Boolean

Returns:

  • (Boolean)


128
129
130
# File 'lib/fastlane/plugin/android_change_string_app_name/actions/android_change_string_app_name_action.rb', line 128

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

.return_valueObject



109
110
111
# File 'lib/fastlane/plugin/android_change_string_app_name/actions/android_change_string_app_name_action.rb', line 109

def self.return_value
  # If your method provides a return value, you can describe here what it does
end

.run(params) ⇒ Object



76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
# File 'lib/fastlane/plugin/android_change_string_app_name/actions/android_change_string_app_name_action.rb', line 76

def self.run(params)
  require 'nokogiri'

  oldName = Actions.lane_context[SharedValues::ANDROID_CHANGE_STRING_APP_NAME_ORIGINAL_NAME]

  if oldName.to_s.strip.length != 0
    stringsFile = params[:stringsFile]
  else
    UI.error("no string for ANDROID_CHANGE_STRING_APP_NAME_ORIGINAL_NAME.  Have you run android_change_string_app_name?")
  end

  doc = File.open(stringsFile) { |f|
    @doc = Nokogiri::XML(f)

    @doc.css("resources string[@name=app_name]").each do |response_node|
      response_node.content = oldName

      UI.message("Reverting app name to: #{oldName}")
    end

    File.write(stringsFile, @doc.to_xml)
  }

end