Sha256: 05c87d6dc99be096484ddc5f3c6190c20829d7446e9ed6cbf2648932aa3c0e10

Contents?: true

Size: 731 Bytes

Versions: 15

Compression:

Stored size: 731 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 directory \"#{path}\"."
          fs_engine.mkdir_p(path)
        else
          LocalPac.ui_logger.warn "Directory \"#{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

15 entries across 15 versions & 1 rubygems

Version Path
local_pac-0.10.2 lib/local_pac/actions/create_directory.rb
local_pac-0.10.1 lib/local_pac/actions/create_directory.rb
local_pac-0.10.0 lib/local_pac/actions/create_directory.rb
local_pac-0.9.0 lib/local_pac/actions/create_directory.rb
local_pac-0.7.0 lib/local_pac/actions/create_directory.rb
local_pac-0.6.3 lib/local_pac/actions/create_directory.rb
local_pac-0.6.2 lib/local_pac/actions/create_directory.rb
local_pac-0.6.1 lib/local_pac/actions/create_directory.rb
local_pac-0.5.0 lib/local_pac/actions/create_directory.rb
local_pac-0.4.0 lib/local_pac/actions/create_directory.rb
local_pac-0.3.0 lib/local_pac/actions/create_directory.rb
local_pac-0.2.3 lib/local_pac/actions/create_directory.rb
local_pac-0.2.2 lib/local_pac/actions/create_directory.rb
local_pac-0.2.1 lib/local_pac/actions/create_directory.rb
local_pac-0.2.0 lib/local_pac/actions/create_directory.rb