Class: GitHub::Command
Direct Known Subclasses
Defined Under Namespace
Classes: Shell
Instance Method Summary collapse
- #call(*args) ⇒ Object
- #current_user?(user) ⇒ Boolean
- #die(message) ⇒ Object
- #git(command) ⇒ Object
- #git_exec(command) ⇒ Object
- #github_user ⇒ Object
- #helper ⇒ Object
-
#initialize(block) ⇒ Command
constructor
A new instance of Command.
- #options ⇒ Object
- #pgit(*command) ⇒ Object
- #run(method, command) ⇒ Object
- #sh(*command) ⇒ Object
- #shell_user ⇒ Object
Constructor Details
#initialize(block) ⇒ Command
Returns a new instance of Command.
14 15 16 |
# File 'lib/github/command.rb', line 14 def initialize(block) (class << self;self end).send :define_method, :command, &block end |
Instance Method Details
#call(*args) ⇒ Object
18 19 20 21 22 |
# File 'lib/github/command.rb', line 18 def call(*args) arity = method(:command).arity args << nil while args.size < arity send :command, *args end |
#current_user?(user) ⇒ Boolean
73 74 75 |
# File 'lib/github/command.rb', line 73 def current_user?(user) user == github_user || user == shell_user end |
#die(message) ⇒ Object
60 61 62 63 |
# File 'lib/github/command.rb', line 60 def die() puts "=> #{}" exit! end |
#git(command) ⇒ Object
36 37 38 |
# File 'lib/github/command.rb', line 36 def git(command) run :sh, command end |
#git_exec(command) ⇒ Object
40 41 42 |
# File 'lib/github/command.rb', line 40 def git_exec(command) run :exec, command end |
#github_user ⇒ Object
65 66 67 |
# File 'lib/github/command.rb', line 65 def github_user git("config --get github.user") end |
#helper ⇒ Object
24 25 26 |
# File 'lib/github/command.rb', line 24 def helper @helper ||= Helper.new end |
#pgit(*command) ⇒ Object
32 33 34 |
# File 'lib/github/command.rb', line 32 def pgit(*command) puts git(*command) end |
#run(method, command) ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/github/command.rb', line 44 def run(method, command) if command.is_a? Array command = [ 'git', command ].flatten GitHub.learn command.join(' ') else command = 'git ' + command GitHub.learn command end send method, *command end |
#sh(*command) ⇒ Object
56 57 58 |
# File 'lib/github/command.rb', line 56 def sh(*command) Shell.new(*command).run end |
#shell_user ⇒ Object
69 70 71 |
# File 'lib/github/command.rb', line 69 def shell_user ENV['USER'] end |