class String def camelize(uppercase_first_letter = true) string = self if uppercase_first_letter string = string.sub(/^[a-z\d]*/) { |match| match.capitalize } else string = string.sub(/^(?:(?=\b|[A-Z_])|\w)/) { |match| match.downcase } end string.gsub(/(?:_|(\/))([a-z\d]*)/) { "#{$1}#{$2.capitalize}" }.gsub("/", "::") end end module KCommercial module Resources class CodeGenerator # The super module default is MKResources # @return [String] attr_reader :super_module # The key defines for the generator # @return [Array] attr_reader :keys # Create a new SwiftGenerator # @param [Array] keys the defines for keys def initialize(keys, options = {}) @keys = keys @keys ||= [] @super_module = options.delete(:super) { :MKResources } end def implementation_contents raise NotImplementedError end private def class_name "Colors" end def key_to_code(key) raise NotImplementedError end def key_to_function_name(key) key = key.camelize(false) if key.length > 0 key[0] = key[0].downcase end key end def append_prefix(contents, prefix) contents.lines.map { |l| "#{prefix}#{l}"}.join('') end end end end