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
88 89 90 |
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/common/gp_downloadmetadata_action.rb', line 88 def self. ['Automattic'] end |
.available_options ⇒ Object
48 49 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 |
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/common/gp_downloadmetadata_action.rb', line 48 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
40 41 42 |
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/common/gp_downloadmetadata_action.rb', line 40 def self.description 'Download translated metadata' end |
.details ⇒ Object
44 45 46 |
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/common/gp_downloadmetadata_action.rb', line 44 def self.details 'Downloads tranlated metadata from GlotPress and updates local files' end |
.is_supported?(platform) ⇒ Boolean
92 93 94 |
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/common/gp_downloadmetadata_action.rb', line 92 def self.is_supported?(platform) true end |
.output ⇒ Object
81 82 |
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/common/gp_downloadmetadata_action.rb', line 81 def self.output end |
.return_value ⇒ Object
84 85 86 |
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/common/gp_downloadmetadata_action.rb', line 84 def self.return_value # If your method provides a return value, you can describe here what it does end |
.run(params) ⇒ Object
7 8 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 |
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/common/gp_downloadmetadata_action.rb', line 7 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 |