Sha256: 613c13602da8459d2fdf6150ee69b0686d367de55c57d3996bee9cbe43ebd40e

Contents?: true

Size: 1.26 KB

Versions: 1

Compression:

Stored size: 1.26 KB

Contents

require 'rake'
require 'shenandoah/runner'
require 'shenandoah/server'

module Shenandoah
  class Tasks
    attr_accessor :locator, :options, :runner
    
    def initialize(options = {})
      @options = options
      @locator =
        if options[:locator]
          options[:locator]
        else
          DefaultLocator.new(options)
        end
      @runner = Shenandoah::Runner.new(@locator)
      create_serve_task
      create_shell_task
      create_run_task
    end
    
    def run_specs
      files = @locator.spec_files
      if ENV['SHEN_SPEC']
        files = files.select { |f| f =~ /#{ENV['SHEN_SPEC']}/ }
      end
      successes = @runner.run_console(files)
      if (successes.size != files.size)
        raise "Shenandoah specs failed!"
      end
    end
    
    protected
    
    def create_serve_task
      task('shen:serve') do |t|
        Shenandoah::Server.set :locator, @locator
        if @options[:project_name]
          Shenandoah::Server.set :project_name, @options[:project_name]
        end
        Shenandoah::Server.run!
      end
    end
    
    def create_shell_task
      task('shen:shell') do |t|
        @runner.run_shell
      end
    end
    
    def create_run_task
      task('shen:spec') do |t|
        run_specs
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
shenandoah-0.0.0 lib/shenandoah/tasks.rb