Class: Locraft::Config
- Inherits:
-
Object
- Object
- Locraft::Config
- Defined in:
- lib/locraft/model/config.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#default_lang ⇒ Object
Returns the value of attribute default_lang.
-
#from_file ⇒ Object
fill automatically in load_from method.
-
#gdoc_comments_column ⇒ Object
Returns the value of attribute gdoc_comments_column.
-
#gdoc_file ⇒ Object
Returns the value of attribute gdoc_file.
-
#gdoc_keys_column ⇒ Object
Returns the value of attribute gdoc_keys_column.
-
#gdoc_sheet ⇒ Object
Returns the value of attribute gdoc_sheet.
-
#keys_map ⇒ Object
Returns the value of attribute keys_map.
-
#langs ⇒ Object
Returns the value of attribute langs.
-
#platform ⇒ Object
Returns the value of attribute platform.
-
#strings_basename ⇒ Object
Returns the value of attribute strings_basename.
-
#strings_destination ⇒ Object
Returns the value of attribute strings_destination.
Class Method Summary collapse
Instance Method Summary collapse
- #from_folder ⇒ Object
-
#initialize {|_self| ... } ⇒ Config
constructor
A new instance of Config.
- #relative_strings_destination ⇒ Object
- #strings_file ⇒ Object
- #strings_generators ⇒ Object
Constructor Details
#initialize {|_self| ... } ⇒ Config
Returns a new instance of Config.
27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/locraft/model/config.rb', line 27 def initialize self.default_lang = 'English' self.gdoc_sheet = 0 self.gdoc_keys_column = 'Keys' self.gdoc_comments_column = 'Comments' self.keys_map = {} self.strings_basename = 'Localizable' self.langs = { 'English' => 'en', 'Russian' => 'ru' } yield self if block_given? end |
Instance Attribute Details
#default_lang ⇒ Object
Returns the value of attribute default_lang.
18 19 20 |
# File 'lib/locraft/model/config.rb', line 18 def default_lang @default_lang end |
#from_file ⇒ Object
fill automatically in load_from method
25 26 27 |
# File 'lib/locraft/model/config.rb', line 25 def from_file @from_file end |
#gdoc_comments_column ⇒ Object
Returns the value of attribute gdoc_comments_column.
21 22 23 |
# File 'lib/locraft/model/config.rb', line 21 def gdoc_comments_column @gdoc_comments_column end |
#gdoc_file ⇒ Object
Returns the value of attribute gdoc_file.
14 15 16 |
# File 'lib/locraft/model/config.rb', line 14 def gdoc_file @gdoc_file end |
#gdoc_keys_column ⇒ Object
Returns the value of attribute gdoc_keys_column.
20 21 22 |
# File 'lib/locraft/model/config.rb', line 20 def gdoc_keys_column @gdoc_keys_column end |
#gdoc_sheet ⇒ Object
Returns the value of attribute gdoc_sheet.
19 20 21 |
# File 'lib/locraft/model/config.rb', line 19 def gdoc_sheet @gdoc_sheet end |
#keys_map ⇒ Object
Returns the value of attribute keys_map.
22 23 24 |
# File 'lib/locraft/model/config.rb', line 22 def keys_map @keys_map end |
#langs ⇒ Object
Returns the value of attribute langs.
17 18 19 |
# File 'lib/locraft/model/config.rb', line 17 def langs @langs end |
#platform ⇒ Object
Returns the value of attribute platform.
13 14 15 |
# File 'lib/locraft/model/config.rb', line 13 def platform @platform end |
#strings_basename ⇒ Object
Returns the value of attribute strings_basename.
16 17 18 |
# File 'lib/locraft/model/config.rb', line 16 def strings_basename @strings_basename end |
#strings_destination ⇒ Object
Returns the value of attribute strings_destination.
15 16 17 |
# File 'lib/locraft/model/config.rb', line 15 def strings_destination @strings_destination end |
Class Method Details
.load_from(file) ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/locraft/model/config.rb', line 41 def self.load_from(file) return unless file || File.file?(file) begin config = eval(File.read(file), binding, 'config loading problem') config.from_file = file return config if config.is_a? Config warn "[#{file}] isn't a Locraft::Config, but #{config.class}." rescue SyntaxError, StandardError => e warn "Invalid config in [#{file}]: #{e}" end end |
Instance Method Details
#from_folder ⇒ Object
54 55 56 |
# File 'lib/locraft/model/config.rb', line 54 def from_folder File.dirname(from_file) end |
#relative_strings_destination ⇒ Object
58 59 60 |
# File 'lib/locraft/model/config.rb', line 58 def relative_strings_destination File.('../' + strings_destination, from_file) end |
#strings_file ⇒ Object
62 63 64 |
# File 'lib/locraft/model/config.rb', line 62 def strings_file raise NotImplementedError end |
#strings_generators ⇒ Object
66 67 68 |
# File 'lib/locraft/model/config.rb', line 66 def strings_generators raise NotImplementedError end |