Class: Monolith::Git
Instance Method Summary collapse
- #clone(url) ⇒ Object
- #cloned? ⇒ Boolean
- #fetch ⇒ Object
-
#initialize(path) ⇒ Git
constructor
A new instance of Git.
- #run(cmd) ⇒ Object
- #run!(cmd) ⇒ Object
- #within_working_dir(&block) ⇒ Object
Methods included from Logger
Constructor Details
#initialize(path) ⇒ Git
Returns a new instance of Git.
5 6 7 |
# File 'lib/monolith/git.rb', line 5 def initialize(path) @path = path end |
Instance Method Details
#clone(url) ⇒ Object
9 10 11 |
# File 'lib/monolith/git.rb', line 9 def clone(url) run("clone #{url} .") end |
#cloned? ⇒ Boolean
13 14 15 |
# File 'lib/monolith/git.rb', line 13 def cloned? File.exists?(@path) end |
#fetch ⇒ Object
17 18 19 |
# File 'lib/monolith/git.rb', line 17 def fetch run("fetch --all") end |
#run(cmd) ⇒ Object
21 22 23 24 25 |
# File 'lib/monolith/git.rb', line 21 def run(cmd) within_working_dir do run!(cmd) end end |
#run!(cmd) ⇒ Object
27 28 29 |
# File 'lib/monolith/git.rb', line 27 def run!(cmd) command(cmd).run end |
#within_working_dir(&block) ⇒ Object
31 32 33 34 |
# File 'lib/monolith/git.rb', line 31 def within_working_dir(&block) create_working_dir unless cloned? cd_working_dir(&block) end |