Class: Fastlane::Actions::GpDownloadmetadataAction
- Inherits:
-
Action
- Object
- Action
- Fastlane::Actions::GpDownloadmetadataAction
- Defined in:
- lib/fastlane/plugin/wpmreleasetoolkit/actions/common/gp_downloadmetadata_action.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
Class Method Details
.authors ⇒ Object
90 91 92 |
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/common/gp_downloadmetadata_action.rb', line 90 def self. ['Automattic'] end |
.available_options ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/common/gp_downloadmetadata_action.rb', line 50 def self. # Define all options your action supports. # Below a few examples [ FastlaneCore::ConfigItem.new(key: :project_url, env_name: 'FL_DOWNLOAD_METADATA_PROJECT_URL', # The name of the environment variable description: 'GlotPress project URL'), FastlaneCore::ConfigItem.new(key: :target_files, env_name: 'FL_DOWNLOAD_METADATA_TARGET_FILES', description: 'The hash with the path to the target files and the key to use to extract their content', type: Hash), FastlaneCore::ConfigItem.new(key: :locales, env_name: 'FL_DOWNLOAD_METADATA_LOCALES', description: 'The hash with the GlotPress locale and the project locale association', is_string: false), FastlaneCore::ConfigItem.new(key: :source_locale, env_name: 'FL_DOWNLOAD_METADATA_SOURCE_LOCALE', description: 'The source locale code', optional: true), FastlaneCore::ConfigItem.new(key: :download_path, env_name: 'FL_DOWNLOAD_METADATA_DOWNLOAD_PATH', description: 'The path of the target files', type: String), FastlaneCore::ConfigItem.new(key: :auto_retry, env_name: 'FL_DOWNLOAD_METADATA_AUTO_RETRY', description: 'Whether to auto retry downloads after Too Many Requests error', type: FastlaneCore::Boolean, optional: true, default_value: true), ] end |
.description ⇒ Object
42 43 44 |
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/common/gp_downloadmetadata_action.rb', line 42 def self.description 'Download translated metadata' end |
.details ⇒ Object
46 47 48 |
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/common/gp_downloadmetadata_action.rb', line 46 def self.details 'Downloads tranlated metadata from GlotPress and updates local files' end |
.is_supported?(platform) ⇒ Boolean
94 95 96 |
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/common/gp_downloadmetadata_action.rb', line 94 def self.is_supported?(platform) true end |
.output ⇒ Object
83 84 |
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/common/gp_downloadmetadata_action.rb', line 83 def self.output end |
.return_value ⇒ Object
86 87 88 |
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/common/gp_downloadmetadata_action.rb', line 86 def self.return_value # If your method provides a return value, you can describe here what it does end |
.run(params) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/common/gp_downloadmetadata_action.rb', line 9 def self.run(params) # fastlane will take care of reading in the parameter and fetching the environment variable: UI. "Project URL: #{params[:project_url]}" UI. "Locales: #{params[:locales].inspect}" UI. "Source locale: #{params[:source_locale].nil? ? '-' : params[:source_locale]}" UI. "Path: #{params[:download_path]}" UI. "Auto-retry: #{params[:auto_retry]}" # Check download path FileUtils.mkdir_p(params[:download_path]) # Download downloader = Fastlane::Helper::MetadataDownloader.new(params[:download_path], params[:target_files], params[:auto_retry]) params[:locales].each do |loc| if loc.is_a?(Array) UI. "Downloading language: #{loc[1]}" complete_url = "#{params[:project_url]}#{loc[0]}/default/export-translations/?filters[status]=current&format=json" downloader.download(loc[1], complete_url, loc[1] == params[:source_locale]) end next unless loc.is_a?(String) UI. "Downloading language: #{loc}" complete_url = "#{params[:project_url]}#{loc}/default/export-translations/?filters[status]=current&format=json" downloader.download(loc, complete_url, loc == params[:source_locale]) end end |