zendesk_apps_tools 1.34.1 → 1.35.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/zat +2 -1
- data/features/new.feature +1 -0
- data/features/step_definitions/app_steps.rb +4 -4
- data/lib/zendesk_apps_tools/api_connection.rb +2 -0
- data/lib/zendesk_apps_tools/bump.rb +0 -2
- data/lib/zendesk_apps_tools/command.rb +26 -17
- data/lib/zendesk_apps_tools/command_helpers.rb +0 -1
- data/lib/zendesk_apps_tools/common.rb +12 -14
- data/lib/zendesk_apps_tools/deploy.rb +3 -2
- data/lib/zendesk_apps_tools/directory.rb +3 -4
- data/lib/zendesk_apps_tools/manifest_handler.rb +1 -0
- data/lib/zendesk_apps_tools/package_helper.rb +4 -5
- data/lib/zendesk_apps_tools/server.rb +5 -12
- data/lib/zendesk_apps_tools/settings.rb +48 -28
- data/lib/zendesk_apps_tools/translate.rb +20 -7
- data/lib/zendesk_apps_tools/version.rb +3 -0
- metadata +24 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 355d252b2c3f34d0695fc2a8439e086a539811e6
|
4
|
+
data.tar.gz: 623e2dbf1511e5b089a1e20d0a5529a241fefe12
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2adc3c34e6c0d4386e56de0f660299c21fc06276a931ac4d2e97635eba73196f830ecea59ebc968dda72d660e54ad5eb8227fd71f6212738a2ad51f73819942f
|
7
|
+
data.tar.gz: 9513cd773c3bfc56fba269e2442d61795cb3a26675a569676fe3284e6d34483b5a5621db54afb20918cbdccc2286effe87683e1cf5263a1d6cd6b74befe7316e
|
data/bin/zat
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
lib_dir = File.expand_path('../../lib', __FILE__)
|
3
|
-
$LOAD_PATH
|
3
|
+
$LOAD_PATH.shift lib_dir unless $LOAD_PATH.include?(lib_dir)
|
4
|
+
ENV['THOR_SHELL'] = 'Color'
|
4
5
|
require 'zendesk_apps_tools'
|
5
6
|
ZendeskAppsTools::Command.start
|
data/features/new.feature
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
require 'fileutils'
|
2
|
-
require 'zip
|
2
|
+
require 'zip'
|
3
3
|
require 'English'
|
4
4
|
|
5
5
|
When /^I move to the app directory$/ do
|
@@ -57,11 +57,11 @@ When /^I run the command "(.*?)" to (validate|package|clean) the app$/ do |cmd,
|
|
57
57
|
end
|
58
58
|
|
59
59
|
Then /^the app file "(.*?)" is created with:$/ do |file, content|
|
60
|
-
File.read(file).chomp.gsub(' ', '').
|
60
|
+
expect(File.read(file).chomp.gsub(' ', '')).to eq content.gsub(' ', '')
|
61
61
|
end
|
62
62
|
|
63
63
|
Then /^the app file "(.*?)" is created$/ do |filename|
|
64
|
-
File.exist?(filename).
|
64
|
+
expect(File.exist?(filename)).to be_truthy
|
65
65
|
end
|
66
66
|
|
67
67
|
Then /^the fixture "(.*?)" is used for "(.*?)"$/ do |fixture, app_file|
|
@@ -97,7 +97,7 @@ Then /^"(.*?)" should be a symlink$/ do |path|
|
|
97
97
|
end
|
98
98
|
|
99
99
|
Then /^the zip file in "(.*?)" should not contain any symlinks$/ do |path|
|
100
|
-
Zip::
|
100
|
+
Zip::File.foreach Dir[path + '/app-*.zip'][0] do |p|
|
101
101
|
p.symlink?.should be_falsy
|
102
102
|
end
|
103
103
|
end
|
@@ -1,24 +1,21 @@
|
|
1
1
|
require 'thor'
|
2
|
-
require 'zip/zip'
|
3
2
|
require 'pathname'
|
4
|
-
require 'net/http'
|
5
3
|
require 'json'
|
6
|
-
require 'faraday'
|
7
|
-
require 'io/console'
|
8
|
-
require 'zendesk_apps_support'
|
9
4
|
|
5
|
+
require 'zendesk_apps_tools/version'
|
10
6
|
require 'zendesk_apps_tools/command_helpers'
|
11
7
|
|
12
8
|
module ZendeskAppsTools
|
13
9
|
class Command < Thor
|
14
10
|
include Thor::Actions
|
15
|
-
include ZendeskAppsSupport
|
16
11
|
include ZendeskAppsTools::CommandHelpers
|
17
12
|
|
18
13
|
SHARED_OPTIONS = {
|
19
14
|
['path', '-p'] => './',
|
20
15
|
clean: false
|
21
|
-
}
|
16
|
+
}.freeze
|
17
|
+
|
18
|
+
map %w(-v) => :version
|
22
19
|
|
23
20
|
source_root File.expand_path(File.join(File.dirname(__FILE__), '../..'))
|
24
21
|
|
@@ -51,8 +48,7 @@ module ZendeskAppsTools
|
|
51
48
|
@iframe_location = if options[:'iframe-only']
|
52
49
|
iframe_uri_text = 'Enter your iFrame URI or leave it blank to use'\
|
53
50
|
" a default local template page:\n"
|
54
|
-
|
55
|
-
value == '' ? 'assets/iframe.html' : value
|
51
|
+
get_value_from_stdin(iframe_uri_text, allow_empty: true, default: 'assets/iframe.html')
|
56
52
|
else
|
57
53
|
'_legacy'
|
58
54
|
end
|
@@ -69,7 +65,15 @@ module ZendeskAppsTools
|
|
69
65
|
method_options SHARED_OPTIONS
|
70
66
|
def validate
|
71
67
|
setup_path(options[:path])
|
72
|
-
|
68
|
+
begin
|
69
|
+
errors = app_package.validate(marketplace: false)
|
70
|
+
rescue ExecJS::RuntimeError
|
71
|
+
error = "There was an error trying to validate this app.\n"
|
72
|
+
if ExecJS.runtime.name == 'JScript'
|
73
|
+
error += 'To validate on Windows, please install node from https://nodejs.org/'
|
74
|
+
end
|
75
|
+
say_error_and_exit error
|
76
|
+
end
|
73
77
|
valid = errors.none?
|
74
78
|
|
75
79
|
if valid
|
@@ -124,24 +128,24 @@ module ZendeskAppsTools
|
|
124
128
|
method_option :app_id, default: DEFAULT_APP_ID, required: false
|
125
129
|
def server
|
126
130
|
setup_path(options[:path])
|
127
|
-
manifest = app_package.
|
131
|
+
manifest = app_package.manifest
|
128
132
|
|
129
|
-
|
133
|
+
require 'zendesk_apps_tools/settings'
|
134
|
+
settings_helper = ZendeskAppsTools::Settings.new(self)
|
130
135
|
|
131
|
-
settings = settings_helper.get_settings_from_file options[:config], manifest
|
136
|
+
settings = settings_helper.get_settings_from_file options[:config], manifest.original_parameters
|
132
137
|
|
133
138
|
unless settings
|
134
|
-
settings = settings_helper.get_settings_from_user_input
|
139
|
+
settings = settings_helper.get_settings_from_user_input manifest.original_parameters
|
135
140
|
end
|
136
141
|
|
137
142
|
require 'zendesk_apps_tools/server'
|
138
143
|
ZendeskAppsTools::Server.tap do |server|
|
144
|
+
server.set :settings_helper, settings_helper
|
139
145
|
server.set :port, options[:port]
|
140
146
|
server.set :root, options[:path]
|
141
147
|
server.set :public_folder, File.join(options[:path], 'assets')
|
142
148
|
server.set :parameters, settings
|
143
|
-
server.set :manifest, manifest['parameters']
|
144
|
-
server.set :config, options[:config]
|
145
149
|
server.set :app_id, options[:app_id]
|
146
150
|
server.run!
|
147
151
|
end
|
@@ -158,7 +162,7 @@ module ZendeskAppsTools
|
|
158
162
|
app_name = JSON.parse(File.read(File.join options[:path], 'manifest.json'))['name']
|
159
163
|
end
|
160
164
|
app_name ||= get_value_from_stdin('Enter app name:')
|
161
|
-
deploy_app(:post, '/api/v2/apps.json',
|
165
|
+
deploy_app(:post, '/api/v2/apps.json', name: app_name)
|
162
166
|
end
|
163
167
|
|
164
168
|
desc 'update', 'Update app on the server'
|
@@ -175,6 +179,11 @@ module ZendeskAppsTools
|
|
175
179
|
deploy_app(:put, "/api/v2/apps/#{app_id}.json", {})
|
176
180
|
end
|
177
181
|
|
182
|
+
desc "version, -v", "Print the version"
|
183
|
+
def version
|
184
|
+
say ZendeskAppsTools::VERSION
|
185
|
+
end
|
186
|
+
|
178
187
|
protected
|
179
188
|
|
180
189
|
def setup_path(path)
|
@@ -4,7 +4,6 @@ require 'zendesk_apps_tools/api_connection'
|
|
4
4
|
require 'zendesk_apps_tools/deploy'
|
5
5
|
require 'zendesk_apps_tools/directory'
|
6
6
|
require 'zendesk_apps_tools/package_helper'
|
7
|
-
require 'zendesk_apps_tools/settings'
|
8
7
|
require 'zendesk_apps_tools/translate'
|
9
8
|
require 'zendesk_apps_tools/bump'
|
10
9
|
|
@@ -1,14 +1,12 @@
|
|
1
|
-
require 'faraday'
|
2
|
-
|
3
1
|
module ZendeskAppsTools
|
4
2
|
module Common
|
5
|
-
def
|
6
|
-
|
3
|
+
def say_error_and_exit(msg)
|
4
|
+
say_error msg
|
5
|
+
exit 1
|
7
6
|
end
|
8
7
|
|
9
|
-
def
|
8
|
+
def say_error(msg)
|
10
9
|
say msg, :red
|
11
|
-
exit 1
|
12
10
|
end
|
13
11
|
|
14
12
|
def get_value_from_stdin(prompt, opts = {})
|
@@ -18,12 +16,14 @@ module ZendeskAppsTools
|
|
18
16
|
allow_empty: false
|
19
17
|
}.merge(opts)
|
20
18
|
|
21
|
-
|
22
|
-
|
23
|
-
|
19
|
+
thor_options = { default: options[:default] }
|
20
|
+
|
21
|
+
while input = ask(prompt, thor_options)
|
22
|
+
return '' if options[:allow_empty] && input.empty?
|
23
|
+
if input.to_s =~ options[:valid_regex]
|
24
24
|
break
|
25
25
|
else
|
26
|
-
|
26
|
+
say_error options[:error_msg]
|
27
27
|
end
|
28
28
|
end
|
29
29
|
|
@@ -31,10 +31,8 @@ module ZendeskAppsTools
|
|
31
31
|
end
|
32
32
|
|
33
33
|
def get_password_from_stdin(prompt)
|
34
|
-
|
35
|
-
|
36
|
-
puts
|
37
|
-
password
|
34
|
+
ask(prompt, echo: false)
|
35
|
+
say ''
|
38
36
|
end
|
39
37
|
end
|
40
38
|
end
|
@@ -2,7 +2,6 @@ module ZendeskAppsTools
|
|
2
2
|
module Deploy
|
3
3
|
def deploy_app(connection_method, url, body)
|
4
4
|
body[:upload_id] = upload(options[:path]).to_s
|
5
|
-
|
6
5
|
connection = get_connection
|
7
6
|
|
8
7
|
response = connection.send(connection_method) do |req|
|
@@ -45,7 +44,9 @@ module ZendeskAppsTools
|
|
45
44
|
|
46
45
|
all_apps = connection.get('/api/v2/apps.json').body
|
47
46
|
|
48
|
-
|
47
|
+
app_json = JSON.parse(all_apps)['apps'].find { |app| app['name'] == name }
|
48
|
+
say_error_and_exit('The app was not found. Please verify your credentials, subdomain, and app name are correct.') unless app_json
|
49
|
+
app_id = app_json['id']
|
49
50
|
|
50
51
|
save_cache 'app_id' => app_id
|
51
52
|
app_id
|
@@ -11,14 +11,13 @@ module ZendeskAppsTools
|
|
11
11
|
end
|
12
12
|
|
13
13
|
def prompt_new_app_dir
|
14
|
-
prompt = "Enter a directory name to save the new app (will create the dir if it does not exist
|
15
|
-
opts = { valid_regex: /^(
|
14
|
+
prompt = "Enter a directory name to save the new app (will create the dir if it does not exist):\n"
|
15
|
+
opts = { valid_regex: /^(.|\w|\/|\\)*$/, default: './' }
|
16
16
|
while @app_dir = get_value_from_stdin(prompt, opts)
|
17
|
-
@app_dir = './' and break if @app_dir.empty?
|
18
17
|
if !File.exist?(@app_dir)
|
19
18
|
break
|
20
19
|
elsif !File.directory?(@app_dir)
|
21
|
-
|
20
|
+
say_error 'Invalid dir, try again:'
|
22
21
|
else
|
23
22
|
break
|
24
23
|
end
|
@@ -1,15 +1,14 @@
|
|
1
1
|
module ZendeskAppsTools
|
2
|
-
require 'zendesk_apps_support'
|
3
2
|
|
4
3
|
module PackageHelper
|
5
|
-
include ZendeskAppsSupport
|
6
|
-
|
7
4
|
def app_package
|
8
|
-
|
5
|
+
require 'zendesk_apps_support'
|
6
|
+
@app_package ||= ZendeskAppsSupport::Package.new(app_dir.to_s)
|
9
7
|
end
|
10
8
|
|
11
9
|
def zip(archive_path)
|
12
|
-
|
10
|
+
require 'zip'
|
11
|
+
Zip::File.open(archive_path, 'w') do |zipfile|
|
13
12
|
app_package.files.each do |file|
|
14
13
|
relative_path = file.relative_path
|
15
14
|
path = relative_path
|
@@ -5,38 +5,31 @@ require 'zendesk_apps_support/package'
|
|
5
5
|
module ZendeskAppsTools
|
6
6
|
class Server < Sinatra::Base
|
7
7
|
set :protection, :except => :frame_options
|
8
|
-
last_mtime = Time.new(0)
|
9
8
|
ZENDESK_DOMAINS_REGEX = /^http(?:s)?:\/\/[a-z0-9-]+\.(?:zendesk|zopim|zd-(?:dev|master|staging))\.com$/
|
10
9
|
|
11
10
|
get '/app.js' do
|
12
11
|
access_control_allow_origin
|
13
12
|
content_type 'text/javascript'
|
14
13
|
|
15
|
-
|
16
|
-
|
17
|
-
if curr_mtime > last_mtime
|
18
|
-
settings_helper = ZendeskAppsTools::Settings.new
|
19
|
-
settings.parameters = settings_helper.get_settings_from_file(settings.config, settings.manifest)
|
20
|
-
last_mtime = curr_mtime
|
21
|
-
end
|
22
|
-
end
|
14
|
+
new_settings = settings.settings_helper.refresh!
|
15
|
+
settings.parameters = new_settings if new_settings
|
23
16
|
|
24
17
|
package = ZendeskAppsSupport::Package.new(settings.root, false)
|
25
|
-
app_name =
|
18
|
+
app_name = ENV.fetch('ZAT_APP_NAME', 'Local App')
|
26
19
|
installation = ZendeskAppsSupport::Installation.new(
|
27
20
|
id: settings.app_id,
|
28
21
|
app_id: settings.app_id,
|
29
22
|
app_name: app_name,
|
30
23
|
enabled: true,
|
31
24
|
requirements: package.requirements_json,
|
32
|
-
settings: settings.parameters.merge(
|
25
|
+
settings: settings.parameters.merge(title: app_name),
|
33
26
|
updated_at: Time.now.iso8601,
|
34
27
|
created_at: Time.now.iso8601
|
35
28
|
)
|
36
29
|
|
37
30
|
app_js = package.compile_js(
|
38
31
|
app_id: settings.app_id,
|
39
|
-
app_name:
|
32
|
+
app_name: app_name,
|
40
33
|
assets_dir: "http://localhost:#{settings.port}/",
|
41
34
|
locale: params['locale']
|
42
35
|
)
|
@@ -1,19 +1,21 @@
|
|
1
1
|
require 'zendesk_apps_tools/common'
|
2
|
-
require 'yaml'
|
3
2
|
|
4
3
|
module ZendeskAppsTools
|
5
4
|
class Settings
|
6
|
-
def
|
5
|
+
def initialize(cli)
|
6
|
+
@cli = cli
|
7
|
+
end
|
8
|
+
|
9
|
+
def get_settings_from_user_input(parameters)
|
7
10
|
return {} if parameters.nil?
|
8
11
|
|
9
12
|
parameters.inject({}) do |settings, param|
|
10
13
|
if param['default']
|
11
|
-
input =
|
12
|
-
input = param['default'] if input.empty?
|
14
|
+
input = @cli.get_value_from_stdin("Enter a value for parameter '#{param['name']}':\n", default: param['default'])
|
13
15
|
elsif param['required']
|
14
|
-
input =
|
16
|
+
input = @cli.get_value_from_stdin("Enter a value for required parameter '#{param['name']}':\n")
|
15
17
|
else
|
16
|
-
input =
|
18
|
+
input = @cli.get_value_from_stdin("Enter a value for optional parameter '#{param['name']}' or press 'Return' to skip:\n", allow_empty: true)
|
17
19
|
end
|
18
20
|
|
19
21
|
if param['type'] == 'checkbox'
|
@@ -25,39 +27,36 @@ module ZendeskAppsTools
|
|
25
27
|
end
|
26
28
|
end
|
27
29
|
|
30
|
+
def refresh!
|
31
|
+
if File.exist? @filepath
|
32
|
+
curr_mtime = File.stat(@filepath).mtime
|
33
|
+
if curr_mtime > @last_mtime
|
34
|
+
@last_mtime = curr_mtime
|
35
|
+
get_settings_from_file(@filepath, @parameters)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
28
40
|
def get_settings_from_file(filepath, parameters)
|
41
|
+
@filepath ||= filepath
|
42
|
+
@parameters ||= parameters
|
43
|
+
|
29
44
|
return {} if parameters.nil?
|
30
45
|
return nil unless File.exist? filepath
|
31
46
|
|
32
47
|
begin
|
33
|
-
settings_file =
|
34
|
-
|
35
|
-
if filepath =~ /\.json$/ || settings_file =~ /\A\s*{/
|
36
|
-
settings_data = JSON.load(settings_file)
|
37
|
-
else
|
38
|
-
settings_data = YAML.load(settings_file)
|
39
|
-
end
|
40
|
-
|
41
|
-
settings_data.each do |index, setting|
|
42
|
-
if setting.is_a?(Hash) || setting.is_a?(Array)
|
43
|
-
settings_data[index] = JSON.dump(setting)
|
44
|
-
end
|
45
|
-
end
|
48
|
+
settings_file = read_settings(filepath)
|
49
|
+
settings_data = parse_settings(filepath, settings_file)
|
46
50
|
rescue => err
|
47
|
-
|
48
|
-
puts err.message
|
51
|
+
@cli.say_error "Failed to load #{filepath}\n#{err.message}"
|
49
52
|
return nil
|
50
53
|
end
|
51
54
|
|
52
|
-
parameters.
|
53
|
-
input = settings_data[param['name']]
|
54
|
-
|
55
|
-
if !input && param['default']
|
56
|
-
input = param['default']
|
57
|
-
end
|
55
|
+
parameters.each_with_object({}) do |param, settings|
|
56
|
+
input = settings_data[param['name']] || param['default']
|
58
57
|
|
59
58
|
if !input && param['required']
|
60
|
-
|
59
|
+
@cli.say_error "'#{param['name']}' is required but not specified in the config file.\n"
|
61
60
|
return nil
|
62
61
|
end
|
63
62
|
|
@@ -72,6 +71,27 @@ module ZendeskAppsTools
|
|
72
71
|
|
73
72
|
private
|
74
73
|
|
74
|
+
def read_settings(filepath)
|
75
|
+
@last_mtime = File.stat(filepath).mtime
|
76
|
+
File.read(filepath)
|
77
|
+
end
|
78
|
+
|
79
|
+
def parse_settings(filepath, contents)
|
80
|
+
settings_data =
|
81
|
+
if filepath =~ /\.json$/ || contents =~ /\A\s*{/
|
82
|
+
JSON.load(contents)
|
83
|
+
else
|
84
|
+
require 'yaml'
|
85
|
+
YAML.load(contents)
|
86
|
+
end
|
87
|
+
settings_data.each do |index, setting|
|
88
|
+
if setting.is_a?(Hash) || setting.is_a?(Array)
|
89
|
+
settings_data[index] = JSON.dump(setting)
|
90
|
+
end
|
91
|
+
end
|
92
|
+
settings_data
|
93
|
+
end
|
94
|
+
|
75
95
|
def convert_to_boolean_for_checkbox(input)
|
76
96
|
unless [TrueClass, FalseClass].include?(input.class)
|
77
97
|
return (input =~ /^(true|t|yes|y|1)$/i) ? true : false
|
@@ -2,15 +2,12 @@ require 'thor'
|
|
2
2
|
require 'json'
|
3
3
|
require 'zendesk_apps_tools/common'
|
4
4
|
require 'zendesk_apps_tools/locale_identifier'
|
5
|
-
require 'zendesk_apps_support'
|
6
|
-
require 'yaml'
|
7
5
|
|
8
6
|
module ZendeskAppsTools
|
9
7
|
class Translate < Thor
|
10
8
|
include Thor::Shell
|
11
9
|
include Thor::Actions
|
12
10
|
include ZendeskAppsTools::Common
|
13
|
-
include ZendeskAppsSupport::BuildTranslation
|
14
11
|
|
15
12
|
LOCALE_ENDPOINT = 'https://support.zendesk.com/api/v2/locales/agent.json'
|
16
13
|
|
@@ -37,6 +34,7 @@ module ZendeskAppsTools
|
|
37
34
|
desc 'to_json', 'Convert Zendesk translation yml to I18n formatted json'
|
38
35
|
method_option :path, default: './', required: false
|
39
36
|
def to_json
|
37
|
+
require 'yaml'
|
40
38
|
setup_path(options[:path]) if options[:path]
|
41
39
|
en_yml = YAML.load_file("#{destination_root}/translations/en.yml")
|
42
40
|
package = /^txt.apps.([^\.]+)/.match(en_yml['parts'][0]['translation']['key'])[1]
|
@@ -56,6 +54,8 @@ module ZendeskAppsTools
|
|
56
54
|
key_prefix = "txt.apps.#{app_package}."
|
57
55
|
|
58
56
|
say('Fetching translations...')
|
57
|
+
require 'net/http'
|
58
|
+
require 'faraday'
|
59
59
|
locale_response = Faraday.get(LOCALE_ENDPOINT)
|
60
60
|
|
61
61
|
if locale_response.status == 200
|
@@ -132,8 +132,8 @@ module ZendeskAppsTools
|
|
132
132
|
end
|
133
133
|
|
134
134
|
def write_yml(en_json, app_name, package_name)
|
135
|
-
titles = to_flattened_namespaced_hash(en_json,
|
136
|
-
values = to_flattened_namespaced_hash(en_json,
|
135
|
+
titles = to_flattened_namespaced_hash(en_json, :title)
|
136
|
+
values = to_flattened_namespaced_hash(en_json, :value)
|
137
137
|
@translations = titles.each { |k, v| titles[k] = { 'title' => v, 'value' => escape_special_characters(values[k]) } }
|
138
138
|
@app_name = app_name
|
139
139
|
@package_name = package_name
|
@@ -144,6 +144,19 @@ module ZendeskAppsTools
|
|
144
144
|
v.gsub('"', '\"')
|
145
145
|
end
|
146
146
|
|
147
|
+
def to_flattened_namespaced_hash(hash, target_key)
|
148
|
+
require 'zendesk_apps_support/build_translation'
|
149
|
+
@includer_class ||= Class.new { include ZendeskAppsSupport::BuildTranslation }
|
150
|
+
target_key_constant = case target_key
|
151
|
+
when :title
|
152
|
+
@includer_class::I18N_TITLE_KEY
|
153
|
+
when :value
|
154
|
+
@includer_class::I18N_VALUE_KEY
|
155
|
+
end
|
156
|
+
(@includer ||= @includer_class.new)
|
157
|
+
.to_flattened_namespaced_hash(hash, target_key_constant)
|
158
|
+
end
|
159
|
+
|
147
160
|
def array_to_nested_hash(array)
|
148
161
|
array.inject({}) do |result, item|
|
149
162
|
keys = item['key'].split('.')
|
@@ -157,8 +170,8 @@ module ZendeskAppsTools
|
|
157
170
|
end
|
158
171
|
|
159
172
|
def build_pseudotranslation(translations_hash, package_name)
|
160
|
-
titles = to_flattened_namespaced_hash(translations_hash,
|
161
|
-
values = to_flattened_namespaced_hash(translations_hash,
|
173
|
+
titles = to_flattened_namespaced_hash(translations_hash, :title)
|
174
|
+
values = to_flattened_namespaced_hash(translations_hash, :value)
|
162
175
|
translations = titles.each { |k, v| titles[k] = { 'title' => v, 'value' => "[日本#{values[k]}éñđ]" } }
|
163
176
|
translations['app.package'] = package_name # don't pseudo translate the package name
|
164
177
|
nest_translations_hash(translations, '')
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: zendesk_apps_tools
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.35.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James A. Rosen
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2016-
|
14
|
+
date: 2016-09-02 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: thor
|
@@ -19,28 +19,28 @@ dependencies:
|
|
19
19
|
requirements:
|
20
20
|
- - "~>"
|
21
21
|
- !ruby/object:Gem::Version
|
22
|
-
version: 0.
|
22
|
+
version: 0.19.1
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
26
26
|
requirements:
|
27
27
|
- - "~>"
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version: 0.
|
29
|
+
version: 0.19.1
|
30
30
|
- !ruby/object:Gem::Dependency
|
31
31
|
name: rubyzip
|
32
32
|
requirement: !ruby/object:Gem::Requirement
|
33
33
|
requirements:
|
34
34
|
- - "~>"
|
35
35
|
- !ruby/object:Gem::Version
|
36
|
-
version:
|
36
|
+
version: 1.2.0
|
37
37
|
type: :runtime
|
38
38
|
prerelease: false
|
39
39
|
version_requirements: !ruby/object:Gem::Requirement
|
40
40
|
requirements:
|
41
41
|
- - "~>"
|
42
42
|
- !ruby/object:Gem::Version
|
43
|
-
version:
|
43
|
+
version: 1.2.0
|
44
44
|
- !ruby/object:Gem::Dependency
|
45
45
|
name: sinatra
|
46
46
|
requirement: !ruby/object:Gem::Requirement
|
@@ -75,14 +75,14 @@ dependencies:
|
|
75
75
|
requirements:
|
76
76
|
- - "~>"
|
77
77
|
- !ruby/object:Gem::Version
|
78
|
-
version:
|
78
|
+
version: 3.1.0
|
79
79
|
type: :runtime
|
80
80
|
prerelease: false
|
81
81
|
version_requirements: !ruby/object:Gem::Requirement
|
82
82
|
requirements:
|
83
83
|
- - "~>"
|
84
84
|
- !ruby/object:Gem::Version
|
85
|
-
version:
|
85
|
+
version: 3.1.0
|
86
86
|
- !ruby/object:Gem::Dependency
|
87
87
|
name: sinatra-cross_origin
|
88
88
|
requirement: !ruby/object:Gem::Requirement
|
@@ -167,6 +167,20 @@ dependencies:
|
|
167
167
|
- - ">="
|
168
168
|
- !ruby/object:Gem::Version
|
169
169
|
version: '0'
|
170
|
+
- !ruby/object:Gem::Dependency
|
171
|
+
name: byebug
|
172
|
+
requirement: !ruby/object:Gem::Requirement
|
173
|
+
requirements:
|
174
|
+
- - ">="
|
175
|
+
- !ruby/object:Gem::Version
|
176
|
+
version: '0'
|
177
|
+
type: :development
|
178
|
+
prerelease: false
|
179
|
+
version_requirements: !ruby/object:Gem::Requirement
|
180
|
+
requirements:
|
181
|
+
- - ">="
|
182
|
+
- !ruby/object:Gem::Version
|
183
|
+
version: '0'
|
170
184
|
description: Tools to help you develop Zendesk Apps.
|
171
185
|
email:
|
172
186
|
- dev@zendesk.com
|
@@ -219,6 +233,7 @@ files:
|
|
219
233
|
- lib/zendesk_apps_tools/server.rb
|
220
234
|
- lib/zendesk_apps_tools/settings.rb
|
221
235
|
- lib/zendesk_apps_tools/translate.rb
|
236
|
+
- lib/zendesk_apps_tools/version.rb
|
222
237
|
- templates/translation.erb.tt
|
223
238
|
homepage: http://github.com/zendesk/zendesk_apps_tools
|
224
239
|
licenses:
|
@@ -240,7 +255,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
240
255
|
version: 1.3.6
|
241
256
|
requirements: []
|
242
257
|
rubyforge_project:
|
243
|
-
rubygems_version: 2.4
|
258
|
+
rubygems_version: 2.6.4
|
244
259
|
signing_key:
|
245
260
|
specification_version: 4
|
246
261
|
summary: Tools to help you develop Zendesk Apps.
|
@@ -252,4 +267,3 @@ test_files:
|
|
252
267
|
- features/step_definitions/app_steps.rb
|
253
268
|
- features/support/env.rb
|
254
269
|
- features/validate.feature
|
255
|
-
has_rdoc:
|