Sha256: 9f48a40a48a4a6200c149d8864db1dd02d19215e66fa5643673320336ff049de

Contents?: true

Size: 477 Bytes

Versions: 1

Compression:

Stored size: 477 Bytes

Contents

require 'fileutils'

class MVCLI::ConfigProvider
  requires :app

  def self.value
    new
  end

  attr_reader :home

  def initialize
    @home = find_or_create "#{ENV['HOME']}/.#{app.name}"
  end

  def directory(name)
    pathname = find_or_create @home.join name
    yield pathname if block_given?
    return pathname
  end

  private

  def find_or_create(path)
    Pathname(path.to_s).tap do |path|
      FileUtils.mkdir_p path.to_s unless path.exist?
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
mvcli-0.1.0 lib/mvcli/std/providers/config_provider.rb