Class: Turn::Configuration

### Home Classes Methods

### In Files

- lib/turn/configuration.rb

### Parent

Object

### Methods

- ::new
- #ansi=
- #ansi?
- #decorate_reporter
- #decorator_class
- #environment_ansi
- #environment_format
- #environment_mode
- #environment_trace
- #exclude=
- #files
- #live?
- #loadpath=
- #natural?
- #reporter
- #reporter_class
- #reporter_options
- #requires=
- #suite_name
- #tests=
- #verbose?

### Files

- History.txt
- LICENSE.txt
- Release.txt
- Version.txt

### Class/Module Index

Quicksearch

- Turn
- Turn::Colorize
- Turn::Command
- Turn::Configuration
- Turn::Controller
- Turn::CrossRunner
- Turn::CueReporter
- Turn::DotReporter
- Turn::IsoRunner
- Turn::MarshalReporter
- Turn::MiniRunner
- Turn::OutlineReporter
- Turn::PrettyReporter
- Turn::ProgressReporter
- Turn::Reporter
- Turn::SoloRunner
- Turn::TestCase
- Turn::TestMethod
- Turn::TestRunner
- Turn::TestSuite
- Turn::ToptenDecorator
- Test
- Test::Unit
- Test::Unit::Failure
- Object
- String

No matching classes.

# Turn::Configuration

Central interface for Turn configuration.

### Attributes

exclude[R]

List of file names or globs to exclude from `tests` list.

format[RW]

Reporter type.

framework[RW]

Test framework, either `:minitest` or `:testunit`. TODO: Is this used any more?

live[RW]

Test against live install (i.e. Don't use loadpath option)

loadpath[R]

Add these folders to the $LOAD_PATH.

log[RW]

Log results? May be true/false or log file name. (TODO)

mark[RW]

Runtime threshold.

matchcase[RW]

Regexp pattern that all test cases must match to be eligible to run.

mode[RW]

Report modifier. These act as decorators on the reporter class.

natural[RW]

Use natural language case names.

pattern[RW]

Regexp pattern that all test name's must match to be eligible to run.

requires[R]

Libs to require when running tests.

runmode[RW]

Run mode, which defaults to `nil`, but can also be `:solo`, `:cross` or `:marshal`.

tests[R]

List of if file names or glob pattern of tests to run.

trace[RW]

Enable full backtrace

verbose[RW]

Verbose output?

### Public Class Methods

new() click to toggle source

    # File lib/turn/configuration.rb, line 91
    def initialize
      yield(self) if block_given?
      initialize_defaults
    end

### Public Instance Methods

ansi=(boolean) click to toggle source

    # File lib/turn/configuration.rb, line 147
    def ansi=(boolean)
      @ansi = boolean ? true : false
    end

ansi?() click to toggle source

    # File lib/turn/configuration.rb, line 84
    def ansi?
      @ansi
    end

decorate_reporter(reporter) click to toggle source

    # File lib/turn/configuration.rb, line 212
    def decorate_reporter(reporter)
      if mode
        decorator_class.new(reporter)
      else
        reporter
      end
    end

decorator_class() click to toggle source

    # File lib/turn/configuration.rb, line 221
    def decorator_class
      return nil unless mode

      class_name = mode.to_s.capitalize + "Decorator"

      path = "turn/decorators/#{mode}_decorator"
      [File.expand_path('~'), Dir.pwd].each do |dir|
        file = File.join(dir, ".turn", "decorators", "#{mode}_reporter.rb")
        path = file if File.exist?(file)
      end

      require path

      Turn.const_get(class_name)
    end

environment_ansi() click to toggle source

    # File lib/turn/configuration.rb, line 258
    def environment_ansi
      case ENV['ansi']
      when 'true','yes','on'
        true
      when 'false','no','off'
        false
      else
        nil
      end
    end

environment_format() click to toggle source

    # File lib/turn/configuration.rb, line 243
    def environment_format
      ENV['rpt']
    end

environment_mode() click to toggle source

    # File lib/turn/configuration.rb, line 248
    def environment_mode
      ENV['mode']
    end

environment_trace() click to toggle source

    # File lib/turn/configuration.rb, line 253
    def environment_trace
      (ENV['backtrace'] ? ENV['backtrace'].to_i : nil)
    end

exclude=(paths) click to toggle source

    # File lib/turn/configuration.rb, line 159
    def exclude=(paths)
      @exclude = list_option(paths)
    end

files() click to toggle source

Test files.

    # File lib/turn/configuration.rb, line 168
    def files
      @files ||= (
        fs = tests.map do |t|
          File.directory?(t) ? Dir[File.join(t, '**', '*')] : Dir[t]
        end
        fs = fs.flatten.reject{ |f| File.directory?(f) }

        ex = exclude.map do |x|
          File.directory?(x) ? Dir[File.join(x, '**', '*')] : Dir[x]
        end
        ex = ex.flatten.reject{ |f| File.directory?(f) }

        (fs - ex).uniq.map{ |f| File.expand_path(f) }
      ).flatten
    end

live?() click to toggle source

    # File lib/turn/configuration.rb, line 74
    def live?
      @live
    end

loadpath=(paths) click to toggle source

    # File lib/turn/configuration.rb, line 155
    def loadpath=(paths)
      @loadpath = list_option(paths)
    end

natural?() click to toggle source

    # File lib/turn/configuration.rb, line 79
    def natural?
      @natural
    end

reporter() click to toggle source

Get selected reporter with any mode decorator.

    # File lib/turn/configuration.rb, line 190
    def reporter
      @reporter ||= decorate_reporter(reporter_class.new($stdout, reporter_options))
    end

reporter_class() click to toggle source

Load reporter based on output mode and return its class.

    # File lib/turn/configuration.rb, line 195
    def reporter_class
      rpt_format = format || :pretty
      class_name = rpt_format.to_s.capitalize + "Reporter"

      path = "turn/reporters/#{rpt_format}_reporter"

      [File.expand_path('~'), Dir.pwd].each do |dir|
        file = File.join(dir, ".turn", "reporters", "#{rpt_format}_reporter.rb")
        path = file if File.exist?(file)
      end

      require path

      Turn.const_get(class_name)
    end

reporter_options() click to toggle source

    # File lib/turn/configuration.rb, line 238
    def reporter_options
      { :trace=>trace, :natural=>natural?, :verbose=>verbose?, :mark=>mark }
    end

requires=(paths) click to toggle source

    # File lib/turn/configuration.rb, line 163
    def requires=(paths)
      @requires = list_option(paths)
    end

suite_name() click to toggle source

TODO: Better name ?

    # File lib/turn/configuration.rb, line 185
    def suite_name
      files.map{ |path| File.dirname(path).sub(Dir.pwd+'/','') }.uniq.join(',')
    end

tests=(paths) click to toggle source

    # File lib/turn/configuration.rb, line 151
    def tests=(paths)
      @tests = list_option(paths)
    end

verbose?() click to toggle source

    # File lib/turn/configuration.rb, line 69
    def verbose?
      @verbose
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.