Sha256: 273d9261e416f7826cbb153906ff43ea9f1696a8e28b6a543ee1cd8a20fb49b9

Contents?: true

Size: 717 Bytes

Versions: 10

Compression:

Stored size: 717 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        = 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

10 entries across 10 versions & 1 rubygems

Version Path
local_pac-0.1.9 lib/local_pac/actions/create_directory.rb
local_pac-0.1.8 lib/local_pac/actions/create_directory.rb
local_pac-0.1.7 lib/local_pac/actions/create_directory.rb
local_pac-0.1.6 lib/local_pac/actions/create_directory.rb
local_pac-0.1.5 lib/local_pac/actions/create_directory.rb
local_pac-0.1.4 lib/local_pac/actions/create_directory.rb
local_pac-0.1.3 lib/local_pac/actions/create_directory.rb
local_pac-0.1.2 lib/local_pac/actions/create_directory.rb
local_pac-0.1.1 lib/local_pac/actions/create_directory.rb
local_pac-0.1.0 lib/local_pac/actions/create_directory.rb