Class: Locraft::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/locraft/model/config.rb

Direct Known Subclasses

AndroidConfig, IOSConfig

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize {|_self| ... } ⇒ Config

Returns a new instance of Config.

Yields:

  • (_self)

Yield Parameters:



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_langObject

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_fileObject

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_columnObject

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_fileObject

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_columnObject

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_sheetObject

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_mapObject

Returns the value of attribute keys_map.



22
23
24
# File 'lib/locraft/model/config.rb', line 22

def keys_map
  @keys_map
end

#langsObject

Returns the value of attribute langs.



17
18
19
# File 'lib/locraft/model/config.rb', line 17

def langs
  @langs
end

#platformObject

Returns the value of attribute platform.



13
14
15
# File 'lib/locraft/model/config.rb', line 13

def platform
  @platform
end

#strings_basenameObject

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_destinationObject

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_folderObject



54
55
56
# File 'lib/locraft/model/config.rb', line 54

def from_folder
  File.dirname(from_file)
end

#relative_strings_destinationObject



58
59
60
# File 'lib/locraft/model/config.rb', line 58

def relative_strings_destination
  File.expand_path('../' + strings_destination, from_file)
end

#strings_fileObject

Raises:

  • (NotImplementedError)


62
63
64
# File 'lib/locraft/model/config.rb', line 62

def strings_file
  raise NotImplementedError
end

#strings_generatorsObject

Raises:

  • (NotImplementedError)


66
67
68
# File 'lib/locraft/model/config.rb', line 66

def strings_generators
  raise NotImplementedError
end