Sha256: 856d8e9679beaa671b40679205e041a396a1ff42b5267ec62d10c33c2b669d5f

Contents?: true

Size: 1.25 KB

Versions: 4

Compression:

Stored size: 1.25 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)
        end

        def name
          'fulmar'
        end

        def run
          Rake.application = self
          super
        end

        def init
          super
          options.rakelib << fulmar_task_dir
          options.rakelib << 'Fulmar'
        end

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

        def wrap_environment
          proc 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_task_dir
          File.expand_path(File.join(File.dirname(__FILE__), '..', 'task'))
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
fulmar-1.3.0 lib/fulmar/domain/service/application_service.rb
fulmar-1.2.1 lib/fulmar/domain/service/application_service.rb
fulmar-1.2.0 lib/fulmar/domain/service/application_service.rb
fulmar-1.1.0 lib/fulmar/domain/service/application_service.rb