module PolyglotIos::Helper::General
Constants
- ESCAPE_KEYWORDS
Public Instance Methods
clean_case_name(name)
click to toggle source
# File lib/ios_polyglot_cli/helpers/general.rb, line 51 def clean_case_name(name) clean_variable_name(name) end
clean_enum_name(name)
click to toggle source
# File lib/ios_polyglot_cli/helpers/general.rb, line 41 def clean_enum_name(name) clean_name = name .split(/[^0-9a-zA-Z]/) .reject { |c| c.empty? } .map { |value| value.capitalize } .join escape_with_underscore_if_needed(clean_name) end
clean_variable_name(name)
click to toggle source
# File lib/ios_polyglot_cli/helpers/general.rb, line 55 def clean_variable_name(name) clean_name = name .split(/[^0-9a-zA-Z]/) .reject { |c| c.empty? } .each_with_index .map { |value, index| index == 0 ? value.downcase : value.capitalize } .join escaped_underscore = escape_with_underscore_if_needed(clean_name) escape_keyword_if_needed(escaped_underscore) end
config()
click to toggle source
# File lib/ios_polyglot_cli/helpers/general.rb, line 19 def config @config ||= PolyglotIos::IO::Config.read.with_indifferent_access end
escape_keyword_if_needed(name)
click to toggle source
# File lib/ios_polyglot_cli/helpers/general.rb, line 72 def escape_keyword_if_needed(name) return name if !ESCAPE_KEYWORDS.include? name "`#{name}`" end
escape_with_underscore_if_needed(name)
click to toggle source
# File lib/ios_polyglot_cli/helpers/general.rb, line 67 def escape_with_underscore_if_needed(name) return name if name.match(/^[A-Za-z_]/) "_" + name end
indent(level = 0, initial = "")
click to toggle source
# File lib/ios_polyglot_cli/helpers/general.rb, line 35 def indent(level = 0, initial = "") (1..level) .to_a.reduce("") { |result, value| result + " " } .concat(initial) end
programming_language()
click to toggle source
# File lib/ios_polyglot_cli/helpers/general.rb, line 27 def programming_language @programming_language ||= config[:language] end
project_configs()
click to toggle source
# File lib/ios_polyglot_cli/helpers/general.rb, line 23 def project_configs @project_configs ||= config[:projects] end
token()
click to toggle source
# File lib/ios_polyglot_cli/helpers/general.rb, line 10 def token @token ||= PolyglotIos::IO::Token.read if @token.to_s.empty? PolyglotIos::Command::Login.init @token = PolyglotIos::IO::Token.read end @token end
use_old_naming()
click to toggle source
# File lib/ios_polyglot_cli/helpers/general.rb, line 31 def use_old_naming @useOldNaming ||= config[:useOldNaming] end