Class: Git::Webby::ProjectHandler
- Inherits:
-
Object
- Object
- Git::Webby::ProjectHandler
- Defined in:
- lib/git/webby.rb
Overview
:nodoc:
Instance Attribute Summary collapse
-
#path ⇒ Object
readonly
Path to git command.
-
#project_root ⇒ Object
readonly
Returns the value of attribute project_root.
-
#repository ⇒ Object
Returns the value of attribute repository.
Instance Method Summary collapse
- #cli(command, *args) ⇒ Object
- #info_packs_path ⇒ Object
-
#initialize(project_root, path = "/usr/bin/git") ⇒ ProjectHandler
constructor
A new instance of ProjectHandler.
- #loose_object_path(*hash) ⇒ Object
- #pack_idx_path(pack) ⇒ Object
- #path_to(*args) ⇒ Object
- #read_file(*file) ⇒ Object
- #run(command, *args) ⇒ Object
Constructor Details
#initialize(project_root, path = "/usr/bin/git") ⇒ ProjectHandler
Returns a new instance of ProjectHandler.
67 68 69 70 71 |
# File 'lib/git/webby.rb', line 67 def initialize(project_root, path = "/usr/bin/git") @repository = nil @path = check_path(File.(path)) @project_root = check_path(File.(project_root)) end |
Instance Attribute Details
#path ⇒ Object (readonly)
Path to git command
61 62 63 |
# File 'lib/git/webby.rb', line 61 def path @path end |
#project_root ⇒ Object (readonly)
Returns the value of attribute project_root.
63 64 65 |
# File 'lib/git/webby.rb', line 63 def project_root @project_root end |
#repository ⇒ Object
Returns the value of attribute repository.
65 66 67 |
# File 'lib/git/webby.rb', line 65 def repository @repository end |
Instance Method Details
#cli(command, *args) ⇒ Object
81 82 83 |
# File 'lib/git/webby.rb', line 81 def cli(command, *args) %Q[#{@path} #{args.unshift(command.to_s.gsub("_","-")).compact.join(" ")}] end |
#info_packs_path ⇒ Object
101 102 103 |
# File 'lib/git/webby.rb', line 101 def info_packs_path path_to(:objects, :info, :packs) end |
#loose_object_path(*hash) ⇒ Object
93 94 95 |
# File 'lib/git/webby.rb', line 93 def loose_object_path(*hash) path_to(:objects, *hash) end |
#pack_idx_path(pack) ⇒ Object
97 98 99 |
# File 'lib/git/webby.rb', line 97 def pack_idx_path(pack) path_to(:objects, :pack, pack) end |
#path_to(*args) ⇒ Object
73 74 75 |
# File 'lib/git/webby.rb', line 73 def path_to(*args) File.join(@repository || @project_root, *(args.compact.map(&:to_s))) end |
#read_file(*file) ⇒ Object
89 90 91 |
# File 'lib/git/webby.rb', line 89 def read_file(*file) File.read(path_to(*file)) end |
#run(command, *args) ⇒ Object
85 86 87 |
# File 'lib/git/webby.rb', line 85 def run(command, *args) chdir{ %x[#{cli command, *args}] } end |