Class: ToptranslationCli::Configuration
- Inherits:
-
Object
- Object
- ToptranslationCli::Configuration
- Defined in:
- lib/toptranslation_cli/configuration.rb
Constant Summary collapse
- FILENAME =
'.toptranslation.yml'
Instance Attribute Summary collapse
-
#access_token ⇒ Object
Returns the value of attribute access_token.
-
#api_base_url ⇒ Object
Returns the value of attribute api_base_url.
-
#files ⇒ Object
Returns the value of attribute files.
-
#files_base_url ⇒ Object
Returns the value of attribute files_base_url.
-
#project_identifier ⇒ Object
Returns the value of attribute project_identifier.
-
#verbose ⇒ Object
Returns the value of attribute verbose.
Instance Method Summary collapse
- #exist? ⇒ Boolean
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
- #load ⇒ Object
- #save ⇒ Object
- #use_examples ⇒ Object
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
9 10 11 12 13 |
# File 'lib/toptranslation_cli/configuration.rb', line 9 def initialize @files_base_url = 'https://files.toptranslation.com' @api_base_url = 'https://api.toptranslation.com' @verbose = !ENV['VERBOSE'].nil? end |
Instance Attribute Details
#access_token ⇒ Object
Returns the value of attribute access_token.
5 6 7 |
# File 'lib/toptranslation_cli/configuration.rb', line 5 def access_token @access_token end |
#api_base_url ⇒ Object
Returns the value of attribute api_base_url.
5 6 7 |
# File 'lib/toptranslation_cli/configuration.rb', line 5 def api_base_url @api_base_url end |
#files ⇒ Object
Returns the value of attribute files.
5 6 7 |
# File 'lib/toptranslation_cli/configuration.rb', line 5 def files @files end |
#files_base_url ⇒ Object
Returns the value of attribute files_base_url.
5 6 7 |
# File 'lib/toptranslation_cli/configuration.rb', line 5 def files_base_url @files_base_url end |
#project_identifier ⇒ Object
Returns the value of attribute project_identifier.
5 6 7 |
# File 'lib/toptranslation_cli/configuration.rb', line 5 def project_identifier @project_identifier end |
#verbose ⇒ Object
Returns the value of attribute verbose.
5 6 7 |
# File 'lib/toptranslation_cli/configuration.rb', line 5 def verbose @verbose end |
Instance Method Details
#exist? ⇒ Boolean
36 37 38 |
# File 'lib/toptranslation_cli/configuration.rb', line 36 def exist? File.exist?(FILENAME) end |
#load ⇒ Object
15 16 17 18 19 20 21 |
# File 'lib/toptranslation_cli/configuration.rb', line 15 def load @project_identifier = configuration['project_identifier'] @access_token = configuration['access_token'] @files_base_url = configuration['files_base_url'] || @files_base_url @api_base_url = configuration['api_base_url'] || @api_base_url @files = configuration['files'] || [] end |
#save ⇒ Object
23 24 25 26 27 28 |
# File 'lib/toptranslation_cli/configuration.rb', line 23 def save File.open(FILENAME, 'w') do |file| # Psych can't stringify keys so we dump it to json before dumping to yml Psych.dump(JSON.parse(configuration_hash.to_json), file) end end |
#use_examples ⇒ Object
30 31 32 33 34 |
# File 'lib/toptranslation_cli/configuration.rb', line 30 def use_examples @project_identifier = '<PROJECT_IDENTIFIER>' @access_token = '<YOUR_ACCESS_TOKEN>' @files = ['config/locales/{locale_code}/**/*.yml'] end |