Class: Standard::Performance::DeterminesYamlPath

Inherits:
Object
  • Object
show all
Defined in:
lib/standard/performance/determines_yaml_path.rb

Instance Method Summary collapse

Instance Method Details

#determine(desired_version) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/standard/performance/determines_yaml_path.rb', line 4

def determine(desired_version)
  desired_version = Gem::Version.new(desired_version) unless desired_version.is_a?(Gem::Version)
  default = "base.yml"

  file_name = if !Gem::Version.correct?(desired_version)
    default
  elsif desired_version < Gem::Version.new("1.9")
    "ruby-1.8.yml"
  elsif desired_version < Gem::Version.new("2.0")
    "ruby-1.9.yml"
  elsif desired_version < Gem::Version.new("2.1")
    "ruby-2.0.yml"
  elsif desired_version < Gem::Version.new("2.2")
    "ruby-2.1.yml"
  elsif desired_version < Gem::Version.new("2.3")
    "ruby-2.2.yml"
  else
    default
  end

  Pathname.new(__dir__).join("../../../config/#{file_name}")
end