polyglot_cli 0.1.1 → 0.1.2

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
  SHA1:
3
- metadata.gz: 642fd850f33d45c62506232f920482c9ba8975df
4
- data.tar.gz: e4d3d1f9bd6dbef49d96919ed1af1f6856b9725e
3
+ metadata.gz: 1471f76c19416f17a16dcd6a5d04fe2ce4c2047d
4
+ data.tar.gz: 5281b395f0dca136b8de0351448127c5fcb633ff
5
5
  SHA512:
6
- metadata.gz: d7099829ae98fce77983b920a04a21114235b8582a32961c18e6e9a139caef73f1ca8348e6ca29dd30ad67ea467734bb0e8be7265ee97b07054cc8bc85ec40de
7
- data.tar.gz: 8b5e040c81b143ce63869727d45f447ea7fb41f00b7ec7f0d3ad7bc22eb7ea042e6eb69b577d132fe322be0fee1e4ca11e57cea5233fc1cd56ef9b6196b3441f
6
+ metadata.gz: f571558a0d97f003db71b9d08708fdcf73b48bf0911352b5e4bf86554a14cd5a9f99b5fefe6635fd1cfd73700b8cdc05ec6bb023ebd5dbd379636bf8686849cd
7
+ data.tar.gz: 6025b508ec34d427554505b43e39c74974ed5375da2ec4287744b04002f7909e73ee628d07be50ca9f9220f076345413995bd52c462e880ed80a8177727d80ea
data/.codeclimate.yml ADDED
@@ -0,0 +1,11 @@
1
+ engines:
2
+ duplication:
3
+ enabled: true
4
+ config:
5
+ languages:
6
+ - ruby
7
+ rubocop:
8
+ enabled: true
9
+ exclude_fingerprints:
10
+ - efcd727fd15e4fa8dcf0687d8f3864be
11
+ - e471e431276c59b9824dcfb84aff4ca3
data/Rakefile CHANGED
@@ -1,6 +1,6 @@
1
- require "bundler/gem_tasks"
2
- require "rspec/core/rake_task"
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
3
 
4
4
  RSpec::Core::RakeTask.new(:spec)
5
5
 
6
- task :default => :spec
6
+ task default: :spec
data/bin/console CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- require "bundler/setup"
4
- require "polyglot_cli"
3
+ require 'bundler/setup'
4
+ require 'polyglot_cli'
5
5
 
6
6
  # You can add fixtures and/or initialization code here to make experimenting
7
7
  # with your gem easier. You can also use a different console, if you like.
@@ -10,5 +10,5 @@ require "polyglot_cli"
10
10
  # require "pry"
11
11
  # Pry.start
12
12
 
13
- require "irb"
13
+ require 'irb'
14
14
  IRB.start
data/exe/polyglot CHANGED
@@ -33,7 +33,7 @@ command :pull do |c|
33
33
  c.description = 'Pulls all translations from Polyglot and stores them in ./config/locales'
34
34
  c.option '--locale STRING', String, 'Only pulls the specified locale'
35
35
  c.option '--path STRING', String, 'Writes the translations to the specified location'
36
- c.action do |args, options|
36
+ c.action do |_args, options|
37
37
  PolyglotCli::ErrorHandler.rescuable do
38
38
  PolyglotCli::Command::Pull.init(options)
39
39
  end
@@ -45,7 +45,7 @@ command :push do |c|
45
45
  c.description = 'Writes all translations to Polyglot API'
46
46
  c.option '--locale STRING', String, 'Only pushes the specified locale'
47
47
  c.option '--path STRING', String, 'Reads the translations from the specified location'
48
- c.action do |args, options|
48
+ c.action do |_args, options|
49
49
  PolyglotCli::ErrorHandler.rescuable do
50
50
  PolyglotCli::Command::Push.init(options)
51
51
  end
@@ -38,17 +38,12 @@ module PolyglotCli
38
38
  def translation_hash(language)
39
39
  hash = { language.locale => {} }
40
40
 
41
- translations(language).each do |t|
41
+ remote_translations(language).each do |t|
42
42
  hash[language.locale].deep_merge!(nest(t.translation_key.name, t.value))
43
43
  end
44
44
 
45
45
  hash
46
46
  end
47
-
48
- def translations(language)
49
- prompt.say("Getting #{language.name} translations...")
50
- PolyglotCli::Resource::Translation.token(token).depaginate(project_id: project_id, language_id: language.id)
51
- end
52
47
  end
53
48
  end
54
49
  end
@@ -46,7 +46,7 @@ module PolyglotCli
46
46
 
47
47
  if key_id.nil?
48
48
  prompt.ok("Creating translation key \"#{key}\"...")
49
- key_id = PolyglotCli::Resource::TranslationKey.token(token).create(name: key, project_id: project_id).id
49
+ key_id = create_translation_key(key)
50
50
  end
51
51
 
52
52
  create_translation(value, key_id, language_id)
@@ -85,11 +85,6 @@ module PolyglotCli
85
85
  end
86
86
  end
87
87
 
88
- def remote_translations(language)
89
- prompt.say("Getting #{language.name} translations...")
90
- PolyglotCli::Resource::Translation.token(token).depaginate(project_id: project_id, language_id: language.id)
91
- end
92
-
93
88
  def local_translations(locale)
94
89
  denest(PolyglotCli::IO::Locale.read(locale_path, locale)[locale])
95
90
  end
@@ -20,7 +20,7 @@ module PolyglotCli
20
20
 
21
21
  def server_changed?
22
22
  return true if config[:project_updated_at].nil?
23
- Time.parse(project.updated_at) > Time.parse(config[:project_updated_at])
23
+ Time.parse(project.updated_at).utc > Time.parse(config[:project_updated_at]).utc
24
24
  end
25
25
 
26
26
  def languages(locale)
@@ -34,6 +34,11 @@ module PolyglotCli
34
34
  config[:project_updated_at] = project.updated_at
35
35
  PolyglotCli::IO::Config.write(config)
36
36
  end
37
+
38
+ def remote_translations(language)
39
+ prompt.say("Getting #{language.name} translations...")
40
+ PolyglotCli::Resource::Translation.token(token).depaginate(project_id: project_id, language_id: language.id)
41
+ end
37
42
  end
38
43
  end
39
44
  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' || ENV['POLYGLOT_CLI_ENV'] == 'test'
6
+ self.site = if ['development', 'test'].include? ENV['POLYGLOT_CLI_ENV']
7
7
  'http://polyglot.infinum.co.dev/api/v2/'
8
8
  else
9
9
  'https://polyglot.infinum.co/api/v2/'
@@ -1,3 +1,3 @@
1
1
  module PolyglotCli
2
- VERSION = '0.1.1'.freeze
2
+ VERSION = '0.1.2'.freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: polyglot_cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ivan Grgurevic
@@ -173,6 +173,7 @@ executables:
173
173
  extensions: []
174
174
  extra_rdoc_files: []
175
175
  files:
176
+ - ".codeclimate.yml"
176
177
  - ".gitignore"
177
178
  - ".rspec"
178
179
  - ".rubocop.yml"