Class: PostIt::Parser

Inherits:
Object
  • Object
show all
Defined in:
lib/postit/parser.rb

Constant Summary collapse

BUNDLED_WITH =
/\n\nBUNDLED WITH\n\s{2,}(#{Gem::Version::VERSION_PATTERN})\n/

Instance Method Summary collapse

Constructor Details

#initialize(file) ⇒ Parser

Returns a new instance of Parser.



5
6
7
# File 'lib/postit/parser.rb', line 5

def initialize(file)
  @file = file
end

Instance Method Details

#parseObject



12
13
14
15
16
17
18
19
# File 'lib/postit/parser.rb', line 12

def parse
  return unless lockfile = File.file?(@file) && File.read(@file)
  if lockfile =~ BUNDLED_WITH
    Regexp.last_match(1)
  else
    '< 1.10'
  end
end