Sha256: 6659ef2a5ae7bf54a66e90393800c223c9993c6535568510ed9dd4d9c029233a

Contents?: true

Size: 730 Bytes

Versions: 2

Compression:

Stored size: 730 Bytes

Contents

# encoding: utf-8
module LocalPac
  module Actions
    class CreateDirectory
      private

      attr_reader :fs_engine, :path, :options

      public

      def initialize(path, options = {}, fs_engine = FileUtils)
        @path      = File.expand_path(path)
        @options   = options
        @fs_engine = fs_engine
      end

      def run
        if need_to_run? || options[:force] == true
          LocalPac.ui_logger.warn "Creating repository \"#{path}\"."
          fs_engine.mkdir_p(path)
        else
          LocalPac.ui_logger.warn "Repository \"#{path}\" already exists. Do not create it again!."
        end
      end

      private

      def need_to_run?
        !File.exists?(path)
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
local_pac-0.1.11 lib/local_pac/actions/create_directory.rb
local_pac-0.1.10 lib/local_pac/actions/create_directory.rb