polyglot_cli 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +34 -5
- data/lib/polyglot_cli/commands/login.rb +9 -6
- data/lib/polyglot_cli/commands/pull.rb +11 -4
- data/lib/polyglot_cli/commands/push.rb +11 -4
- data/lib/polyglot_cli/resources/base.rb +1 -1
- data/lib/polyglot_cli/version.rb +1 -1
- data/lib/polyglot_cli.rb +1 -1
- data/polyglot_cli.gemspec +9 -11
- metadata +63 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 642fd850f33d45c62506232f920482c9ba8975df
|
4
|
+
data.tar.gz: e4d3d1f9bd6dbef49d96919ed1af1f6856b9725e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d7099829ae98fce77983b920a04a21114235b8582a32961c18e6e9a139caef73f1ca8348e6ca29dd30ad67ea467734bb0e8be7265ee97b07054cc8bc85ec40de
|
7
|
+
data.tar.gz: 8b5e040c81b143ce63869727d45f447ea7fb41f00b7ec7f0d3ad7bc22eb7ea042e6eb69b577d132fe322be0fee1e4ca11e57cea5233fc1cd56ef9b6196b3441f
|
data/README.md
CHANGED
@@ -1,8 +1,9 @@
|
|
1
1
|
# PolyglotCli
|
2
2
|
|
3
|
-
|
3
|
+
[![Gem Version](https://badge.fury.io/rb/polyglot_cli.svg)](https://badge.fury.io/rb/polyglot_cli) [![Code Climate](https://codeclimate.com/repos/5875055a2c6a0b7145003aec/badges/37ca549d69fb7b786979/gpa.svg)](https://codeclimate.com/repos/5875055a2c6a0b7145003aec/feed) [![Test Coverage](https://codeclimate.com/repos/5875055a2c6a0b7145003aec/badges/37ca549d69fb7b786979/coverage.svg)](https://codeclimate.com/repos/5875055a2c6a0b7145003aec/coverage) [![Issue Count](https://codeclimate.com/repos/5875055a2c6a0b7145003aec/badges/37ca549d69fb7b786979/issue_count.svg)](https://codeclimate.com/repos/5875055a2c6a0b7145003aec/feed) [![Build Status](https://semaphoreci.com/api/v1/projects/13ad022a-36ce-4b0d-9d3d-48634e2c2591/1126271/shields_badge.svg)](https://semaphoreci.com/infinum/rails-polyglot-cli)
|
4
4
|
|
5
|
-
|
5
|
+
|
6
|
+
Pulls and pushes translations to and from locale files.
|
6
7
|
|
7
8
|
## Installation
|
8
9
|
|
@@ -20,9 +21,38 @@ Or install it yourself as:
|
|
20
21
|
|
21
22
|
$ gem install polyglot_cli
|
22
23
|
|
24
|
+
## Setup
|
25
|
+
All commands have --help with detailed descriptions of options.
|
26
|
+
|
27
|
+
First we need to login to Polyglot:
|
28
|
+
|
29
|
+
polyglot login
|
30
|
+
|
31
|
+
This will prompt you for your email and password. If the the login attempt is successful. The API token will be written to a file in your home directory: `~/.polyglot.auth`
|
32
|
+
|
33
|
+
Next you have to initialize the project and go through a quick setup:
|
34
|
+
|
35
|
+
polyglot init
|
36
|
+
|
37
|
+
This will prompt you to choose from a list of projects, and set your locale directory. The default locale directory is `config/locales` for rails apps.
|
38
|
+
|
23
39
|
## Usage
|
40
|
+
Once you have setup the project you can use any of the following commands:
|
41
|
+
|
42
|
+
### polyglot pull
|
43
|
+
This command will query the Polyglot API and retrieve all translations. If you use the `--locale` option it will only retrieve that locale. If you use `--path` option you will override the default locale path. Both options are optional. Please be careful when pulling, it will overwrite any changes that are not stored on the server.
|
44
|
+
|
45
|
+
polyglot pull [--locale --path]
|
46
|
+
|
47
|
+
### polyglot push
|
48
|
+
This command will read the locale files and push them to the server. It will update and create both translations and translation keys. If your locales aren't up to date with the server, the command will fail. If you use the `--locale` option it will only retrieve that locale. If you use `--path` option you will override the default locale path. Both options are optional.
|
24
49
|
|
25
|
-
|
50
|
+
polyglot push [--locale --path]
|
51
|
+
|
52
|
+
### polyglot status
|
53
|
+
This command simply checks if your version of the locales are up to date with the sever.
|
54
|
+
|
55
|
+
polyglot status
|
26
56
|
|
27
57
|
## Development
|
28
58
|
|
@@ -32,10 +62,9 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
32
62
|
|
33
63
|
## Contributing
|
34
64
|
|
35
|
-
Bug reports and pull requests are welcome on
|
65
|
+
Bug reports and pull requests are welcome on Bitbucket at https://bitbucket.org/infinum_hr/rails-polyglot-cli/.
|
36
66
|
|
37
67
|
|
38
68
|
## License
|
39
69
|
|
40
70
|
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
41
|
-
|
@@ -7,11 +7,6 @@ module PolyglotCli
|
|
7
7
|
new.call
|
8
8
|
end
|
9
9
|
|
10
|
-
def initialize
|
11
|
-
@email = prompt.ask('Email:') { |q| q.validate :email }
|
12
|
-
@password = prompt.mask('Password:')
|
13
|
-
end
|
14
|
-
|
15
10
|
def call
|
16
11
|
PolyglotCli::IO::Token.write(token)
|
17
12
|
success
|
@@ -21,7 +16,15 @@ module PolyglotCli
|
|
21
16
|
|
22
17
|
def token
|
23
18
|
prompt.say('Logging into API...')
|
24
|
-
PolyglotCli::Resource::Session.create(email:
|
19
|
+
PolyglotCli::Resource::Session.create(email: email, password: password).token
|
20
|
+
end
|
21
|
+
|
22
|
+
def email
|
23
|
+
prompt.ask('Email:') { |q| q.validate :email }
|
24
|
+
end
|
25
|
+
|
26
|
+
def password
|
27
|
+
prompt.mask('Password:')
|
25
28
|
end
|
26
29
|
end
|
27
30
|
end
|
@@ -10,12 +10,11 @@ module PolyglotCli
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def initialize(options)
|
13
|
-
@
|
14
|
-
@path = options.path
|
13
|
+
@options = options
|
15
14
|
end
|
16
15
|
|
17
16
|
def call
|
18
|
-
languages(
|
17
|
+
languages(option_locale).each do |language|
|
19
18
|
PolyglotCli::IO::Locale.write(locale_path, translation_hash(language))
|
20
19
|
end
|
21
20
|
update_config
|
@@ -25,7 +24,15 @@ module PolyglotCli
|
|
25
24
|
private
|
26
25
|
|
27
26
|
def locale_path
|
28
|
-
|
27
|
+
option_path || config[:locale_path]
|
28
|
+
end
|
29
|
+
|
30
|
+
def option_locale
|
31
|
+
@options.locale
|
32
|
+
end
|
33
|
+
|
34
|
+
def option_path
|
35
|
+
@options.path
|
29
36
|
end
|
30
37
|
|
31
38
|
def translation_hash(language)
|
@@ -10,15 +10,14 @@ module PolyglotCli
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def initialize(options)
|
13
|
-
@
|
14
|
-
@path = options.path
|
13
|
+
@options = options
|
15
14
|
end
|
16
15
|
|
17
16
|
def call
|
18
17
|
if server_changed?
|
19
18
|
prompt.error('Changes have been made on the server. Please pull before pushing.')
|
20
19
|
else
|
21
|
-
languages(
|
20
|
+
languages(option_locale).each do |language|
|
22
21
|
prompt.say("Processing push for #{language.name}...")
|
23
22
|
process(language)
|
24
23
|
end
|
@@ -95,8 +94,16 @@ module PolyglotCli
|
|
95
94
|
denest(PolyglotCli::IO::Locale.read(locale_path, locale)[locale])
|
96
95
|
end
|
97
96
|
|
97
|
+
def option_locale
|
98
|
+
@options.locale
|
99
|
+
end
|
100
|
+
|
101
|
+
def option_path
|
102
|
+
@options.path
|
103
|
+
end
|
104
|
+
|
98
105
|
def locale_path
|
99
|
-
|
106
|
+
option_path || config[:locale_path]
|
100
107
|
end
|
101
108
|
end
|
102
109
|
end
|
@@ -3,7 +3,7 @@ module PolyglotCli
|
|
3
3
|
class Base < JsonApiClient::Resource
|
4
4
|
extend PolyglotCli::Helper::Depaginate
|
5
5
|
|
6
|
-
self.site = if ENV['POLYGLOT_CLI_ENV'] == 'development'
|
6
|
+
self.site = if ENV['POLYGLOT_CLI_ENV'] == 'development' || ENV['POLYGLOT_CLI_ENV'] == 'test'
|
7
7
|
'http://polyglot.infinum.co.dev/api/v2/'
|
8
8
|
else
|
9
9
|
'https://polyglot.infinum.co/api/v2/'
|
data/lib/polyglot_cli/version.rb
CHANGED
data/lib/polyglot_cli.rb
CHANGED
data/polyglot_cli.gemspec
CHANGED
@@ -10,17 +10,11 @@ Gem::Specification.new do |spec|
|
|
10
10
|
spec.email = ['ivan.grgurevic@infinum.hr']
|
11
11
|
|
12
12
|
spec.summary = 'A ruby cli for pulling and pushing polyglot translations'
|
13
|
-
|
14
|
-
|
13
|
+
spec.description = 'A ruby cli that takes translations from Polyglot and writes them to yml locale files. Also allows pushing of new translations to Polyglot.'
|
14
|
+
spec.homepage = 'https://bitbucket.org/infinum_hr/rails-polyglot-cli/'
|
15
15
|
spec.license = 'MIT'
|
16
16
|
|
17
|
-
|
18
|
-
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
19
|
-
if spec.respond_to?(:metadata)
|
20
|
-
spec.metadata['allowed_push_host'] = 'https://rubygems.org'
|
21
|
-
else
|
22
|
-
raise 'RubyGems 2.0 or newer is required to protect against public gem pushes.'
|
23
|
-
end
|
17
|
+
spec.metadata['allowed_push_host'] = 'https://rubygems.org'
|
24
18
|
|
25
19
|
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
26
20
|
f.match(%r{^(test|spec|features)/})
|
@@ -29,10 +23,14 @@ Gem::Specification.new do |spec|
|
|
29
23
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
30
24
|
spec.require_paths = ['lib']
|
31
25
|
|
32
|
-
spec.add_development_dependency 'bundler', '~> 1.
|
26
|
+
spec.add_development_dependency 'bundler', '~> 1.12.5'
|
33
27
|
spec.add_development_dependency 'rake', '~> 10.0'
|
34
28
|
spec.add_development_dependency 'rspec', '~> 3.0'
|
35
|
-
spec.add_development_dependency 'pry-byebug'
|
29
|
+
spec.add_development_dependency 'pry-byebug', '~> 3.4'
|
30
|
+
spec.add_development_dependency 'vcr', '~> 3.0'
|
31
|
+
spec.add_development_dependency 'simplecov'
|
32
|
+
spec.add_development_dependency 'codeclimate-test-reporter', '~> 1.0'
|
33
|
+
spec.add_development_dependency 'webmock', '~> 2.3.2'
|
36
34
|
spec.add_dependency 'json_api_client'
|
37
35
|
spec.add_dependency 'commander'
|
38
36
|
spec.add_dependency 'tty-prompt'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: polyglot_cli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ivan Grgurevic
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-01-
|
11
|
+
date: 2017-01-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 1.12.5
|
20
20
|
type: :development
|
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:
|
26
|
+
version: 1.12.5
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -54,6 +54,34 @@ dependencies:
|
|
54
54
|
version: '3.0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: pry-byebug
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '3.4'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '3.4'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: vcr
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '3.0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '3.0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: simplecov
|
57
85
|
requirement: !ruby/object:Gem::Requirement
|
58
86
|
requirements:
|
59
87
|
- - ">="
|
@@ -66,6 +94,34 @@ dependencies:
|
|
66
94
|
- - ">="
|
67
95
|
- !ruby/object:Gem::Version
|
68
96
|
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: codeclimate-test-reporter
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '1.0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '1.0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: webmock
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - "~>"
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: 2.3.2
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - "~>"
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: 2.3.2
|
69
125
|
- !ruby/object:Gem::Dependency
|
70
126
|
name: json_api_client
|
71
127
|
requirement: !ruby/object:Gem::Requirement
|
@@ -108,7 +164,8 @@ dependencies:
|
|
108
164
|
- - ">="
|
109
165
|
- !ruby/object:Gem::Version
|
110
166
|
version: '0'
|
111
|
-
description:
|
167
|
+
description: A ruby cli that takes translations from Polyglot and writes them to yml
|
168
|
+
locale files. Also allows pushing of new translations to Polyglot.
|
112
169
|
email:
|
113
170
|
- ivan.grgurevic@infinum.hr
|
114
171
|
executables:
|
@@ -150,7 +207,7 @@ files:
|
|
150
207
|
- lib/polyglot_cli/resources/translation_key.rb
|
151
208
|
- lib/polyglot_cli/version.rb
|
152
209
|
- polyglot_cli.gemspec
|
153
|
-
homepage:
|
210
|
+
homepage: https://bitbucket.org/infinum_hr/rails-polyglot-cli/
|
154
211
|
licenses:
|
155
212
|
- MIT
|
156
213
|
metadata:
|