Sha256: b2d41a7adb620f9ec43bc74ff9d708611f9c8b53e539531d06bb6dd93c24ead5

Contents?: true

Size: 1.84 KB

Versions: 31

Compression:

Stored size: 1.84 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 raw_load_rakefile
          glob("#{fulmar_task_dir}/initialization/*.rake") do |name|
            Rake.load_rakefile name
          end
          super
        end

        def wrap_environment
          proc do |t, args|
            configuration = Fulmar::Domain::Service::ConfigurationService.instance
            environment = configuration.environment
            target = configuration.target

            yield(t, args) 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

        def standard_rake_options
          options = super
          options.reject { |option| option[0] == '--version' }
          options << [
            '--version',
            '-V',
            'Display the program version.',
            lambda do |_value|
              puts "fulmar #{Fulmar::VERSION} (using rake, version #{RAKEVERSION})"
              exit
            end
          ]
        end
      end
    end
  end
end

Version data entries

31 entries across 31 versions & 1 rubygems

Version Path
fulmar-1.8.0 lib/fulmar/domain/service/application_service.rb
fulmar-1.7.5 lib/fulmar/domain/service/application_service.rb
fulmar-1.7.4 lib/fulmar/domain/service/application_service.rb
fulmar-1.7.3 lib/fulmar/domain/service/application_service.rb
fulmar-1.7.2 lib/fulmar/domain/service/application_service.rb
fulmar-1.7.1 lib/fulmar/domain/service/application_service.rb
fulmar-1.7.0 lib/fulmar/domain/service/application_service.rb
fulmar-1.6.4 lib/fulmar/domain/service/application_service.rb
fulmar-1.6.3 lib/fulmar/domain/service/application_service.rb
fulmar-1.6.2 lib/fulmar/domain/service/application_service.rb
fulmar-1.6.1 lib/fulmar/domain/service/application_service.rb