class Mapa::Utility

Public Class Methods

new(args) click to toggle source
# 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

Public Instance Methods

ad() click to toggle source
# File lib/mapa/utility.rb, line 37
def ad
  e 'git add .'
end
br(*options) click to toggle source
# 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) click to toggle source
# File lib/mapa/utility.rb, line 45
def cm(message)
  e "git commit -m '#{message}'"
end
co(*options) click to toggle source
# 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
df() click to toggle source
# File lib/mapa/utility.rb, line 62
def df
  e 'git diff'
end
fo() click to toggle source
# File lib/mapa/utility.rb, line 66
def fo
  e 'git fetch origin'
end
go(message) click to toggle source
# File lib/mapa/utility.rb, line 29
def go(message)
  e "git add . && git commit -m '#{message}' && git branch | xargs git push origin"
end
in() click to toggle source
# File lib/mapa/utility.rb, line 25
def in
  e 'git init'
end
ph() click to toggle source
# File lib/mapa/utility.rb, line 74
def ph
  e 'git rev-parse --abbrev-ref HEAD | xargs git push origin'
end
pl() click to toggle source
# File lib/mapa/utility.rb, line 70
def pl
  e 'git rev-parse --abbrev-ref HEAD | xargs git pull origin'
end
rh() click to toggle source
# File lib/mapa/utility.rb, line 33
def rh
  e 'git reset --hard'
end
st() click to toggle source
# File lib/mapa/utility.rb, line 41
def st
  e 'git status'
end

Private Instance Methods

e(action) click to toggle source
# File lib/mapa/utility.rb, line 88
def e(action)
  exec action
end