Sha256: b3eeae906a62da17a9f5ea870c2af64c1656199b59e3ae944d9324ca85532117

Contents?: true

Size: 1.5 KB

Versions: 2

Compression:

Stored size: 1.5 KB

Contents

require 'uncool/meta/data'
require 'uncool/trace'

module Uncool

  #
  class App

    #
    def initialize(options={})
      @options    = options
      @namespaces = options[:namespaces]
    end

    #
    attr :namespaces

    #
    alias_method :targets, :namespaces

    #
    attr :options

    #
    #def targets
    #  @targets ||= namespaces.map{ |ns| eval(ns, TOPLEVEL_BINDING) }
    #end

    #
    def trace
      @trace ||= Trace.new(targets, options)
    end

    #
    def analysis
      @analysis ||= Analysis.new(trace, options)
    end

    #
    def report
      @report ||= Report.new(analysis, options)
    end

    # This is the main method for activating hte trace and
    # recording the results.
    def log(logdir=nil)
      logdir = logdir || options[:output]
      trace.setup
      at_exit {
        trace.deactivate
        logdir ? report.save(logdir) : report.display
      }
      trace.activate
    end

    #
    def generate(scripts)
      require 'uncool/generator/ko'
      require 'uncool/generator/qed'
      require 'uncool/generator/lemon'

      generator = (
        case options[:framework]
        when :ko
          GeneratorKO.new(options)
        when :qed
          GeneratorQED.new(options)
        when :rspec
          #GeneratorRSpec.new(options)
        when :cuke, :cucumber
          #GeneratorCucumber.new(options)
        else
          GeneratorLemon.new(options)
        end
      )

      scripts.each{ |script| require(script) }

      generator.generate
    end

  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
uncool-1.0.1 lib/uncool/app.rb
uncool-1.0.0 lib/uncool/app.rb