lokalise_rails 0.2.0 → 1.3.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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +30 -0
- data/README.md +87 -27
- data/lib/generators/lokalise_rails/install_generator.rb +1 -1
- data/lib/generators/templates/lokalise_rails_config.rb +46 -25
- data/lib/lokalise_rails.rb +69 -19
- data/lib/lokalise_rails/railtie.rb +1 -3
- data/lib/lokalise_rails/task_definition/base.rb +51 -11
- data/lib/lokalise_rails/task_definition/exporter.rb +78 -0
- data/lib/lokalise_rails/task_definition/importer.rb +75 -15
- data/lib/lokalise_rails/version.rb +2 -2
- data/lib/tasks/lokalise_rails_tasks.rake +5 -6
- data/lokalise_rails.gemspec +5 -7
- data/spec/dummy/config/application.rb +2 -2
- data/spec/dummy/config/environments/test.rb +1 -3
- data/spec/dummy/config/lokalise_rails.rb +4 -28
- data/spec/lib/generators/lokalise_rails/install_generator_spec.rb +1 -1
- data/spec/lib/lokalise_rails/task_definition/base_spec.rb +85 -0
- data/spec/lib/lokalise_rails/task_definition/exporter_spec.rb +165 -0
- data/spec/lib/lokalise_rails/task_definition/importer_spec.rb +49 -0
- data/spec/lib/lokalise_rails_spec.rb +62 -7
- data/spec/lib/tasks/export_task_spec.rb +7 -0
- data/spec/lib/tasks/import_task_spec.rb +46 -20
- data/spec/spec_helper.rb +8 -5
- data/spec/support/file_manager.rb +81 -0
- data/spec/support/rake_utils.rb +4 -0
- data/spec/support/spec_addons.rb +11 -0
- metadata +29 -48
- data/spec/lib/lokalise_rails/importer_spec.rb +0 -31
- data/spec/support/file_utils.rb +0 -27
@@ -1,31 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
describe LokaliseRails::TaskDefinition::Importer do
|
4
|
-
describe '.download_files' do
|
5
|
-
it 'returns a proper download URL' do
|
6
|
-
expect(LokaliseRails).to receive(:project_id).and_return('189934715f57a162257d74.88352370')
|
7
|
-
response = VCR.use_cassette('download_files') do
|
8
|
-
described_class.download_files
|
9
|
-
end
|
10
|
-
|
11
|
-
expect(response['project_id']).to eq('189934715f57a162257d74.88352370')
|
12
|
-
expect(response['bundle_url']).to include('s3-eu-west-1.amazonaws.com')
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
describe '.import!' do
|
17
|
-
it 'halts when the API key is not set' do
|
18
|
-
expect(LokaliseRails).to receive(:api_token).and_return(nil)
|
19
|
-
result = described_class.import!
|
20
|
-
expect(result).to include('API token is not set')
|
21
|
-
expect(count_translations).to eq(0)
|
22
|
-
end
|
23
|
-
|
24
|
-
it 'halts when the project_id is not set' do
|
25
|
-
expect(LokaliseRails).to receive(:project_id).and_return(nil)
|
26
|
-
result = described_class.import!
|
27
|
-
expect(result).to include('Project ID is not set')
|
28
|
-
expect(count_translations).to eq(0)
|
29
|
-
end
|
30
|
-
end
|
31
|
-
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/lokalise_rails.rb"
|
26
|
-
end
|
27
|
-
end
|