Class: Mapa::Utility
- Inherits:
-
Object
- Object
- Mapa::Utility
- Defined in:
- lib/mapa/utility.rb
Instance Method Summary collapse
- #gad ⇒ Object
- #gbr(*options) ⇒ Object
- #gbrd(*patterns) ⇒ Object
- #gcm(message) ⇒ Object
- #gco(branch) ⇒ Object
- #gcob(new_branch) ⇒ Object
- #gdif ⇒ Object
- #gfo ⇒ Object
- #ginit ⇒ Object
- #go(*options) ⇒ Object
- #gph(remote_branch) ⇒ Object
- #gpl(remote_branch) ⇒ Object
- #grh ⇒ Object
- #gst ⇒ Object
-
#initialize(args) ⇒ Utility
constructor
A new instance of Utility.
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
#gad ⇒ Object
30 31 32 |
# File 'lib/mapa/utility.rb', line 30 def gad exec 'git add .' end |
#gbr(*options) ⇒ Object
42 43 44 45 46 47 48 |
# File 'lib/mapa/utility.rb', line 42 def gbr(*) if .flatten.first == '-a' exec 'git branch' else exec 'git rev-parse --abbrev-ref HEAD' end end |
#gbrd(*patterns) ⇒ Object
50 51 52 53 54 |
# File 'lib/mapa/utility.rb', line 50 def gbrd(*patterns) patterns.each do |branch| exec "git branch | grep '#{branch}' | xargs git branch -D" end end |
#gcm(message) ⇒ Object
38 39 40 |
# File 'lib/mapa/utility.rb', line 38 def gcm() exec "git commit -m '#{}'" end |
#gco(branch) ⇒ Object
72 73 74 |
# File 'lib/mapa/utility.rb', line 72 def gco(branch) exec "git checkout #{branch}" end |
#gcob(new_branch) ⇒ Object
76 77 78 |
# File 'lib/mapa/utility.rb', line 76 def gcob(new_branch) exec "git checkout -b #{new_branch}" end |
#gdif ⇒ Object
56 57 58 |
# File 'lib/mapa/utility.rb', line 56 def gdif exec 'git diff' end |
#gfo ⇒ Object
60 61 62 |
# File 'lib/mapa/utility.rb', line 60 def gfo exec 'git fetch origin' end |
#ginit ⇒ Object
17 18 19 |
# File 'lib/mapa/utility.rb', line 17 def ginit exec 'git init' 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 |
#gph(remote_branch) ⇒ Object
68 69 70 |
# File 'lib/mapa/utility.rb', line 68 def gph(remote_branch) exec "git push origin #{remote_branch}" end |
#gpl(remote_branch) ⇒ Object
64 65 66 |
# File 'lib/mapa/utility.rb', line 64 def gpl(remote_branch) exec "git pull origin #{remote_branch}" end |
#grh ⇒ Object
26 27 28 |
# File 'lib/mapa/utility.rb', line 26 def grh exec 'git reset --hard' end |
#gst ⇒ Object
34 35 36 |
# File 'lib/mapa/utility.rb', line 34 def gst exec 'git status' end |