Class: Fastlane::Actions::GpUpdateMetadataSourceAction
- Inherits:
-
Action
- Object
- Action
- Fastlane::Actions::GpUpdateMetadataSourceAction
- Defined in:
- lib/fastlane/plugin/wpmreleasetoolkit/actions/common/gp_update_metadata_source.rb
Documentation collapse
- .authors ⇒ Object
- .available_options ⇒ Object
- .description ⇒ Object
- .details ⇒ Object
- .is_supported?(platform) ⇒ Boolean
- .output ⇒ Object
- .return_value ⇒ Object
Class Method Summary collapse
- .commit_changes(params) ⇒ Object
- .run(params) ⇒ Object
- .validate_source_files(source_files) ⇒ Object
Class Method Details
.authors ⇒ Object
106 107 108 |
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/common/gp_update_metadata_source.rb', line 106 def self. ['Automattic'] end |
.available_options ⇒ Object
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/common/gp_update_metadata_source.rb', line 71 def self. [ FastlaneCore::ConfigItem.new(key: :po_file_path, env_name: 'FL_UPDATE_METADATA_SOURCE_PO_FILE_PATH', description: 'The path of the .po file to generate', type: String, verify_block: proc do |value| UI.user_error!("No .po file path given, pass using `po_file_path: 'file path'`") unless value && !value.empty? end), FastlaneCore::ConfigItem.new(key: :release_version, env_name: 'FL_UPDATE_METADATA_SOURCE_RELEASE_VERSION', description: 'The release version of the app (used for release notes)', verify_block: proc do |value| UI.user_error!("No release version given, pass using `release_version: 'version'`") unless value && !value.empty? end), FastlaneCore::ConfigItem.new(key: :source_files, env_name: 'FL_UPDATE_METADATA_SOURCE_SOURCE_FILES', description: 'Hash mapping keys to file paths (String) or hashes with :path and optional :comment', type: Hash, verify_block: proc do |value| UI.user_error!("No source files given, pass using `source_files: { key: 'path' }`") unless value && !value.empty? end), FastlaneCore::ConfigItem.new(key: :commit_changes, description: 'If true, adds and commits the changes', type: Boolean, default_value: false), ] end |
.commit_changes(params) ⇒ Object
33 34 35 36 37 38 39 40 |
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/common/gp_update_metadata_source.rb', line 33 def self.commit_changes(params) other_action.git_add(path: params[:po_file_path]) other_action.git_commit( path: params[:po_file_path], message: 'Update metadata strings', allow_nothing_to_commit: true ) end |
.description ⇒ Object
46 47 48 |
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/common/gp_update_metadata_source.rb', line 46 def self.description 'Generates a .po file from source .txt files' end |
.details ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/common/gp_update_metadata_source.rb', line 50 def self.details <<~DETAILS Generates a .po file from source .txt files for localization via GlotPress. The `source_files` parameter accepts either simple file paths or hashes with path and comment: ```ruby source_files: { # Simple path (no translator comment) app_name: 'path/to/name.txt', # Hash with path and translator comment app_store_subtitle: { path: 'path/to/subtitle.txt', comment: 'translators: Limit to 30 characters!' } } ``` DETAILS end |
.is_supported?(platform) ⇒ Boolean
110 111 112 |
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/common/gp_update_metadata_source.rb', line 110 def self.is_supported?(platform) true end |
.output ⇒ Object
100 101 |
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/common/gp_update_metadata_source.rb', line 100 def self.output end |
.return_value ⇒ Object
103 104 |
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/common/gp_update_metadata_source.rb', line 103 def self.return_value end |
.run(params) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/common/gp_update_metadata_source.rb', line 8 def self.run(params) UI. "PO file path: #{params[:po_file_path]}" UI. "Release version: #{params[:release_version]}" validate_source_files(params[:source_files]) generator = Fastlane::Helper::PoFileGenerator.new( release_version: params[:release_version], source_files: params[:source_files] ) generator.write(params[:po_file_path]) UI.success "File #{params[:po_file_path]} updated!" commit_changes(params) if params[:commit_changes] end |
.validate_source_files(source_files) ⇒ Object
26 27 28 29 30 31 |
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/common/gp_update_metadata_source.rb', line 26 def self.validate_source_files(source_files) source_files.each_value do |value| file_path = value.is_a?(Hash) ? value[:path] : value UI.user_error!("Couldn't find file at path '#{file_path}'") unless File.exist?(file_path) end end |