Class: POEditor::Configuration
- Inherits:
-
Object
- Object
- POEditor::Configuration
- Defined in:
- lib/Configuration.rb
Instance Attribute Summary collapse
-
#api_key ⇒ String
POEditor API key.
-
#filters ⇒ Array<String>
Filters by ‘translated’, ‘untranslated’, ‘fuzzy’, ‘not_fuzzy’, ‘automatic’, ‘not_automatic’, ‘proofread’, ‘not_proofread’ (optional).
-
#language_alias ⇒ Hash{Sting => String}
The languages aliases.
-
#languages ⇒ Array<String>
The languages codes.
-
#path ⇒ String
The path template.
-
#path_copy ⇒ Hash{Sting => String}
The path copies.
-
#path_replace ⇒ Hash{Sting => String}
The path replacements.
-
#project_id ⇒ String
POEditor project ID.
-
#tags ⇒ Array<String>
Tag filters (optional).
-
#type ⇒ String
Export file type (po, apple_strings, android_strings).
Instance Method Summary collapse
- #from_env(value) ⇒ Object
-
#initialize(api_key:, project_id:, type:, tags: nil, filters: nil, languages:, language_alias: nil, path:, path_replace: nil, path_copy: nil) ⇒ Configuration
constructor
A new instance of Configuration.
Constructor Details
#initialize(api_key:, project_id:, type:, tags: nil, filters: nil, languages:, language_alias: nil, path:, path_replace: nil, path_copy: nil) ⇒ Configuration
Returns a new instance of Configuration.
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/Configuration.rb', line 34 def initialize(api_key:, project_id:, type:, tags:nil, filters:nil, languages:, language_alias:nil, path:, path_replace:nil, path_copy:nil) @api_key = from_env(api_key) @project_id = from_env(project_id.to_s) @type = type @tags = || [] @filters = filters || [] @languages = languages @language_alias = language_alias || {} @path = path @path_replace = path_replace || {} @path_copy = path_copy || {} if @path_replace.any? and @path_copy.any? @path_replace.each { |language_key, v| if @path_copy.key?(language_key) raise POEditor::Exception.new "'path_replace' and 'path_copy' are different strategies of one functionality and thus cannot be in use simultaneously for same language." end } end end |
Instance Attribute Details
#api_key ⇒ String
Returns POEditor API key.
5 6 7 |
# File 'lib/Configuration.rb', line 5 def api_key @api_key end |
#filters ⇒ Array<String>
Returns Filters by ‘translated’, ‘untranslated’, ‘fuzzy’, ‘not_fuzzy’, ‘automatic’, ‘not_automatic’, ‘proofread’, ‘not_proofread’ (optional).
17 18 19 |
# File 'lib/Configuration.rb', line 17 def filters @filters end |
#language_alias ⇒ Hash{Sting => String}
Returns The languages aliases.
23 24 25 |
# File 'lib/Configuration.rb', line 23 def language_alias @language_alias end |
#languages ⇒ Array<String>
Returns The languages codes.
20 21 22 |
# File 'lib/Configuration.rb', line 20 def languages @languages end |
#path ⇒ String
Returns The path template.
26 27 28 |
# File 'lib/Configuration.rb', line 26 def path @path end |
#path_copy ⇒ Hash{Sting => String}
Returns The path copies.
32 33 34 |
# File 'lib/Configuration.rb', line 32 def path_copy @path_copy end |
#path_replace ⇒ Hash{Sting => String}
Returns The path replacements.
29 30 31 |
# File 'lib/Configuration.rb', line 29 def path_replace @path_replace end |
#project_id ⇒ String
Returns POEditor project ID.
8 9 10 |
# File 'lib/Configuration.rb', line 8 def project_id @project_id end |
#tags ⇒ Array<String>
Returns Tag filters (optional).
14 15 16 |
# File 'lib/Configuration.rb', line 14 def @tags end |
#type ⇒ String
Returns Export file type (po, apple_strings, android_strings).
11 12 13 |
# File 'lib/Configuration.rb', line 11 def type @type end |
Instance Method Details
#from_env(value) ⇒ Object
58 59 60 61 62 63 64 65 |
# File 'lib/Configuration.rb', line 58 def from_env(value) if value.start_with?("$") key = value[1..-1] ENV[key] else value end end |