Sha256: 4e8281c1cf49a45251a1f8765b653257ba40d64b6fbf8c44a1b855bf1ddb2813

Contents?: true

Size: 1.08 KB

Versions: 1

Compression:

Stored size: 1.08 KB

Contents

# frozen_string_literal: true

class Tasks
  attr_accessor :env

  @@default = nil

  def initialize(env = nil)
    @@default = self
    @env = env
    @env = Environment.new if @env.nil?
  end

  def execute(value)
    if value.respond_to?(:execute)
      value.update if value.respond_to?(:update)
      value.execute
    elsif value.is_a?(String)
      puts `#{value}`
    elsif value.is_a?(Array)
      value.each { |e| execute(e) }
    end
  end

  def execute_task(task)
    if defined?(COMMANDS) && COMMANDS.key?(task)
      puts DELIMITER if defined?(DEBUG)
      puts ":#{task}" unless @env.colorize?
      if @env.colorize?
        require "ansi/code"
        puts ANSI.white + ANSI.bold + ":#{task}" + ANSI.reset if @env.colorize?
      end
      execute(COMMANDS[task])
    end
  end

  def self.execute_task(task)
    @@default = Tasks.new if @@default.nil?
    @@default.execute_task task
  end
end

%w[add analyze build clobber commit
   doc info package publish pull push setup test
   update].each { |name| require_relative("tasks/#{name}.rb") }

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
dev-2.1.154 lib/tasks.rb