lokalise_rails 0.0.2.1 → 1.0.0

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.
@@ -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,19 @@ 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 FileUtils
31
+ config.include FileManager
31
32
  config.include RakeUtils
32
33
  end
33
34
 
35
+ # rubocop:disable Style/MixinUsage
36
+ include FileManager
37
+ # rubocop:enable Style/MixinUsage
38
+
39
+ add_config!
34
40
  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
@@ -5,6 +5,10 @@ module RakeUtils
5
5
  -> { Rake::Task['lokalise_rails:import'].execute }
6
6
  end
7
7
 
8
+ def export_executor
9
+ -> { Rake::Task['lokalise_rails:export'].execute }
10
+ end
11
+
8
12
  def install_invoker
9
13
  Rails::Generators.invoke 'lokalise_rails:install'
10
14
  end
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: 0.0.2.1
4
+ version: 1.0.0
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-09-26 00:00:00.000000000 Z
11
+ date: 2020-10-01 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,18 +235,20 @@ 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/file_utils.rb
251
+ - spec/support/file_manager.rb
262
252
  - spec/support/rake_utils.rb
263
253
  - spec/support/vcr.rb
264
254
  homepage: https://github.com/bodrovis/lokalise_rails
@@ -301,17 +291,19 @@ test_files:
301
291
  - spec/dummy/config/initializers/cookies_serializer.rb
302
292
  - spec/dummy/config/initializers/filter_parameter_logging.rb
303
293
  - spec/dummy/config/initializers/inflections.rb
304
- - spec/dummy/config/initializers/lokalise_rails.rb
305
294
  - spec/dummy/config/initializers/mime_types.rb
306
295
  - spec/dummy/config/initializers/wrap_parameters.rb
296
+ - spec/dummy/config/lokalise_rails.rb
307
297
  - spec/dummy/config/puma.rb
308
298
  - spec/dummy/config/routes.rb
309
299
  - spec/dummy/db/seeds.rb
310
300
  - spec/lib/generators/lokalise_rails/install_generator_spec.rb
301
+ - spec/lib/lokalise_rails/exporter_spec.rb
311
302
  - spec/lib/lokalise_rails/importer_spec.rb
312
303
  - spec/lib/lokalise_rails_spec.rb
304
+ - spec/lib/tasks/export_task_spec.rb
313
305
  - spec/lib/tasks/import_task_spec.rb
314
306
  - spec/spec_helper.rb
315
- - spec/support/file_utils.rb
307
+ - spec/support/file_manager.rb
316
308
  - spec/support/rake_utils.rb
317
309
  - 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
@@ -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