Sha256: 1e9e3605f07092de6d7af2b33da2467a4f1a866fe0206986796c9e6a42813c31

Contents?: true

Size: 1 KB

Versions: 1

Compression:

Stored size: 1 KB

Contents

module PactBroker
  module DB
    class CleanTask < ::Rake::TaskLib

      attr_accessor :database_connection
      attr_accessor :keep

      def initialize &block
        rake_task &block
      end

      def rake_task &block
        namespace :pact_broker do
          namespace :db do
            desc "Clean unnecessary pacts and verifications from database"
            task :clean do | t, args |

              instance_eval(&block)

              require 'pact_broker/db/clean'
              require 'pact_broker/matrix/unresolved_selector'
              require 'yaml'

              keep_selectors = nil
              if keep
                keep_selectors = [*keep].collect do | hash |
                  PactBroker::Matrix::UnresolvedSelector.new(hash)
                end
              end
              # TODO time it
              results = PactBroker::DB::Clean.call(database_connection, keep: keep_selectors)
              puts results.to_yaml
            end
          end
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
pact_broker-2.69.0 lib/pact_broker/tasks/clean_task.rb