Sha256: de0d6cffed3908862d637c4906e529425d181a2b572f39544254fee4f51484f4

Contents?: true

Size: 680 Bytes

Versions: 4

Compression:

Stored size: 680 Bytes

Contents

class BenchmarkCLI
  module Ruby
    class Command
      include Flows::Result::Helpers
      extend Flows::Result::Do

      attr_reader :benchmarks

      def initialize(benchmarks)
        @benchmarks = benchmarks.map(&:to_sym)
      end

      do_notation(:call)
      def call
        yield validate
        run
      end

      private

      def validate
        benchmarks.each do |benchmark|
          return err_data("Unexpected benchmark: #{benchmark}") unless BENCHMARKS.key?(benchmark)
        end

        ok
      end

      def run
        benchmarks.each do |benchmark|
          BENCHMARKS[benchmark].new.call
        end

        ok
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
flows-0.6.0 bin/benchmark_cli/ruby/command.rb
flows-0.5.1 bin/benchmark_cli/ruby/command.rb
flows-0.5.0 bin/benchmark_cli/ruby/command.rb
flows-0.4.0 bin/benchmark_cli/ruby/command.rb