Sha256: b3d3ebccbd9252f99a66b45061b26ff3597973b55ec94c5e22a5e6b536fb042a

Contents?: true

Size: 832 Bytes

Versions: 10

Compression:

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

10 entries across 10 versions & 1 rubygems

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