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 => { # See https://www.ruby-lang.org/en/downloads/branches/ for stable branches :rubies => [ '3.2.2', '3.1.4', '3.0.6', '2.7.8'], :version => '3.1.4', :versionfile => '.ruby-version', :gemsetfile => '.ruby-gemset' }, :pyenv => { # See https://devguide.python.org/#status-of-python-branches :versions => ['3.9.13', '3.8.13', '3.7.13', '2.7.18' ], :version => '3.7.13', :versionfile => '.python-version', :virtualenvfile => '.python-virtualenv', :direnvfile => '.envrc', :direnvrc => File.join( ENV['HOME'], '.config', 'direnv', 'direnvrc') }, :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
121 122 123 124 125 126 |
# File 'lib/falkorlib/config.rb', line 121 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.
85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 |
# File 'lib/falkorlib/config.rb', line 85 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
111 112 113 114 115 116 |
# File 'lib/falkorlib/config.rb', line 111 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
135 136 137 138 139 140 141 142 143 144 |
# File 'lib/falkorlib/config.rb', line 135 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 |