polyglot_cli 0.1.5 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 986b39f475cd63d9f801d4973287cf232ede2e29
4
- data.tar.gz: 22fbff7667ff6d7d8f2ccbf3fb5793c10f926528
2
+ SHA256:
3
+ metadata.gz: ff5f065d97ab493e63b3bf053b1cd00ef76c7ce61b18d89b7635e86e219f08b2
4
+ data.tar.gz: 9d7e56011431cef1308a4a280fb1f100690a0b972e3b78c4c27def0332e38d25
5
5
  SHA512:
6
- metadata.gz: b264d809b955779fbf69c3fc0a5b9e326749c6b8e545699b2d2b6359ec998809cec568481a5485d6fde6b526bee67d25986bd8c618420f38e637bc3e070274a9
7
- data.tar.gz: ab938488a64bdd00cd43ff5e3b66d691a43c4cb8eb23998b62031e3d3a282116a0263e844cb0b2021c0c2efd7260204aedc3907570dc6cab332665b3c5f7a5f7
6
+ metadata.gz: d950cd0f92427923d409d71feecb1698cb79c46e7b7db56dffc6fc0a84a64d31a49f9e97a0b39e836cdecb4b97ffc40a8e85af2ccecc53ec90292fbe47a42b4c
7
+ data.tar.gz: 3e396a1f14590dd52aaa61736201bf3e69470a17d2844d2847cb55bdeff74a93a53484433eb2ea043becac2fd2696ffa1d57bcef597d347603848d5b1117588d
@@ -1 +1 @@
1
- 2.3.1
1
+ 2.7.1
@@ -53,12 +53,12 @@ module PolyglotCli
53
53
  end
54
54
 
55
55
  def create_translation_key(name)
56
- PolyglotCli::Resource::TranslationKey.token(token).create(name: name, project_id: project_id).id
56
+ PolyglotCli::Resource::TranslationKey.with_subdomain(subdomain).token(token).create(name: name, project_id: project_id).id
57
57
  end
58
58
 
59
59
  def create_translation(value, key_name, key_id, language_id)
60
60
  prompt.ok("Creating translation for key: #{key_name}...")
61
- PolyglotCli::Resource::Translation.token(token).create(
61
+ PolyglotCli::Resource::Translation.with_subdomain(subdomain).token(token).create(
62
62
  value: value,
63
63
  translation_key_id: key_id,
64
64
  language_id: language_id
@@ -78,6 +78,7 @@ module PolyglotCli
78
78
  prompt.say('Getting translation keys...')
79
79
  @translation_keys =
80
80
  PolyglotCli::Resource::TranslationKey
81
+ .with_subdomain(subdomain)
81
82
  .token(token)
82
83
  .depaginate(project_id: project_id)
83
84
  .each_with_object({}) do |translation_key, hash|
@@ -17,6 +17,7 @@ module PolyglotCli
17
17
 
18
18
  def call
19
19
  @config = {
20
+ subdomain: subdomain_prompt,
20
21
  project_id: project_id_prompt,
21
22
  locale_path: locale_path_prompt
22
23
  }
@@ -26,6 +27,12 @@ module PolyglotCli
26
27
  prompt.error('Could not find any projects. Please try a new search.')
27
28
  end
28
29
 
30
+ # override subdomain for the setup,
31
+ # use the cached value (from prompt)
32
+ # instead of reading it from the config file
33
+ # (which does not exist yet during the setup)
34
+ attr_reader :subdomain
35
+
29
36
  private
30
37
 
31
38
  def locale_mapping
@@ -55,8 +62,16 @@ module PolyglotCli
55
62
  prompt.select("Choose a locale for #{language}: ", locales)
56
63
  end
57
64
 
65
+ def subdomain_prompt
66
+ @subdomain = prompt.ask('Enter your subdomain: ', default: 'infinum')
67
+ end
68
+
58
69
  def project_id_prompt
59
- prompt.select('Choose a project: ', filtered_projects)
70
+ if filtered_projects.any?
71
+ prompt.select('Choose a project: ', filtered_projects)
72
+ else
73
+ raise StandardError, "No projects for the subdomain #{subdomain}!"
74
+ end
60
75
  end
61
76
 
62
77
  def locale_path_prompt
@@ -65,13 +80,13 @@ module PolyglotCli
65
80
 
66
81
  def projects
67
82
  prompt.say('Getting projects...')
68
- PolyglotCli::Resource::Project.token(token).depaginate.each_with_object({}) do |r, hash|
83
+ PolyglotCli::Resource::Project.with_subdomain(subdomain).token(token).depaginate.each_with_object({}) do |r, hash|
69
84
  hash[r.name] = r.id
70
85
  end
71
86
  end
72
87
 
73
88
  def filtered_projects
74
- projects.select { |key, _id| key[/^(.*?(#{option_query})[^$]*)$/i] }.sort_by { |p| p[0].downcase }.to_h
89
+ @filtered_projects ||= projects.select { |key, _id| key[/^(.*?(#{option_query})[^$]*)$/i] }.sort_by { |p| p[0].downcase }.to_h
75
90
  end
76
91
 
77
92
  def option_query
@@ -5,6 +5,10 @@ module PolyglotCli
5
5
  @token ||= PolyglotCli::IO::Token.read
6
6
  end
7
7
 
8
+ def subdomain
9
+ config[:subdomain]
10
+ end
11
+
8
12
  def config
9
13
  @config ||= PolyglotCli::IO::Config.read
10
14
  end
@@ -15,7 +19,7 @@ module PolyglotCli
15
19
 
16
20
  def project
17
21
  prompt.say('Getting project...')
18
- PolyglotCli::Resource::Project.token(token).find(project_id).first
22
+ PolyglotCli::Resource::Project.with_subdomain(subdomain).token(token).find(project_id).first
19
23
  end
20
24
 
21
25
  def server_changed?
@@ -27,7 +31,7 @@ module PolyglotCli
27
31
  prompt.say('Getting languages...')
28
32
  select_languages(
29
33
  locale,
30
- PolyglotCli::Resource::Language.token(token).depaginate(project_id: project_id)
34
+ PolyglotCli::Resource::Language.with_subdomain(subdomain).token(token).depaginate(project_id: project_id)
31
35
  )
32
36
  end
33
37
 
@@ -51,7 +55,7 @@ module PolyglotCli
51
55
 
52
56
  def remote_translations(language)
53
57
  prompt.say("Getting #{language.name} translations...")
54
- PolyglotCli::Resource::Translation.token(token).depaginate(project_id: project_id, language_id: language.id)
58
+ PolyglotCli::Resource::Translation.with_subdomain(subdomain).token(token).depaginate(project_id: project_id, language_id: language.id)
55
59
  end
56
60
  end
57
61
  end
@@ -3,12 +3,20 @@ module PolyglotCli
3
3
  class Base < JsonApiClient::Resource
4
4
  extend PolyglotCli::Helper::Depaginate
5
5
 
6
- self.site = if ['development', 'test'].include? ENV['POLYGLOT_CLI_ENV']
7
- 'http://polyglot.infinum.co.dev/api/v2/'
6
+ self.site = case ENV['POLYGLOT_CLI_ENV']
7
+ when 'development', 'test'
8
+ 'http://polyglothq.test/api/v2/'
9
+ when 'staging'
10
+ 'https://staging-polyglothq.com/api/v2/'
8
11
  else
9
- 'https://polyglot.infinum.co/api/v2/'
12
+ 'https://polyglothq.com/api/v2/'
10
13
  end
11
14
 
15
+ def self.with_subdomain(subdomain)
16
+ self.site = site.sub(/http(s)?\:\/\//, "http\\1://#{subdomain}.")
17
+ self
18
+ end
19
+
12
20
  def self.token(token)
13
21
  self.connection_options = { headers: { 'X-Auth-Token' => token } }
14
22
  self
@@ -1,3 +1,3 @@
1
1
  module PolyglotCli
2
- VERSION = '0.1.5'.freeze
2
+ VERSION = '0.2.0'.freeze
3
3
  end
@@ -23,15 +23,15 @@ Gem::Specification.new do |spec|
23
23
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
24
24
  spec.require_paths = ['lib']
25
25
 
26
- spec.add_development_dependency 'bundler', '~> 1.12.5'
27
- spec.add_development_dependency 'rake', '~> 10.0'
26
+ spec.add_development_dependency 'bundler'
27
+ spec.add_development_dependency 'rake'
28
28
  spec.add_development_dependency 'rspec', '~> 3.0'
29
29
  spec.add_development_dependency 'pry-byebug', '~> 3.4'
30
30
  spec.add_development_dependency 'vcr', '~> 3.0'
31
31
  spec.add_development_dependency 'simplecov'
32
32
  spec.add_development_dependency 'codeclimate-test-reporter', '~> 1.0'
33
33
  spec.add_development_dependency 'webmock', '~> 2.3.2'
34
- spec.add_dependency 'json_api_client'
34
+ spec.add_dependency 'json_api_client', '~> 1.4.0' # newer versions have some breaking changes with the pagination; issue: https://github.com/JsonApiClient/json_api_client/issues/365
35
35
  spec.add_dependency 'commander'
36
36
  spec.add_dependency 'tty-prompt'
37
37
  end
metadata CHANGED
@@ -1,43 +1,43 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: polyglot_cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.2.0
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-25 00:00:00.000000000 Z
11
+ date: 2020-07-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 1.12.5
19
+ version: '0'
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: 1.12.5
26
+ version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: '10.0'
33
+ version: '0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - "~>"
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: '10.0'
40
+ version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rspec
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -126,16 +126,16 @@ dependencies:
126
126
  name: json_api_client
127
127
  requirement: !ruby/object:Gem::Requirement
128
128
  requirements:
129
- - - ">="
129
+ - - "~>"
130
130
  - !ruby/object:Gem::Version
131
- version: '0'
131
+ version: 1.4.0
132
132
  type: :runtime
133
133
  prerelease: false
134
134
  version_requirements: !ruby/object:Gem::Requirement
135
135
  requirements:
136
- - - ">="
136
+ - - "~>"
137
137
  - !ruby/object:Gem::Version
138
- version: '0'
138
+ version: 1.4.0
139
139
  - !ruby/object:Gem::Dependency
140
140
  name: commander
141
141
  requirement: !ruby/object:Gem::Requirement
@@ -228,8 +228,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
228
228
  - !ruby/object:Gem::Version
229
229
  version: '0'
230
230
  requirements: []
231
- rubyforge_project:
232
- rubygems_version: 2.6.7
231
+ rubygems_version: 3.1.2
233
232
  signing_key:
234
233
  specification_version: 4
235
234
  summary: A ruby cli for pulling and pushing polyglot translations