Class: FPM::Cookery::Config
- Inherits:
-
Object
- Object
- FPM::Cookery::Config
- Defined in:
- lib/fpm/cookery/config.rb
Constant Summary collapse
- ATTRIBUTES =
[ :color, :debug, :target, :platform, :maintainer, :vendor, :skip_package, :keep_destdir, :dependency_check, :quiet, :tmp_root, :pkg_dir, :cache_dir, :data_dir, :hiera_config, :vendor_delimiter, :docker, :docker_image, :docker_keep_container, :docker_cache, :docker_bin, :dockerfile ].freeze
- DEFAULTS =
{ :color => true, :debug => false, :dependency_check => true, :skip_package => false, :keep_destdir => false, :quiet => false, :docker => false, :docker_image => nil, :docker_keep_container => false, :docker_cache => nil, :docker_bin => 'docker', :dockerfile => 'Dockerfile' }.freeze
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(data = {}) ⇒ Config
constructor
A new instance of Config.
- #to_hash ⇒ Object
Constructor Details
Class Method Details
.from_cli(cli) ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/fpm/cookery/config.rb', line 36 def self.from_cli(cli) new.tap do |config| ATTRIBUTES.each do |name| if cli.respond_to?("#{name}?") value = cli.__send__("#{name}?") elsif cli.respond_to?(name) value = cli.__send__(name) else value = nil end config.__send__("#{name}=", value) unless value.nil? end end end |
.load_file(paths) ⇒ Object
30 31 32 33 34 |
# File 'lib/fpm/cookery/config.rb', line 30 def self.load_file(paths) path = Array(paths).find {|p| File.exist?(p) } path ? new(YAML.load_file(path)) : new end |
Instance Method Details
#to_hash ⇒ Object
70 71 72 73 74 75 |
# File 'lib/fpm/cookery/config.rb', line 70 def to_hash ATTRIBUTES.inject({}) do |hash, attribute| hash[attribute] = __send__(attribute) hash end end |