Class: Winter::MavenPom

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

Class Method Summary collapse

Class Method Details

.fetch(path, options = {}) ⇒ Object



26
27
28
29
# File 'lib/maven_pom.rb', line 26

def fetch(path, options = {})
  $LOG.debug "Reading POM from #{path}" 
  fetch_pom(path, options)
end

.fetch_pom(path, options = {}) ⇒ Object



31
32
33
34
# File 'lib/maven_pom.rb', line 31

def fetch_pom(path, options = {})
  path =~ /^http:\/\// ? fetch_url(path) :
    fetch_file(path)
end

.parse_pom(pom_doc, options = {}) ⇒ Object



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/maven_pom.rb', line 36

def parse_pom(pom_doc, options = {})
  $LOG.debug "Processing POM" 

  pom = OpenStruct.new
  doc = REXML::Document.new(pom_doc)

  pom.group        = xpath_group(doc)
  pom.artifact     = xpath_text(doc, '/project/artifactId')
  pom.version      = xpath_text(doc, '/project/version') || xpath_text(doc, '/project/parent/version')
  pom.description  = xpath_text(doc, '/project/description')
  pom.url          = xpath_text(doc, '/project/url')
  pom.dependencies = xpath_dependencies(doc)
  pom.authors      = xpath_authors(doc)

  pom.name       = "#{pom.group}.#{pom.artifact}"
  pom.lib_name   = "#{pom.artifact}.rb"
  pom.gem_name   = "#{pom.name}-#{pom.version}"
  pom.jar_file   = "#{pom.artifact}-#{pom.maven_version}.jar"
  pom.remote_dir = "#{pom.group.gsub('.', '/')}/#{pom.artifact}/#{pom.version}"
  pom
end