Class: FubuRake::Storyteller

Inherits:
Object
  • Object
show all
Defined in:
lib/fuburake.rb

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ Storyteller

Returns a new instance of Storyteller.



375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
# File 'lib/fuburake.rb', line 375

def initialize(options)
  # :path

  # :compilemode -- take it from @solution.compiletarget

  # :results

  # :workspace

  # :profile

  # :title

  # :source

  # :prefix

  # :st_path

  # :specs


  @directory = options[:dir]
  @prefix = options.fetch(:prefix, 'st')
  @src = options.fetch(:source, 'src')
  @results = options.fetch(:results, 'results.htm')
  @st_path = options.fetch(:st_path, "#{@src}/packages/Storyteller2/tools")
  @title = options.fetch(:title, 'Storyteller Specs')
  @specs = options.fetch(:specs, 'specs')
  @suites = options.fetch(:suites, [])

  to_task 'run', 'ST.exe', "run #{to_args(options, @results)}", "Run the Storyteller tests for #{@directory}"
  to_task 'specs', 'ST.exe', "specs #{to_args(options, @specs)} --title \"#{@title}\"", "dump the specs for Storyteller tests at #{@directory}"
  
  @suites.each do |s|
    to_task "run:#{s.downcase}", 'ST.exe', "run #{to_args(options, @results)} -w #{s}", "Run the Storyteller tests for suite #{s}"
  end

  if !Platform.is_nix
    # StoryTellerUI.exe is a WPF application which is 

    # not supported on nix and therefore setting up the task

    # is pointless.

    openTask = Rake::Task.define_task "#{@prefix}:open" do
      tool = 'StoryTellerUI.exe'
      cmd = Platform.runtime("#{File.join(@st_path, tool)}") + " #{to_args(options, @results)}"
      puts "Opening the Storyteller UI to #{@directory}"
      sh cmd
    end
    openTask.add_description "Open the Storyteller UI for tests at #{@directory}"
    openTask.enhance [:compile]
  end
end

Instance Method Details

#to_args(options, output) ⇒ Object



430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
# File 'lib/fuburake.rb', line 430

def to_args(options, output)
  args = "#{options[:path]} #{output}"

  if (options[:compilemode] != nil)
    args += " --compile #{options[:compilemode]}"
  end

  if (options[:workspace] != nil)
    args += " --workspace #{options[:workspace]}"
  end

  if (options[:profile] != nil)
    args += " --profile #{options[:profile]}"
  end

  return args
end

#to_task(name, tool, args, description) ⇒ Object



419
420
421
422
423
424
425
426
427
428
# File 'lib/fuburake.rb', line 419

def to_task(name, tool, args, description)
  task = Rake::Task.define_task "#{@prefix}:#{name}" do
    sh Platform.runtime("#{File.join(@st_path, tool)}") + " #{args}"
  end

  task.add_description description
  task.enhance [:compile]

  return task
end