Sha256: 2e340b53e09efc6c75e6f1a8ecaa7e4d1265a82b24bbfd64a887fa29bf3b2780

Contents?: true

Size: 1023 Bytes

Versions: 2

Compression:

Stored size: 1023 Bytes

Contents

module Dotman
  class Git
    def self.klone(git_location, alias_name = nil)
      unless git_location.nil?
        Dotman::Base.ensure_dotman_folder_exists
        Dotman::Base.ensure_default_folder_exists
        Dotman::Base.ensure_current_dotman_file_exists
        clone_repository(git_location, alias_name)
      end
    end

    def self.folder_name(git_location)
      folder_name = git_location.scan(/[^:]+[\/]{1}[a-zA-Z0-9]+/).first.gsub('/', '_')
    end

    def self.clone_repository(git_location, alias_name = nil)
      if git_location && !git_location.strip.empty?
        dotfile_location = "#{ENV['HOME']}/.dotman/#{folder_name(git_location)}"
      else
        return Dotman::Notification.unspecified_git_path
      end

      if (File.directory?(dotfile_location))
        Dotman::Notification.already_cloned
      else
        system "git clone #{git_location} #{dotfile_location}"
        Dotman::DotfileCollection.new_configuration(folder_name(git_location), alias_name)
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
dotman-0.0.3.7 lib/dotman/git.rb
dotman-0.0.3.6 lib/dotman/git.rb