Sha256: ce6304fe288b4e95885cccd05fbc76cbcdf6fed8879afd4f6bc218c26c94e842

Contents?: true

Size: 740 Bytes

Versions: 18

Compression:

Stored size: 740 Bytes

Contents

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

18 entries across 18 versions & 1 rubygems

Version Path
proxy_tester-0.1.10 lib/proxy_tester/actions/create_directory.rb
proxy_tester-0.1.8 lib/proxy_tester/actions/create_directory.rb
proxy_tester-0.1.6 lib/proxy_tester/actions/create_directory.rb
proxy_tester-0.1.5 lib/proxy_tester/actions/create_directory.rb
proxy_tester-0.1.4 lib/proxy_tester/actions/create_directory.rb
proxy_tester-0.1.3 lib/proxy_tester/actions/create_directory.rb
proxy_tester-0.1.2 lib/proxy_tester/actions/create_directory.rb
proxy_tester-0.1.1 lib/proxy_tester/actions/create_directory.rb
proxy_tester-0.1.0 lib/proxy_tester/actions/create_directory.rb
proxy_tester-0.0.9 lib/proxy_tester/actions/create_directory.rb
proxy_tester-0.0.8 lib/proxy_tester/actions/create_directory.rb
proxy_tester-0.0.7 lib/proxy_tester/actions/create_directory.rb
proxy_tester-0.0.6 lib/proxy_tester/actions/create_directory.rb
proxy_tester-0.0.5 lib/proxy_tester/actions/create_directory.rb
proxy_tester-0.0.4 lib/proxy_tester/actions/create_directory.rb
proxy_tester-0.0.3 lib/proxy_tester/actions/create_directory.rb
proxy_tester-0.0.2 lib/proxy_tester/actions/create_directory.rb
proxy_tester-0.0.1 lib/proxy_tester/actions/create_directory.rb