phraseapp_updater 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/bin/phraseapp_updater +25 -10
- data/lib/phraseapp_updater.rb +5 -0
- data/lib/phraseapp_updater/version.rb +1 -1
- data/lib/phraseapp_updater/yml_config_loader.rb +21 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b9bfceed600065602f978bbafed9f6e6a729636c
|
4
|
+
data.tar.gz: 581f527db36b94cb44ab4fdf9eeaf621ecdbbf4e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: baedaa18f216752c02e01b79c12b7236c38b624089fe54d904e75abc1f0c41e26fefdb95451eaa74b6054d9dd6d7aae2a79a4bd1175d620b3d6c195d80340d33
|
7
|
+
data.tar.gz: 443a35fde4d991f45e4f540539aae8ed0ee1f926efce325279a5978129dbcab8d35ec7c70e1a84cff99603cdadd0d176dba3ed9c1993ca2d9f4207bb455e73aa
|
data/bin/phraseapp_updater
CHANGED
@@ -8,11 +8,36 @@ class PhraseAppUpdaterCLI < Thor
|
|
8
8
|
option :previous_locales_path, type: :string
|
9
9
|
option :phraseapp_api_key, type: :string
|
10
10
|
option :phraseapp_project_id, type: :string
|
11
|
+
option :config_file_path, type: :string
|
11
12
|
option :store_results_path, type: :string
|
12
13
|
option :store_phraseapp_originals_path, type: :string
|
13
14
|
|
14
15
|
def push
|
16
|
+
if options[:config_file_path]
|
17
|
+
|
18
|
+
if options[:phraseapp_api_key] || options[:phraseapp_project_id]
|
19
|
+
raise RuntimeError.new("Provided both a path to PhraseApp config file and command line arguments. Specify only one. #{options}")
|
20
|
+
end
|
21
|
+
|
22
|
+
config = PhraseAppUpdater.load_config(options[:config_file_path])
|
23
|
+
|
24
|
+
phraseapp_api_key = config.api_key
|
25
|
+
phraseapp_project_id = config.project_id
|
26
|
+
else
|
27
|
+
phraseapp_api_key = options.fetch(:phraseapp_api_key, ENV["PA_API_KEY"])
|
28
|
+
phraseapp_project_id = options.fetch(:phraseapp_project_id, ENV["PA_PROJECT_ID"])
|
29
|
+
end
|
30
|
+
|
31
|
+
if phraseapp_api_key.to_s.empty?
|
32
|
+
raise RuntimeError.new("Must provide Phraseapp API key. --phraseapp_api_key or PA_API_KEY")
|
33
|
+
end
|
34
|
+
|
35
|
+
if phraseapp_project_id.to_s.empty?
|
36
|
+
raise RuntimeError.new("Must provide Phraseapp project ID. --phraseapp_project_id or PA_PROJECT_ID")
|
37
|
+
end
|
38
|
+
|
15
39
|
new_locales_path = options.fetch(:new_locales_path, ENV["PA_NEW_LOCALES_PATH"])
|
40
|
+
|
16
41
|
if new_locales_path.to_s.empty?
|
17
42
|
raise RuntimeError.new("Must provide a path to the locale files to upload. --new_locales_path or PA_NEW_LOCALES_PATH")
|
18
43
|
end
|
@@ -30,16 +55,6 @@ class PhraseAppUpdaterCLI < Thor
|
|
30
55
|
raise RuntimeError.new("Path to locales is not a readable directory: #{previous_locales_path}")
|
31
56
|
end
|
32
57
|
|
33
|
-
phraseapp_api_key = options.fetch(:phraseapp_api_key, ENV["PA_API_KEY"])
|
34
|
-
if phraseapp_api_key.to_s.empty?
|
35
|
-
raise RuntimeError.new("Must provide Phraseapp API key. --phraseapp_api_key or PA_API_KEY")
|
36
|
-
end
|
37
|
-
|
38
|
-
phraseapp_project_id = options.fetch(:phraseapp_project_id, ENV["PA_PROJECT_ID"])
|
39
|
-
if phraseapp_project_id.to_s.empty?
|
40
|
-
raise RuntimeError.new("Must provide Phraseapp project ID. --phraseapp_project_id or PA_PROJECT_ID")
|
41
|
-
end
|
42
|
-
|
43
58
|
store_results_path = options.fetch(:store_results_path, ENV["PA_store_results_path"]).to_s
|
44
59
|
|
45
60
|
if !store_results_path.empty? && (!File.writable?(store_results_path) || !File.directory?(store_results_path))
|
data/lib/phraseapp_updater.rb
CHANGED
@@ -4,6 +4,7 @@ require 'phraseapp_updater/differ'
|
|
4
4
|
require 'phraseapp_updater/locale_file'
|
5
5
|
require 'phraseapp_updater/locale_file_loader'
|
6
6
|
require 'phraseapp_updater/phraseapp_api'
|
7
|
+
require 'phraseapp_updater/yml_config_loader'
|
7
8
|
|
8
9
|
class PhraseAppUpdater
|
9
10
|
using IndexBy
|
@@ -72,6 +73,10 @@ class PhraseAppUpdater
|
|
72
73
|
end
|
73
74
|
end
|
74
75
|
|
76
|
+
def self.load_config(config_file_path)
|
77
|
+
YMLConfigLoader.new(config_file_path)
|
78
|
+
end
|
79
|
+
|
75
80
|
def self.find_default_locale_file(locales, files)
|
76
81
|
default_locale = locales.find(&:default?)
|
77
82
|
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
|
3
|
+
class PhraseAppUpdater
|
4
|
+
class YMLConfigLoader
|
5
|
+
attr_reader :api_key, :project_id
|
6
|
+
def initialize(file_path)
|
7
|
+
unless File.readable?(file_path)
|
8
|
+
raise RuntimeError.new("Can't read config file at #{file_path}")
|
9
|
+
end
|
10
|
+
|
11
|
+
parsed_yaml = YAML.load(File.read(file_path))
|
12
|
+
|
13
|
+
unless parsed_yaml
|
14
|
+
raise RuntimeError.new("Couldn't parse file contents: #{File.read(file_path)}")
|
15
|
+
end
|
16
|
+
|
17
|
+
@api_key = parsed_yaml.fetch("phraseapp").fetch("access_token")
|
18
|
+
@project_id = parsed_yaml.fetch("phraseapp").fetch("project_id")
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: phraseapp_updater
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kevin Griffin
|
@@ -177,6 +177,7 @@ files:
|
|
177
177
|
- lib/phraseapp_updater/locale_file_loader.rb
|
178
178
|
- lib/phraseapp_updater/phraseapp_api.rb
|
179
179
|
- lib/phraseapp_updater/version.rb
|
180
|
+
- lib/phraseapp_updater/yml_config_loader.rb
|
180
181
|
- phraseapp_updater.gemspec
|
181
182
|
homepage: https://app.engoo.com
|
182
183
|
licenses:
|
@@ -198,8 +199,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
198
199
|
version: '0'
|
199
200
|
requirements: []
|
200
201
|
rubyforge_project:
|
201
|
-
rubygems_version: 2.
|
202
|
+
rubygems_version: 2.4.8
|
202
203
|
signing_key:
|
203
204
|
specification_version: 4
|
204
205
|
summary: A three-way differ for PhraseApp projects.
|
205
206
|
test_files: []
|
207
|
+
has_rdoc:
|