lokalise_rails 4.0.0 → 5.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: eac9b215d2e4002517b8dc09f29841e78cf349178639069e963bd4b0555cce93
4
- data.tar.gz: 00aacebe6b1f54d80b4d3832c16a38e6863c469ba09cee44fffae9e8373772a6
3
+ metadata.gz: e0766634c77c771d4a7750da1a98c0d6c3a8f7f0ecf06ae071c4c4becc34c288
4
+ data.tar.gz: cdb4a114a582b30465e82fad8eefb5d89be6bbae8943f83255a9fd3c683c6b3c
5
5
  SHA512:
6
- metadata.gz: b8647b6b7b1b691a03146fc69934f54fe550a76c547d4add769900095fa409949e982777b210cf977ee8523087f2f2864d5c4d141953d0513c5465b5ec21254b
7
- data.tar.gz: 5e807d85f5cdf3c693d90ae0bbff1c2e0fcedc2ac5cf76d90ae65bb9e9992583cb72c13db29f05b028f9015668b4ace1e20936e3d67b4003337931b03233d2b3
6
+ metadata.gz: 11cc6c1dabc982278a58bc89e71c883501029badf2af8a627595e46cef2c4ed541734d872e00fa0c83bcaa7fce5b9e344ab06f1564c79a4bae78a740bd307347
7
+ data.tar.gz: 88c8ef5767a31660dd317cc828b088874cd5075eeea4afa7c9f58b1eebaa1e7a8a1917392e89e3da679558faca8346061e1aaad0e981e004f5f5497a41472e8b
data/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # Changelog
2
2
 
3
+ ## 5.0.0 (11-Mar-2022)
4
+
5
+ * **Breaking change**: require Ruby 2.7+
6
+ * Use Zeitwerk loader
7
+ * Use newer LokaliseManager (v3) and RubyLokaliseApi (v6)
8
+ * Prettify code
9
+
3
10
  ## 4.0.0 (27-Jan-22)
4
11
 
5
12
  * File exporting is now multi-threaded as Lokalise API started to support parallel requests since January 2022
data/Gemfile CHANGED
@@ -7,7 +7,7 @@ gemspec
7
7
  group :test do
8
8
  gem 'codecov', '~> 0.2'
9
9
  gem 'dotenv', '~> 2.5'
10
- gem 'rails', '~> 7.0.0'
10
+ gem 'rails', '~> 7.0'
11
11
  gem 'rake', '~> 13.0'
12
12
  gem 'rspec', '~> 3.6'
13
13
  gem 'rubocop', '~> 1.0'
@@ -15,6 +15,6 @@ group :test do
15
15
  gem 'rubocop-rspec', '~> 2.6'
16
16
  gem 'simplecov', '~> 0.16'
17
17
  gem 'sprockets-rails', '~> 3'
18
- gem 'tzinfo-data', platforms: %i[mingw mswin x64_mingw jruby]
18
+ gem 'tzinfo-data' # , platforms: %i[mingw mswin x64_mingw jruby]
19
19
  gem 'vcr', '~> 6.0'
20
20
  end
@@ -3,7 +3,9 @@
3
3
  require 'rails/generators'
4
4
 
5
5
  module LokaliseRails
6
+ # Generators for LokaliseRails
6
7
  module Generators
8
+ # Installs LokaliseRails config
7
9
  class InstallGenerator < Rails::Generators::Base
8
10
  source_root File.expand_path('../templates', __dir__)
9
11
 
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module LokaliseRails
4
+ # Global configuration, based on LokaliseManager config
4
5
  class GlobalConfig < LokaliseManager::GlobalConfig
5
6
  class << self
6
7
  def locales_path
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module LokaliseRails
4
+ # Load Rake tasks
4
5
  class Railtie < Rails::Railtie
5
6
  rake_tasks do
6
7
  load 'tasks/lokalise_rails_tasks.rake'
@@ -3,12 +3,15 @@
3
3
  require 'pathname'
4
4
 
5
5
  module LokaliseRails
6
+ # Util methods
6
7
  module Utils
7
8
  class << self
9
+ # Current project root
8
10
  def root
9
11
  Pathname.new(rails_root || Dir.getwd)
10
12
  end
11
13
 
14
+ # Tries to get Rails root if Rails is defined
12
15
  def rails_root
13
16
  return ::Rails.root.to_s if defined?(::Rails.root) && ::Rails.root
14
17
  return RAILS_ROOT.to_s if defined?(RAILS_ROOT)
@@ -2,6 +2,6 @@
2
2
 
3
3
  # :nocov:
4
4
  module LokaliseRails
5
- VERSION = '4.0.0'
5
+ VERSION = '5.0.0'
6
6
  end
7
7
  # :nocov:
@@ -1,11 +1,14 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'zeitwerk'
3
4
  require 'lokalise_manager'
4
5
 
5
- require 'lokalise_rails/utils'
6
- require 'lokalise_rails/global_config'
6
+ loader = Zeitwerk::Loader.for_gem
7
+ loader.ignore "#{__dir__}/lokalise_rails/railtie.rb"
8
+ loader.setup
7
9
 
10
+ # Main LokaliseRails module
8
11
  module LokaliseRails
9
12
  end
10
13
 
11
- require 'lokalise_rails/railtie' if defined?(Rails)
14
+ require_relative 'lokalise_rails/railtie' if defined?(Rails)
@@ -5,14 +5,14 @@ require File.expand_path('lib/lokalise_rails/version', __dir__)
5
5
  Gem::Specification.new do |spec|
6
6
  spec.name = 'lokalise_rails'
7
7
  spec.version = LokaliseRails::VERSION
8
- spec.authors = ['Ilya Bodrov']
8
+ spec.authors = ['Ilya Bodrov-Krukowski']
9
9
  spec.email = ['golosizpru@gmail.com']
10
10
  spec.summary = 'Lokalise integration for Ruby on Rails'
11
11
  spec.description = 'This gem allows to exchange translation files between your Rails app and Lokalise TMS.'
12
12
  spec.homepage = 'https://github.com/bodrovis/lokalise_rails'
13
13
  spec.license = 'MIT'
14
14
  spec.platform = Gem::Platform::RUBY
15
- spec.required_ruby_version = '>= 2.5.0'
15
+ spec.required_ruby_version = '>= 2.7.0'
16
16
 
17
17
  spec.files = Dir['README.md', 'LICENSE',
18
18
  'CHANGELOG.md', 'lib/**/*.rb',
@@ -23,7 +23,8 @@ Gem::Specification.new do |spec|
23
23
  spec.extra_rdoc_files = ['README.md']
24
24
  spec.require_paths = ['lib']
25
25
 
26
- spec.add_dependency 'lokalise_manager', '~> 2.0'
26
+ spec.add_dependency 'lokalise_manager', '~> 3.0'
27
+ spec.add_dependency 'zeitwerk', '~> 2.4'
27
28
 
28
29
  spec.metadata = {
29
30
  'rubygems_mfa_required' => 'true'
@@ -3,11 +3,11 @@
3
3
  require 'generators/lokalise_rails/install_generator'
4
4
 
5
5
  describe LokaliseRails::Generators::InstallGenerator do
6
- before :all do
6
+ before do
7
7
  remove_config
8
8
  end
9
9
 
10
- after :all do
10
+ after do
11
11
  remove_config
12
12
  add_config!
13
13
  end
@@ -6,14 +6,14 @@ RSpec.describe 'Export Rake task' do
6
6
  it 'halts when the API key is not set' do
7
7
  allow(global_config).to receive(:api_token).and_return(nil)
8
8
 
9
- expect(export_executor).to raise_error(SystemExit, /API token is not set/i)
9
+ expect { Rake::Task['lokalise_rails:export'].execute }.to raise_error(SystemExit, /API token is not set/i)
10
10
  expect(global_config).to have_received(:api_token)
11
11
  end
12
12
 
13
13
  it 'halts when the project ID is not set' do
14
14
  allow(global_config).to receive(:project_id).and_return(nil)
15
15
 
16
- expect(export_executor).to raise_error(SystemExit, /ID is not set/i)
16
+ expect { Rake::Task['lokalise_rails:export'].execute }.to raise_error(SystemExit, /ID is not set/i)
17
17
 
18
18
  expect(global_config).to have_received(:project_id)
19
19
  end
@@ -22,11 +22,11 @@ RSpec.describe 'Export Rake task' do
22
22
  let(:filename_ru) { 'ru.yml' }
23
23
  let(:path_ru) { "#{Rails.root}/config/locales/#{filename_ru}" }
24
24
 
25
- before :all do
25
+ before do
26
26
  add_translation_files! with_ru: true
27
27
  end
28
28
 
29
- after :all do
29
+ after do
30
30
  rm_translation_files
31
31
  end
32
32
 
@@ -34,7 +34,7 @@ RSpec.describe 'Export Rake task' do
34
34
  it 'is callable' do
35
35
  allow_project_id global_config, ENV['LOKALISE_PROJECT_ID'] do
36
36
  VCR.use_cassette('upload_files') do
37
- expect(export_executor).to output(/complete!/).to_stdout
37
+ expect { Rake::Task['lokalise_rails:export'].execute }.to output(/complete!/).to_stdout
38
38
  end
39
39
  end
40
40
  end
@@ -42,7 +42,7 @@ RSpec.describe 'Export Rake task' do
42
42
  it 're-raises export errors' do
43
43
  allow_project_id global_config, '542886116159f798720dc4.94769464' do
44
44
  VCR.use_cassette('upload_files_error') do
45
- expect(export_executor).to raise_error(SystemExit, /Unknown `lang_iso`/)
45
+ expect { Rake::Task['lokalise_rails:export'].execute }.to raise_error(SystemExit, /Unknown `lang_iso`/)
46
46
  end
47
47
  end
48
48
  end
@@ -7,14 +7,14 @@ RSpec.describe 'Import Rake task' do
7
7
  it 'halts when the API key is not set' do
8
8
  allow(global_config).to receive(:api_token).and_return(nil)
9
9
 
10
- expect(import_executor).to raise_error(SystemExit, /API token is not set/i)
10
+ expect { Rake::Task['lokalise_rails:import'].execute }.to raise_error(SystemExit, /API token is not set/i)
11
11
  expect(global_config).to have_received(:api_token)
12
12
  end
13
13
 
14
14
  it 'halts when the project ID is not set' do
15
15
  allow(global_config).to receive(:project_id).and_return(nil)
16
16
 
17
- expect(import_executor).to raise_error(SystemExit, /ID is not set/i)
17
+ expect { Rake::Task['lokalise_rails:import'].execute }.to raise_error(SystemExit, /ID is not set/i)
18
18
 
19
19
  expect(global_config).to have_received(:project_id)
20
20
  end
@@ -25,7 +25,7 @@ RSpec.describe 'Import Rake task' do
25
25
  rm_translation_files
26
26
  end
27
27
 
28
- after :all do
28
+ after do
29
29
  rm_translation_files
30
30
  end
31
31
 
@@ -33,7 +33,7 @@ RSpec.describe 'Import Rake task' do
33
33
  it 'is callable' do
34
34
  allow_project_id global_config, ENV['LOKALISE_PROJECT_ID'] do
35
35
  VCR.use_cassette('download_files') do
36
- expect(import_executor).to output(/complete!/).to_stdout
36
+ expect { Rake::Task['lokalise_rails:import'].execute }.to output(/complete!/).to_stdout
37
37
  end
38
38
 
39
39
  expect(count_translations).to eq(4)
@@ -47,7 +47,9 @@ RSpec.describe 'Import Rake task' do
47
47
  it 're-raises export errors' do
48
48
  allow_project_id global_config, 'fake' do
49
49
  VCR.use_cassette('download_files_error') do
50
- expect(import_executor).to raise_error(SystemExit, /Invalid `project_id` parameter/)
50
+ expect do
51
+ Rake::Task['lokalise_rails:import'].execute
52
+ end.to raise_error(SystemExit, /Invalid `project_id` parameter/)
51
53
  end
52
54
  end
53
55
  end
data/spec/spec_helper.rb CHANGED
@@ -24,7 +24,6 @@ ENV['RAILS_ROOT'] ||= "#{File.dirname(__FILE__)}../../../spec/dummy"
24
24
 
25
25
  RSpec.configure do |config|
26
26
  config.include FileManager
27
- config.include RakeUtils
28
27
  config.include SpecAddons
29
28
  end
30
29
 
@@ -4,7 +4,9 @@ require 'fileutils'
4
4
 
5
5
  module FileManager
6
6
  def mkdir_locales
7
- FileUtils.mkdir_p(LokaliseRails::GlobalConfig.locales_path) unless File.directory?(LokaliseRails::GlobalConfig.locales_path)
7
+ return if File.directory?(LokaliseRails::GlobalConfig.locales_path)
8
+
9
+ FileUtils.mkdir_p(LokaliseRails::GlobalConfig.locales_path)
8
10
  end
9
11
 
10
12
  def rm_translation_files
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.0.0
4
+ version: 5.0.0
5
5
  platform: ruby
6
6
  authors:
7
- - Ilya Bodrov
7
+ - Ilya Bodrov-Krukowski
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-01-27 00:00:00.000000000 Z
11
+ date: 2022-03-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: lokalise_manager
@@ -16,14 +16,28 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '2.0'
19
+ version: '3.0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '2.0'
26
+ version: '3.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: zeitwerk
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '2.4'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '2.4'
27
41
  description: This gem allows to exchange translation files between your Rails app
28
42
  and Lokalise TMS.
29
43
  email:
@@ -74,7 +88,6 @@ files:
74
88
  - spec/lib/utils_spec.rb
75
89
  - spec/spec_helper.rb
76
90
  - spec/support/file_manager.rb
77
- - spec/support/rake_utils.rb
78
91
  - spec/support/spec_addons.rb
79
92
  - spec/support/vcr.rb
80
93
  homepage: https://github.com/bodrovis/lokalise_rails
@@ -90,14 +103,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
90
103
  requirements:
91
104
  - - ">="
92
105
  - !ruby/object:Gem::Version
93
- version: 2.5.0
106
+ version: 2.7.0
94
107
  required_rubygems_version: !ruby/object:Gem::Requirement
95
108
  requirements:
96
109
  - - ">="
97
110
  - !ruby/object:Gem::Version
98
111
  version: '0'
99
112
  requirements: []
100
- rubygems_version: 3.3.5
113
+ rubygems_version: 3.3.8
101
114
  signing_key:
102
115
  specification_version: 4
103
116
  summary: Lokalise integration for Ruby on Rails
@@ -126,6 +139,5 @@ test_files:
126
139
  - spec/lib/utils_spec.rb
127
140
  - spec/spec_helper.rb
128
141
  - spec/support/file_manager.rb
129
- - spec/support/rake_utils.rb
130
142
  - spec/support/spec_addons.rb
131
143
  - spec/support/vcr.rb
@@ -1,15 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module RakeUtils
4
- def import_executor
5
- -> { Rake::Task['lokalise_rails:import'].execute }
6
- end
7
-
8
- def export_executor
9
- -> { Rake::Task['lokalise_rails:export'].execute }
10
- end
11
-
12
- def install_invoker
13
- Rails::Generators.invoke 'lokalise_rails:install'
14
- end
15
- end