Class: I28s::Cli::Push
- Inherits:
-
Object
- Object
- I28s::Cli::Push
- Defined in:
- lib/i28s/cli/push.rb
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(locale_identifier, branch: "main") ⇒ Push
constructor
A new instance of Push.
Constructor Details
#initialize(locale_identifier, branch: "main") ⇒ Push
Returns a new instance of Push.
9 10 11 12 |
# File 'lib/i28s/cli/push.rb', line 9 def initialize(locale_identifier, branch: "main") @locale_identifier = locale_identifier @branch = branch end |
Instance Method Details
#call ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/i28s/cli/push.rb', line 14 def call translations = Dir.glob("./config/locales/**/*.yml").each_with_object({}) do |filename, translations| translations.deep_merge!(YAML.load_file(filename)) end translations = translations[@locale_identifier] raise "No translations" unless translations&.any? response = Faraday.post( "#{I28s::Cli.configuration.base_url}/projects/#{I28s::Cli.configuration.project_token}/#{@branch}/locales/#{@locale_identifier}/import", { data: JSON.dump(translations) }, { "Authorization": "Bearer #{I28s::Cli.configuration.api_key}" } ) puts response.status end |