lokalise_rails 4.0.0 → 5.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (41) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +17 -0
  3. data/Gemfile +3 -3
  4. data/LICENSE +1 -1
  5. data/README.md +3 -3
  6. data/lib/generators/lokalise_rails/install_generator.rb +2 -0
  7. data/lib/generators/templates/lokalise_rails_config.rb +2 -2
  8. data/lib/lokalise_rails/global_config.rb +1 -0
  9. data/lib/lokalise_rails/railtie.rb +1 -0
  10. data/lib/lokalise_rails/utils.rb +3 -0
  11. data/lib/lokalise_rails/version.rb +1 -3
  12. data/lib/lokalise_rails.rb +8 -3
  13. data/lokalise_rails.gemspec +4 -4
  14. metadata +22 -62
  15. data/spec/dummy/app/controllers/application_controller.rb +0 -4
  16. data/spec/dummy/app/helpers/application_helper.rb +0 -4
  17. data/spec/dummy/app/models/application_record.rb +0 -5
  18. data/spec/dummy/config/application.rb +0 -36
  19. data/spec/dummy/config/boot.rb +0 -5
  20. data/spec/dummy/config/environment.rb +0 -7
  21. data/spec/dummy/config/environments/development.rb +0 -56
  22. data/spec/dummy/config/environments/production.rb +0 -100
  23. data/spec/dummy/config/environments/test.rb +0 -38
  24. data/spec/dummy/config/initializers/assets.rb +0 -14
  25. data/spec/dummy/config/initializers/cookies_serializer.rb +0 -7
  26. data/spec/dummy/config/initializers/filter_parameter_logging.rb +0 -6
  27. data/spec/dummy/config/lokalise_rails.rb +0 -5
  28. data/spec/dummy/config/puma.rb +0 -40
  29. data/spec/dummy/config/routes.rb +0 -5
  30. data/spec/dummy/db/seeds.rb +0 -8
  31. data/spec/lib/generators/lokalise_rails/install_generator_spec.rb +0 -19
  32. data/spec/lib/lokalise_rails/global_config_spec.rb +0 -117
  33. data/spec/lib/lokalise_rails/version_spec.rb +0 -7
  34. data/spec/lib/tasks/export_task_spec.rb +0 -51
  35. data/spec/lib/tasks/import_task_spec.rb +0 -56
  36. data/spec/lib/utils_spec.rb +0 -16
  37. data/spec/spec_helper.rb +0 -36
  38. data/spec/support/file_manager.rb +0 -84
  39. data/spec/support/rake_utils.rb +0 -15
  40. data/spec/support/spec_addons.rb +0 -16
  41. data/spec/support/vcr.rb +0 -11
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: eac9b215d2e4002517b8dc09f29841e78cf349178639069e963bd4b0555cce93
4
- data.tar.gz: 00aacebe6b1f54d80b4d3832c16a38e6863c469ba09cee44fffae9e8373772a6
3
+ metadata.gz: 22e008938f4d8c056bd3ab42087a3ea5a996e32e0c5fc1eb5fbcaab978235c42
4
+ data.tar.gz: e2ca1a4c9a6888e357c660ec721c8d6cee37ce51297ed5afb3992b7cbaba6b64
5
5
  SHA512:
6
- metadata.gz: b8647b6b7b1b691a03146fc69934f54fe550a76c547d4add769900095fa409949e982777b210cf977ee8523087f2f2864d5c4d141953d0513c5465b5ec21254b
7
- data.tar.gz: 5e807d85f5cdf3c693d90ae0bbff1c2e0fcedc2ac5cf76d90ae65bb9e9992583cb72c13db29f05b028f9015668b4ace1e20936e3d67b4003337931b03233d2b3
6
+ metadata.gz: 56a4e4b06697bb5b1ddf40f43792e75b2321028665059833c7986d41821717f64cb3ea950b19a05fc9434854c8bfec61e4dd84f895172e0b53ac985265a4ccbd
7
+ data.tar.gz: 82c589564b69dbc2d2e6921e2f6e5164959bbcf08ea2a5dd9822de474fc6d11c27429f957a2d05128e3927b0ecbe9da5bcdc4d4a9de6081a6b5be42dce6841be
data/CHANGELOG.md CHANGED
@@ -1,5 +1,22 @@
1
1
  # Changelog
2
2
 
3
+ ## 5.1.0 (26-Aug-2022)
4
+
5
+ * Fixed an issue with `\n` being improperly imported
6
+ * Changed default `yaml` format to `ruby_yaml`
7
+ * Update dependencies
8
+
9
+ ## 5.0.1 (15-Mar-2022)
10
+
11
+ * Fix issue with Zeitwerk and files loading
12
+
13
+ ## 5.0.0 (11-Mar-2022)
14
+
15
+ * **Breaking change**: require Ruby 2.7+
16
+ * Use Zeitwerk loader
17
+ * Use newer LokaliseManager (v3) and RubyLokaliseApi (v6)
18
+ * Prettify code
19
+
3
20
  ## 4.0.0 (27-Jan-22)
4
21
 
5
22
  * 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]
19
- gem 'vcr', '~> 6.0'
18
+ gem 'tzinfo-data' # , platforms: %i[mingw mswin x64_mingw jruby]
19
+ gem 'vcr', '~> 6.1'
20
20
  end
data/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2020 Lokalise team, Ilya Bodrov
3
+ Copyright (c) 2020 Lokalise team, Ilya Krukowski
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining
6
6
  a copy of this software and associated documentation files (the
data/README.md CHANGED
@@ -131,7 +131,7 @@ LokaliseRails::GlobalConfig.config do |c|
131
131
 
132
132
  # Import options have the following defaults:
133
133
  # c.import_opts = {
134
- # format: 'yaml',
134
+ # format: 'ruby_yaml',
135
135
  # placeholder_format: :icu,
136
136
  # yaml_include_root: true,
137
137
  # original_filenames: true,
@@ -156,7 +156,7 @@ LokaliseRails::GlobalConfig.config do |c|
156
156
  ## c.translations_loader = ->(raw_data) { YAML.safe_load raw_data }
157
157
 
158
158
  ## Convert translations data to a proper format:
159
- ## c.translations_converter = ->(raw_data) { raw_data.to_yaml }
159
+ ## c.translations_converter = ->(raw_data) { YAML.dump(raw_data).gsub(/\\\\n/, '\n') }
160
160
 
161
161
  ## Infer language ISO code for the translation file:
162
162
  ## c.lang_iso_inferer = ->(data) { YAML.safe_load(data)&.keys&.first }
@@ -170,4 +170,4 @@ end
170
170
 
171
171
  ## License
172
172
 
173
- Copyright (c) [Lokalise team](http://lokalise.com), [Ilya Bodrov](http://bodrovis.tech). License type is [MIT](https://github.com/bodrovis/lokalise_rails/blob/master/LICENSE).
173
+ Copyright (c) [Lokalise team](http://lokalise.com), [Ilya Krukowski](http://bodrovis.tech). License type is [MIT](https://github.com/bodrovis/lokalise_rails/blob/master/LICENSE).
@@ -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
 
@@ -22,7 +22,7 @@ LokaliseRails::GlobalConfig.config do |c|
22
22
 
23
23
  # Import options have the following defaults:
24
24
  # c.import_opts = {
25
- # format: 'yaml',
25
+ # format: 'ruby_yaml',
26
26
  # placeholder_format: :icu,
27
27
  # yaml_include_root: true,
28
28
  # original_filenames: true,
@@ -47,7 +47,7 @@ LokaliseRails::GlobalConfig.config do |c|
47
47
  ## c.translations_loader = ->(raw_data) { YAML.safe_load raw_data }
48
48
 
49
49
  ## Convert translations data to a proper format:
50
- ## c.translations_converter = ->(raw_data) { raw_data.to_yaml }
50
+ ## c.translations_converter = ->(raw_data) { YAML.dump(raw_data).gsub(/\\\\n/, '\n') }
51
51
 
52
52
  ## Infer language ISO code for the translation file:
53
53
  ## c.lang_iso_inferer = ->(data) { YAML.safe_load(data)&.keys&.first }
@@ -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)
@@ -1,7 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # :nocov:
4
3
  module LokaliseRails
5
- VERSION = '4.0.0'
4
+ VERSION = '5.1.0'
6
5
  end
7
- # :nocov:
@@ -1,11 +1,16 @@
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.ignore "#{__dir__}/generators/templates/lokalise_rails_config.rb"
9
+ loader.ignore "#{__dir__}/generators/lokalise_rails/install_generator.rb"
10
+ loader.setup
7
11
 
12
+ # Main LokaliseRails module
8
13
  module LokaliseRails
9
14
  end
10
15
 
11
- require 'lokalise_rails/railtie' if defined?(Rails)
16
+ require_relative 'lokalise_rails/railtie' if defined?(Rails)
@@ -5,25 +5,25 @@ 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 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',
19
19
  'lib/**/*.rake',
20
20
  'lokalise_rails.gemspec', '.github/*.md',
21
21
  'Gemfile', 'Rakefile']
22
- spec.test_files = Dir['spec/**/*.rb']
23
22
  spec.extra_rdoc_files = ['README.md']
24
23
  spec.require_paths = ['lib']
25
24
 
26
- spec.add_dependency 'lokalise_manager', '~> 2.0'
25
+ spec.add_dependency 'lokalise_manager', '~> 3.2'
26
+ spec.add_dependency 'zeitwerk', '~> 2.4'
27
27
 
28
28
  spec.metadata = {
29
29
  'rubygems_mfa_required' => 'true'
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.1.0
5
5
  platform: ruby
6
6
  authors:
7
- - Ilya Bodrov
7
+ - Ilya 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-08-26 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.2'
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.2'
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:
@@ -50,33 +64,6 @@ files:
50
64
  - lib/lokalise_rails/version.rb
51
65
  - lib/tasks/lokalise_rails_tasks.rake
52
66
  - lokalise_rails.gemspec
53
- - spec/dummy/app/controllers/application_controller.rb
54
- - spec/dummy/app/helpers/application_helper.rb
55
- - spec/dummy/app/models/application_record.rb
56
- - spec/dummy/config/application.rb
57
- - spec/dummy/config/boot.rb
58
- - spec/dummy/config/environment.rb
59
- - spec/dummy/config/environments/development.rb
60
- - spec/dummy/config/environments/production.rb
61
- - spec/dummy/config/environments/test.rb
62
- - spec/dummy/config/initializers/assets.rb
63
- - spec/dummy/config/initializers/cookies_serializer.rb
64
- - spec/dummy/config/initializers/filter_parameter_logging.rb
65
- - spec/dummy/config/lokalise_rails.rb
66
- - spec/dummy/config/puma.rb
67
- - spec/dummy/config/routes.rb
68
- - spec/dummy/db/seeds.rb
69
- - spec/lib/generators/lokalise_rails/install_generator_spec.rb
70
- - spec/lib/lokalise_rails/global_config_spec.rb
71
- - spec/lib/lokalise_rails/version_spec.rb
72
- - spec/lib/tasks/export_task_spec.rb
73
- - spec/lib/tasks/import_task_spec.rb
74
- - spec/lib/utils_spec.rb
75
- - spec/spec_helper.rb
76
- - spec/support/file_manager.rb
77
- - spec/support/rake_utils.rb
78
- - spec/support/spec_addons.rb
79
- - spec/support/vcr.rb
80
67
  homepage: https://github.com/bodrovis/lokalise_rails
81
68
  licenses:
82
69
  - MIT
@@ -90,42 +77,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
90
77
  requirements:
91
78
  - - ">="
92
79
  - !ruby/object:Gem::Version
93
- version: 2.5.0
80
+ version: 2.7.0
94
81
  required_rubygems_version: !ruby/object:Gem::Requirement
95
82
  requirements:
96
83
  - - ">="
97
84
  - !ruby/object:Gem::Version
98
85
  version: '0'
99
86
  requirements: []
100
- rubygems_version: 3.3.5
87
+ rubygems_version: 3.3.21
101
88
  signing_key:
102
89
  specification_version: 4
103
90
  summary: Lokalise integration for Ruby on Rails
104
- test_files:
105
- - spec/dummy/app/controllers/application_controller.rb
106
- - spec/dummy/app/helpers/application_helper.rb
107
- - spec/dummy/app/models/application_record.rb
108
- - spec/dummy/config/application.rb
109
- - spec/dummy/config/boot.rb
110
- - spec/dummy/config/environment.rb
111
- - spec/dummy/config/environments/development.rb
112
- - spec/dummy/config/environments/production.rb
113
- - spec/dummy/config/environments/test.rb
114
- - spec/dummy/config/initializers/assets.rb
115
- - spec/dummy/config/initializers/cookies_serializer.rb
116
- - spec/dummy/config/initializers/filter_parameter_logging.rb
117
- - spec/dummy/config/lokalise_rails.rb
118
- - spec/dummy/config/puma.rb
119
- - spec/dummy/config/routes.rb
120
- - spec/dummy/db/seeds.rb
121
- - spec/lib/generators/lokalise_rails/install_generator_spec.rb
122
- - spec/lib/lokalise_rails/global_config_spec.rb
123
- - spec/lib/lokalise_rails/version_spec.rb
124
- - spec/lib/tasks/export_task_spec.rb
125
- - spec/lib/tasks/import_task_spec.rb
126
- - spec/lib/utils_spec.rb
127
- - spec/spec_helper.rb
128
- - spec/support/file_manager.rb
129
- - spec/support/rake_utils.rb
130
- - spec/support/spec_addons.rb
131
- - spec/support/vcr.rb
91
+ test_files: []
@@ -1,4 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- class ApplicationController < ActionController::Base
4
- end
@@ -1,4 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module ApplicationHelper
4
- end
@@ -1,5 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- class ApplicationRecord < ActiveRecord::Base
4
- self.abstract_class = true
5
- end
@@ -1,36 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative 'boot'
4
-
5
- require 'rails'
6
- # Pick the frameworks you want:
7
- # require 'active_model/railtie'
8
- # require "active_job/railtie"
9
- # require 'active_record/railtie'
10
- # require "active_storage/engine"
11
- require 'action_controller/railtie'
12
- # require "action_mailer/railtie"
13
- # require "action_mailbox/engine"
14
- # require "action_text/engine"
15
- require 'action_view/railtie'
16
- # require "action_cable/engine"
17
- require 'sprockets/railtie'
18
- # require "rails/test_unit/railtie"
19
-
20
- # Require the gems listed in Gemfile, including any gems
21
- # you've limited to :test, :development, or :production.
22
- Bundler.require(*Rails.groups)
23
-
24
- require 'dotenv/load'
25
-
26
- module Dummy
27
- class Application < Rails::Application
28
- # Settings in config/environments/* take precedence over those specified here.
29
- # Application configuration can go into files in config/initializers
30
- # -- all .rb files in that directory are automatically loaded after loading
31
- # the framework and any gems in your application.
32
-
33
- # Don't generate system test files.
34
- config.generators.system_tests = nil
35
- end
36
- end
@@ -1,5 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../../Gemfile', __dir__)
4
- require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])
5
- $LOAD_PATH.unshift File.expand_path('../../../lib', __dir__)
@@ -1,7 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # Load the Rails application.
4
- require_relative 'application'
5
-
6
- # Initialize the Rails application.
7
- Rails.application.initialize!
@@ -1,56 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- Rails.application.configure do
4
- # Settings specified here will take precedence over those in config/application.rb.
5
-
6
- # In the development environment your application's code is reloaded on
7
- # every request. This slows down response time but is perfect for development
8
- # since you don't have to restart the web server when you make code changes.
9
- config.cache_classes = false
10
-
11
- # Do not eager load code on boot.
12
- config.eager_load = false
13
-
14
- # Show full error reports.
15
- config.consider_all_requests_local = true
16
-
17
- # Enable/disable caching. By default caching is disabled.
18
- # Run rails dev:cache to toggle caching.
19
- if Rails.root.join('tmp', 'caching-dev.txt').exist?
20
- config.action_controller.perform_caching = true
21
- config.action_controller.enable_fragment_cache_logging = true
22
-
23
- config.cache_store = :memory_store
24
- config.public_file_server.headers = {
25
- 'Cache-Control' => "public, max-age=#{2.days.to_i}"
26
- }
27
- else
28
- config.action_controller.perform_caching = false
29
-
30
- config.cache_store = :null_store
31
- end
32
-
33
- # Print deprecation notices to the Rails logger.
34
- config.active_support.deprecation = :log
35
-
36
- # Raise an error on page load if there are pending migrations.
37
- config.active_record.migration_error = :page_load
38
-
39
- # Highlight code that triggered database queries in logs.
40
- config.active_record.verbose_query_logs = true
41
-
42
- # Debug mode disables concatenation and preprocessing of assets.
43
- # This option may cause significant delays in view rendering with a large
44
- # number of complex assets.
45
- config.assets.debug = true
46
-
47
- # Suppress logger output for asset requests.
48
- config.assets.quiet = true
49
-
50
- # Raises error for missing translations.
51
- # config.action_view.raise_on_missing_translations = true
52
-
53
- # Use an evented file watcher to asynchronously detect changes in source code,
54
- # routes, locales, etc. This feature depends on the listen gem.
55
- # config.file_watcher = ActiveSupport::EventedFileUpdateChecker
56
- end
@@ -1,100 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- Rails.application.configure do
4
- # Settings specified here will take precedence over those in config/application.rb.
5
-
6
- # Code is not reloaded between requests.
7
- config.cache_classes = true
8
-
9
- # Eager load code on boot. This eager loads most of Rails and
10
- # your application in memory, allowing both threaded web servers
11
- # and those relying on copy on write to perform better.
12
- # Rake tasks automatically ignore this option for performance.
13
- config.eager_load = true
14
-
15
- # Full error reports are disabled and caching is turned on.
16
- config.consider_all_requests_local = false
17
- config.action_controller.perform_caching = true
18
-
19
- # Ensures that a master key has been made available in either ENV["RAILS_MASTER_KEY"]
20
- # or in config/master.key. This key is used to decrypt credentials (and other encrypted files).
21
- # config.require_master_key = true
22
-
23
- # Disable serving static files from the `/public` folder by default since
24
- # Apache or NGINX already handles this.
25
- config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present?
26
-
27
- # Compress CSS using a preprocessor.
28
- # config.assets.css_compressor = :sass
29
-
30
- # Do not fallback to assets pipeline if a precompiled asset is missed.
31
- config.assets.compile = false
32
-
33
- # Enable serving of images, stylesheets, and JavaScripts from an asset server.
34
- # config.action_controller.asset_host = 'http://assets.example.com'
35
-
36
- # Specifies the header that your server uses for sending files.
37
- # config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache
38
- # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX
39
-
40
- # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
41
- # config.force_ssl = true
42
-
43
- # Use the lowest log level to ensure availability of diagnostic information
44
- # when problems arise.
45
- config.log_level = :debug
46
-
47
- # Prepend all log lines with the following tags.
48
- config.log_tags = [:request_id]
49
-
50
- # Use a different cache store in production.
51
- # config.cache_store = :mem_cache_store
52
-
53
- # Use a real queuing backend for Active Job (and separate queues per environment).
54
- # config.active_job.queue_adapter = :resque
55
- # config.active_job.queue_name_prefix = "dummy_production"
56
-
57
- # Enable locale fallbacks for I18n (makes lookups for any locale fall back to
58
- # the I18n.default_locale when a translation cannot be found).
59
- config.i18n.fallbacks = true
60
-
61
- # Send deprecation notices to registered listeners.
62
- config.active_support.deprecation = :notify
63
-
64
- # Use default logging formatter so that PID and timestamp are not suppressed.
65
- config.log_formatter = ::Logger::Formatter.new
66
-
67
- # Use a different logger for distributed setups.
68
- # require 'syslog/logger'
69
- # config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name')
70
-
71
- if ENV['RAILS_LOG_TO_STDOUT'].present?
72
- logger = ActiveSupport::Logger.new($stdout)
73
- logger.formatter = config.log_formatter
74
- config.logger = ActiveSupport::TaggedLogging.new(logger)
75
- end
76
-
77
- # Do not dump schema after migrations.
78
- config.active_record.dump_schema_after_migration = false
79
-
80
- # Inserts middleware to perform automatic connection switching.
81
- # The `database_selector` hash is used to pass options to the DatabaseSelector
82
- # middleware. The `delay` is used to determine how long to wait after a write
83
- # to send a subsequent read to the primary.
84
- #
85
- # The `database_resolver` class is used by the middleware to determine which
86
- # database is appropriate to use based on the time delay.
87
- #
88
- # The `database_resolver_context` class is used by the middleware to set
89
- # timestamps for the last write to the primary. The resolver uses the context
90
- # class timestamps to determine how long to wait before reading from the
91
- # replica.
92
- #
93
- # By default Rails will store a last write timestamp in the session. The
94
- # DatabaseSelector middleware is designed as such you can define your own
95
- # strategy for connection switching and pass that into the middleware through
96
- # these configuration options.
97
- # config.active_record.database_selector = { delay: 2.seconds }
98
- # config.active_record.database_resolver = ActiveRecord::Middleware::DatabaseSelector::Resolver
99
- # config.active_record.database_resolver_context = ActiveRecord::Middleware::DatabaseSelector::Resolver::Session
100
- end
@@ -1,38 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # The test environment is used exclusively to run your application's
4
- # test suite. You never need to work with it otherwise. Remember that
5
- # your test database is "scratch space" for the test suite and is wiped
6
- # and recreated between test runs. Don't rely on the data there!
7
-
8
- Rails.application.configure do
9
- # Settings specified here will take precedence over those in config/application.rb.
10
-
11
- config.cache_classes = true
12
-
13
- # Do not eager load code on boot. This avoids loading your whole application
14
- # just for the purpose of running a single test. If you are using a tool that
15
- # preloads Rails for running tests, you may have to set it to true.
16
- config.eager_load = false
17
-
18
- # Configure public file server for tests with Cache-Control for performance.
19
- config.public_file_server.enabled = true
20
- config.public_file_server.headers = {'Cache-Control' => 'public, max-age=3600'}
21
-
22
- # Show full error reports and disable caching.
23
- config.consider_all_requests_local = true
24
- config.action_controller.perform_caching = false
25
- config.cache_store = :null_store
26
-
27
- # Raise exceptions instead of rendering exception templates.
28
- config.action_dispatch.show_exceptions = false
29
-
30
- # Disable request forgery protection in test environment.
31
- config.action_controller.allow_forgery_protection = false
32
-
33
- # Print deprecation notices to the stderr.
34
- config.active_support.deprecation = :stderr
35
-
36
- # Raises error for missing translations.
37
- # config.action_view.raise_on_missing_translations = true
38
- end
@@ -1,14 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # Be sure to restart your server when you modify this file.
4
-
5
- # Version of your assets, change this if you want to expire all your assets.
6
- Rails.application.config.assets.version = '1.0'
7
-
8
- # Add additional assets to the asset load path.
9
- # Rails.application.config.assets.paths << Emoji.images_path
10
-
11
- # Precompile additional assets.
12
- # application.js, application.css, and all non-JS/CSS in the app/assets
13
- # folder are already added.
14
- # Rails.application.config.assets.precompile += %w( admin.js admin.css )
@@ -1,7 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # Be sure to restart your server when you modify this file.
4
-
5
- # Specify a serializer for the signed and encrypted cookie jars.
6
- # Valid options are :json, :marshal, and :hybrid.
7
- Rails.application.config.action_dispatch.cookies_serializer = :json
@@ -1,6 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # Be sure to restart your server when you modify this file.
4
-
5
- # Configure sensitive parameters which will be filtered from the log file.
6
- Rails.application.config.filter_parameters += [:password]
@@ -1,5 +0,0 @@
1
- LokaliseRails::GlobalConfig.config do |c|
2
- c.api_token = ENV['LOKALISE_API_TOKEN']
3
- c.project_id = ENV['LOKALISE_PROJECT_ID']
4
-
5
- end
@@ -1,40 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # Puma can serve each request in a thread from an internal thread pool.
4
- # The `threads` method setting takes two numbers: a minimum and maximum.
5
- # Any libraries that use thread pools should be configured to match
6
- # the maximum value specified for Puma. Default is set to 5 threads for minimum
7
- # and maximum; this matches the default thread size of Active Record.
8
- #
9
- max_threads_count = ENV.fetch('RAILS_MAX_THREADS', 5)
10
- min_threads_count = ENV.fetch('RAILS_MIN_THREADS') { max_threads_count }
11
- threads min_threads_count, max_threads_count
12
-
13
- # Specifies the `port` that Puma will listen on to receive requests; default is 3000.
14
- #
15
- port ENV.fetch('PORT', 3000)
16
-
17
- # Specifies the `environment` that Puma will run in.
18
- #
19
- environment ENV.fetch('RAILS_ENV', 'development')
20
-
21
- # Specifies the `pidfile` that Puma will use.
22
- pidfile ENV.fetch('PIDFILE', 'tmp/pids/server.pid')
23
-
24
- # Specifies the number of `workers` to boot in clustered mode.
25
- # Workers are forked web server processes. If using threads and workers together
26
- # the concurrency of the application would be max `threads` * `workers`.
27
- # Workers do not work on JRuby or Windows (both of which do not support
28
- # processes).
29
- #
30
- # workers ENV.fetch("WEB_CONCURRENCY") { 2 }
31
-
32
- # Use the `preload_app!` method when specifying a `workers` number.
33
- # This directive tells Puma to first boot the application and load code
34
- # before forking the application. This takes advantage of Copy On Write
35
- # process behavior so workers use less memory.
36
- #
37
- # preload_app!
38
-
39
- # Allow puma to be restarted by `rails restart` command.
40
- plugin :tmp_restart
@@ -1,5 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- Rails.application.routes.draw do
4
- # For details on the DSL available within this file, see https://guides.rubyonrails.org/routing.html
5
- end
@@ -1,8 +0,0 @@
1
- # frozen_string_literal: true
2
- # This file should contain all the record creation needed to seed the database with its default values.
3
- # The data can then be loaded with the rails db:seed command (or created alongside the database with db:setup).
4
- #
5
- # Examples:
6
- #
7
- # movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the Rings' }])
8
- # Character.create(name: 'Luke', movie: movies.first)
@@ -1,19 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'generators/lokalise_rails/install_generator'
4
-
5
- describe LokaliseRails::Generators::InstallGenerator do
6
- before :all do
7
- remove_config
8
- end
9
-
10
- after :all do
11
- remove_config
12
- add_config!
13
- end
14
-
15
- it 'installs config file properly' do
16
- described_class.start
17
- expect(File.file?(config_file)).to be true
18
- end
19
- end
@@ -1,117 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- describe LokaliseRails::GlobalConfig do
4
- let(:child_config) { Class.new(described_class) }
5
-
6
- it 'is possible to provide config options' do
7
- described_class.config do |c|
8
- expect(c).to eq(described_class)
9
- end
10
- end
11
-
12
- it 'can be redefined' do
13
- child_config.config do |c|
14
- c.api_token = ENV['LOKALISE_API_TOKEN']
15
- c.project_id = ENV['LOKALISE_PROJECT_ID']
16
-
17
- c.branch = 'develop'
18
- end
19
-
20
- expect(child_config.branch).to eq('develop')
21
- importer = LokaliseManager::TaskDefinitions::Importer.new({}, child_config)
22
- expect(importer.config.branch).to eq('develop')
23
- expect(importer.config.api_token).to eq(ENV['LOKALISE_API_TOKEN'])
24
- end
25
-
26
- describe 'parameters' do
27
- let(:fake_class) { class_double(described_class) }
28
-
29
- it 'is possible to set project_id' do
30
- allow(fake_class).to receive(:project_id=).with('123.abc')
31
- fake_class.project_id = '123.abc'
32
- end
33
-
34
- it 'is possible to set file_ext_regexp' do
35
- allow(fake_class).to receive(:file_ext_regexp=).with(Regexp.new('.*'))
36
- fake_class.file_ext_regexp = Regexp.new('.*')
37
- end
38
-
39
- it 'is possible to set import_opts' do
40
- allow(fake_class).to receive(:import_opts=).with(duck_type(:each))
41
- fake_class.import_opts = {
42
- format: 'json',
43
- indentation: '8sp'
44
- }
45
- end
46
-
47
- it 'is possible to set export_opts' do
48
- allow(fake_class).to receive(:export_opts=).with(duck_type(:each))
49
- fake_class.export_opts = {
50
- convert_placeholders: true,
51
- detect_icu_plurals: true
52
- }
53
- end
54
-
55
- it 'is possible to set branch' do
56
- allow(fake_class).to receive(:branch=).with('custom')
57
- fake_class.branch = 'custom'
58
- end
59
-
60
- it 'is possible to set timeouts' do
61
- allow(fake_class).to receive(:timeouts=).with(duck_type(:each))
62
- fake_class.timeouts = {
63
- open_timeout: 100,
64
- timeout: 500
65
- }
66
- end
67
-
68
- it 'is possible to set import_safe_mode' do
69
- allow(fake_class).to receive(:import_safe_mode=).with(true)
70
- fake_class.import_safe_mode = true
71
- end
72
-
73
- it 'is possible to set max_retries_export' do
74
- allow(fake_class).to receive(:max_retries_export=).with(10)
75
- fake_class.max_retries_export = 10
76
- end
77
-
78
- it 'is possible to set max_retries_import' do
79
- allow(fake_class).to receive(:max_retries_import=).with(10)
80
- fake_class.max_retries_import = 10
81
- end
82
-
83
- it 'is possible to set api_token' do
84
- allow(fake_class).to receive(:api_token=).with('abc')
85
- fake_class.api_token = 'abc'
86
- end
87
-
88
- it 'is possible to override locales_path' do
89
- allow(fake_class).to receive(:locales_path=).with('/demo/path')
90
- fake_class.locales_path = '/demo/path'
91
- end
92
-
93
- it 'is possible to set skip_file_export' do
94
- cond = ->(f) { f.nil? }
95
- allow(fake_class).to receive(:skip_file_export=).with(cond)
96
- fake_class.skip_file_export = cond
97
- end
98
-
99
- it 'is possible to set translations_loader' do
100
- runner = ->(f) { f.to_json }
101
- allow(fake_class).to receive(:translations_loader=).with(runner)
102
- fake_class.translations_loader = runner
103
- end
104
-
105
- it 'is possible to set translations_converter' do
106
- runner = ->(f) { f.to_json }
107
- allow(fake_class).to receive(:translations_converter=).with(runner)
108
- fake_class.translations_converter = runner
109
- end
110
-
111
- it 'is possible to set lang_iso_inferer' do
112
- runner = ->(f) { f.to_json }
113
- allow(fake_class).to receive(:lang_iso_inferer=).with(runner)
114
- fake_class.lang_iso_inferer = runner
115
- end
116
- end
117
- end
@@ -1,7 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- describe LokaliseRails do
4
- it 'returns a proper version' do
5
- expect(LokaliseRails::VERSION).to be_a(String)
6
- end
7
- end
@@ -1,51 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- RSpec.describe 'Export Rake task' do
4
- let(:global_config) { LokaliseRails::GlobalConfig }
5
-
6
- it 'halts when the API key is not set' do
7
- allow(global_config).to receive(:api_token).and_return(nil)
8
-
9
- expect(export_executor).to raise_error(SystemExit, /API token is not set/i)
10
- expect(global_config).to have_received(:api_token)
11
- end
12
-
13
- it 'halts when the project ID is not set' do
14
- allow(global_config).to receive(:project_id).and_return(nil)
15
-
16
- expect(export_executor).to raise_error(SystemExit, /ID is not set/i)
17
-
18
- expect(global_config).to have_received(:project_id)
19
- end
20
-
21
- context 'with two translation files' do
22
- let(:filename_ru) { 'ru.yml' }
23
- let(:path_ru) { "#{Rails.root}/config/locales/#{filename_ru}" }
24
-
25
- before :all do
26
- add_translation_files! with_ru: true
27
- end
28
-
29
- after :all do
30
- rm_translation_files
31
- end
32
-
33
- describe 'export' do
34
- it 'is callable' do
35
- allow_project_id global_config, ENV['LOKALISE_PROJECT_ID'] do
36
- VCR.use_cassette('upload_files') do
37
- expect(export_executor).to output(/complete!/).to_stdout
38
- end
39
- end
40
- end
41
-
42
- it 're-raises export errors' do
43
- allow_project_id global_config, '542886116159f798720dc4.94769464' do
44
- VCR.use_cassette('upload_files_error') do
45
- expect(export_executor).to raise_error(SystemExit, /Unknown `lang_iso`/)
46
- end
47
- end
48
- end
49
- end
50
- end
51
- end
@@ -1,56 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- RSpec.describe 'Import Rake task' do
4
- let(:global_config) { LokaliseRails::GlobalConfig }
5
- let(:loc_path) { global_config.locales_path }
6
-
7
- it 'halts when the API key is not set' do
8
- allow(global_config).to receive(:api_token).and_return(nil)
9
-
10
- expect(import_executor).to raise_error(SystemExit, /API token is not set/i)
11
- expect(global_config).to have_received(:api_token)
12
- end
13
-
14
- it 'halts when the project ID is not set' do
15
- allow(global_config).to receive(:project_id).and_return(nil)
16
-
17
- expect(import_executor).to raise_error(SystemExit, /ID is not set/i)
18
-
19
- expect(global_config).to have_received(:project_id)
20
- end
21
-
22
- context 'when directory is empty' do
23
- before do
24
- mkdir_locales
25
- rm_translation_files
26
- end
27
-
28
- after :all do
29
- rm_translation_files
30
- end
31
-
32
- describe 'import' do
33
- it 'is callable' do
34
- allow_project_id global_config, ENV['LOKALISE_PROJECT_ID'] do
35
- VCR.use_cassette('download_files') do
36
- expect(import_executor).to output(/complete!/).to_stdout
37
- end
38
-
39
- expect(count_translations).to eq(4)
40
-
41
- expect_file_exist loc_path, 'en.yml'
42
- expect_file_exist loc_path, 'ru.yml'
43
- expect_file_exist loc_path, 'yo.yml'
44
- end
45
- end
46
-
47
- it 're-raises export errors' do
48
- allow_project_id global_config, 'fake' do
49
- VCR.use_cassette('download_files_error') do
50
- expect(import_executor).to raise_error(SystemExit, /Invalid `project_id` parameter/)
51
- end
52
- end
53
- end
54
- end
55
- end
56
- end
@@ -1,16 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- describe LokaliseRails::Utils do
4
- describe '.rails_root' do
5
- it 'returns RAILS_ROOT if defined' do
6
- allow(::Rails).to receive(:root).and_return(nil)
7
- stub_const('RAILS_ROOT', '/stub')
8
- expect(described_class.rails_root).to eq('/stub')
9
- end
10
-
11
- it 'fallbacks if neither roots are present' do
12
- allow(::Rails).to receive(:root).and_return(nil)
13
- expect(described_class.rails_root).to be_nil
14
- end
15
- end
16
- end
data/spec/spec_helper.rb DELETED
@@ -1,36 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'dotenv/load'
4
- require 'simplecov'
5
-
6
- SimpleCov.start 'rails' do
7
- add_filter 'spec/'
8
- add_filter '.github/'
9
- add_filter 'lib/generators/templates/'
10
- end
11
-
12
- if ENV['CI'] == 'true'
13
- require 'codecov'
14
- SimpleCov.formatter = SimpleCov::Formatter::Codecov
15
- end
16
-
17
- # Support files
18
- Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].sort.each { |f| require f }
19
-
20
- # Configure Rails Environment
21
- ENV['RAILS_ENV'] = 'test'
22
- require_relative '../spec/dummy/config/environment'
23
- ENV['RAILS_ROOT'] ||= "#{File.dirname(__FILE__)}../../../spec/dummy"
24
-
25
- RSpec.configure do |config|
26
- config.include FileManager
27
- config.include RakeUtils
28
- config.include SpecAddons
29
- end
30
-
31
- # rubocop:disable Style/MixinUsage
32
- include FileManager
33
- # rubocop:enable Style/MixinUsage
34
-
35
- add_config!
36
- Rails.application.load_tasks
@@ -1,84 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'fileutils'
4
-
5
- module FileManager
6
- def mkdir_locales
7
- FileUtils.mkdir_p(LokaliseRails::GlobalConfig.locales_path) unless File.directory?(LokaliseRails::GlobalConfig.locales_path)
8
- end
9
-
10
- def rm_translation_files
11
- FileUtils.rm_rf locales_dir
12
- end
13
-
14
- def locales_dir
15
- Dir["#{LokaliseRails::GlobalConfig.locales_path}/**/*"]
16
- end
17
-
18
- def count_translations
19
- locales_dir.count { |file| File.file?(file) }
20
- end
21
-
22
- def add_translation_files!(with_ru: false, additional: nil)
23
- FileUtils.mkdir_p "#{Rails.root}/config/locales/nested"
24
- open_and_write('config/locales/nested/en.yml') { |f| f.write en_data }
25
-
26
- return unless with_ru
27
-
28
- open_and_write('config/locales/ru.yml') { |f| f.write ru_data }
29
-
30
- return unless additional
31
-
32
- additional.times do |i|
33
- data = {'en' => {"key_#{i}" => "value #{i}"}}
34
-
35
- open_and_write("config/locales/en_#{i}.yml") { |f| f.write data.to_yaml }
36
- end
37
- end
38
-
39
- def add_config!(custom_text = '')
40
- data = <<~DATA
41
- LokaliseRails::GlobalConfig.config do |c|
42
- c.api_token = ENV['LOKALISE_API_TOKEN']
43
- c.project_id = ENV['LOKALISE_PROJECT_ID']
44
- DATA
45
-
46
- data += custom_text
47
- data += "\nend"
48
- open_and_write('config/lokalise_rails.rb') { |f| f.write data }
49
- end
50
-
51
- def open_and_write(rel_path, &block)
52
- return unless block
53
-
54
- File.open("#{Rails.root}/#{rel_path}", 'w+:UTF-8', &block)
55
- end
56
-
57
- def remove_config
58
- FileUtils.remove_file config_file if File.file?(config_file)
59
- end
60
-
61
- def config_file
62
- "#{Rails.root}/config/lokalise_rails.rb"
63
- end
64
-
65
- private
66
-
67
- def en_data
68
- <<~DATA
69
- en:
70
- my_key: "My value"
71
- nested:
72
- key: "Value 2"
73
- DATA
74
- end
75
-
76
- def ru_data
77
- <<~DATA
78
- ru_RU:
79
- my_key: "Моё значение"
80
- nested:
81
- key: "Значение 2"
82
- DATA
83
- end
84
- end
@@ -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
@@ -1,16 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module SpecAddons
4
- def expect_file_exist(path, file)
5
- file_path = File.join path, file
6
- expect(File.file?(file_path)).to be true
7
- end
8
-
9
- def allow_project_id(obj, value)
10
- allow(obj).to receive(:project_id).and_return(value)
11
- return unless block_given?
12
-
13
- yield
14
- expect(obj).to have_received(:project_id)
15
- end
16
- end
data/spec/support/vcr.rb DELETED
@@ -1,11 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'vcr'
4
-
5
- VCR.configure do |c|
6
- c.ignore_hosts 'codeclimate.com'
7
- c.hook_into :faraday
8
- c.cassette_library_dir = File.join(File.dirname(__FILE__), '..', 'fixtures', 'vcr_cassettes')
9
- c.filter_sensitive_data('<LOKALISE_TOKEN>') { ENV.fetch('LOKALISE_API_TOKEN') }
10
- c.configure_rspec_metadata!
11
- end