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 +4 -4
 - data/CHANGELOG.md +4 -0
 - data/README.md +21 -0
 - data/lib/lokalise_rails/task_definition/exporter.rb +1 -1
 - data/lib/lokalise_rails/version.rb +1 -1
 - data/spec/lib/lokalise_rails/exporter_spec.rb +4 -0
 - data/spec/lib/lokalise_rails/importer_spec.rb +3 -2
 - data/spec/spec_helper.rb +1 -0
 - data/spec/support/spec_addons.rb +6 -0
 - metadata +4 -2
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA256:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: b8341e9150b8080050eb672077a415739178279e452ccad5d9f25bc7a24f83be
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 4b6a74a12e62625d7bd6a41c8b46a93d029ef315551d4c6883375d9bf765aa72
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: 13f5680ba0f8cfcd279929d7ab577712b1392760ca1d11460f6290d03d1ac9c4fe4915057656e3440cdda5a0958e5b230547549c9f2d4fe431c774fd7fe9ebd2
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 4b98524742a8ed099f176351e073526db7e9fdae8e492318ac9f86c5b6ec8a7e650d9726a0b57571856e04a973e7aa9bcd7456aa9a6117e677d5039de33d1580
         
     | 
    
        data/CHANGELOG.md
    CHANGED
    
    
    
        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)
         
     | 
| 
         @@ -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
         
     | 
    
        data/spec/spec_helper.rb
    CHANGED
    
    
    
        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. 
     | 
| 
      
 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- 
     | 
| 
      
 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
         
     |