Class: Mapa::Utility
- Inherits:
-
Object
- Object
- Mapa::Utility
- Defined in:
- lib/mapa/utility.rb
Instance Method Summary collapse
- #ad ⇒ Object
- #br(*options) ⇒ Object
- #cm(message) ⇒ Object
- #co(*options) ⇒ Object
- #df ⇒ Object
- #fo ⇒ Object
- #go(message) ⇒ Object
- #in ⇒ Object
-
#initialize(args) ⇒ Utility
constructor
A new instance of Utility.
- #ph ⇒ Object
- #pl ⇒ 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 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] = args[1..-1] if self.respond_to? action case self.method(action).arity when 1 self.send(action, option) when -1 self.send(action, ) else self.send(action) end else if not(.empty?) e "git #{action.to_s} #{}" else e "git #{action.to_s}" end end end |
Instance Method Details
#ad ⇒ Object
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(*) case (patterns = .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() e "git commit -m '#{}'" end |
#co(*options) ⇒ Object
78 79 80 81 82 83 84 85 |
# File 'lib/mapa/utility.rb', line 78 def co(*) case ( = .flatten).first when '-b' e "git checkout -b #{[1]}" else e "git checkout '#{[1]}' && git rev-parse --abbrev-ref HEAD" end end |
#df ⇒ Object
62 63 64 |
# File 'lib/mapa/utility.rb', line 62 def df e 'git diff' end |
#fo ⇒ Object
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() e "git add . && git commit -m '#{}' && git branch | xargs git push origin" end |
#in ⇒ Object
25 26 27 |
# File 'lib/mapa/utility.rb', line 25 def in e 'git init' end |
#ph ⇒ Object
74 75 76 |
# File 'lib/mapa/utility.rb', line 74 def ph e 'git rev-parse --abbrev-ref HEAD | xargs git push origin' end |
#pl ⇒ Object
70 71 72 |
# File 'lib/mapa/utility.rb', line 70 def pl e 'git rev-parse --abbrev-ref HEAD | xargs git pull origin' end |
#rh ⇒ Object
33 34 35 |
# File 'lib/mapa/utility.rb', line 33 def rh e 'git reset --hard' end |
#st ⇒ Object
41 42 43 |
# File 'lib/mapa/utility.rb', line 41 def st e 'git status' end |