Class: Matrixeval::Config::YAML

Inherits:
Object
  • Object
show all
Defined in:
lib/matrixeval/config/yaml.rb

Defined Under Namespace

Classes: MissingError, MissingTargetGem

Class Method Summary collapse

Class Method Details

.[](key) ⇒ Object



28
29
30
# File 'lib/matrixeval/config/yaml.rb', line 28

def [](key)
  yaml[key]
end

.create_for(target_name) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
# File 'lib/matrixeval/config/yaml.rb', line 12

def create_for(target_name)
  return if File.exist?(path)
  require "matrixeval/#{target_name}" unless target_name.nil?

  FileUtils.cp(
    target(target_name).matrixeval_yml_template_path,
    path
  )
rescue LoadError
  raise MissingTargetGem.new("Missing gem for the target #{target_name}")
end

.pathObject



24
25
26
# File 'lib/matrixeval/config/yaml.rb', line 24

def path
  Matrixeval.working_dir.join("matrixeval.yml")
end

.yamlObject

Raises:



32
33
34
35
36
# File 'lib/matrixeval/config/yaml.rb', line 32

def yaml
  raise MissingError unless File.exist?(path)

  ::YAML.load File.read(path)
end