Class: Ora::Cli::Task

Inherits:
Object
  • Object
show all
Defined in:
lib/ora/cli/task.rb

Constant Summary collapse

DEFAULT_DEVELOP_BRANCH =
'develop'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(from, inputs: [], print: Print.new, develop_branch: nil) ⇒ Task

Returns a new instance of Task.



13
14
15
16
17
18
19
20
# File 'lib/ora/cli/task.rb', line 13

def initialize(from, inputs: [], print: Print.new, develop_branch: nil)
  @from           = from
  @bash           = Bash.new(self, from: @from, print: print)
  @branch         = current_branch
  @stdin          = Stdin.new(bash: @bash, print: print, inputs: inputs)
  @print          = print
  @develop_branch = develop_branch || DEFAULT_DEVELOP_BRANCH
end

Instance Attribute Details

#branchObject (readonly)

Returns the value of attribute branch.



9
10
11
# File 'lib/ora/cli/task.rb', line 9

def branch
  @branch
end

#develop_branchObject (readonly)

Returns the value of attribute develop_branch.



9
10
11
# File 'lib/ora/cli/task.rb', line 9

def develop_branch
  @develop_branch
end

Returns the value of attribute print.



9
10
11
# File 'lib/ora/cli/task.rb', line 9

def print
  @print
end

#stdinObject (readonly)

Returns the value of attribute stdin.



9
10
11
# File 'lib/ora/cli/task.rb', line 9

def stdin
  @stdin
end

Instance Method Details

#commandsObject

Raises:



29
30
31
# File 'lib/ora/cli/task.rb', line 29

def commands
  raise PreconditionError, "Override this method in subclass."
end

#runObject



22
23
24
25
26
27
# File 'lib/ora/cli/task.rb', line 22

def run
  @bash.run commands
  save_on_fail
rescue PreconditionError => e
  @print.red("Precondition not met!\n#{e.message}")
end

#success?Boolean

Returns:

  • (Boolean)


33
34
35
# File 'lib/ora/cli/task.rb', line 33

def success?
  @bash.success?
end