Class: Fastlane::Helper::Ios::L10nLinterHelper
- Inherits:
-
Object
- Object
- Fastlane::Helper::Ios::L10nLinterHelper
- Defined in:
- lib/fastlane/plugin/wpmreleasetoolkit/helper/ios/ios_l10n_linter_helper.rb
Constant Summary collapse
- SWIFTGEN_VERSION =
'6.6.2'.freeze
- DEFAULT_BASE_LANG =
'en'.freeze
- CONFIG_FILE_NAME =
'swiftgen-stringtypes.yml'.freeze
Instance Attribute Summary collapse
-
#install_path ⇒ Object
readonly
Returns the value of attribute install_path.
-
#version ⇒ Object
readonly
Returns the value of attribute version.
Instance Method Summary collapse
-
#check_swiftgen_installed ⇒ Object
Check if SwiftGen is installed in the provided ‘install_path` and if so if the installed version matches the expected `version`.
-
#initialize(install_path:, version: SWIFTGEN_VERSION) ⇒ L10nLinterHelper
constructor
A new instance of L10nLinterHelper.
-
#install_swiftgen! ⇒ Object
Download the ZIP of SwiftGen for the requested ‘version` and install it in the `install_path`.
-
#run(input_dir:, base_lang: DEFAULT_BASE_LANG, only_langs: nil) ⇒ Hash<String, Array<String>>
Install SwiftGen if necessary (if not installed yet with the expected version), then run the checks and returns the violations found, if any.
Constructor Details
#initialize(install_path:, version: SWIFTGEN_VERSION) ⇒ L10nLinterHelper
Returns a new instance of L10nLinterHelper.
20 21 22 23 |
# File 'lib/fastlane/plugin/wpmreleasetoolkit/helper/ios/ios_l10n_linter_helper.rb', line 20 def initialize(install_path:, version: SWIFTGEN_VERSION) @install_path = install_path @version = version || SWIFTGEN_VERSION end |
Instance Attribute Details
#install_path ⇒ Object (readonly)
Returns the value of attribute install_path.
12 13 14 |
# File 'lib/fastlane/plugin/wpmreleasetoolkit/helper/ios/ios_l10n_linter_helper.rb', line 12 def install_path @install_path end |
#version ⇒ Object (readonly)
Returns the value of attribute version.
12 13 14 |
# File 'lib/fastlane/plugin/wpmreleasetoolkit/helper/ios/ios_l10n_linter_helper.rb', line 12 def version @version end |
Instance Method Details
#check_swiftgen_installed ⇒ Object
Check if SwiftGen is installed in the provided ‘install_path` and if so if the installed version matches the expected `version`
27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/fastlane/plugin/wpmreleasetoolkit/helper/ios/ios_l10n_linter_helper.rb', line 27 def check_swiftgen_installed return false unless File.exist?(swiftgen_bin) vers_string = `#{swiftgen_bin} --version` # The SwiftGen version string has this format: # # SwiftGen v6.4.0 (Stencil v0.13.1, StencilSwiftKit v2.7.2, SwiftGenKit v6.4.0) vers_string.include?("SwiftGen v#{version}") rescue StandardError false end |
#install_swiftgen! ⇒ Object
This action nukes anything at ‘install_path` – if something already exists – prior to install SwiftGen there
Download the ZIP of SwiftGen for the requested ‘version` and install it in the `install_path`
43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/fastlane/plugin/wpmreleasetoolkit/helper/ios/ios_l10n_linter_helper.rb', line 43 def install_swiftgen! UI. "Installing SwiftGen #{version} into #{install_path}" Dir.mktmpdir do |tmpdir| zipfile = File.join(tmpdir, "swiftgen-#{version}.zip") Action.sh('curl', '--fail', '--location', '-o', zipfile, "https://github.com/SwiftGen/SwiftGen/releases/download/#{version}/swiftgen-#{version}.zip") extracted_dir = File.join(tmpdir, "swiftgen-#{version}") Action.sh('unzip', zipfile, '-d', extracted_dir) FileUtils.rm_rf(install_path) FileUtils.mkdir_p(install_path) FileUtils.cp_r("#{extracted_dir}/.", install_path) end end |
#run(input_dir:, base_lang: DEFAULT_BASE_LANG, only_langs: nil) ⇒ Hash<String, Array<String>>
Install SwiftGen if necessary (if not installed yet with the expected version), then run the checks and returns the violations found, if any
63 64 65 66 |
# File 'lib/fastlane/plugin/wpmreleasetoolkit/helper/ios/ios_l10n_linter_helper.rb', line 63 def run(input_dir:, base_lang: DEFAULT_BASE_LANG, only_langs: nil) check_swiftgen_installed || install_swiftgen! find_diffs(input_dir: input_dir, base_lang: base_lang, only_langs: only_langs) end |