Class: GitRunner::Instruction::Base

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

Direct Known Subclasses

Display

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args, opts = {}) ⇒ Base

Returns a new instance of Base.



7
8
9
10
# File 'lib/git-runner/instructions/base.rb', line 7

def initialize(args, opts={})
  self.args = args
  self.opts = opts
end

Instance Attribute Details

#argsObject

Returns the value of attribute args.



4
5
6
# File 'lib/git-runner/instructions/base.rb', line 4

def args
  @args
end

#branchObject

Returns the value of attribute branch.



4
5
6
# File 'lib/git-runner/instructions/base.rb', line 4

def branch
  @branch
end

#optsObject

Returns the value of attribute opts.



4
5
6
# File 'lib/git-runner/instructions/base.rb', line 4

def opts
  @opts
end

Instance Method Details

#fail!Object

Raises:



31
32
33
# File 'lib/git-runner/instructions/base.rb', line 31

def fail!
  raise Failure.new(self)
end

#performObject



12
13
14
# File 'lib/git-runner/instructions/base.rb', line 12

def perform
  # No-op
end

#runObject



16
17
18
19
20
21
22
23
24
25
# File 'lib/git-runner/instructions/base.rb', line 16

def run
  if should_run?
    perform
    Text.new_line

    if opts[:fail]
      raise Failure.new(self)
    end
  end
end

#should_run?Boolean

Returns:

  • (Boolean)


27
28
29
# File 'lib/git-runner/instructions/base.rb', line 27

def should_run?
  true
end