Sha256: fcdeca55826c17086ad67370b9c2c85b0fee2fbe4801311904df90bb35676453

Contents?: true

Size: 647 Bytes

Versions: 15

Compression:

Stored size: 647 Bytes

Contents

require 'forwardable'
require 'cl/config'
require 'cl/ui'

class Cl
  class Ctx
    extend Forwardable

    def_delegators :ui, :puts, :stdout, :announce, :info, :notice, :warn,
      :error, :success, :cmd

    attr_accessor :config, :name, :opts

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

    def ui
      @ui ||= opts[:ui] || Ui.new(self, opts)
    end

    def abort(error, *strs)
      abort? ? ui.abort(error, *strs) : raise(error)
    end

    def abort?
      !opts[:abort].is_a?(FalseClass)
    end

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

Version data entries

15 entries across 15 versions & 2 rubygems

Version Path
travis-cl-1.2.4 lib/cl/ctx.rb
cl-1.2.4 lib/cl/ctx.rb
cl-1.2.3 lib/cl/ctx.rb
cl-1.2.2 lib/cl/ctx.rb
cl-1.2.1 lib/cl/ctx.rb
cl-1.2.0 lib/cl/ctx.rb
cl-1.1.5 lib/cl/ctx.rb
cl-1.1.4 lib/cl/ctx.rb
cl-1.1.3 lib/cl/ctx.rb
cl-1.1.2 lib/cl/ctx.rb
cl-1.1.1 lib/cl/ctx.rb
cl-1.1.0 lib/cl/ctx.rb
cl-1.0.5 lib/cl/ctx.rb
cl-1.0.4 lib/cl/ctx.rb
cl-1.0.3 lib/cl/ctx.rb