Sha256: 4607fe2de8c8faaa8b220ca2170c8c4a343814bb60c8732907ac926a45031268

Contents?: true

Size: 1.19 KB

Versions: 3

Compression:

Stored size: 1.19 KB

Contents

require 'rake'

module Fulmar
  module Domain
    module Service
      # The main application which extends rake
      class ApplicationService < Rake::Application
        def initialize
          super
          @rakefiles = %w(fulmarfile Fulmarfile fulmarfile.rb Fulmarfile.rb)
          @rakefiles.push(*fulmar_tasks)
        end

        def name
          'fulmar'
        end

        def run
          Rake.application = self
          super
        end

        def define_task(task_class, *args, &block)
          super(task_class, *args, &wrap_environment(&block))
        end

        def wrap_environment
          Proc.new do
            configuration = Fulmar::Domain::Service::ConfigurationService.instance
            environment = configuration.environment
            target = configuration.target

            yield if block_given?

            configuration.environment = environment unless environment.nil?
            configuration.target = target unless target.nil?
          end
        end

        # Add fulmar application tasks
        def fulmar_tasks
          Dir.glob(File.expand_path(File.join(File.dirname(__FILE__), '../', 'task')) + '/*.rake')
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
fulmar-0.6.5 lib/fulmar/domain/service/application_service.rb
fulmar-0.6.4 lib/fulmar/domain/service/application_service.rb
fulmar-0.6.3 lib/fulmar/domain/service/application_service.rb