class ProbeDockProbe::Tasks

Public Class Methods

new(workspace: nil) click to toggle source
# File lib/probe_dock_ruby/tasks.rb, line 8
def initialize workspace: nil

  @workspace = workspace || ENV['PROBEDOCK_WORKSPACE']

  namespace :spec do

    namespace 'probedock' do

      desc "Generate a test run UID to group test results in Probe Dock (stored in an environment variable)"
      task :uid do
        trace do
          uid = uid_manager.generate_uid_to_env
          puts Paint["Probe Dock - Generated UID for test run: #{uid}", :cyan]
        end
      end

      namespace :uid do

        desc "Generate a test run UID to group test results in Probe Dock (stored in a file)"
        task :file do
          trace do
            uid = uid_manager.generate_uid_to_file
            puts Paint["Probe Dock - Generated UID for test run: #{uid}", :cyan]
          end
        end

        desc "Clean the test run UID (file and environment variable)"
        task :clean do
          trace do
            uid_manager.clean_uid
            puts Paint["Probe Dock - Cleaned test run UID", :cyan]
          end
        end
      end
    end
  end
end

Private Instance Methods

trace(&block) click to toggle source
# File lib/probe_dock_ruby/tasks.rb, line 48
def trace &block
  if Rake.application.options.trace
    block.call
  else
    begin
      block.call
    rescue UID::Error => e
      warn Paint["Probe Dock - #{e.message}", :red]
    end
  end
end
uid_manager() click to toggle source
# File lib/probe_dock_ruby/tasks.rb, line 60
def uid_manager
  UID.new workspace: @workspace
end