Class: Mapa::Utility

Inherits:
Object
  • Object
show all
Defined in:
lib/mapa/utility.rb

Instance Method Summary collapse

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

#adObject



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(*options)
  if options.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(message)
  exec "git commit -m '#{message}'"
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

#difObject



56
57
58
# File 'lib/mapa/utility.rb', line 56

def dif
  exec 'git diff'
end

#foObject



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(*options)
  options = options.flatten
  exec "git add . && git commit -m '#{options[0]}' && git push origin #{options[1]}"
end

#inObject



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

#rhObject



26
27
28
# File 'lib/mapa/utility.rb', line 26

def rh
  exec 'git reset --hard'
end

#stObject



34
35
36
# File 'lib/mapa/utility.rb', line 34

def st
  exec 'git status'
end