Class: RubybenchRunner::DependenciesChecker

Inherits:
Object
  • Object
show all
Defined in:
lib/rubybench_runner/dependencies_checker.rb

Class Method Summary collapse

Class Method Details

.check(pg:, mysql:) ⇒ Object



7
8
9
10
# File 'lib/rubybench_runner/dependencies_checker.rb', line 7

def self.check(pg:, mysql:)
  check_pg if pg
  check_mysql if mysql
end

.check_mysqlObject



28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/rubybench_runner/dependencies_checker.rb', line 28

def self.check_mysql
  config = RubybenchRunner::Configurations.new(mysql_map: true)[:mysql2]
  config = config.merge(database: "mysql")
  client = Mysql2::Client.new(config)
  begin
    version = client.info[:version]
    if version != CURRENT_MYSQL_VERSION
      warn("MySQL", version, CURRENT_MYSQL_VERSION)
    end
  ensure
    client.close
  end
end

.check_pgObject



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/rubybench_runner/dependencies_checker.rb', line 12

def self.check_pg
  config = RubybenchRunner::Configurations.new[:postgres]
  config = config.merge(dbname: "postgres")
  conn = PG.connect(config)
  begin
    output = conn.parameter_status("server_version")
    output =~ /^([\d.]+) \(/
    version = $1
    if version != CURRENT_PG_VERSION
      warn("PostgreSQL", version, CURRENT_PG_VERSION)
    end
  ensure
    conn.close
  end
end

.warn(program, installed, recommended) ⇒ Object



42
43
44
45
46
# File 'lib/rubybench_runner/dependencies_checker.rb', line 42

def self.warn(program, installed, recommended)
  puts "    Warning: rubybench.org is currently running version \#{recommended} of \#{program}, you're running version \#{installed}.\n  ALERT\nend\n"