Sha256: 10337b63bf517d6e42b96053c8c5e13ec1341b460bc057550822ddb9ad148c5b

Contents?: true

Size: 737 Bytes

Versions: 20

Compression:

Stored size: 737 Bytes

Contents

# encoding: utf-8
module TestServer
  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
          TestServer.ui_logger.warn "Creating directory \"#{path}\"."
          fs_engine.mkdir_p(path)
        else
          TestServer.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

20 entries across 20 versions & 1 rubygems

Version Path
test_server-0.5.2 lib/test_server/actions/create_directory.rb
test_server-0.5.1 lib/test_server/actions/create_directory.rb
test_server-0.5.0 lib/test_server/actions/create_directory.rb
test_server-0.4.1 lib/test_server/actions/create_directory.rb
test_server-0.4.0 lib/test_server/actions/create_directory.rb
test_server-0.3.7 lib/test_server/actions/create_directory.rb
test_server-0.3.6 lib/test_server/actions/create_directory.rb
test_server-0.3.5 lib/test_server/actions/create_directory.rb
test_server-0.3.4 lib/test_server/actions/create_directory.rb
test_server-0.3.2 lib/test_server/actions/create_directory.rb
test_server-0.3.1 lib/test_server/actions/create_directory.rb
test_server-0.2.4 lib/test_server/actions/create_directory.rb
test_server-0.2.3 lib/test_server/actions/create_directory.rb
test_server-0.2.2 lib/test_server/actions/create_directory.rb
test_server-0.2.1 lib/test_server/actions/create_directory.rb
test_server-0.2.0 lib/test_server/actions/create_directory.rb
test_server-0.1.2 lib/test_server/actions/create_directory.rb
test_server-0.1.1 lib/test_server/actions/create_directory.rb
test_server-0.1.0 lib/test_server/actions/create_directory.rb
test_server-0.0.11 lib/test_server/actions/create_directory.rb