Module: Git_Repo::Base
- Included in:
- Git_Repo
- Defined in:
- lib/Git_Repo.rb
Instance Attribute Summary collapse
-
#address ⇒ Object
readonly
Returns the value of attribute address.
Instance Method Summary collapse
- #add(str) ⇒ Object
- #bundle_update ⇒ Object
- #commit(msg) ⇒ Object
- #commit_pending? ⇒ Boolean
- #init ⇒ Object
- #initialize(dir) ⇒ Object
- #nothing_to_commit? ⇒ Boolean
- #reset ⇒ Object
- #shell(cmd) ⇒ Object
- #staged? ⇒ Boolean
- #status ⇒ Object
- #tag(str) ⇒ Object
- #update ⇒ Object
Instance Attribute Details
#address ⇒ Object (readonly)
Returns the value of attribute address.
10 11 12 |
# File 'lib/Git_Repo.rb', line 10 def address @address end |
Instance Method Details
#add(str) ⇒ Object
19 20 21 |
# File 'lib/Git_Repo.rb', line 19 def add str shell "git add #{str}" end |
#bundle_update ⇒ Object
56 57 58 |
# File 'lib/Git_Repo.rb', line 56 def bundle_update shell "bundle update" end |
#commit(msg) ⇒ Object
36 37 38 |
# File 'lib/Git_Repo.rb', line 36 def commit msg shell "git commit -m \"#{msg.gsub(%r!\r|\n!, ' ').gsub('"', "'")}\"" end |
#commit_pending? ⇒ Boolean
48 49 50 |
# File 'lib/Git_Repo.rb', line 48 def commit_pending? !nothing_to_commit? end |
#init ⇒ Object
15 16 17 |
# File 'lib/Git_Repo.rb', line 15 def init shell "git init" end |
#initialize(dir) ⇒ Object
11 12 13 |
# File 'lib/Git_Repo.rb', line 11 def initialize dir @address = File.(dir) end |
#nothing_to_commit? ⇒ Boolean
44 45 46 |
# File 'lib/Git_Repo.rb', line 44 def nothing_to_commit? !!( status['nothing to commit (working directory clean)'] ) end |
#reset ⇒ Object
32 33 34 |
# File 'lib/Git_Repo.rb', line 32 def reset shell "git reset" end |
#shell(cmd) ⇒ Object
60 61 62 63 64 65 66 67 68 |
# File 'lib/Git_Repo.rb', line 60 def shell cmd val = `cd #{address} && #{cmd} 2>&1`.to_s.strip puts cmd if $?.exitstatus != 0 raise Failed_Shell_Command, "Results:\n#{val}" end puts val val end |
#staged? ⇒ Boolean
52 53 54 |
# File 'lib/Git_Repo.rb', line 52 def staged? commit_pending? end |
#status ⇒ Object
40 41 42 |
# File 'lib/Git_Repo.rb', line 40 def status shell "git status" end |
#tag(str) ⇒ Object
28 29 30 |
# File 'lib/Git_Repo.rb', line 28 def tag str shell "git tag #{str}" end |
#update ⇒ Object
23 24 25 26 |
# File 'lib/Git_Repo.rb', line 23 def update add '.' add '-u' end |