fci 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -2
- data/lib/fci/commands/02_import.rb +3 -3
- data/lib/fci/commands/03_download.rb +1 -1
- data/lib/fci/commands/04_export.rb +18 -16
- data/lib/fci/version.rb +1 -1
- 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: 63e52509bac34e31f3b77df1785037f32bab9124
|
4
|
+
data.tar.gz: 5290ee3ebf5ec6b60ce1373afa709cfc0ddada52
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c5d27104d14292fc5e3fae45240de84c3f2f723ed2efbf1c08375e0373fad4bdb3d3d5eb946b9a37a916dc6fcfd1bfcff03155f971df13b128e8630273a56903
|
7
|
+
data.tar.gz: 79652a8c2fe666f43bce024295b0c43d3dc15803f4d1e248a898c6abd494ab9bef117092eb4664e288602aefc5ea1bff5b19a0bbebb4a1d1e701fd51596caa6a
|
data/README.md
CHANGED
@@ -29,7 +29,7 @@ The simplest way to get started is to create a scaffold project:
|
|
29
29
|
> fci init todo
|
30
30
|
```
|
31
31
|
|
32
|
-
A new ./todo directory is created
|
32
|
+
A new ./todo directory is created with sample config `fci.yml`. View the basic output of the scaffold with:
|
33
33
|
|
34
34
|
```
|
35
35
|
> cd todo
|
@@ -58,7 +58,7 @@ COMMANDS
|
|
58
58
|
help - Shows a list of commands or help for one command
|
59
59
|
init:project - Create a new FCI-based project
|
60
60
|
import:sources - Read folders/articles from Freshdesk and upload resource files to Crowdin
|
61
|
-
download:translations - Build and download
|
61
|
+
download:translations - Build and download translation resources from Crowdin
|
62
62
|
export:translations - Add or update localized resource files(folders and articles) in Freshdesk
|
63
63
|
```
|
64
64
|
|
@@ -52,7 +52,7 @@ command :'import:sources' do |c|
|
|
52
52
|
end
|
53
53
|
|
54
54
|
# Get category's folders in Freshdesk
|
55
|
-
puts "[Freshdesk] Get folders for Category
|
55
|
+
puts "[Freshdesk] Get folders for Category\##{source_category_id}"
|
56
56
|
folders = @freshdesk.solution_folders(category_id: source_category_id).all!
|
57
57
|
|
58
58
|
folders_builder = []
|
@@ -76,7 +76,7 @@ command :'import:sources' do |c|
|
|
76
76
|
# Get articles for each folder
|
77
77
|
articles_builder = []
|
78
78
|
folders.each do |folder|
|
79
|
-
puts "[Freshdesk] Get articles for Folder
|
79
|
+
puts "[Freshdesk] Get articles for Folder\##{folder.id}"
|
80
80
|
articles = @freshdesk.solution_articles(category_id: source_category_id, folder_id: folder.id).all!
|
81
81
|
|
82
82
|
articles.each do |article|
|
@@ -167,7 +167,7 @@ command :'import:sources' do |c|
|
|
167
167
|
end
|
168
168
|
|
169
169
|
# Write resources config file
|
170
|
-
puts "Write config file for Category
|
170
|
+
puts "[INFO] Write config file for Category\##{source_category_id}"
|
171
171
|
File.open(resources_config_file, 'w') do |f|
|
172
172
|
f.write resources_config.to_yaml
|
173
173
|
end
|
@@ -22,7 +22,7 @@ command :'export:translations' do |c|
|
|
22
22
|
|
23
23
|
# for store information about folders/articles ids
|
24
24
|
unless File.exists?(resources_config_file)
|
25
|
-
raise "Error! Config file does not exist. First run `
|
25
|
+
raise "Error! Config file does not exist. First run `import:sources` command."
|
26
26
|
end
|
27
27
|
|
28
28
|
resources_config = YAML.load(File.open(resources_config_file))
|
@@ -33,11 +33,17 @@ command :'export:translations' do |c|
|
|
33
33
|
|
34
34
|
@cli_config['categories'].each do |category|
|
35
35
|
category['translations'].each do |lang|
|
36
|
+
unless freshdesk_category = FreshdeskAPI::SolutionCategory.find(@freshdesk, id: lang['freshdesk_category_id'].to_i)
|
37
|
+
puts "[WARNING] Not such Category\##{lang['freshdesk_category_id']} for language `#{lang['crowdin_language_code']}` in Freshdesk. Please create new one and set `:freshdesk_category_id` in config file."
|
38
|
+
next
|
39
|
+
end
|
40
|
+
|
36
41
|
folder_xml_files = Dir["#{resources_dir}/#{lang['crowdin_language_code']}/#{category['freshdesk_category']}/folder_*.xml"]
|
37
42
|
article_xml_files = Dir["#{resources_dir}/#{lang['crowdin_language_code']}/#{category['freshdesk_category']}/article_*.xml"]
|
38
43
|
|
39
|
-
|
40
|
-
|
44
|
+
if folder_xml_files.empty? && article_xml_files.empty?
|
45
|
+
puts "[WARNING] There are no translations for language `#{lang['crowdin_language_code']}`. First run `download:translations` command."
|
46
|
+
next
|
41
47
|
end
|
42
48
|
|
43
49
|
all_folders = []
|
@@ -46,18 +52,14 @@ command :'export:translations' do |c|
|
|
46
52
|
# Read folders from XML files
|
47
53
|
folder_xml_files.each do |file|
|
48
54
|
folder_xml_file = File.read(file)
|
49
|
-
|
50
55
|
folder = parse_folder_xml(folder_xml_file)
|
51
|
-
|
52
56
|
all_folders << folder
|
53
57
|
end
|
54
58
|
|
55
59
|
# Read articles from XML filse
|
56
60
|
article_xml_files.each do |file|
|
57
61
|
article_xml_file = File.read(file)
|
58
|
-
|
59
62
|
article = parse_article_xml(article_xml_file)
|
60
|
-
|
61
63
|
all_articles << article
|
62
64
|
end
|
63
65
|
|
@@ -81,10 +83,10 @@ command :'export:translations' do |c|
|
|
81
83
|
|
82
84
|
# Remove Folder translation from config it it not found in Freshdesk
|
83
85
|
if freshdesk_folder.nil?
|
84
|
-
puts "
|
86
|
+
puts "[INFO] Removing undefined Folder from config."
|
85
87
|
folder_config[:translations].delete_if { |tr| tr[:lang] == lang['crowdin_language_code'] }
|
86
88
|
|
87
|
-
puts "[Freshdesk] Create new Folder
|
89
|
+
puts "[Freshdesk] Create new Folder `#{folder[:name]}` for language `#{lang['crowdin_language_code']}`."
|
88
90
|
freshdesk_folder = FreshdeskAPI::SolutionFolder.create!(
|
89
91
|
@freshdesk,
|
90
92
|
category_id: lang['freshdesk_category_id'].to_i,
|
@@ -100,11 +102,11 @@ command :'export:translations' do |c|
|
|
100
102
|
puts "[Freshdesk] Update existing Folder."
|
101
103
|
freshdesk_folder.update!(name: folder[:name], description: folder[:description])
|
102
104
|
else
|
103
|
-
puts "[Freshdesk] Nothing to update. An existing Folder still the same."
|
105
|
+
puts "[Freshdesk] Nothing to update. An existing Folder\##{folder[:id]} still the same."
|
104
106
|
end
|
105
107
|
else
|
106
108
|
# create new folder in Freshdesk and save id to config file
|
107
|
-
puts "[Freshdesk] Create new Folder
|
109
|
+
puts "[Freshdesk] Create new Folder `#{folder[:name]}` for language `#{lang['crowdin_language_code']}`."
|
108
110
|
freshdesk_folder = FreshdeskAPI::SolutionFolder.create!(
|
109
111
|
@freshdesk,
|
110
112
|
category_id: lang['freshdesk_category_id'].to_i,
|
@@ -120,7 +122,7 @@ command :'export:translations' do |c|
|
|
120
122
|
end
|
121
123
|
end # all_folders.each
|
122
124
|
|
123
|
-
puts "Write info about Folders localization for
|
125
|
+
puts "[INFO] Write info about Folders localization for language `#{lang['crowdin_language_code']}` for Category\##{freshdesk_category.id} to config."
|
124
126
|
File.open(resources_config_file, 'w') do |f|
|
125
127
|
f.write resources_config.to_yaml
|
126
128
|
end
|
@@ -148,7 +150,7 @@ command :'export:translations' do |c|
|
|
148
150
|
|
149
151
|
# Remove Article translation from config if it not found in Freshdesk
|
150
152
|
if freshdesk_article.nil?
|
151
|
-
puts "
|
153
|
+
puts "[INFO] Removing undefined Article from config."
|
152
154
|
article_config[:translations].delete_if { |tr| tr[:lang] == lang['crowdin_language_code'] }
|
153
155
|
|
154
156
|
puts "[Freshdesk] Create new Article."
|
@@ -164,14 +166,14 @@ command :'export:translations' do |c|
|
|
164
166
|
end
|
165
167
|
|
166
168
|
if freshdesk_article.attributes[:title] != article[:title] || freshdesk_article.attributes[:description] != article[:description]
|
167
|
-
puts "[Freshdesk] Update existing Article."
|
169
|
+
puts "[Freshdesk] Update existing Article\##{article[:id]}."
|
168
170
|
|
169
171
|
freshdesk_article.update!(
|
170
172
|
title: article[:title],
|
171
173
|
description: article[:description]
|
172
174
|
)
|
173
175
|
else
|
174
|
-
puts "[Freshdesk] Nothing to update. An existing Article still the same."
|
176
|
+
puts "[Freshdesk] Nothing to update. An existing Article\##{article[:id]} still the same."
|
175
177
|
end
|
176
178
|
|
177
179
|
else
|
@@ -200,7 +202,7 @@ command :'export:translations' do |c|
|
|
200
202
|
end
|
201
203
|
end # all_articles.each
|
202
204
|
|
203
|
-
puts "Write info about Articles localization for
|
205
|
+
puts "[INFO] Write info about Articles localization for language `#{lang['crowdin_language_code']}` for Category\##{freshdesk_category.id} to config."
|
204
206
|
File.open(resources_config_file, 'w') do |f|
|
205
207
|
f.write resources_config.to_yaml
|
206
208
|
end
|
data/lib/fci/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fci
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Anton Maminov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-06-
|
11
|
+
date: 2015-06-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|