phrase 0.4.15 → 0.4.16

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- MmNlOGM1Yzc0NmYwYTM0M2ZmMmUyMjUzN2Q3MmMzMWIwNmRlYTg2ZQ==
4
+ OTQyMmI5YjJkMDUxNGJhNDc0MDBjNDQ2ODc5OGUzOTQxYTJjYzliMw==
5
5
  data.tar.gz: !binary |-
6
- OTE5ZDBmMGE4YWZkYWZiMjc4YzIwNDc0YTFlYjg5Y2I0NzZiNjQ1YQ==
6
+ OWVlZDk4MDc4OGJhZWJmOWE1MTU5Y2M3OWNjNmMzOTQzYjI3ZTIzOA==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- Yzc5ZWJmMDhkOWNjNmIwYWFkNmY2YjdkNDk2YjBlN2EzOTg3MjNkMmIzMDgx
10
- ODRhMmZiZjQyMjJmYjNhNDgxZGQwNjFlMzIzMzE1ZDJhZDY3MTFjMThmMmQ0
11
- NmUzMjJlODRjN2E2NTMwZjg0ZTgyOTUxMDNhNTRkZDY0OTQwN2Q=
9
+ NThlZWM4YmFiNGI1NTBjMjdhMjYxZTAzM2FhZWI2OTI4OGY4N2IxYjM2MDdk
10
+ N2Y5ZGE0ZGJlOTNiOTcyMDgzMjllODE2MjM5OGUzMTc1ZTFjNzI0MDY2YTRh
11
+ OWY4ZTEwNDBlNjA4NDkwOTNkZTc0Y2IzYWVmODkzNjQ0YTkzZDU=
12
12
  data.tar.gz: !binary |-
13
- NzA5NzkyMDU2YTJkYzMyYTcwYmYwOGIzYTE4ZTNmZTJlM2RiOGYzYmY5Mjcz
14
- YzZlODI3ZjY0ZTFkYjliNjY5ZWZkOWNmNDIzMmUxYjUyNjc1YTdmNmE1YThj
15
- ZWIwMmM4YmY4NjgzZDA3ZTY2MDY4YWFkNGE4OTFhMDMyNjljN2Y=
13
+ ZTkzNzFiMGYxNjExMjI4OWJjMDY1MTQ4Y2JmNDMzMWZiOGY4ZWYxY2Y5ZDIy
14
+ OTZiMTEwMDI5YmU4M2JmZTllZWMyZjk1MzliYzBkMmI2ZWUxNmU5Nzk4YjU2
15
+ Zjk0MzY4YWQ1ZTdlMzUxN2I3ZTlkMmJhZDRjNDQ2ZDQ3NTY3Yzc=
@@ -59,12 +59,7 @@ module Phrase
59
59
  end
60
60
 
61
61
  def self.config
62
- @config ||= get_config
63
- end
64
-
65
- def self.get_config
66
- config = Phrase::Tool::Config.new
67
- config.load
62
+ Phrase::Tool.config
68
63
  end
69
64
  private_class_method :config
70
65
  end
@@ -95,12 +90,7 @@ module Phrase
95
90
  }
96
91
 
97
92
  def self.config
98
- @config ||= get_config
99
- end
100
-
101
- def self.get_config
102
- config = Phrase::Tool::Config.new
103
- config.load
93
+ Phrase::Tool.config
104
94
  end
105
95
 
106
96
  def self.custom_handler
data/lib/phrase/tool.rb CHANGED
@@ -39,4 +39,8 @@ class Phrase::Tool
39
39
  end
40
40
  command.execute!
41
41
  end
42
+
43
+ def self.config
44
+ @@config_instance ||= Phrase::Tool::Config.new.load
45
+ end
42
46
  end
@@ -5,6 +5,7 @@ module Phrase::Tool::Commands
5
5
  def initialize(options, args=[])
6
6
  @options = options
7
7
  @args = args
8
+ config.overwrite!('secret', options.get('secret')) if options.set?('secret')
8
9
  end
9
10
 
10
11
  def execute!
@@ -46,12 +47,7 @@ module Phrase::Tool::Commands
46
47
  end
47
48
 
48
49
  def config
49
- @config ||= get_config
50
- end
51
-
52
- def get_config
53
- config = Phrase::Tool::Config.new
54
- config.load
50
+ Phrase::Tool.config
55
51
  end
56
52
 
57
53
  def options
@@ -4,6 +4,7 @@ require 'json'
4
4
 
5
5
  class Phrase::Tool::Config
6
6
  def load
7
+ @config = {}
7
8
  if File.exist?(".phrase")
8
9
  begin
9
10
  contents = File.read(".phrase")
@@ -15,8 +16,23 @@ class Phrase::Tool::Config
15
16
  self
16
17
  end
17
18
 
19
+ def reset!
20
+ @config = {}
21
+ @overwrites = {}
22
+ end
23
+
24
+ def overwrite!(var, value)
25
+ @overwrites ||= {}
26
+ @overwrites[var.to_s] = value
27
+ end
28
+
29
+ def overwrite_for(var)
30
+ @overwrites ||= {}
31
+ @overwrites[var.to_s]
32
+ end
33
+
18
34
  def secret
19
- config["secret"]
35
+ get_setting("secret")
20
36
  end
21
37
 
22
38
  def secret=(new_secret)
@@ -25,7 +41,7 @@ class Phrase::Tool::Config
25
41
  end
26
42
 
27
43
  def default_locale
28
- config["default_locale"]
44
+ get_setting("default_locale")
29
45
  end
30
46
 
31
47
  def default_locale=(new_default_locale)
@@ -34,7 +50,7 @@ class Phrase::Tool::Config
34
50
  end
35
51
 
36
52
  def domain
37
- config["domain"] || 'phrase'
53
+ get_setting("domain") || 'phrase'
38
54
  end
39
55
 
40
56
  def domain=(new_domain)
@@ -43,7 +59,7 @@ class Phrase::Tool::Config
43
59
  end
44
60
 
45
61
  def format
46
- config["format"]
62
+ get_setting("format")
47
63
  end
48
64
 
49
65
  def format=(new_domain)
@@ -52,7 +68,7 @@ class Phrase::Tool::Config
52
68
  end
53
69
 
54
70
  def target_directory
55
- config["target_directory"]
71
+ get_setting("target_directory")
56
72
  end
57
73
 
58
74
  def target_directory=(new_domain)
@@ -61,7 +77,7 @@ class Phrase::Tool::Config
61
77
  end
62
78
 
63
79
  def locale_directory
64
- config["locale_directory"]
80
+ get_setting("locale_directory")
65
81
  end
66
82
 
67
83
  def locale_directory=(new_domain)
@@ -70,7 +86,7 @@ class Phrase::Tool::Config
70
86
  end
71
87
 
72
88
  def locale_filename
73
- config["locale_filename"]
89
+ get_setting("locale_filename")
74
90
  end
75
91
 
76
92
  def locale_filename=(new_domain)
@@ -83,6 +99,10 @@ private
83
99
  @config ||= {}
84
100
  end
85
101
 
102
+ def get_setting(var)
103
+ overwrite_for(var) || config[var]
104
+ end
105
+
86
106
  def save_config!
87
107
  File.open(".phrase", "w+") do |file|
88
108
  file.write(JSON.pretty_generate(config))
@@ -30,8 +30,7 @@ class Phrase::Tool::Locale
30
30
  end
31
31
 
32
32
  def self.config
33
- config = Phrase::Tool::Config.new
34
- config.load
33
+ Phrase::Tool.config
35
34
  end
36
35
  private_class_method :config
37
36
 
@@ -11,10 +11,16 @@ class Phrase::Tool::Options
11
11
 
12
12
  def get(name)
13
13
  return @data.fetch(command_name).fetch(name.to_sym)
14
- rescue => e
14
+ rescue => _
15
15
  $stderr.puts "Invalid or missing option \"#{name}\" for command \"#{command_name}\""
16
16
  end
17
17
 
18
+ def set?(name)
19
+ return @data.fetch(command_name)[name.to_sym]
20
+ rescue => _
21
+ $stderr.puts "Invalid command name"
22
+ end
23
+
18
24
  private
19
25
  def options
20
26
  OptionsFactory.options_for(command_name, @data)
@@ -66,6 +66,10 @@ class OptionsFactory
66
66
  opts.on("--skip-unverification", "When force updating translations, skip unverification of non-main locale translations") do |skip_unverification|
67
67
  set[:skip_unverification] = skip_unverification
68
68
  end
69
+
70
+ opts.on("--secret=YOUR_AUTH_TOKEN", String, "The Auth Token to use for this operation instead of the saved one (optional)") do |secret|
71
+ set[:secret] = secret
72
+ end
69
73
  end
70
74
  private_class_method :push
71
75
 
@@ -83,6 +87,10 @@ class OptionsFactory
83
87
  opts.on("--tag=foo", String, "Limit results to a given tag instead of all translations") do |tag|
84
88
  set[:tag] = tag
85
89
  end
90
+
91
+ opts.on("--secret=YOUR_AUTH_TOKEN", String, "The Auth Token to use for this operation instead of the saved one (optional)") do |secret|
92
+ set[:secret] = secret
93
+ end
86
94
  end
87
95
  private_class_method :pull
88
96
 
@@ -1,3 +1,3 @@
1
1
  module Phrase
2
- VERSION = "0.4.15"
2
+ VERSION = "0.4.16"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: phrase
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.15
4
+ version: 0.4.16
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dynport GmbH
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-09-16 00:00:00.000000000 Z
11
+ date: 2013-09-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: colorize