Sha256: 5293fefdbc5413d6ac524364cc1c9e1d8c09488a236c22b91087aa85695f5693

Contents?: true

Size: 1.96 KB

Versions: 63

Compression:

Stored size: 1.96 KB

Contents

module Beaker
  module Shared
    # Methods for parsing options.
    module OptionsResolver
      # parses local and global options to determine if a particular mode should
      # be run in parallel. typically, local_options will specify a true/false
      # value, while global_options will specify an array of mode names that should
      # be run in parallel. the value specified in local_options will take precedence
      # over the values specified in global_options.
      # @param [Hash] local_options local options for running in parallel
      # @option local_options [Boolean] :run_in_parallel flag for running in parallel
      # @param [Hash] global_options global options for running in parallel
      # @option global_options [Array<String>] :run_in_parallel list of modes to run in parallel
      # @param [String] mode the mode we want to query global_options for
      # @return [Boolean] true if the specified mode is in global_options and :run_in_parallel in local_options is not false,
      #   or if :run_in_parallel in local_options is true, false otherwise
      # @example
      #   run_in_parallel?({:run_in_parallel => true})
      #   -> will return true
      #
      #   run_in_parallel?({:run_in_parallel => true}, {:run_in_parallel => ['install','configure']}, 'install')
      #   -> will return true
      #
      #   run_in_parallel?({:run_in_parallel => false}, {:run_in_parallel => ['install','configure']}, 'install')
      #   -> will return false
      def run_in_parallel?(local_options=nil, global_options=nil, mode=nil)
        run_in_parallel = local_options[:run_in_parallel] unless local_options.nil?

        if !run_in_parallel.nil? && run_in_parallel.is_a?(Array)
          run_in_parallel = false
        end

        if run_in_parallel.nil? && global_options && global_options[:run_in_parallel].is_a?(Array)
          run_in_parallel = global_options[:run_in_parallel].include?(mode)
        end

        run_in_parallel
      end
    end
  end
end

Version data entries

63 entries across 63 versions & 1 rubygems

Version Path
beaker-4.16.0 lib/beaker/shared/options_resolver.rb
beaker-4.15.0 lib/beaker/shared/options_resolver.rb
beaker-4.14.1 lib/beaker/shared/options_resolver.rb
beaker-4.14.0 lib/beaker/shared/options_resolver.rb
beaker-4.13.1 lib/beaker/shared/options_resolver.rb
beaker-4.13.0 lib/beaker/shared/options_resolver.rb
beaker-4.12.0 lib/beaker/shared/options_resolver.rb
beaker-4.11.1 lib/beaker/shared/options_resolver.rb
beaker-4.11.0 lib/beaker/shared/options_resolver.rb
beaker-4.10.0 lib/beaker/shared/options_resolver.rb
beaker-4.9.0 lib/beaker/shared/options_resolver.rb
beaker-4.8.0 lib/beaker/shared/options_resolver.rb
beaker-4.7.0 lib/beaker/shared/options_resolver.rb
beaker-4.6.0 lib/beaker/shared/options_resolver.rb
beaker-4.5.0 lib/beaker/shared/options_resolver.rb
beaker-4.4.0 lib/beaker/shared/options_resolver.rb
beaker-4.3.0 lib/beaker/shared/options_resolver.rb
beaker-4.2.0 lib/beaker/shared/options_resolver.rb
beaker-4.1.0 lib/beaker/shared/options_resolver.rb
beaker-4.0.0 lib/beaker/shared/options_resolver.rb