Sha256: 96dc3f039f02c80378175ac46cdc1a154b39c9c7a15415fdf01122a59bef5bfe

Contents?: true

Size: 1.51 KB

Versions: 6

Compression:

Stored size: 1.51 KB

Contents

require 'rake'
require 'tap/support/gems/rake'

module Tap
  module Tasks
    # :startdoc::manifest run rake tasks
    # 
    # Simply enques the specified rake task(s) for execution.  Useful when a
    # rake task needs to be executed within a workflow.  For example these
    # are equivalent:
    #
    #   % tap run -- rake test
    #   % rake test
    # 
    # The only exeception is in the use of the --help option.  Use --rake-help
    # to access the rake help, and --help to access this help.
    #
    class Rake < Tap::Task
      class << self
      
        # Overrides Tap::Support::FrameworkClass#parse! to do  
        # nothing so that all args get passed forward to rake.
        def parse!(argv, app=Tap::App.instance) # => instance, argv
          if argv.include?('--help')
            puts help
            exit
          end
          [new({}, default_name, app), argv.collect {|arg| arg == '--rake-help' ? '--help' : arg}]
        end
      end
      
      def enq(*argv)
        rake = ::Rake.application
        
        # run as if from command line using argv
        current_argv = ARGV.dup
        begin
          ARGV.clear
          ARGV.concat(argv)
    
          # now follow the same protocol as 
          # in run, handling options
          rake.init
          rake.load_rakefile
        ensure
          ARGV.clear
          ARGV.concat(current_argv)
        end
      
        rake.enq_top_level(app)
      
        nil
      end
      
    end
  end
end

Version data entries

6 entries across 6 versions & 2 rubygems

Version Path
bahuvrihi-tap-0.11.0 lib/tap/tasks/rake.rb
bahuvrihi-tap-0.11.1 lib/tap/tasks/rake.rb
bahuvrihi-tap-0.11.2 lib/tap/tasks/rake.rb
bahuvrihi-tap-0.12.0 lib/tap/tasks/rake.rb
tap-0.11.0 lib/tap/tasks/rake.rb
tap-0.11.1 lib/tap/tasks/rake.rb