Class: Locraft::Config
- Inherits:
-
Object
- Object
- Locraft::Config
- Defined in:
- lib/locraft/config.rb
Instance Attribute Summary collapse
-
#default_lang ⇒ Object
Returns the value of attribute default_lang.
-
#destination_dir ⇒ Object
Returns the value of attribute destination_dir.
-
#dev_lang ⇒ Object
Returns the value of attribute dev_lang.
-
#dev_prefix ⇒ Object
Returns the value of attribute dev_prefix.
-
#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.
-
#info_plist_basename ⇒ Object
Returns the value of attribute info_plist_basename.
-
#keys_separator ⇒ Object
Returns the value of attribute keys_separator.
-
#langs ⇒ Object
Returns the value of attribute langs.
-
#macro_destination_dir ⇒ Object
Returns the value of attribute macro_destination_dir.
-
#macro_file ⇒ Object
Returns the value of attribute macro_file.
-
#strings_basename ⇒ Object
Returns the value of attribute strings_basename.
Class Method Summary collapse
Instance Method Summary collapse
- #info_plist_file ⇒ Object
-
#initialize {|_self| ... } ⇒ Config
constructor
A new instance of Config.
- #relative_destination_dir ⇒ Object
- #relative_macro_destination_dir ⇒ Object
- #strings_file ⇒ Object
Constructor Details
#initialize {|_self| ... } ⇒ Config
Returns a new instance of Config.
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/locraft/config.rb', line 25 def initialize self.info_plist_basename = 'InfoPlist' self.strings_basename = 'Localizable' self.destination_dir = './Localizations' self.default_lang = 'English' self.gdoc_sheet = 0 self.gdoc_keys_column = 'Keys' self.gdoc_comments_column = 'Comments' self.dev_lang = OBJC self.dev_prefix = 'XYZ' self.macro_file = 'LocalizedConstants' self.macro_destination_dir = './' self.keys_separator = '.' 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.
8 9 10 |
# File 'lib/locraft/config.rb', line 8 def default_lang @default_lang end |
#destination_dir ⇒ Object
Returns the value of attribute destination_dir.
9 10 11 |
# File 'lib/locraft/config.rb', line 9 def destination_dir @destination_dir end |
#dev_lang ⇒ Object
Returns the value of attribute dev_lang.
14 15 16 |
# File 'lib/locraft/config.rb', line 14 def dev_lang @dev_lang end |
#dev_prefix ⇒ Object
Returns the value of attribute dev_prefix.
15 16 17 |
# File 'lib/locraft/config.rb', line 15 def dev_prefix @dev_prefix end |
#from_file ⇒ Object
fill automatically in load_from method
23 24 25 |
# File 'lib/locraft/config.rb', line 23 def from_file @from_file end |
#gdoc_comments_column ⇒ Object
Returns the value of attribute gdoc_comments_column.
13 14 15 |
# File 'lib/locraft/config.rb', line 13 def gdoc_comments_column @gdoc_comments_column end |
#gdoc_file ⇒ Object
Returns the value of attribute gdoc_file.
10 11 12 |
# File 'lib/locraft/config.rb', line 10 def gdoc_file @gdoc_file end |
#gdoc_keys_column ⇒ Object
Returns the value of attribute gdoc_keys_column.
12 13 14 |
# File 'lib/locraft/config.rb', line 12 def gdoc_keys_column @gdoc_keys_column end |
#gdoc_sheet ⇒ Object
Returns the value of attribute gdoc_sheet.
11 12 13 |
# File 'lib/locraft/config.rb', line 11 def gdoc_sheet @gdoc_sheet end |
#info_plist_basename ⇒ Object
Returns the value of attribute info_plist_basename.
20 21 22 |
# File 'lib/locraft/config.rb', line 20 def info_plist_basename @info_plist_basename end |
#keys_separator ⇒ Object
Returns the value of attribute keys_separator.
17 18 19 |
# File 'lib/locraft/config.rb', line 17 def keys_separator @keys_separator end |
#langs ⇒ Object
Returns the value of attribute langs.
7 8 9 |
# File 'lib/locraft/config.rb', line 7 def langs @langs end |
#macro_destination_dir ⇒ Object
Returns the value of attribute macro_destination_dir.
18 19 20 |
# File 'lib/locraft/config.rb', line 18 def macro_destination_dir @macro_destination_dir end |
#macro_file ⇒ Object
Returns the value of attribute macro_file.
16 17 18 |
# File 'lib/locraft/config.rb', line 16 def macro_file @macro_file end |
#strings_basename ⇒ Object
Returns the value of attribute strings_basename.
19 20 21 |
# File 'lib/locraft/config.rb', line 19 def strings_basename @strings_basename end |
Class Method Details
.load_from(file) ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/locraft/config.rb', line 45 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 === 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
#info_plist_file ⇒ Object
70 71 72 |
# File 'lib/locraft/config.rb', line 70 def info_plist_file "#{info_plist_basename}#{STRINGS_EXTENSION}" end |
#relative_destination_dir ⇒ Object
58 59 60 |
# File 'lib/locraft/config.rb', line 58 def relative_destination_dir File.('../' + destination_dir, from_file) end |
#relative_macro_destination_dir ⇒ Object
62 63 64 |
# File 'lib/locraft/config.rb', line 62 def relative_macro_destination_dir File.('../' + macro_destination_dir, from_file) end |
#strings_file ⇒ Object
66 67 68 |
# File 'lib/locraft/config.rb', line 66 def strings_file "#{strings_basename}#{STRINGS_EXTENSION}" end |