Class: Jnlp::MavenJnlpFamily
- Inherits:
-
Object
- Object
- Jnlp::MavenJnlpFamily
- Defined in:
- lib/jnlp/maven_jnlp.rb
Overview
MavenJnlpFamily
Encapsulates a single MavenJnlp Family of versioned jnlps.
Jnlp::MavenJnlpFamily.new(base_url, family_path)
Example:
require 'jnlp'
mjf = Jnlp::MavenJnlpFamily.new('http://jnlp.concord.org', '/dev/org/concord/maven-jnlp/all-otrunk-snapshot')
mjf = Jnlp::MavenJnlpFamily.new('http://jnlp.concord.org', '/dev/org/concord/maven-jnlp/all-otrunk-snapshot',
{ :versions => ['0.1.0-20100513.161426', '0.1.0-20100513.154925'] })
You can pass in an options hash to limit the number of versioned jnlps parsed:
Example
mjf = Jnlp::MavenJnlpFamily.new('http://jnlp.concord.org', '/dev/org/concord/maven-jnlp/all-otrunk-snapshot',
{ :versions => ['0.1.0-20100513.161426', '0.1.0-20100513.154925'] })
mjf.versions.length
=> 2
Instance Attribute Summary collapse
-
#base_url ⇒ Object
readonly
Contains the base_url for this MavenJnlp server.
-
#name ⇒ Object
readonly
Contains the name for this family of jnlps .
-
#path ⇒ Object
readonly
Contains the path from the base_url to the root for this family of jnlps .
-
#snapshot ⇒ Object
readonly
Contains the VersionedJnlpUrl referencing the latest versioned jnlp.
-
#snapshot_version ⇒ Object
readonly
Contains the version string for the latest versioned jnlp.
-
#url ⇒ Object
readonly
Contains the root url for this family of jnlps .
-
#versions ⇒ Object
readonly
Contains an array of VersionedJnlpUrls.
Instance Method Summary collapse
-
#initialize(base_url, family_path, options = {}) ⇒ MavenJnlpFamily
constructor
Pass in:.
- #latest_snapshot_version ⇒ Object
- #update ⇒ Object
Constructor Details
#initialize(base_url, family_path, options = {}) ⇒ MavenJnlpFamily
Pass in:
base_url, family_path
139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 |
# File 'lib/jnlp/maven_jnlp.rb', line 139 def initialize(base_url, family_path, ={}) @base_url = base_url @path = family_path @url = @base_url + @path @name = File.basename(@path) @versions = [] doc = Nokogiri::HTML(open(@url).read) = doc.search("//a") snapshot_version_path = .find {|a| a['href'][/CURRENT_VERSION\.txt$/] }['href'] @snapshot_version = open(base_url + snapshot_version_path).read jnlp_paths = .find_all { |a| a['href'][/jnlp$/] }.collect { |a| a['href'] } jnlp_paths.each do |jnlp_path| version = jnlp_path[/#{name}\/#{name}-(.*)\.jnlp/, 1] # skip processing unless this jnlp has a version string if version # only continue processing if: # no options[:version] was passed in OR # the current version matches one of the desired versions OR # one of the desired versions is 'snapshot' and this version IS the snapshot version if [:versions] == nil || [:versions].any? { |v| v == version } || [:versions].any? { |v| v == 'snapshot' && version == @snapshot_version } versioned_jnlp_url = VersionedJnlpUrl.new(@name, jnlp_path, @base_url) @versions << versioned_jnlp_url if versioned_jnlp_url.version == @snapshot_version @snapshot = versioned_jnlp_url end end end end end |
Instance Attribute Details
#base_url ⇒ Object (readonly)
Contains the base_url for this MavenJnlp server
Example:
"http://jnlp.concord.org"
87 88 89 |
# File 'lib/jnlp/maven_jnlp.rb', line 87 def base_url @base_url end |
#name ⇒ Object (readonly)
Contains the name for this family of jnlps
Example:
"all-otrunk-snapshot"
112 113 114 |
# File 'lib/jnlp/maven_jnlp.rb', line 112 def name @name end |
#path ⇒ Object (readonly)
Contains the path from the base_url to the root for this family of jnlps
Example:
"/dev/org/concord/maven-jnlp/"
96 97 98 |
# File 'lib/jnlp/maven_jnlp.rb', line 96 def path @path end |
#snapshot ⇒ Object (readonly)
Contains the VersionedJnlpUrl referencing the latest versioned jnlp. This jnlp is identical to the snapshot jnlp at the time of instantiation.
132 133 134 |
# File 'lib/jnlp/maven_jnlp.rb', line 132 def snapshot @snapshot end |
#snapshot_version ⇒ Object (readonly)
Contains the version string for the latest versioned jnlp. This jnlp this version string refers to is identical to the snapshot jnlp at the of processing.
Example:
"0.1.0-20090327.222627"
126 127 128 |
# File 'lib/jnlp/maven_jnlp.rb', line 126 def snapshot_version @snapshot_version end |
#url ⇒ Object (readonly)
Contains the root url for this family of jnlps
Example:
"http://jnlp.concord.org/dev/org/concord/maven-jnlp/all-otrunk-snapshot"
104 105 106 |
# File 'lib/jnlp/maven_jnlp.rb', line 104 def url @url end |
#versions ⇒ Object (readonly)
Contains an array of VersionedJnlpUrls
116 117 118 |
# File 'lib/jnlp/maven_jnlp.rb', line 116 def versions @versions end |
Instance Method Details
#latest_snapshot_version ⇒ Object
175 176 177 |
# File 'lib/jnlp/maven_jnlp.rb', line 175 def latest_snapshot_version open("#{@url}/#{@name}-CURRENT_VERSION.txt").read end |
#update ⇒ Object
171 172 173 |
# File 'lib/jnlp/maven_jnlp.rb', line 171 def update end |