class Config
Configuration singleton for `dlz`
Attributes
data[RW]
Public Class Methods
config?()
click to toggle source
# File lib/dlz/config.rb, line 47 def self.config? return true if File.exist?("#{local_path}/dlz.yaml") false end
dlz_init_path()
click to toggle source
# File lib/dlz/config.rb, line 57 def self.dlz_init_path "#{dlz_path}/#{dlz_init_path_trailing}" end
dlz_init_path_trailing()
click to toggle source
# File lib/dlz/config.rb, line 61 def self.dlz_init_path_trailing 'init' end
dlz_path()
click to toggle source
# File lib/dlz/config.rb, line 53 def self.dlz_path File.expand_path(File.dirname(__dir__)) end
dlz_template_path()
click to toggle source
# File lib/dlz/config.rb, line 65 def self.dlz_template_path "#{dlz_path}/#{dlz_template_path_trailing}" end
dlz_template_path_trailing()
click to toggle source
# File lib/dlz/config.rb, line 69 def self.dlz_template_path_trailing 'templates' end
init()
click to toggle source
# File lib/dlz/config.rb, line 11 def self.init return Interface.panic(message: 'config seems to already exist!') if config? FileUtils.mkdir_p(local_dlz_template_path) FileUtils.cp( "#{dlz_init_path}/dlz.yaml", "#{local_path}/dlz.yaml" ) Interface.info(message: 'created new default configuration.') end
load()
click to toggle source
# File lib/dlz/config.rb, line 22 def self.load unless File.exist?("#{local_path}/dlz.yaml") return Interface.panic(message: 'no config file found. try `dlz init`.') end if @data.empty? # Load, deserialize and symbolize keys @data = YAML.load_file("#{local_path}/dlz.yaml") .each_with_object({}) do |(key, value), obj| obj[key.to_sym] = value end end @data end
local_dlz_template_path()
click to toggle source
# File lib/dlz/config.rb, line 85 def self.local_dlz_template_path "#{local_path}/#{local_dlz_template_path_trailing}" end
local_dlz_template_path_trailing()
click to toggle source
# File lib/dlz/config.rb, line 89 def self.local_dlz_template_path_trailing 'templates/dlz' end
local_path()
click to toggle source
# File lib/dlz/config.rb, line 73 def self.local_path Dir.pwd end
local_template_path()
click to toggle source
# File lib/dlz/config.rb, line 77 def self.local_template_path "#{local_path}/#{local_template_path_trailing}" end
local_template_path_trailing()
click to toggle source
# File lib/dlz/config.rb, line 81 def self.local_template_path_trailing 'templates' end
print()
click to toggle source
# File lib/dlz/config.rb, line 43 def self.print ap load end
version()
click to toggle source
# File lib/dlz/config.rb, line 37 def self.version Interface.info( message: "current version is 'dlz-#{Gem.loaded_specs['dlz'].version}'" ) end