Sha256: b3023fdee5243e6ddb80c7fdfe7274e675eca54848c041dd89568867eb492b71

Contents?: true

Size: 1.31 KB

Versions: 3

Compression:

Stored size: 1.31 KB

Contents

module Knapsack
  module Distributors
    class BaseDistributor
      attr_reader :report, :node_specs, :spec_pattern

      def initialize(args={})
        @report = args[:report] || default_report
        @ci_node_total = args[:ci_node_total] || config.ci_node_total
        @ci_node_index = args[:ci_node_index] || config.ci_node_index
        @spec_pattern = args[:spec_pattern] || config.spec_pattern
      end

      def ci_node_total
        @ci_node_total.to_i
      end

      def ci_node_index
        @ci_node_index.to_i
      end

      def specs_for_current_node
        specs_for_node(ci_node_index)
      end

      def specs_for_node(node_index)
        assign_spec_files_to_node
        post_specs_for_node(node_index)
      end

      def assign_spec_files_to_node
        default_node_specs
        post_assign_spec_files_to_node
      end

      def all_specs
        @all_specs ||= Dir[spec_pattern]
      end

      protected

      def post_specs_for_node(node_index)
        raise NotImplementedError
      end

      def post_assign_spec_files_to_node
        raise NotImplementedError
      end

      def default_node_specs
        raise NotImplementedError
      end

      private

      def config
        Knapsack::Config
      end

      def default_report
        Knapsack.report.open
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
knapsack-0.5.0 lib/knapsack/distributors/base_distributor.rb
knapsack-0.4.0 lib/knapsack/distributors/base_distributor.rb
knapsack-0.3.0 lib/knapsack/distributors/base_distributor.rb