poeditor-pull 1.0.3 → 1.0.4
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/lib/Configuration.rb +8 -1
- data/lib/Core.rb +15 -10
- data/lib/PullCommand.rb +10 -5
- data/lib/Version.rb +2 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 442a05ff61a3c7845aa28f144c9a97d4430aee49
|
4
|
+
data.tar.gz: 84376d58a5bd9ad35a12049d3edd2af85a11020b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9ec2d8a6559a1be9bcabac2e63689365b927c35ff1e45ad782b39653470e608477ab30e2d5346ab473566a69612a04cd30c0a3773764f62fc118324a7d990e8d
|
7
|
+
data.tar.gz: 5dd9a32a7ef4e6e24ef3c821b94decbe075357eca0239cbc2a2c829bd7d4524747f26770232272db581187cfffc71cbc675aed88144f8571bda6e9ceb6228cd6
|
data/lib/Configuration.rb
CHANGED
@@ -28,9 +28,12 @@ module POEditor
|
|
28
28
|
# @return [Hash{Sting => String}] The path replacements
|
29
29
|
attr_accessor :path_replace
|
30
30
|
|
31
|
+
# @return [Hash{Sting => String}] The path copies
|
32
|
+
attr_accessor :path_copy
|
33
|
+
|
31
34
|
def initialize(api_key:, project_id:, type:, tags:nil,
|
32
35
|
filters:nil, languages:, language_alias:nil,
|
33
|
-
path:, path_replace:nil)
|
36
|
+
path:, path_replace:nil, path_copy:nil)
|
34
37
|
@api_key = from_env(api_key)
|
35
38
|
@project_id = from_env(project_id.to_s)
|
36
39
|
@type = type
|
@@ -42,6 +45,10 @@ module POEditor
|
|
42
45
|
|
43
46
|
@path = path
|
44
47
|
@path_replace = path_replace || {}
|
48
|
+
@path_copy = path_copy || {}
|
49
|
+
if @path_replace.any? and @path_copy.any?
|
50
|
+
raise POEditor::Exception.new "'path_replace' and 'path_copy' are different strategies of one functionality and thus cannot be in use simultaneously."
|
51
|
+
end
|
45
52
|
end
|
46
53
|
|
47
54
|
def from_env(value)
|
data/lib/Core.rb
CHANGED
@@ -116,7 +116,21 @@ module POEditor
|
|
116
116
|
UI.puts " #{"\xe2\x9c\x95".red} Ignoring language: #{language} because there are no any translations."
|
117
117
|
return
|
118
118
|
end
|
119
|
-
|
119
|
+
paths = paths_for_language(language)
|
120
|
+
paths.each { | path | write_translation_to_path(path, content)}
|
121
|
+
end
|
122
|
+
|
123
|
+
def paths_for_language(language)
|
124
|
+
if @configuration.path_copy[language]
|
125
|
+
[@configuration.path_copy[language], @configuration.path.gsub("{LANGUAGE}", language)]
|
126
|
+
elsif @configuration.path_replace[language]
|
127
|
+
[@configuration.path_replace[language]]
|
128
|
+
else
|
129
|
+
[@configuration.path.gsub("{LANGUAGE}", language)]
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
133
|
+
def write_translation_to_path(path, content)
|
120
134
|
if path.to_s.empty?
|
121
135
|
raise POEditor::Exception.new "#{path} doesn't exist"
|
122
136
|
end
|
@@ -127,14 +141,5 @@ module POEditor
|
|
127
141
|
File.write(path, content)
|
128
142
|
UI.puts " #{"\xe2\x9c\x93".green} Saved at '#{path}'"
|
129
143
|
end
|
130
|
-
|
131
|
-
def path_for_language(language)
|
132
|
-
if @configuration.path_replace[language]
|
133
|
-
@configuration.path_replace[language]
|
134
|
-
else
|
135
|
-
@configuration.path.gsub("{LANGUAGE}", language)
|
136
|
-
end
|
137
|
-
end
|
138
|
-
|
139
144
|
end
|
140
145
|
end
|
data/lib/PullCommand.rb
CHANGED
@@ -69,11 +69,8 @@ Configuration file doesn't exist: #{config_path}.
|
|
69
69
|
|
70
70
|
def create_configuration(json_config, target_name)
|
71
71
|
translations_path = File.join(@project_path, path_for_target(get_or_raise(json_config, "path"), target_name))
|
72
|
-
|
73
|
-
|
74
|
-
path_replace_array.each { |language, language_filepath| path_replace_array[language] = File.join(@project_path,
|
75
|
-
path_for_target(language_filepath, target_name)) }
|
76
|
-
end
|
72
|
+
path_copy_array = parse_paths_array(json_config, target_name, "path_copy")
|
73
|
+
path_replace_array = parse_paths_array(json_config, target_name, "path_replace")
|
77
74
|
Configuration.new(
|
78
75
|
api_key: get_or_raise(json_config, "api_key"),
|
79
76
|
project_id: get_or_raise(json_config, "project_id"),
|
@@ -84,6 +81,7 @@ Configuration file doesn't exist: #{config_path}.
|
|
84
81
|
language_alias: json_config["language_alias"],
|
85
82
|
path: translations_path,
|
86
83
|
path_replace: path_replace_array,
|
84
|
+
path_copy: path_copy_array
|
87
85
|
)
|
88
86
|
end
|
89
87
|
|
@@ -104,5 +102,12 @@ Configuration file doesn't exist: #{config_path}.
|
|
104
102
|
path.gsub("{TARGET_NAME}", target_name)
|
105
103
|
end
|
106
104
|
|
105
|
+
def parse_paths_array(json_config, target_name, array_name)
|
106
|
+
paths_array = json_config[array_name]
|
107
|
+
if paths_array != nil
|
108
|
+
paths_array.each { |language, language_filepath| paths_array[language] = File.join(@project_path,
|
109
|
+
path_for_target(language_filepath, target_name)) }
|
110
|
+
end
|
111
|
+
end
|
107
112
|
end
|
108
113
|
end
|
data/lib/Version.rb
CHANGED
@@ -1,3 +1,3 @@
|
|
1
1
|
module POEditor
|
2
|
-
VERSION = "1.0.
|
3
|
-
end
|
2
|
+
VERSION = "1.0.4"
|
3
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: poeditor-pull
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Suyeol Jeon
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2019-07-
|
12
|
+
date: 2019-07-16 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: colorize
|