Class: Raykit::Git::Files
- Inherits:
-
Object
- Object
- Raykit::Git::Files
- Defined in:
- lib/raykit/git/files.rb
Overview
Functionality to manage a local clone of a git repository
Instance Method Summary collapse
- #clean ⇒ Object
- #commit_path ⇒ Object
- #filename(name) ⇒ Object
- #get(name) ⇒ Object
-
#initialize(url, commit_id) ⇒ Files
constructor
A new instance of Files.
Constructor Details
#initialize(url, commit_id) ⇒ Files
Returns a new instance of Files.
7 8 9 10 |
# File 'lib/raykit/git/files.rb', line 7 def initialize(url,commit_id) @url = url @commit_id = commit_id end |
Instance Method Details
#clean ⇒ Object
12 13 14 15 16 |
# File 'lib/raykit/git/files.rb', line 12 def clean if Dir.exists?(commit_path()) FileUtils.rm_rf(commit_path()) end end |
#commit_path ⇒ Object
36 37 38 |
# 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) ⇒ Object
40 41 42 |
# File 'lib/raykit/git/files.rb', line 40 def filename(name) commit_path() + File::SEPARATOR + name end |
#get(name) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# 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 |