class Raykit::Git::Files

Functionality to manage a local clone of a git repository

Public Class Methods

new(url,commit_id) click to toggle source
# File lib/raykit/git/files.rb, line 7
def initialize(url,commit_id)
    @url = url
    @commit_id = commit_id
end

Public Instance Methods

clean() click to toggle source
# File lib/raykit/git/files.rb, line 12
def clean
    if Dir.exists?(commit_path())
        FileUtils.rm_rf(commit_path())
    end
end
commit_path() click to toggle source
# File lib/raykit/git/files.rb, line 36
def commit_path
    Dir.tmpdir() + File::SEPARATOR + 'Raykit.Git.Files' + File::SEPARATOR + @url.gsub('://','.') + File::SEPARATOR + @commit_id
end
filename(name) click to toggle source
# File lib/raykit/git/files.rb, line 40
def filename(name)
    commit_path() + File::SEPARATOR + name
end
get(name) click to toggle source
# File lib/raykit/git/files.rb, line 18
def get(name)
    puts "commit_path(): " + commit_path()
    if !Dir.exists?(commit_path())
        puts 'cloning commit path...'
        clone = Raykit::Command.new('git clone ' + @url + ' ' + commit_path())
        puts clone.output
        puts clone.error
        Dir.chdir(commit_path()) do
            checkout = Raykit::Command.new('git checkout ' + @commit_id)
        end
    end

    if File.exists?(filename(name))
        return filename(name)
    end
    ''
end