Sha256: de7aea20a9e2562025ffc30f39ae0b10bd395448cbfb48d278550245cc4274fe

Contents?: true

Size: 1013 Bytes

Versions: 1

Compression:

Stored size: 1013 Bytes

Contents

module Wool
  module Rake
    class WoolTask
      class Settings < Struct.new(:libs, :extras, :options, :using, :fix)
        def initialize(*args)
          super
          self.libs ||= []
          self.extras ||= []
          self.options ||= ''
          self.using ||= []
          self.fix ||= []
        end
      end

      attr_accessor :settings

      def initialize(task_name)
        @settings = Settings.new
        yield @settings if block_given?
        @settings.using = [:all] if @settings.using.empty?
        task task_name do
          run
        end
      end

      def run
        files = []
        if @settings.libs.any?
          @settings.libs.each do |lib|
            Dir["#{lib}/**/*.rb"].each do |file|
              files << file
            end
          end
        end
        runner = Wool::Runner.new(self.settings.options.split(/\s/) + files)
        runner.using = self.settings.using
        runner.fix = self.settings.fix
        runner.run
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
wool-0.5.1 lib/wool/rake/task.rb