Module: FalkorLib::Config
- Defined in:
- lib/falkorlib/config.rb,
lib/falkorlib/git/base.rb,
lib/falkorlib/git/flow.rb,
lib/falkorlib/versioning.rb,
lib/falkorlib/puppet/base.rb,
lib/falkorlib/bootstrap/base.rb,
lib/falkorlib/puppet/modules.rb
Overview
:nodoc:
Defined Under Namespace
Modules: Bootstrap, Git, GitFlow, Puppet, Versioning
Constant Summary collapse
- DEFAULTS =
Defaults global settings
{ :debug => false, :verbose => false, :no_interaction => false, :root => Dir.pwd, :config_files => { :local => '.falkor/config', :private => '.falkor/private', #:project => '.falkor/project', }, #:custom_cfg => '.falkorlib.yaml', :rvm => { :rubies => [ '1.9.3', '2.0.0', '2.1.0'], :version => '1.9.3', :versionfile => '.ruby-version', :gemsetfile => '.ruby-gemset' }, :templates => { :trashdir => '.Trash', :puppet => {} }, :tokens => { :code_climate => '' }, :project => {} }
Class Method Summary collapse
-
.config_file(dir = Dir.pwd, type = :local, options = {}) ⇒ Object
get_or_save ###### wrapper for get and save operations.
-
.default ⇒ Object
Build the default configuration hash, to be used to initiate the default.
-
.get(dir = Dir.pwd, type = :local, options = {}) ⇒ Object
get ###### Return the { local | private } FalkorLib configuration Supported options: * :file [string] filename for the local configuration.
-
.save(dir = Dir.pwd, config = {}, type = :local, options = {}) ⇒ Object
save ###### save the { local | private } configuration on YAML format Supported options: * :file [string] filename for the saved configuration * :no_interaction [boolean]: do not interact.
Class Method Details
.config_file(dir = Dir.pwd, type = :local, options = {}) ⇒ Object
get_or_save ###### wrapper for get and save operations
108 109 110 111 112 113 |
# File 'lib/falkorlib/config.rb', line 108 def config_file(dir = Dir.pwd, type = :local, = {}) path = normalized_path(dir) path = FalkorLib::Git.rootdir(path) if FalkorLib::Git.init?(path) raise FalkorLib::Error, "Wrong FalkorLib configuration type" unless FalkorLib.config[:config_files].keys.include?( type.to_sym) return [:file] ? [:file] : File.join(path, FalkorLib.config[:config_files][type.to_sym]) end |
.default ⇒ Object
Build the default configuration hash, to be used to initiate the default. The hash is built depending on the loaded files.
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/falkorlib/config.rb', line 72 def default res = FalkorLib::Config::DEFAULTS.clone $LOADED_FEATURES.each do |path| res[:git] = FalkorLib::Config::Git::DEFAULTS if path.include?('lib/falkorlib/git.rb') res[:gitflow] = FalkorLib::Config::GitFlow::DEFAULTS if path.include?('lib/falkorlib/git.rb') res[:versioning] = FalkorLib::Config::Versioning::DEFAULTS if path.include?('lib/falkorlib/versioning.rb') if path.include?('lib/falkorlib/puppet.rb') res[:puppet] = FalkorLib::Config::Puppet::DEFAULTS res[:templates][:puppet][:modules] = FalkorLib::Config::Puppet::Modules::DEFAULTS[:metadata] end end # Check the potential local customizations [:local, :private].each do |type| custom_cfg = File.join( res[:root], res[:config_files][type.to_sym]) if File.exists?( custom_cfg ) res.deep_merge!( load_config( custom_cfg ) ) end end res end |
.get(dir = Dir.pwd, type = :local, options = {}) ⇒ Object
get ###### Return the { local | private } FalkorLib configuration Supported options:
* :file [string] filename for the local configuration
98 99 100 101 102 103 |
# File 'lib/falkorlib/config.rb', line 98 def get(dir = Dir.pwd, type = :local, = {}) conffile = config_file(dir,type,) res = {} res = load_config( conffile ) if File.exists?( conffile ) res end |
.save(dir = Dir.pwd, config = {}, type = :local, options = {}) ⇒ Object
save ###### save the { local | private } configuration on YAML format Supported options:
* :file [string] filename for the saved configuration
* :no_interaction [boolean]: do not interact
122 123 124 125 126 127 128 129 130 131 |
# File 'lib/falkorlib/config.rb', line 122 def save(dir = Dir.pwd, config = {}, type = :local, = {}) conffile = config_file(dir,type,) confdir = File.dirname( conffile ) unless File.directory?( confdir ) warning "about to create the configuration directory #{confdir}" really_continue? unless [:no_interaction] run %{ mkdir -p #{confdir} } end store_config(conffile, config, ) end |