Class: GitHub::Command

Inherits:
Object
  • Object
show all
Defined in:
lib/github/command.rb

Defined Under Namespace

Classes: Shell

Instance Method Summary collapse

Constructor Details

#initialize(block) ⇒ Command

Returns a new instance of Command.



16
17
18
# File 'lib/github/command.rb', line 16

def initialize(block)
  (class << self;self end).send :define_method, :command, &block
end

Instance Method Details

#call(*args) ⇒ Object



20
21
22
23
24
# File 'lib/github/command.rb', line 20

def call(*args)
  arity = method(:command).arity
  args << nil while args.size < arity
  send :command, *args
end

#die(message) ⇒ Object



50
51
52
53
# File 'lib/github/command.rb', line 50

def die(message)
  puts "=> #{message}"
  exit!
end

#git(*command) ⇒ Object



38
39
40
# File 'lib/github/command.rb', line 38

def git(*command)
  sh ['git', command].flatten.join(' ')
end

#git_exec(*command) ⇒ Object



42
43
44
# File 'lib/github/command.rb', line 42

def git_exec(*command)
  exec ['git', command].flatten.join(' ')
end

#helperObject



26
27
28
# File 'lib/github/command.rb', line 26

def helper
  @helper ||= Helper.new
end

#optionsObject



30
31
32
# File 'lib/github/command.rb', line 30

def options
  GitHub.options
end

#pgit(*command) ⇒ Object



34
35
36
# File 'lib/github/command.rb', line 34

def pgit(*command)
  puts git(*command)
end

#sh(*command) ⇒ Object



46
47
48
# File 'lib/github/command.rb', line 46

def sh(*command)
  Shell.new(*command).run
end