Class: Locraft::Config

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

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:



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/locraft/config.rb', line 26

def initialize
  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.keys_map = {}
  self.macro_file = 'LocalizedConstants'
  self.strings_basename = 'Localizable'
  self.info_plist_basename = 'InfoPlist'
  self.langs = {
    'English' => 'en',
    'Russian' => 'ru'
  }
  yield self if block_given?
end

Instance Attribute Details

#default_langObject

Returns the value of attribute default_lang.



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

def default_lang
  @default_lang
end

#dev_langObject

Returns the value of attribute dev_lang.



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

def dev_lang
  @dev_lang
end

#dev_prefixObject

Returns the value of attribute dev_prefix.



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

def dev_prefix
  @dev_prefix
end

#from_fileObject

fill automatically in load_from method



24
25
26
# File 'lib/locraft/config.rb', line 24

def from_file
  @from_file
end

#gdoc_comments_columnObject

Returns the value of attribute gdoc_comments_column.



15
16
17
# File 'lib/locraft/config.rb', line 15

def gdoc_comments_column
  @gdoc_comments_column
end

#gdoc_fileObject

Returns the value of attribute gdoc_file.



7
8
9
# File 'lib/locraft/config.rb', line 7

def gdoc_file
  @gdoc_file
end

#gdoc_keys_columnObject

Returns the value of attribute gdoc_keys_column.



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

def gdoc_keys_column
  @gdoc_keys_column
end

#gdoc_sheetObject

Returns the value of attribute gdoc_sheet.



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

def gdoc_sheet
  @gdoc_sheet
end

#info_plist_basenameObject

Returns the value of attribute info_plist_basename.



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

def info_plist_basename
  @info_plist_basename
end

#info_plist_destinationObject

Returns the value of attribute info_plist_destination.



8
9
10
# File 'lib/locraft/config.rb', line 8

def info_plist_destination
  @info_plist_destination
end

#keys_mapObject

Returns the value of attribute keys_map.



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

def keys_map
  @keys_map
end

#langsObject

Returns the value of attribute langs.



11
12
13
# File 'lib/locraft/config.rb', line 11

def langs
  @langs
end

#macro_destinationObject

Returns the value of attribute macro_destination.



9
10
11
# File 'lib/locraft/config.rb', line 9

def macro_destination
  @macro_destination
end

#macro_fileObject

Returns the value of attribute macro_file.



19
20
21
# File 'lib/locraft/config.rb', line 19

def macro_file
  @macro_file
end

#strings_basenameObject

Returns the value of attribute strings_basename.



20
21
22
# File 'lib/locraft/config.rb', line 20

def strings_basename
  @strings_basename
end

#strings_destinationObject

Returns the value of attribute strings_destination.



10
11
12
# File 'lib/locraft/config.rb', line 10

def strings_destination
  @strings_destination
end

Class Method Details

.load_from(file) ⇒ Object



44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/locraft/config.rb', line 44

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



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

def from_folder
  File.dirname(from_file)
end

#info_plist_fileObject



77
78
79
# File 'lib/locraft/config.rb', line 77

def info_plist_file
  "#{info_plist_basename}#{STRINGS_EXTENSION}"
end

#relative_macro_destinationObject



69
70
71
# File 'lib/locraft/config.rb', line 69

def relative_macro_destination
  File.expand_path('../' + macro_destination, from_file)
end

#relative_plist_destinationObject



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

def relative_plist_destination
  File.expand_path('../' + info_plist_destination, from_file)
end

#relative_strings_destinationObject



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

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

#strings_fileObject



73
74
75
# File 'lib/locraft/config.rb', line 73

def strings_file
  "#{strings_basename}#{STRINGS_EXTENSION}"
end