Class: Fastlane::Actions::AnValidateLibStringsAction

Inherits:
Action
  • Object
show all
Defined in:
lib/fastlane/plugin/wpmreleasetoolkit/actions/android/an_validate_lib_strings_action.rb

Class Method Summary collapse

Class Method Details

.authorsObject



26
27
28
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/android/an_validate_lib_strings_action.rb', line 26

def self.authors
  ['Automattic']
end

.available_optionsObject



49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/android/an_validate_lib_strings_action.rb', line 49

def self.available_options
  [
    FastlaneCore::ConfigItem.new(key: :app_strings_path,
                                 description: 'The path of the main strings file',
                                 optional: false,
                                 type: String),
    FastlaneCore::ConfigItem.new(key: :libs_strings_path,
                                 env_name: 'CHECK_LIBS_STRINGS_PATH',
                                 description: 'The list of libs to merge. This should be an array of Hashes.',
                                 optional: false,
                                 type: Array),
    FastlaneCore::ConfigItem.new(key: :diff_url,
                                 env_name: 'CHECK_LIBS_DIFF_URL',
                                 description: 'The url of the diff to check',
                                 optional: true,
                                 type: String),
  ]
end

.descriptionObject



22
23
24
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/android/an_validate_lib_strings_action.rb', line 22

def self.description
  'Checks that the strings to be localised are updated from the libs into the main application file'
end

.detailsObject



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/android/an_validate_lib_strings_action.rb', line 33

def self.details
  <<~DETAILS
    Checks that the strings to be localised are updated from the libs into the main application file

    For the `lib_strings_path` ConfigItem, it is an array of Hashes, each describing a library and
    containing these specific keys:
      - `:library`: The human readable name of the library, used to display in console messages
      - `:strings_path`: The path to the strings.xml file of the library to merge into the main one
      - `:exclusions`: An array of strings keys to exclude during merge. Any of those keys from the
         library's `strings.xml` will be skipped and won't be merged into the main one.
      - `:source_id`: An optional `String` which will be added as the `a8c-src-lib` XML attribute
         to strings coming from this library, to help identify their source in the merged file.
      - `:add_ignore_attr`: If set to `true`, will add `tools:ignore="UnusedResources"` to merged strings.
  DETAILS
end

.is_supported?(platform) ⇒ Boolean

Returns:

  • (Boolean)


68
69
70
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/android/an_validate_lib_strings_action.rb', line 68

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

.return_valueObject



30
31
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/android/an_validate_lib_strings_action.rb', line 30

def self.return_value
end

.run(params) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/android/an_validate_lib_strings_action.rb', line 7

def self.run(params)
  main_strings_path = params[:app_strings_path]
  libraries_strings_path = params[:libs_strings_path]
  diff_url = params[:diff_url]

  source_diff = nil
  if diff_url.nil? == false
    data = open(params[:diff_url])
    source_diff = data.read
  end
  libraries_strings_path.each do |lib|
    Fastlane::Helper::Android::LocalizeHelper.verify_lib(main_strings_path, lib, source_diff)
  end
end