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
16
17
18
19
20
21
22
23
# File 'lib/mapa/utility.rb', line 3

def initialize(args)
  action = args[0].to_sym
  option = args[1]
  options = args[1..-1]
  if self.respond_to? action
    case self.method(action).arity
    when 1
      self.send(action, option)
    when -1
      self.send(action, options)
    else
      self.send(action)
    end
  else
    if not(options.empty?)
      e "git #{action.to_s} #{options}"
    else
      e "git #{action.to_s}"
    end
  end
end

Instance Method Details

#adObject



37
38
39
# File 'lib/mapa/utility.rb', line 37

def ad
  e 'git add .'
end

#br(*options) ⇒ Object



49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/mapa/utility.rb', line 49

def br(*options)
  case (patterns = options.flatten).first
  when '-a'
    e 'git branch'
  when '-d'
    patterns[1..-1].each do |branch|
      e "git branch | grep '#{branch}' | xargs git branch -D"
    end
  else
    e 'git rev-parse --abbrev-ref HEAD'
  end
end

#cm(message) ⇒ Object



45
46
47
# File 'lib/mapa/utility.rb', line 45

def cm(message)
  e "git commit -m '#{message}'"
end

#co(*options) ⇒ Object



78
79
80
81
82
83
84
85
# File 'lib/mapa/utility.rb', line 78

def co(*options)
  case (options = options.flatten).first
  when '-b'
    e "git checkout -b #{options[1]}"
  else
    e "git checkout '#{options[1]}' && git rev-parse --abbrev-ref HEAD"
  end
end

#dfObject



62
63
64
# File 'lib/mapa/utility.rb', line 62

def df
  e 'git diff'
end

#foObject



66
67
68
# File 'lib/mapa/utility.rb', line 66

def fo
  e 'git fetch origin'
end

#go(message) ⇒ Object



29
30
31
# File 'lib/mapa/utility.rb', line 29

def go(message)
  e "git add . && git commit -m '#{message}' && git branch | xargs git push origin"
end

#inObject



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

def in
  e 'git init'
end

#phObject



74
75
76
# File 'lib/mapa/utility.rb', line 74

def ph
  e 'git rev-parse --abbrev-ref HEAD | xargs git push origin'
end

#plObject



70
71
72
# File 'lib/mapa/utility.rb', line 70

def pl
  e 'git rev-parse --abbrev-ref HEAD | xargs git pull origin'
end

#rhObject



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

def rh
  e 'git reset --hard'
end

#stObject



41
42
43
# File 'lib/mapa/utility.rb', line 41

def st
  e 'git status'
end