Class: EY::Serverside::LockfileParser::Parse09

Inherits:
BaseParser show all
Defined in:
lib/engineyard-serverside/lockfile_parser.rb

Direct Known Subclasses

Parse10

Instance Method Summary collapse

Methods inherited from BaseParser

#initialize

Constructor Details

This class inherits a constructor from EY::Serverside::LockfileParser::BaseParser

Instance Method Details

#parseObject



24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/engineyard-serverside/lockfile_parser.rb', line 24

def parse
  from_yaml = safe_yaml_load(@contents)
  unless from_yaml.is_a?(Hash)
    return super
  end
  bundler_version = from_yaml['specs'].map do |spec|
    # spec is a one-element hash: the key is the gem name, and
    # the value is {"version" => the-version}.
    if spec.keys.first == "bundler"
      spec.values.first["version"]
    end
  end.compact.first
  [:bundler09, bundler_version]
end

#safe_yaml_load(loadable) ⇒ Object



38
39
40
41
42
# File 'lib/engineyard-serverside/lockfile_parser.rb', line 38

def safe_yaml_load(loadable)
  YAML.load(loadable) #won't always raise... soemtimes parses the contents as 1 big string
rescue ArgumentError => e  # not yaml
  nil
end