Class: Molt::Configuration
- Inherits:
-
Object
- Object
- Molt::Configuration
- Defined in:
- lib/molt/helpers/configuration.rb
Class Method Summary collapse
- .apply_cli_overrides(config, options, module_name, template_set) ⇒ Object
- .config_for_xcode(config, options, module_name, template_set) ⇒ Object
- .defaults_from_git_config ⇒ Object
- .load_or_initialize ⇒ Object
Class Method Details
.apply_cli_overrides(config, options, module_name, template_set) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/molt/helpers/configuration.rb', line 28 def self.apply_cli_overrides config, , module_name, template_set config["template_set"] = template_set config["target"] = "raw" config["developer"]["name"] = .name if .name config["developer"]["email"] = .email if .email config["developer"]["company"] = .company if .company config["project"]["name"] = .project if .project config["module_name"] = module_name config["model"] = "#{.model}Model" || "<# Model #>" config["entity"] = .model || "<# Entity #>" config["year"] = Time.now.strftime("%Y") config["date"] = Time.now.strftime("%d/%m/%Y") config end |
.config_for_xcode(config, options, module_name, template_set) ⇒ Object
46 47 48 49 50 51 52 53 54 |
# File 'lib/molt/helpers/configuration.rb', line 46 def self.config_for_xcode config, , module_name, template_set config["template_set"] = template_set config["target"] = "xcode" config["module_name"] = "___VARIABLE_productName:identifier___" config["model"] = "___VARIABLE_MODEL___Model" config["entity"] = "___VARIABLE_MODEL___" config end |
.defaults_from_git_config ⇒ Object
19 20 21 22 23 24 25 26 |
# File 'lib/molt/helpers/configuration.rb', line 19 def self.defaults_from_git_config user = { } name = `git config --get user.name`.chomp email = `git config --get user.email`.chomp user["name"] = name.length > 0 ? name : "REPLACE_ME_IN_CONFIG" user["email"] = email.length > 0 ? email : "REPLACE_ME_IN_CONFIG" return { "developer" => user } end |
.load_or_initialize ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/molt/helpers/configuration.rb', line 5 def self.load_or_initialize config_path = nil [ Molt::CONFIG_PROJECT, Molt::CONFIG_GLOBAL ].each do |path| if File.exist? path config_path = path break end end return YAML.load_file(config_path) if config_path puts 'Please run "molt setup" first'.red exit end |