Module: Rubyul

Defined in:
lib/rubyul.rb,
lib/rubyul/version.rb

Overview

All the small helper functions are here.

Constant Summary collapse

PLATFORM_REGEXES =
JSON.parse(File.read(File.dirname(__FILE__) +
"/platform_regexes.json"))
IGNORABLE_REGEXES =
JSON.parse(File.read(File.dirname(__FILE__) +
"/ignorable_regexes.json"))
VERSION =
"0.5.5"

Class Method Summary collapse

Class Method Details

.academic_year(date) ⇒ Object



8
9
10
11
# File 'lib/rubyul.rb', line 8

def self.academic_year(date)
  # Academic years go from September to August.
  (Date.parse(date) << 8).year
end

.hostname_to_platform(hostname, ignore: FALSE) ⇒ Object



20
21
22
23
24
25
26
27
28
29
# File 'lib/rubyul.rb', line 20

def self.hostname_to_platform(hostname, ignore: FALSE)
  # TODO: Deal with ignores or not, with an option.
  if ignore == TRUE
    return "ignore" if $ignorable_pattern_match =~ hostname
  end
  PLATFORM_REGEXES.each do |regexp, platform_name|
    return platform_name if Regexp.new(regexp) =~ hostname
  end
  nil
end