Class: WhatTheGem::Changes::Parser

Inherits:
Object
  • Object
show all
Extended by:
I::Callable
Defined in:
lib/whatthegem/changes/parser.rb

Direct Known Subclasses

MarkdownParser, RDocParser

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from I::Callable

to_proc

Constructor Details

#initialize(file) ⇒ Parser



24
25
26
# File 'lib/whatthegem/changes/parser.rb', line 24

def initialize(file)
  @file = file
end

Instance Attribute Details

#fileObject (readonly)

Returns the value of attribute file.



22
23
24
# File 'lib/whatthegem/changes/parser.rb', line 22

def file
  @file
end

Class Method Details

.call(file) ⇒ Object



7
8
9
# File 'lib/whatthegem/changes/parser.rb', line 7

def call(file)
  parser_for(file).versions
end

.parser_for(file) ⇒ Object



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

def parser_for(file)
  case file.basename
  when /\.(md|markdown)$/i
    MarkdownParser.new(file)
  else
    # Most of the time in Ruby-land, when no extension it is RDoc or RDoc-alike
    RDocParser.new(file)
  end
end