Class: PomPomPom::Metadata

Inherits:
Object
  • Object
show all
Defined in:
lib/pompompom/metadata.rb

Instance Method Summary collapse

Constructor Details

#initialize(io) ⇒ Metadata

Returns a new instance of Metadata.



3
4
5
# File 'lib/pompompom/metadata.rb', line 3

def initialize(io)
  @io = io
end

Instance Method Details

#latest_versionObject



22
23
24
# File 'lib/pompompom/metadata.rb', line 22

def latest_version
  @latest_version
end

#parse!Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/pompompom/metadata.rb', line 7

def parse!
  doc = Hpricot.XML(@io)
  versioning = doc.at('/metadata/versioning')
  if versioning
    release = versioning.at('release/text()')
    if release
      @latest_version = release.to_s
    else
      @latest_version = versioning.search('versions/version/text()').map(&:to_s).sort.last
    end
  else
    @latest_version = doc.at('/metadata/version/text()').to_s
  end
end