Sha256: a6e9518bef24679c8342b0909da847e84d7d32d5d753589aa80999172bd26a5e

Contents?: true

Size: 1.54 KB

Versions: 2

Compression:

Stored size: 1.54 KB

Contents

require 'fileutils'
require 'rake/tasklib'

module ProbeDockProbe

  class Tasks < ::Rake::TaskLib

    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

    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

    def uid_manager
      UID.new workspace: @workspace
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
probedock-ruby-0.2.1 lib/probe_dock_ruby/tasks.rb
probedock-ruby-0.2.0 lib/probe_dock_ruby/tasks.rb