Sha256: c1e66cc03568b27c67f88e89230ad800fdb6c08e0527d83d23032860e3ab715b

Contents?: true

Size: 1.35 KB

Versions: 1

Compression:

Stored size: 1.35 KB

Contents

require 'albacore/application'

# The albacore module instance methods.
module Albacore
  class << self
    # Accessor for the Albacore application. Configuration
    # and similar singleton values will be stored in this
    # instance. Multiple calls will yield the same instance.
    def application
      @application ||= Albacore::Application.new
    end

    # set the application -- good for testing
    # the infrastructure of albacore by resetting the
    # state after each test
    def set_application app
      @application = app
    end

    # Defines a new task with all of what that entails:
    # will call application.define_task.
    def define_task *args, &block
      # delegate to the application singleton
      application.define_task *args, &block
    end

    # Set the global albacore logging level.
    def log_level= level
      application.logger.level = level
    end

    # Use to write to STDOUT (by default)
    def puts *args
      application.puts *args
    end

    def events
      @events ||= {}
    end

    def subscribe event, &block
      event = event.to_sym unless event.is_a? Symbol
      events[event] ||= Set.new
      events[event].add block
    end

    def publish event, obj
      if events.member? event
        events[event].each { |m| m.call(obj) }
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
albacore-0.6.2.rc1 lib/albacore/albacore_module.rb