jtrupiano / better-benchmark forked from Pistos/better-benchmark

Statistically correct benchmarking for Ruby.

This URL has Read+Write access

better-benchmark / lib / better-benchmark / version.rb
100644 21 lines (17 sloc) 0.654 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
module BetterBenchmark
  module Version #:nodoc:
    # A method for comparing versions of required modules. It expects two
    # arrays of integers as parameters, the first being the minimum version
    # required, and the second being the actual version available. It returns
    # true if the actual version is at least equal to the required version.
    def self.check(required, actual) #:nodoc:
      required = required.map { |v| "%06d" % v }.join(".")
      actual = actual.map { |v| "%06d" % v }.join(".")
      return actual >= required
    end
 
    MAJOR = 0
    MINOR = 1
    TINY = 0
 
    STRING = [MAJOR, MINOR, TINY].join(".")
  end
end