Class: Cl::Ctx

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/cl/ctx.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, opts = {}) ⇒ Ctx

Returns a new instance of Ctx.


14
15
16
17
# File 'lib/cl/ctx.rb', line 14

def initialize(name, opts = {})
  @config = Config.new(name).to_h
  @ui = Ui.new(self, opts)
end

Instance Attribute Details

#configObject

Returns the value of attribute config


12
13
14
# File 'lib/cl/ctx.rb', line 12

def config
  @config
end

#uiObject

Returns the value of attribute ui


12
13
14
# File 'lib/cl/ctx.rb', line 12

def ui
  @ui
end

Instance Method Details

#abort(str) ⇒ Object


19
20
21
22
23
# File 'lib/cl/ctx.rb', line 19

def abort(str)
  fail(str) if test?
  ui.error(str)
  exit 1
end

#test?Boolean

Returns:

  • (Boolean)

25
26
27
# File 'lib/cl/ctx.rb', line 25

def test?
  ENV['ENV'] == 'test'
end