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 => [ '2.4.1', '2.3.4', '2.2.7', '2.1.10', '2.0.0', '1.9.3' ], :version => '2.3.4', :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
111 112 113 114 115 116 |
# File 'lib/falkorlib/config.rb', line 111 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) ([: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.
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 |
# File 'lib/falkorlib/config.rb', line 75 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.exist?( 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
101 102 103 104 105 106 |
# File 'lib/falkorlib/config.rb', line 101 def get(dir = Dir.pwd, type = :local, = {}) conffile = config_file(dir, type, ) res = {} res = load_config( conffile ) if File.exist?( 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
125 126 127 128 129 130 131 132 133 134 |
# File 'lib/falkorlib/config.rb', line 125 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 |