Class: Ruboty::Gominohi::YAML

Inherits:
Object
  • Object
show all
Defined in:
lib/ruboty/gominohi/yaml.rb

Constant Summary collapse

YAML_DIRS =
[
  Dir.pwd,
  File.join(File.dirname(File.expand_path(__FILE__)), '..', '..', '..')
].freeze
YAML_FILE =
'.gominohi.yml'.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeYAML

Returns a new instance of YAML.



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/ruboty/gominohi/yaml.rb', line 15

def initialize
  YAML_DIRS.each do |dir|
    filename = File.join(dir, YAML_FILE)
    if File.exists?(filename)
      @data = deep_symbolize_keys(::YAML.load(File.read(filename)))
      break
    end
  end

  raise "#{YAML_FILE} is not found" if @data.nil?

  yaml_version     = parse_and_truncate_patch_version(@data[:version])
  gominohi_version = parse_and_truncate_patch_version(::Ruboty::Gominohi::VERSION)
  raise 'version of `.gominohi.yml` is invalid' unless yaml_version == gominohi_version
end

Instance Attribute Details

#dataObject (readonly)

Returns the value of attribute data.



13
14
15
# File 'lib/ruboty/gominohi/yaml.rb', line 13

def data
  @data
end