Class: GitRunner::Instruction

Inherits:
Object
  • Object
show all
Defined in:
lib/git-runner/instruction.rb,
lib/git-runner/instruction.rb,
lib/git-runner/instructions/base.rb,
lib/git-runner/instructions/display.rb

Defined Under Namespace

Classes: Base, Display, Failure

Class Method Summary collapse

Class Method Details

.from_raw(raw) ⇒ Object



19
20
21
# File 'lib/git-runner/instruction.rb', line 19

def self.from_raw(raw)
  new(*%r[#{Regexp.escape(Configuration.instruction_prefix)}\s*(\w+)\s*(.*)$].match(raw).captures)
end

.new(name, args = {}) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/git-runner/instruction.rb', line 6

def self.new(name, args={})
  begin
    const_get(name).new(args)

  rescue NameError => e
    # Display message for missing instruction, halt further execution
    Display.new(Text.red("\u2716 Instruction not found: #{name}"), {
      :fail     => true,
      :priority => true
    })
  end
end