Class: MavenPom::Pom
- Inherits:
-
Object
- Object
- MavenPom::Pom
- Defined in:
- lib/maven_pom/pom.rb
Instance Attribute Summary collapse
-
#uri ⇒ Object
readonly
Returns the value of attribute uri.
Instance Method Summary collapse
- #artifact_id ⇒ Object
- #as_json(opts = nil) ⇒ Object
- #build_plugins ⇒ Object
- #dependencies ⇒ Object
- #dependency_name_from(node) ⇒ Object
- #group_id ⇒ Object
-
#initialize(str, uri) ⇒ Pom
constructor
A new instance of Pom.
- #inspect ⇒ Object
- #key ⇒ Object
- #name ⇒ Object
- #packaging ⇒ Object
- #parent ⇒ Object
- #parent_pom ⇒ Object
- #properties ⇒ Object
- #to_json(*args) ⇒ Object
Constructor Details
Instance Attribute Details
#uri ⇒ Object (readonly)
Returns the value of attribute uri.
3 4 5 |
# File 'lib/maven_pom/pom.rb', line 3 def uri @uri end |
Instance Method Details
#artifact_id ⇒ Object
69 70 71 |
# File 'lib/maven_pom/pom.rb', line 69 def artifact_id @pom.css("project > artifactId").text end |
#as_json(opts = nil) ⇒ Object
12 13 14 15 16 17 18 19 |
# File 'lib/maven_pom/pom.rb', line 12 def as_json(opts = nil) { :key => key, :name => name, :parent => parent, :packaging => packaging } end |
#build_plugins ⇒ Object
37 38 39 40 41 |
# File 'lib/maven_pom/pom.rb', line 37 def build_plugins @pom.css("plugins > plugin").map do |node| dependency_name_from(node) end end |
#dependencies ⇒ Object
77 78 79 80 81 |
# File 'lib/maven_pom/pom.rb', line 77 def dependencies @pom.css("dependencies > dependency").map do |node| dependency_name_from(node) end end |
#dependency_name_from(node) ⇒ Object
93 94 95 96 97 98 99 100 |
# File 'lib/maven_pom/pom.rb', line 93 def dependency_name_from(node) gid = node.css("groupId").text aid = node.css("artifactId").text gid = group_id if gid == "${project.groupId}" # ugh "#{gid}:#{aid}" end |
#group_id ⇒ Object
54 55 56 57 58 59 60 61 62 63 |
# File 'lib/maven_pom/pom.rb', line 54 def group_id gid = @pom.css("project > groupId").text gid = @pom.css("project > parent > groupId").text if gid.empty? if gid.empty? raise MissingGroupIdError, "could not find groupId in pom (uri=#{uri.inspect})" end gid end |
#inspect ⇒ Object
25 26 27 |
# File 'lib/maven_pom/pom.rb', line 25 def inspect "#<MavenPom::Pom:0x%x key=%s name=%s parent=%s>" % [object_id << 1, key.inspect, name.inspect, parent.inspect] end |
#key ⇒ Object
73 74 75 |
# File 'lib/maven_pom/pom.rb', line 73 def key @key ||= "#{group_id}:#{artifact_id}" end |
#name ⇒ Object
33 34 35 |
# File 'lib/maven_pom/pom.rb', line 33 def name @pom.css("project > name").text.strip end |
#packaging ⇒ Object
29 30 31 |
# File 'lib/maven_pom/pom.rb', line 29 def packaging @pom.css("project > packaging").text end |
#parent ⇒ Object
43 44 45 46 47 48 49 50 51 52 |
# File 'lib/maven_pom/pom.rb', line 43 def parent parent = @pom.css("project > parent").first if parent gid = parent.css("groupId").text aid = parent.css("artifactId").text "#{gid}:#{aid}" end end |
#parent_pom ⇒ Object
65 66 67 |
# File 'lib/maven_pom/pom.rb', line 65 def parent_pom MavenPom.all[parent] end |
#properties ⇒ Object
83 84 85 86 87 88 89 90 91 |
# File 'lib/maven_pom/pom.rb', line 83 def properties props = {} @pom.css("project > properties > *").each do |element| props[element.name] = element.inner_text end props end |
#to_json(*args) ⇒ Object
21 22 23 |
# File 'lib/maven_pom/pom.rb', line 21 def to_json(*args) as_json.to_json(*args) end |