class Locraft::ObjcConstantsGenerator
Constants
- OBJC_CONST_TEMPLATE_H
- OBJC_CONST_TEMPLATE_M
Public Instance Methods
constant_from(key)
click to toggle source
# File lib/locraft/generators/objc_constants_generator.rb, line 32 def constant_from(key) parts = key.split(/\W/).reject(&:empty?).map do |p| p[0] = p[0].capitalize p end "k#{@config.dev_prefix}#{parts.join}Localized" end
generate(localizations_hash)
click to toggle source
# File lib/locraft/generators/objc_constants_generator.rb, line 12 def generate(localizations_hash) localizations = localizations_hash[@config.default_lang] destination_dir = @config.relative_macro_destination mkdir_p destination_dir unless Dir.exist?(destination_dir) write_file_content("#{destination_dir}/#{files_name}.h", h_file(localizations)) write_file_content("#{destination_dir}/#{files_name}.m", m_file(localizations)) puts 'constants files was created for [objc] language' end
h_file(localizations)
click to toggle source
# File lib/locraft/generators/objc_constants_generator.rb, line 27 def h_file(localizations) content = constants_keys_with(localizations).map { |d| OBJC_CONST_TEMPLATE_H % d }.join("\n") Utils.resource_file('objc_h_macro_template.txt') % content end
m_file(localizations)
click to toggle source
# File lib/locraft/generators/objc_constants_generator.rb, line 21 def m_file(localizations) content = %(#import "#{files_name}.h"\n\n) content += constants_keys_with(localizations).map { |d| OBJC_CONST_TEMPLATE_M % d }.join("\n") Utils.resource_file('objc_m_macro_template.txt') % content end
valid?()
click to toggle source
# File lib/locraft/generators/objc_constants_generator.rb, line 8 def valid? !@config.relative_macro_destination.nil? end