Class: Mapa::Utility
- Inherits:
-
Object
- Object
- Mapa::Utility
- Defined in:
- lib/mapa/utility.rb
Instance Method Summary collapse
- #ad ⇒ Object
- #br(*options) ⇒ Object
- #brd(*patterns) ⇒ Object
- #cm(message) ⇒ Object
- #co(branch) ⇒ Object
- #cob(new_branch) ⇒ Object
- #dif ⇒ Object
- #fo ⇒ Object
- #go(*options) ⇒ Object
- #in ⇒ Object
-
#initialize(args) ⇒ Utility
constructor
A new instance of Utility.
- #ph(remote_branch) ⇒ Object
- #pl(remote_branch) ⇒ Object
- #rh ⇒ Object
- #st ⇒ Object
Constructor Details
#initialize(args) ⇒ Utility
Returns a new instance of Utility.
3 4 5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/mapa/utility.rb', line 3 def initialize(args) action = args[0] if self.respond_to? action.to_sym case self.method(action.to_sym).arity when 1 self.send(action.to_sym, args[1]) when -1 self.send(action.to_sym, args[1..-1]) else self.send(action.to_sym) end end end |
Instance Method Details
#ad ⇒ Object
30 31 32 |
# File 'lib/mapa/utility.rb', line 30 def ad exec 'git add .' end |
#br(*options) ⇒ Object
42 43 44 45 46 47 48 |
# File 'lib/mapa/utility.rb', line 42 def br(*) if .flatten.first == '-a' exec 'git branch' else exec 'git rev-parse --abbrev-ref HEAD' end end |
#brd(*patterns) ⇒ Object
50 51 52 53 54 |
# File 'lib/mapa/utility.rb', line 50 def brd(*patterns) patterns.each do |branch| exec "git branch | grep '#{branch}' | xargs git branch -D" end end |
#cm(message) ⇒ Object
38 39 40 |
# File 'lib/mapa/utility.rb', line 38 def cm() exec "git commit -m '#{}'" end |
#co(branch) ⇒ Object
72 73 74 |
# File 'lib/mapa/utility.rb', line 72 def co(branch) exec "git checkout #{branch}" end |
#cob(new_branch) ⇒ Object
76 77 78 |
# File 'lib/mapa/utility.rb', line 76 def cob(new_branch) exec "git checkout -b #{new_branch}" end |
#dif ⇒ Object
56 57 58 |
# File 'lib/mapa/utility.rb', line 56 def dif exec 'git diff' end |
#fo ⇒ Object
60 61 62 |
# File 'lib/mapa/utility.rb', line 60 def fo exec 'git fetch origin' end |
#go(*options) ⇒ Object
21 22 23 24 |
# File 'lib/mapa/utility.rb', line 21 def go(*) = .flatten exec "git add . && git commit -m '#{[0]}' && git push origin #{[1]}" end |
#in ⇒ Object
17 18 19 |
# File 'lib/mapa/utility.rb', line 17 def in exec 'git init' end |
#ph(remote_branch) ⇒ Object
68 69 70 |
# File 'lib/mapa/utility.rb', line 68 def ph(remote_branch) exec "git push origin #{remote_branch}" end |
#pl(remote_branch) ⇒ Object
64 65 66 |
# File 'lib/mapa/utility.rb', line 64 def pl(remote_branch) exec "git pull origin #{remote_branch}" end |
#rh ⇒ Object
26 27 28 |
# File 'lib/mapa/utility.rb', line 26 def rh exec 'git reset --hard' end |
#st ⇒ Object
34 35 36 |
# File 'lib/mapa/utility.rb', line 34 def st exec 'git status' end |