Sha256: e3474a68f75e578acbf6206eac59372ac4841b60f15c9d71058189ec3761120b

Contents?: true

Size: 1.41 KB

Versions: 3

Compression:

Stored size: 1.41 KB

Contents

# Processors can perform any action on a release
module Roger::Release::Processors
  extend Roger::Helpers::Registration

  # Abstract Processor class
  class Base
    attr_reader :options, :release

    class << self
      attr_writer :name

      # Name of this processor
      def name
        @name || raise(ArgumentError, "Implement in subclass")
      end
    end

    # Default options for this processor
    def default_options
      {}
    end

    # Name of this processor.
    # - Can be set by setting the :name config in the release block
    # - Can be overwritten in implementation if needed
    def name
      options && options[:name] || self.class.name
    end

    def call(release, options = {})
      @release = release
      @options = {}.update(default_options)
      @options.update(options) if options
      @options.update(my_project_options)

      # Stop immideatly if we've been disabled
      return if @options[:disable]

      perform
    end

    protected

    # The options passed through the project. This can contain
    # command line options
    def my_project_options
      project_options = release.project.options
      project_options[:release] && project_options[:release][name] || {}
    end

    def perform
      raise ArgumentError, "Implement in subclass"
    end
  end
end

require File.dirname(__FILE__) + "/processors/mockup"
require File.dirname(__FILE__) + "/processors/url_relativizer"

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
roger-1.8.0 lib/roger/release/processors.rb
roger-1.7.2 lib/roger/release/processors.rb
roger-1.7.1 lib/roger/release/processors.rb