lokalise_rails 0.0.2.2 → 1.0.1
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/CHANGELOG.md +14 -5
- data/README.md +71 -26
- data/lib/generators/lokalise_rails/install_generator.rb +2 -2
- data/lib/generators/templates/lokalise_rails_config.rb +30 -25
- data/lib/lokalise_rails.rb +44 -19
- data/lib/lokalise_rails/railtie.rb +2 -3
- data/lib/lokalise_rails/task_definition/base.rb +37 -6
- data/lib/lokalise_rails/task_definition/exporter.rb +80 -0
- data/lib/lokalise_rails/task_definition/importer.rb +57 -15
- data/lib/lokalise_rails/version.rb +2 -2
- data/lib/tasks/lokalise_rails_tasks.rake +14 -0
- data/lokalise_rails.gemspec +1 -1
- data/spec/dummy/config/application.rb +4 -2
- data/spec/dummy/config/lokalise_rails.rb +5 -0
- data/spec/lib/generators/lokalise_rails/install_generator_spec.rb +1 -1
- data/spec/lib/lokalise_rails/exporter_spec.rb +148 -0
- data/spec/lib/lokalise_rails/importer_spec.rb +22 -4
- data/spec/lib/lokalise_rails_spec.rb +27 -3
- data/spec/lib/tasks/export_task_spec.rb +7 -0
- data/spec/lib/tasks/import_task_spec.rb +34 -14
- data/spec/spec_helper.rb +9 -2
- data/spec/support/file_manager.rb +81 -0
- data/spec/support/rake_utils.rb +4 -0
- data/spec/support/spec_addons.rb +6 -0
- metadata +14 -20
- data/spec/dummy/config/initializers/lokalise_rails.rb +0 -29
- data/spec/support/file_utils.rb +0 -27
data/spec/spec_helper.rb
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
require 'dotenv/load'
|
4
4
|
require 'simplecov'
|
5
|
+
|
5
6
|
SimpleCov.start 'rails' do
|
6
7
|
add_filter 'spec/'
|
7
8
|
add_filter '.github/'
|
@@ -21,14 +22,20 @@ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].sort.each { |f| require f }
|
|
21
22
|
ENV['RAILS_ENV'] = 'test'
|
22
23
|
|
23
24
|
require_relative '../spec/dummy/config/environment'
|
24
|
-
ActiveRecord::Migrator.migrations_paths = [File.expand_path('../spec/dummy/db/migrate', __dir__)]
|
25
|
+
# ActiveRecord::Migrator.migrations_paths = [File.expand_path('../spec/dummy/db/migrate', __dir__)]
|
25
26
|
ENV['RAILS_ROOT'] ||= "#{File.dirname(__FILE__)}../../../spec/dummy"
|
26
27
|
|
27
28
|
require 'rspec/rails'
|
28
29
|
|
29
30
|
RSpec.configure do |config|
|
30
|
-
config.include
|
31
|
+
config.include FileManager
|
31
32
|
config.include RakeUtils
|
33
|
+
config.include SpecAddons
|
32
34
|
end
|
33
35
|
|
36
|
+
# rubocop:disable Style/MixinUsage
|
37
|
+
include FileManager
|
38
|
+
# rubocop:enable Style/MixinUsage
|
39
|
+
|
40
|
+
add_config!
|
34
41
|
Rails.application.load_tasks
|
@@ -0,0 +1,81 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'fileutils'
|
4
|
+
|
5
|
+
module FileManager
|
6
|
+
def expect_file_exist(path, file)
|
7
|
+
file_path = File.join path, file
|
8
|
+
expect(File.file?(file_path)).to be true
|
9
|
+
end
|
10
|
+
|
11
|
+
def mkdir_locales
|
12
|
+
FileUtils.mkdir_p(LokaliseRails.locales_path) unless File.directory?(LokaliseRails.locales_path)
|
13
|
+
end
|
14
|
+
|
15
|
+
def rm_translation_files
|
16
|
+
FileUtils.rm_rf locales_dir
|
17
|
+
end
|
18
|
+
|
19
|
+
def locales_dir
|
20
|
+
Dir["#{LokaliseRails.locales_path}/**/*"]
|
21
|
+
end
|
22
|
+
|
23
|
+
def count_translations
|
24
|
+
locales_dir.count { |file| File.file?(file) }
|
25
|
+
end
|
26
|
+
|
27
|
+
def add_translation_files!(with_ru: false)
|
28
|
+
FileUtils.mkdir_p "#{Rails.root}/config/locales/nested"
|
29
|
+
File.open("#{Rails.root}/config/locales/nested/en.yml", 'w+:UTF-8') do |f|
|
30
|
+
f.write en_data
|
31
|
+
end
|
32
|
+
|
33
|
+
return unless with_ru
|
34
|
+
|
35
|
+
File.open("#{Rails.root}/config/locales/ru.yml", 'w+:UTF-8') do |f|
|
36
|
+
f.write ru_data
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def add_config!
|
41
|
+
data = <<~DATA
|
42
|
+
require 'lokalise_rails'
|
43
|
+
LokaliseRails.config do |c|
|
44
|
+
c.api_token = ENV['LOKALISE_API_TOKEN']
|
45
|
+
c.project_id = ENV['LOKALISE_PROJECT_ID']
|
46
|
+
end
|
47
|
+
DATA
|
48
|
+
|
49
|
+
File.open("#{Rails.root}/config/lokalise_rails.rb", 'w+:UTF-8') do |f|
|
50
|
+
f.write data
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
def remove_config
|
55
|
+
FileUtils.remove_file config_file if File.file?(config_file)
|
56
|
+
end
|
57
|
+
|
58
|
+
def config_file
|
59
|
+
"#{Rails.root}/config/lokalise_rails.rb"
|
60
|
+
end
|
61
|
+
|
62
|
+
private
|
63
|
+
|
64
|
+
def en_data
|
65
|
+
<<~DATA
|
66
|
+
en:
|
67
|
+
my_key: "My value"
|
68
|
+
nested:
|
69
|
+
key: "Value 2"
|
70
|
+
DATA
|
71
|
+
end
|
72
|
+
|
73
|
+
def ru_data
|
74
|
+
<<~DATA
|
75
|
+
ru_RU:
|
76
|
+
my_key: "Моё значение"
|
77
|
+
nested:
|
78
|
+
key: "Значение 2"
|
79
|
+
DATA
|
80
|
+
end
|
81
|
+
end
|
data/spec/support/rake_utils.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lokalise_rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ilya Bodrov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-10-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ruby-lokalise-api
|
@@ -178,20 +178,6 @@ dependencies:
|
|
178
178
|
- - "~>"
|
179
179
|
- !ruby/object:Gem::Version
|
180
180
|
version: '0.16'
|
181
|
-
- !ruby/object:Gem::Dependency
|
182
|
-
name: sqlite3
|
183
|
-
requirement: !ruby/object:Gem::Requirement
|
184
|
-
requirements:
|
185
|
-
- - "~>"
|
186
|
-
- !ruby/object:Gem::Version
|
187
|
-
version: '1.4'
|
188
|
-
type: :development
|
189
|
-
prerelease: false
|
190
|
-
version_requirements: !ruby/object:Gem::Requirement
|
191
|
-
requirements:
|
192
|
-
- - "~>"
|
193
|
-
- !ruby/object:Gem::Version
|
194
|
-
version: '1.4'
|
195
181
|
- !ruby/object:Gem::Dependency
|
196
182
|
name: vcr
|
197
183
|
requirement: !ruby/object:Gem::Requirement
|
@@ -228,8 +214,10 @@ files:
|
|
228
214
|
- lib/lokalise_rails.rb
|
229
215
|
- lib/lokalise_rails/railtie.rb
|
230
216
|
- lib/lokalise_rails/task_definition/base.rb
|
217
|
+
- lib/lokalise_rails/task_definition/exporter.rb
|
231
218
|
- lib/lokalise_rails/task_definition/importer.rb
|
232
219
|
- lib/lokalise_rails/version.rb
|
220
|
+
- lib/tasks/lokalise_rails_tasks.rake
|
233
221
|
- lokalise_rails.gemspec
|
234
222
|
- spec/dummy/app/controllers/application_controller.rb
|
235
223
|
- spec/dummy/app/helpers/application_helper.rb
|
@@ -247,19 +235,22 @@ files:
|
|
247
235
|
- spec/dummy/config/initializers/cookies_serializer.rb
|
248
236
|
- spec/dummy/config/initializers/filter_parameter_logging.rb
|
249
237
|
- spec/dummy/config/initializers/inflections.rb
|
250
|
-
- spec/dummy/config/initializers/lokalise_rails.rb
|
251
238
|
- spec/dummy/config/initializers/mime_types.rb
|
252
239
|
- spec/dummy/config/initializers/wrap_parameters.rb
|
240
|
+
- spec/dummy/config/lokalise_rails.rb
|
253
241
|
- spec/dummy/config/puma.rb
|
254
242
|
- spec/dummy/config/routes.rb
|
255
243
|
- spec/dummy/db/seeds.rb
|
256
244
|
- spec/lib/generators/lokalise_rails/install_generator_spec.rb
|
245
|
+
- spec/lib/lokalise_rails/exporter_spec.rb
|
257
246
|
- spec/lib/lokalise_rails/importer_spec.rb
|
258
247
|
- spec/lib/lokalise_rails_spec.rb
|
248
|
+
- spec/lib/tasks/export_task_spec.rb
|
259
249
|
- spec/lib/tasks/import_task_spec.rb
|
260
250
|
- spec/spec_helper.rb
|
261
|
-
- spec/support/
|
251
|
+
- spec/support/file_manager.rb
|
262
252
|
- spec/support/rake_utils.rb
|
253
|
+
- spec/support/spec_addons.rb
|
263
254
|
- spec/support/vcr.rb
|
264
255
|
homepage: https://github.com/bodrovis/lokalise_rails
|
265
256
|
licenses:
|
@@ -301,17 +292,20 @@ test_files:
|
|
301
292
|
- spec/dummy/config/initializers/cookies_serializer.rb
|
302
293
|
- spec/dummy/config/initializers/filter_parameter_logging.rb
|
303
294
|
- spec/dummy/config/initializers/inflections.rb
|
304
|
-
- spec/dummy/config/initializers/lokalise_rails.rb
|
305
295
|
- spec/dummy/config/initializers/mime_types.rb
|
306
296
|
- spec/dummy/config/initializers/wrap_parameters.rb
|
297
|
+
- spec/dummy/config/lokalise_rails.rb
|
307
298
|
- spec/dummy/config/puma.rb
|
308
299
|
- spec/dummy/config/routes.rb
|
309
300
|
- spec/dummy/db/seeds.rb
|
310
301
|
- spec/lib/generators/lokalise_rails/install_generator_spec.rb
|
302
|
+
- spec/lib/lokalise_rails/exporter_spec.rb
|
311
303
|
- spec/lib/lokalise_rails/importer_spec.rb
|
312
304
|
- spec/lib/lokalise_rails_spec.rb
|
305
|
+
- spec/lib/tasks/export_task_spec.rb
|
313
306
|
- spec/lib/tasks/import_task_spec.rb
|
314
307
|
- spec/spec_helper.rb
|
315
|
-
- spec/support/
|
308
|
+
- spec/support/file_manager.rb
|
316
309
|
- spec/support/rake_utils.rb
|
310
|
+
- spec/support/spec_addons.rb
|
317
311
|
- spec/support/vcr.rb
|
@@ -1,29 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'lokalise_rails'
|
4
|
-
|
5
|
-
# These are mandatory options that you must set before running rake tasks:
|
6
|
-
LokaliseRails.api_token = ENV['LOKALISE_API_TOKEN']
|
7
|
-
LokaliseRails.project_id = ENV['LOKALISE_PROJECT_ID']
|
8
|
-
|
9
|
-
# Import options have the following defaults:
|
10
|
-
# LokaliseRails.import_opts = {
|
11
|
-
# format: 'yaml',
|
12
|
-
# placeholder_format: :icu,
|
13
|
-
# yaml_include_root: true,
|
14
|
-
# original_filenames: true,
|
15
|
-
# directory_prefix: '',
|
16
|
-
# indentation: '2sp'
|
17
|
-
# }
|
18
|
-
|
19
|
-
# Safe mode is disabled by default:
|
20
|
-
# LokaliseRails.import_safe_mode = false
|
21
|
-
|
22
|
-
# Provide a custom path to the directory with your translation files:
|
23
|
-
# class LokaliseRails
|
24
|
-
# class << self
|
25
|
-
# def locales_path
|
26
|
-
# "#{Rails.root}/config/locales"
|
27
|
-
# end
|
28
|
-
# end
|
29
|
-
# end
|
data/spec/support/file_utils.rb
DELETED
@@ -1,27 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module FileUtils
|
4
|
-
def mkdir_locales
|
5
|
-
FileUtils.mkdir_p(LokaliseRails.locales_path) unless File.directory?(LokaliseRails.locales_path)
|
6
|
-
end
|
7
|
-
|
8
|
-
def rm_translation_files
|
9
|
-
FileUtils.rm_rf locales_dir
|
10
|
-
end
|
11
|
-
|
12
|
-
def locales_dir
|
13
|
-
Dir["#{LokaliseRails.locales_path}/*"]
|
14
|
-
end
|
15
|
-
|
16
|
-
def count_translations
|
17
|
-
locales_dir.count { |file| File.file?(file) }
|
18
|
-
end
|
19
|
-
|
20
|
-
def remove_config
|
21
|
-
FileUtils.remove_file config_file if File.file?(config_file)
|
22
|
-
end
|
23
|
-
|
24
|
-
def config_file
|
25
|
-
"#{Rails.root}/config/initializers/lokalise_rails.rb"
|
26
|
-
end
|
27
|
-
end
|