Sha256: e912b2d38b109d2d061a71dd57c28786b013629beb80ae56a40c1fe2994d1a89

Contents?: true

Size: 810 Bytes

Versions: 1

Compression:

Stored size: 810 Bytes

Contents

require "yaml"

module Caravan
  class Config < Hash
    DEFAULT_CONFIG = {
      "deploy_mode" => "rsync_local",
      "incremental" => true,
      "exclude" => %w(
        .git .svn
      )
    }.freeze

    class << self
      def default_conf
        DEFAULT_CONFIG
      end

      def from(user_config_path)
        if File.exist?(user_config_path)
          YAML.load_file(user_config_path)
        else
          dump_conf(user_config_path, default_conf)
          default_conf
        end
      end

      def dump_conf(user_config_path, user_config)
        File.open(user_config_path, "w") do |f|
          f.write(user_config.to_yaml)
        end
      end

      def pretty_puts(conf)
        conf.each do |k, v|
          Message.info("    => #{k}: #{v}")
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
caravan-0.3.1 lib/caravan/config.rb