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.
9 10 11 12 |
# File 'lib/raykit/git/files.rb', line 9 def initialize(url, commit_id) @url = url @commit_id = commit_id end |
Instance Method Details
#clean ⇒ Object
14 15 16 |
# File 'lib/raykit/git/files.rb', line 14 def clean FileUtils.rm_rf(commit_path) if Dir.exist?(commit_path) end |
#commit_path ⇒ Object
35 36 37 38 |
# File 'lib/raykit/git/files.rb', line 35 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 |
# File 'lib/raykit/git/files.rb', line 18 def get(name) puts "commit_path(): #{commit_path}" unless Dir.exist?(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 return filename(name) if File.exist?(filename(name)) '' end |