lokalise_rails 1.0.0 → 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 87524123a10425d69c33950f4b2c16366146f5c1ab14c19dbc7185de61fb726a
4
- data.tar.gz: 39ba0b0a91f443ea162d7804c89906f4523f7c13411fbd541624bafb9197a569
3
+ metadata.gz: b8341e9150b8080050eb672077a415739178279e452ccad5d9f25bc7a24f83be
4
+ data.tar.gz: 4b6a74a12e62625d7bd6a41c8b46a93d029ef315551d4c6883375d9bf765aa72
5
5
  SHA512:
6
- metadata.gz: 4e36f385c123ab80402aaa428973c2c0706b2cbceabade8bcf12689fe0955bdc927a223c27a9114c102d83af6a709b061e1c10d2e189ca832b5b56a0a6b043f8
7
- data.tar.gz: bbbe1857d99cdc7c3595f611d664c555981fbdf5f1d37c30a52cb179d641902f879b1492996dc7c1c1cb6dacdfbd7c2a3ca226f31a687879fddf59b1e8f9fe7a
6
+ metadata.gz: 13f5680ba0f8cfcd279929d7ab577712b1392760ca1d11460f6290d03d1ac9c4fe4915057656e3440cdda5a0958e5b230547549c9f2d4fe431c774fd7fe9ebd2
7
+ data.tar.gz: 4b98524742a8ed099f176351e073526db7e9fdae8e492318ac9f86c5b6ec8a7e650d9726a0b57571856e04a973e7aa9bcd7456aa9a6117e677d5039de33d1580
@@ -1,5 +1,9 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.0.1 (14-Oct-20)
4
+
5
+ * Minor bug fixes and spec updates
6
+
3
7
  ## 1.0.0 (01-Oct-20)
4
8
 
5
9
  * Added export feature
data/README.md CHANGED
@@ -62,6 +62,22 @@ To export translations from your Rails app to the specified Lokalise project, ru
62
62
  rails lokalise_rails:export
63
63
  ```
64
64
 
65
+ ## Running tasks programmatically
66
+
67
+ You can also run the import and export tasks from the Rails app:
68
+
69
+ ```ruby
70
+ require "#{Rails.root}/config/lokalise_rails.rb"
71
+
72
+ # Import the files:
73
+ result = LokaliseRails::TaskDefinition::Importer.import!
74
+ # `result` contains a boolean value with the result of the operation
75
+
76
+ # Export the files:
77
+ processes = LokaliseRails::TaskDefinition::Exporter.export!
78
+ # `processes` contains a list of queued background processes
79
+ ```
80
+
65
81
  ## Configuration
66
82
 
67
83
  Options are specified in the `config/lokalise_rails.rb` file.
@@ -111,6 +127,11 @@ en_US:
111
127
  c.skip_file_export = ->(file) { f.split[1].to_s.include?('fr') }
112
128
  ```
113
129
 
130
+ ## Running tests
131
+
132
+ 1. Copypaste `.env.example` file as `.env`. Put your Lokalise API token and project ID inside. The `.env` file is excluded from version control so your data is safe. All in all, we use pre-recorded VCR cassettes, so the actual API requests won’t be sent. However, providing at least some values is required.
133
+ 2. Run `rspec .`. Observe test results and code coverage.
134
+
114
135
  ## License
115
136
 
116
137
  Copyright (c) [Lokalise team](http://lokalise.com), [Ilya Bodrov](http://bodrovis.tech)
@@ -14,7 +14,7 @@ module LokaliseRails
14
14
 
15
15
  if errors.any?
16
16
  errors.each { |e| $stdout.puts e }
17
- return false
17
+ return errors
18
18
  end
19
19
 
20
20
  queued_processes = []
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module LokaliseRails
4
- VERSION = '1.0.0'
4
+ VERSION = '1.0.1'
5
5
  end
@@ -18,6 +18,8 @@ describe LokaliseRails::TaskDefinition::Exporter do
18
18
 
19
19
  describe '.export!' do
20
20
  it 'sends a proper API request' do
21
+ allow_project_id
22
+
21
23
  process = VCR.use_cassette('upload_files') do
22
24
  described_class.export!
23
25
  end.first
@@ -91,6 +93,8 @@ describe LokaliseRails::TaskDefinition::Exporter do
91
93
 
92
94
  describe '.export!' do
93
95
  it 'rescues from export errors' do
96
+ allow_project_id
97
+
94
98
  processes = VCR.use_cassette('upload_files_error') do
95
99
  described_class.export!
96
100
  end
@@ -22,6 +22,7 @@ describe LokaliseRails::TaskDefinition::Importer do
22
22
  end
23
23
 
24
24
  it 'rescues from errors during file download' do
25
+ allow_project_id
25
26
  allow(LokaliseRails).to receive(:api_token).and_return('incorrect')
26
27
 
27
28
  VCR.use_cassette('download_files_error') do
@@ -34,13 +35,13 @@ describe LokaliseRails::TaskDefinition::Importer do
34
35
  describe '.import!' do
35
36
  it 'halts when the API key is not set' do
36
37
  expect(LokaliseRails).to receive(:api_token).and_return(nil)
37
- expect(-> {described_class.import!}).to output(/API token is not set/).to_stdout
38
+ expect(-> { described_class.import! }).to output(/API token is not set/).to_stdout
38
39
  expect(count_translations).to eq(0)
39
40
  end
40
41
 
41
42
  it 'halts when the project_id is not set' do
42
43
  expect(LokaliseRails).to receive(:project_id).and_return(nil)
43
- expect(-> {described_class.import!}).to output(/Project ID is not set/).to_stdout
44
+ expect(-> { described_class.import! }).to output(/Project ID is not set/).to_stdout
44
45
  expect(count_translations).to eq(0)
45
46
  end
46
47
  end
@@ -30,6 +30,7 @@ require 'rspec/rails'
30
30
  RSpec.configure do |config|
31
31
  config.include FileManager
32
32
  config.include RakeUtils
33
+ config.include SpecAddons
33
34
  end
34
35
 
35
36
  # rubocop:disable Style/MixinUsage
@@ -0,0 +1,6 @@
1
+ module SpecAddons
2
+ def allow_project_id
3
+ allow(LokaliseRails).to receive(:project_id).
4
+ and_return('189934715f57a162257d74.88352370')
5
+ end
6
+ 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: 1.0.0
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-10-01 00:00:00.000000000 Z
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
@@ -250,6 +250,7 @@ files:
250
250
  - spec/spec_helper.rb
251
251
  - spec/support/file_manager.rb
252
252
  - spec/support/rake_utils.rb
253
+ - spec/support/spec_addons.rb
253
254
  - spec/support/vcr.rb
254
255
  homepage: https://github.com/bodrovis/lokalise_rails
255
256
  licenses:
@@ -306,4 +307,5 @@ test_files:
306
307
  - spec/spec_helper.rb
307
308
  - spec/support/file_manager.rb
308
309
  - spec/support/rake_utils.rb
310
+ - spec/support/spec_addons.rb
309
311
  - spec/support/vcr.rb