Sha256: 25fbfbcb40bf2d2c70667db8ea82493d001a14dca8e87205c88b468610b244a9

Contents?: true

Size: 690 Bytes

Versions: 6

Compression:

Stored size: 690 Bytes

Contents

require 'delegate'
require 'hashie/mash'
require 'yaml'

module Stevenson
  class Dotfile < SimpleDelegator

    TEMPLATE_PATH = File.join(File.dirname(__FILE__), '..', '..', 'assets', 'stevenson_dotfile.yml')
    DOTFILE_FILENAME = ".stevenson"

    class << self
      def install
        FileUtils.copy TEMPLATE_PATH, path
      end

      def path
        File.join(user_path, DOTFILE_FILENAME)
      end

      private

      def user_path
        Dir.home rescue ENV.fetch('HOME', "/")
      end
    end

    def initialize
      dotfile_path = File.exist?(self.class.path) ? self.class.path : TEMPLATE_PATH
      super Hashie::Mash.new YAML.load_file(dotfile_path)
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
stevenson-2.5.1 lib/stevenson/dotfile.rb
stevenson-2.5.0 lib/stevenson/dotfile.rb
stevenson-2.3.3 lib/stevenson/dotfile.rb
stevenson-2.3.2 lib/stevenson/dotfile.rb
stevenson-2.3.1 lib/stevenson/dotfile.rb
stevenson-2.2.2 lib/stevenson/dotfile.rb