Sha256: 09d20e5e45740706d2ebe0a9460b00e54f58aaa69a6177dab28821055afb0964

Contents?: true

Size: 850 Bytes

Versions: 3

Compression:

Stored size: 850 Bytes

Contents

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

      attr_reader :vcs_engine, :path, :options

      public

      def initialize(path, options = {}, vcs_engine = LocalPac::Git)
        @path        = File.expand_path(path)
        @options     = options
        @vcs_engine  = vcs_engine
      end

      def run
        if need_to_run? || options[:force] == true
          LocalPac.ui_logger.warn "Creating repository \"#{path}\"."

          if options[:bare] == true
            vcs_engine.init(path, true)
          else
            vcs_engine.init(path)
          end
        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

3 entries across 3 versions & 1 rubygems

Version Path
local_pac-0.1.13 lib/local_pac/actions/create_repository.rb
local_pac-0.1.11 lib/local_pac/actions/create_repository.rb
local_pac-0.1.10 lib/local_pac/actions/create_repository.rb