class Fastlane::Actions::CreateTranslationAction
Public Class Methods
available_options()
click to toggle source
# File lib/fastlane/plugin/translation/actions/create_translation_action.rb, line 48 def self.available_options [ FastlaneCore::ConfigItem.new(key: :config_path, env_name: "FL_TRANSLATION_CONFIG_PATH", description: "reference for the config json file, see https://github.com/gimite/google-drive-ruby/blob/master/doc/authorization.md for more info", optional: false), FastlaneCore::ConfigItem.new(key: :doc_name, env_name: "FL_TRANSLATION_DOC_NAME", description: "unique name of the google sheet", optional: false), FastlaneCore::ConfigItem.new(key: :owner_email, env_name: "FL_TRANSLATION_OWNER_EMAIL", description: "The mail to give ownership over the the document", optional: false), FastlaneCore::ConfigItem.new(key: :seed_email, env_name: "FL_TRANSLATION_SEED_EMAIL", description: "The mail to give rights when initializing the document", optional: false) ] end
description()
click to toggle source
@!group Documentation
# File lib/fastlane/plugin/translation/actions/create_translation_action.rb, line 33 def self.description "Create sheet for translations in Google sheets." end
details()
click to toggle source
# File lib/fastlane/plugin/translation/actions/create_translation_action.rb, line 44 def self.details nil end
is_supported?(platform)
click to toggle source
# File lib/fastlane/plugin/translation/actions/create_translation_action.rb, line 69 def self.is_supported?(platform) true end
return_value()
click to toggle source
# File lib/fastlane/plugin/translation/actions/create_translation_action.rb, line 41 def self.return_value end
run(params)
click to toggle source
# File lib/fastlane/plugin/translation/actions/create_translation_action.rb, line 6 def self.run(params) UI.message "Logging into google using #{params[:config_path]}" session = GoogleDrive::Session.from_config(params[:config_path]) UI.message "Creating document with title '#{params[:doc_name]}'" file = session.spreadsheet_by_title(params[:doc_name]) if file raise "Document already exists, please change to a different doc_name".red else tmp_file = "#{FastlaneCore::FastlaneFolder.path}/translations" f = File.open(tmp_file, "w") f.close file = session.upload_from_file(File.absolute_path(tmp_file).to_s, params[:doc_name], convert: true, content_type: "text/csv") File.delete(tmp_file) file.acl.push({ type: 'user', value: params[:owner_email], role: 'owner' }) file.acl.push({ type: 'user', value: params[:seed_email], role: 'writer' }) unless params[:owner_email] == params[:seed_email] UI.message "Done creating document, use doc_id:'#{file.id}' for pulling translations.".yellow end end