Sha256: d7dbd7352f53fb07c2ed9ac9ae4075ea44445b06aad0e803c278e4a2ab02e733

Contents?: true

Size: 830 Bytes

Versions: 1

Compression:

Stored size: 830 Bytes

Contents

require 'fileutils'

module ProjectStore

  module Initializer


    def self.setup(path = Dir.pwd)
      FileUtils.mkpath path
    end

    private

    def find_store_dir(dir_basename, from_dir)
      raise "Invalid directory '#{from_dir}'" unless Dir.exist?(from_dir) and File.readable?(from_dir)

      candidate = File.join from_dir, dir_basename

      if Dir.exists? candidate
        if File.readable? candidate and File.writable? candidate
          candidate
        else
          raise "Found a project directory '#{candidate}', but with wrong access rights."
        end
      else
        next_dir = File.expand_path '..', from_dir
        if next_dir == from_dir
          raise 'No project directory found.'
        else
          find_store_dir dir_basename, next_dir
        end
      end

    end



  end


end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
project_store-0.1.1 lib/project_store/initializer.rb