jnlp 0.0.5.4 → 0.6.1
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +22 -0
- data/README.rdoc +134 -0
- data/Rakefile +97 -10
- data/jnlp.gemspec +27 -0
- data/lib/jnlp/jnlp.rb +0 -6
- data/lib/jnlp/maven_jnlp.rb +101 -20
- data/lib/jnlp/maven_jnlp_server.rb +29 -0
- data/lib/jnlp/otrunk.rb +0 -8
- data/lib/jnlp/version.rb +1 -1
- data/spec/jnlp_with_certficate_versions_spec.rb +1 -1
- data/spec/jnlp_with_specific_os_arch_j2ses_spec.rb +48 -0
- data/spec/jnlp_without_versioned_jars_spec.rb +1 -1
- metadata +58 -31
- data/Manifest.txt +0 -19
- data/README.txt +0 -48
- data/spec/fixtures/all-otrunk-snapshot-0.1.0-20090624.030355.jnlp +0 -150
- data/spec/fixtures/all-otrunk-snapshot-0.1.0-20091221.214313.jnlp +0 -169
- data/spec/fixtures/all-otrunk-snapshot-CURRENT_VERSION.txt +0 -1
- data/spec/fixtures/jnlp_without_versioned_jars.jnlp +0 -45
- data/spec/fixtures/maven-jnlp.html +0 -180
data/History.txt
CHANGED
@@ -1,3 +1,25 @@
|
|
1
|
+
== 0.6.1 2010-05-17
|
2
|
+
|
3
|
+
Clear up new version numbering.
|
4
|
+
|
5
|
+
== 0.6.0 2010-05-17
|
6
|
+
|
7
|
+
Added ability to limit the number of families parsed when creating a Jnlp::MavenJnlp.
|
8
|
+
|
9
|
+
Added ability to limit the number of versions parsed when creating a Jnlp::MavenJnlpFamily.
|
10
|
+
|
11
|
+
Updates to the README
|
12
|
+
|
13
|
+
== 0.0.5.5 2010-04-19
|
14
|
+
|
15
|
+
Removed use of the development dependency on hoe. Much simpler to
|
16
|
+
just check-in and manage the gemspec file itself.
|
17
|
+
See: http://yehudakatz.com/2010/04/02/using-gemspecs-as-intended/
|
18
|
+
|
19
|
+
Updates to the README
|
20
|
+
|
21
|
+
new specs for new behaviors
|
22
|
+
|
1
23
|
== 0.0.5.4 2010-02-11
|
2
24
|
|
3
25
|
addition optional parameter: arch for Jnlp::Jnlp instance methods:
|
data/README.rdoc
ADDED
@@ -0,0 +1,134 @@
|
|
1
|
+
= Jnlp:Jnlp
|
2
|
+
|
3
|
+
A gem for encapsulating the content and resources referenced by Java Web Start jnlps
|
4
|
+
and interacting with jnlp repositories managed by the maven-jnlp Eclipse plugin.
|
5
|
+
|
6
|
+
Complete rdoc available here: Jnlp::Jnlp
|
7
|
+
|
8
|
+
For more information about the structure of Java Web Start see Sun's documentation[http://java.sun.com/javase/6/docs/technotes/guides/javaws/developersguide/contents.html]
|
9
|
+
|
10
|
+
To create a new Jnlp::Jnlp call Jnlp::Jnlp#new with a string that contains either a local path or a url.
|
11
|
+
|
12
|
+
== Examples:
|
13
|
+
|
14
|
+
=== Creating a new Jnlp::Jnlp object from a local Java Web Start jnlp file.
|
15
|
+
|
16
|
+
j = Jnlp::Jnlp.new("authoring.jnlp")
|
17
|
+
|
18
|
+
=== Creating a new Jnlp::Jnlp object from a Java Web Start jnlp referenced with a url.
|
19
|
+
|
20
|
+
j = Jnlp::Jnlp.new("jnlp.concord.org/dev/org/concord/maven-jnlp/otrunk-sensor/otrunk-sensor.jnlp")
|
21
|
+
|
22
|
+
Once the Jnlp::Jnlp object is created you can call Jnlp::Jnlp#cache_resources to create a local cache of all the jar and nativelib resources.
|
23
|
+
|
24
|
+
The structure of the cache directory and the naming using for the jar and nativelib files is the same as that used by the Java Web Start Download Servlet, see Sun's servelet guide[http://java.sun.com/javase/6/docs/technotes/guides/javaws/developersguide/downloadservletguide.html].
|
25
|
+
|
26
|
+
== Creating MavenJnlp objects that represent the resources deployed by a maven jnlp servlet.
|
27
|
+
|
28
|
+
=== Creating a MavenJnlp object that represents the all the resources deployed by a maven jnlp servlet.
|
29
|
+
|
30
|
+
require 'jnlp'
|
31
|
+
mj = Jnlp::MavenJnlp.new('http://jnlp.concord.org', '/dev/org/concord/maven-jnlp/')
|
32
|
+
|
33
|
+
This takes about 90s on a 3Mbps connection processing Concord's
|
34
|
+
Maven Jnlp Web Start server.
|
35
|
+
|
36
|
+
You can now do this:
|
37
|
+
|
38
|
+
mj.maven_jnlp_families.length # => 26
|
39
|
+
mj.maven_jnlp_families[0].name # => "all-otrunk-snapshot"
|
40
|
+
mj.maven_jnlp_families[0].versions.length # => 1568
|
41
|
+
mj.maven_jnlp_families[0].versions.first.version # => "0.1.0-20070420.131610"
|
42
|
+
mj.maven_jnlp_families[0].snapshot_version # => "0.1.0-20090327.222627"
|
43
|
+
|
44
|
+
mj.maven_jnlp_families[0].versions.last.url
|
45
|
+
|
46
|
+
# => "/dev/org/concord/maven-jnlp/all-otrunk-snapshot/all-otrunk-snapshot-0.1.0-20090327.222627.jnlp"
|
47
|
+
|
48
|
+
mj.maven_jnlp_families[0].snapshot.url
|
49
|
+
|
50
|
+
# => "/dev/org/concord/maven-jnlp/all-otrunk-snapshot/all-otrunk-snapshot-0.1.0-20090327.222627.jnlp"
|
51
|
+
|
52
|
+
mj.maven_jnlp_families[0].versions.first.url
|
53
|
+
|
54
|
+
# => "/dev/org/concord/maven-jnlp/all-otrunk-snapshot/all-otrunk-snapshot-0.1.0-20070420.131610.jnlp"
|
55
|
+
|
56
|
+
=== Creating MavenJnlp objects that represent some all the resources deployed by a maven jnlp servlet.
|
57
|
+
|
58
|
+
You can pass in an options hash to limit the number of maven jnlp families parsed:
|
59
|
+
|
60
|
+
Example: passing in an optional array of maven jnlp families
|
61
|
+
This will get all versions of each family.
|
62
|
+
|
63
|
+
mj = Jnlp::MavenJnlp.new('http://jnlp.concord.org', '/dev/org/concord/maven-jnlp/',
|
64
|
+
{ :families => ['all-otrunk-snapshot', 'gui-testing'] })
|
65
|
+
|
66
|
+
mj.maven_jnlp_families.length
|
67
|
+
=> 2
|
68
|
+
|
69
|
+
Example: passing in an optional hash of maven jnlp families
|
70
|
+
This will get all versions of each family.
|
71
|
+
|
72
|
+
mj = Jnlp::MavenJnlp.new('http://jnlp.concord.org', '/dev/org/concord/maven-jnlp/',
|
73
|
+
{ :families => { 'all-otrunk-snapshot' => nil, 'gui-testing' => nil } })
|
74
|
+
|
75
|
+
mj.maven_jnlp_families.length
|
76
|
+
=> 2
|
77
|
+
|
78
|
+
Example: passing in an optional hash of maven jnlp families and specifying
|
79
|
+
the versions of the jnlp urls to get for one family.
|
80
|
+
|
81
|
+
mj = Jnlp::MavenJnlp.new('http://jnlp.concord.org', '/dev/org/concord/maven-jnlp/',
|
82
|
+
{ :families => {
|
83
|
+
'all-otrunk-snapshot' => { :versions => ['0.1.0-20100513.161426', '0.1.0-20100513.154925'] },
|
84
|
+
'gui-testing' => nil }
|
85
|
+
})
|
86
|
+
mjfs = mj.maven_jnlp_families
|
87
|
+
[mjfs.length, mjfs[0].versions.length, mjfs[1].versions.length]
|
88
|
+
=> [2, 2, 50]
|
89
|
+
|
90
|
+
== Building the gem
|
91
|
+
|
92
|
+
=== The source code
|
93
|
+
|
94
|
+
The source code for the jnlp gem is on github[http://github.com/stepheneb/jnlp/tree/master].
|
95
|
+
|
96
|
+
git clone git://github.com/stepheneb/jnlp.git
|
97
|
+
|
98
|
+
=== Runtime dependencies
|
99
|
+
|
100
|
+
hpricot '= 0.6.164'
|
101
|
+
|
102
|
+
=== Development dependencies
|
103
|
+
|
104
|
+
rspec -v'>= 1.3.0'
|
105
|
+
ci_reporter -v'>= 1.6.0'
|
106
|
+
|
107
|
+
=== rake tasks
|
108
|
+
|
109
|
+
$ rake -T
|
110
|
+
rake spec # run spec tests (the default task)
|
111
|
+
rake package # generate the gem package: jnlp-0.0.5.4.gem
|
112
|
+
rake release # push the packaged gem: jnlp-0.0.5.4.gem to rubygems.org
|
113
|
+
rake hudson:spec # run the spec tests and generate JUnit XML reports (for integrating with a Hudson CIS server)
|
114
|
+
rake rdoc # generate the rdoc documentation in doc/
|
115
|
+
|
116
|
+
=== Running the tests
|
117
|
+
|
118
|
+
JRuby:
|
119
|
+
|
120
|
+
jruby -S rake spec
|
121
|
+
|
122
|
+
MRI:
|
123
|
+
|
124
|
+
rake spec
|
125
|
+
|
126
|
+
Generating JUnit XML for integrating with the Hudson CIS server:
|
127
|
+
|
128
|
+
rake hudson:spec
|
129
|
+
|
130
|
+
=== TODO
|
131
|
+
|
132
|
+
Add tests for the MavenJnlp features.
|
133
|
+
|
134
|
+
=== Packaging and installing
|
data/Rakefile
CHANGED
@@ -1,19 +1,106 @@
|
|
1
1
|
require 'rubygems'
|
2
|
-
require 'hoe'
|
3
2
|
|
4
|
-
|
3
|
+
JRUBY = defined? RUBY_ENGINE && RUBY_ENGINE == 'jruby'
|
5
4
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
spec.email = 'stephen.bannasch@gmail.com'
|
10
|
-
spec.url = 'http://rubywebstart.rubyforge.org/jnlp/rdoc/'
|
11
|
-
spec.summary = "Ruby tools for working with Java Web Start JNLPs."
|
12
|
-
spec.description = "For manipulation of Java Web Start Jnlps and the resources they reference."
|
13
|
-
spec.extra_deps << ['hpricot','=0.6.164']
|
5
|
+
def gem_install_command_strings(missing_gems)
|
6
|
+
command = JRUBY ? " jruby -S gem install " : " sudo gem install "
|
7
|
+
command + missing_gems.collect {|g| "#{g[0]} -v '#{g[1]}'"}.join(' ') + "\n"
|
14
8
|
end
|
15
9
|
|
10
|
+
@development_gems = [['hpricot', '= 0.6.164'], ['rspec', '>= 1.3.0'], ['ci_reporter', '>= 1.6.0']]
|
11
|
+
@missing_gems = []
|
12
|
+
@development_gems.each do |gem_name_and_version|
|
13
|
+
begin
|
14
|
+
gem gem_name_and_version[0], gem_name_and_version[1]
|
15
|
+
rescue Gem::LoadError
|
16
|
+
@missing_gems << gem_name_and_version
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
unless @missing_gems.empty?
|
21
|
+
message = <<-HEREDOC
|
22
|
+
|
23
|
+
The following gem(s) need to be installed to run, test and package the jnlp gem.
|
24
|
+
|
25
|
+
#{gem_install_command_strings(@missing_gems.reverse)}
|
26
|
+
|
27
|
+
HEREDOC
|
28
|
+
raise message
|
29
|
+
end
|
30
|
+
|
31
|
+
require 'spec/rake/spectask'
|
32
|
+
|
33
|
+
require File.join(File.expand_path(File.dirname(__FILE__)), 'lib', 'jnlp.rb')
|
34
|
+
|
16
35
|
task :default => :spec
|
36
|
+
|
37
|
+
desc 'run spec tests (the default task)'
|
17
38
|
Spec::Rake::SpecTask.new do |t|
|
18
39
|
t.spec_files = FileList["spec/**/*_spec.rb"]
|
19
40
|
end
|
41
|
+
|
42
|
+
desc "generate the gem package: jnlp-#{Jnlp::VERSION}.gem"
|
43
|
+
task :package do
|
44
|
+
system "gem build jnlp.gemspec"
|
45
|
+
end
|
46
|
+
|
47
|
+
desc "push the packaged gem: jnlp-#{Jnlp::VERSION}.gem to rubygems.org"
|
48
|
+
task :release => :package do
|
49
|
+
system "gem push jnlp-#{Jnlp::VERSION}.gem"
|
50
|
+
end
|
51
|
+
|
52
|
+
namespace :hudson do
|
53
|
+
desc "run the spec tests and generate JUnit XML reports (for integrating with a Hudson CIS server)"
|
54
|
+
task :spec => ["hudson:setup:rspec", 'rake:spec']
|
55
|
+
|
56
|
+
namespace :setup do
|
57
|
+
task :pre_ci do
|
58
|
+
ENV["CI_REPORTS"] = 'spec/reports/'
|
59
|
+
gem 'ci_reporter'
|
60
|
+
require 'ci/reporter/rake/rspec'
|
61
|
+
end
|
62
|
+
task :rspec => [:pre_ci, "ci:setup:rspec"]
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
# Documentation tasks
|
67
|
+
#
|
68
|
+
# You can generate the doc by hand as follows:
|
69
|
+
#
|
70
|
+
# rdoc -U --main=README.rdoc --title='Jnlp::Jnlp' README.rdoc History.txt License.txt lib
|
71
|
+
#
|
72
|
+
# yardoc -o ydoc - README.rdoc History.txt License.txt
|
73
|
+
|
74
|
+
begin
|
75
|
+
# try using the rdoc gem if it is installed
|
76
|
+
require 'rdoc/task'
|
77
|
+
RDoc::Task.new do |rdoc|
|
78
|
+
rdoc.rdoc_dir = 'doc'
|
79
|
+
rdoc.template = "darkfish"
|
80
|
+
rdoc.main = "README.rdoc"
|
81
|
+
rdoc.title = 'Jnlp::Jnlp'
|
82
|
+
rdoc.rdoc_files.include("README.rdoc", 'History.txt', 'License.txt', "lib/**/*.rb")
|
83
|
+
rdoc.options += ['-f', 'darkfish']
|
84
|
+
end
|
85
|
+
rescue LoadError
|
86
|
+
# else use Rake's rdoc task (but this won't use the darkfish template)
|
87
|
+
require 'rake/rdoctask'
|
88
|
+
Rake::RDocTask.new do |rdoc|
|
89
|
+
rdoc.rdoc_dir = 'doc'
|
90
|
+
rdoc.main = "README.rdoc"
|
91
|
+
rdoc.title = 'Jnlp::Jnlp'
|
92
|
+
rdoc.rdoc_files.include("README.rdoc", 'History.txt', 'License.txt', "lib/**/*.rb")
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
begin
|
97
|
+
require 'yard'
|
98
|
+
YARD::Rake::YardocTask.new do |ydoc|
|
99
|
+
ydoc.files = ["README.rdoc", 'History.txt', 'License.txt', "lib/**/*.rb"]
|
100
|
+
ydoc.options = ['-o', 'ydoc', '--main', 'README.rdoc']
|
101
|
+
end
|
102
|
+
rescue LoadError
|
103
|
+
task :yardoc do
|
104
|
+
abort "YARD is not available. In order to run yardoc: sudo gem install yard"
|
105
|
+
end
|
106
|
+
end
|
data/jnlp.gemspec
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
GEM_ROOT = File.expand_path(File.dirname(__FILE__))
|
2
|
+
$:.unshift File.join(GEM_ROOT, 'lib')
|
3
|
+
require 'jnlp'
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = 'jnlp'
|
7
|
+
s.version = Jnlp::VERSION
|
8
|
+
s.authors = ["Stephen Bannasch"]
|
9
|
+
s.email = 'stephen.bannasch@gmail.com'
|
10
|
+
s.homepage = 'http://rubywebstart.rubyforge.org/jnlp/rdoc'
|
11
|
+
s.summary = %q{Ruby tools for working with Java Web Start JNLPs.}
|
12
|
+
s.description = %q{For manipulation of Java Web Start Jnlps and the resources they reference.}
|
13
|
+
s.date = '2010-02-11'
|
14
|
+
s.rubyforge_project = 'rubywebstart'
|
15
|
+
|
16
|
+
s.rdoc_options = ["--main", "README.rdoc"]
|
17
|
+
s.extra_rdoc_files = %w{ History.txt License.txt README.rdoc}
|
18
|
+
|
19
|
+
s.required_rubygems_version = ">= 1.3.2"
|
20
|
+
s.require_path = 'lib'
|
21
|
+
|
22
|
+
s.files = Dir.glob("{lib,spec}/**/*.{rb}") + %w{ History.txt License.txt README.rdoc Rakefile jnlp.gemspec }
|
23
|
+
|
24
|
+
s.add_runtime_dependency('hpricot', "= 0.6.164")
|
25
|
+
s.add_development_dependency("rspec", '>= 1.3.0')
|
26
|
+
s.add_development_dependency("ci_reporter", '>= 1.6.0')
|
27
|
+
end
|
data/lib/jnlp/jnlp.rb
CHANGED
data/lib/jnlp/maven_jnlp.rb
CHANGED
@@ -1,9 +1,3 @@
|
|
1
|
-
# :main: Jnlp::Jnlp
|
2
|
-
# :title: Jnlp::Jnlp RDoc
|
3
|
-
#
|
4
|
-
# to regenerate and display this rdoc:
|
5
|
-
# rdoc -U -SN jnlp.rb otrunk.rb ; open doc/index.html
|
6
|
-
#
|
7
1
|
require 'open-uri'
|
8
2
|
require 'hpricot'
|
9
3
|
|
@@ -16,6 +10,17 @@ module Jnlp #:nodoc:
|
|
16
10
|
#
|
17
11
|
# Encapsulates a versioned jnlp in a Maven Jnlp Web Start server.
|
18
12
|
#
|
13
|
+
# Jnlp::VersionedJnlpUrl.new(family_name, path, base_url)
|
14
|
+
#
|
15
|
+
# Example:
|
16
|
+
#
|
17
|
+
# require 'jnlp'
|
18
|
+
# vju = Jnlp::VersionedJnlpUrl("concord", "/dev/org/concord/maven-jnlp/", "http://jnlp.concord.org")
|
19
|
+
#
|
20
|
+
# Example:
|
21
|
+
#
|
22
|
+
# vju = Jnlp::VersionedJnlpUrl("concord", "/dev/org/concord/maven-jnlp/", "http://jnlp.concord.org")
|
23
|
+
#
|
19
24
|
class VersionedJnlpUrl
|
20
25
|
#
|
21
26
|
# Contains the the full path to the jnlp
|
@@ -52,6 +57,25 @@ module Jnlp #:nodoc:
|
|
52
57
|
#
|
53
58
|
# Encapsulates a single MavenJnlp Family of versioned jnlps.
|
54
59
|
#
|
60
|
+
# Jnlp::MavenJnlpFamily.new(base_url, family_path)
|
61
|
+
#
|
62
|
+
# Example:
|
63
|
+
#
|
64
|
+
# require 'jnlp'
|
65
|
+
# mjf = Jnlp::MavenJnlpFamily.new('http://jnlp.concord.org', '/dev/org/concord/maven-jnlp/all-otrunk-snapshot')
|
66
|
+
#
|
67
|
+
# mjf = Jnlp::MavenJnlpFamily.new('http://jnlp.concord.org', '/dev/org/concord/maven-jnlp/all-otrunk-snapshot',
|
68
|
+
# { :versions => ['0.1.0-20100513.161426', '0.1.0-20100513.154925'] })
|
69
|
+
# You can pass in an options hash to limit the number of versioned jnlps parsed:
|
70
|
+
#
|
71
|
+
# Example
|
72
|
+
#
|
73
|
+
# mjf = Jnlp::MavenJnlpFamily.new('http://jnlp.concord.org', '/dev/org/concord/maven-jnlp/all-otrunk-snapshot',
|
74
|
+
# { :versions => ['0.1.0-20100513.161426', '0.1.0-20100513.154925'] })
|
75
|
+
#
|
76
|
+
# mjf.versions.length
|
77
|
+
# => 2
|
78
|
+
#
|
55
79
|
class MavenJnlpFamily
|
56
80
|
#
|
57
81
|
# Contains the base_url for this MavenJnlp server
|
@@ -103,7 +127,7 @@ module Jnlp #:nodoc:
|
|
103
127
|
#
|
104
128
|
# Contains the VersionedJnlpUrl referencing the latest
|
105
129
|
# versioned jnlp. This jnlp is identical to the snapshot
|
106
|
-
# jnlp at the of
|
130
|
+
# jnlp at the time of instantiation.
|
107
131
|
#
|
108
132
|
attr_reader :snapshot
|
109
133
|
#
|
@@ -111,7 +135,8 @@ module Jnlp #:nodoc:
|
|
111
135
|
#
|
112
136
|
# base_url, family_path
|
113
137
|
#
|
114
|
-
|
138
|
+
|
139
|
+
def initialize(base_url, family_path, options={})
|
115
140
|
@base_url = base_url
|
116
141
|
@path = family_path
|
117
142
|
@url = @base_url + @path
|
@@ -121,16 +146,23 @@ module Jnlp #:nodoc:
|
|
121
146
|
anchor_tags = doc.search("//a")
|
122
147
|
snapshot_version_path = anchor_tags.find {|a| a['href'][/CURRENT_VERSION\.txt$/] }['href']
|
123
148
|
@snapshot_version = open(base_url + snapshot_version_path).read
|
124
|
-
|
125
149
|
jnlp_paths = anchor_tags.find_all { |a| a['href'][/jnlp$/] }.collect { |a| a['href'] }
|
126
150
|
jnlp_paths.each do |jnlp_path|
|
127
|
-
|
151
|
+
version = jnlp_path[/#{name}\/#{name}-(.*)\.jnlp/, 1]
|
128
152
|
# skip processing unless this jnlp has a version string
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
153
|
+
if version
|
154
|
+
# only continue processing if:
|
155
|
+
# no options[:version] was passed in OR
|
156
|
+
# the current version matches one of the desired versions OR
|
157
|
+
# one of the desired versions is 'snapshot' and this version IS the snapshot version
|
158
|
+
if options[:versions] == nil ||
|
159
|
+
options[:versions].any? { |v| v == version } ||
|
160
|
+
options[:versions].any? { |v| v == 'snapshot' && version == @snapshot_version }
|
161
|
+
versioned_jnlp_url = VersionedJnlpUrl.new(@name, jnlp_path, @base_url)
|
162
|
+
@versions << versioned_jnlp_url
|
163
|
+
if versioned_jnlp_url.version == @snapshot_version
|
164
|
+
@snapshot = versioned_jnlp_url
|
165
|
+
end
|
134
166
|
end
|
135
167
|
end
|
136
168
|
end
|
@@ -179,6 +211,38 @@ module Jnlp #:nodoc:
|
|
179
211
|
#
|
180
212
|
# # => "/dev/org/concord/maven-jnlp/all-otrunk-snapshot/all-otrunk-snapshot-0.1.0-20070420.131610.jnlp"
|
181
213
|
#
|
214
|
+
# You can pass in an options hash to limit the number of maven jnlp families parsed:
|
215
|
+
#
|
216
|
+
# Example: passing in an optional array of maven jnlp families
|
217
|
+
# This will get all versions of each family.
|
218
|
+
#
|
219
|
+
# mj = Jnlp::MavenJnlp.new('http://jnlp.concord.org', '/dev/org/concord/maven-jnlp/',
|
220
|
+
# { :families => ['all-otrunk-snapshot', 'gui-testing'] })
|
221
|
+
#
|
222
|
+
# mj.maven_jnlp_families.length
|
223
|
+
# => 2
|
224
|
+
#
|
225
|
+
# Example: passing in an optional hash of maven jnlp families
|
226
|
+
# This will get all versions of each family.
|
227
|
+
#
|
228
|
+
# mj = Jnlp::MavenJnlp.new('http://jnlp.concord.org', '/dev/org/concord/maven-jnlp/',
|
229
|
+
# { :families => { 'all-otrunk-snapshot' => nil, 'gui-testing' => nil } })
|
230
|
+
#
|
231
|
+
# mj.maven_jnlp_families.length
|
232
|
+
# => 2
|
233
|
+
#
|
234
|
+
# Example: passing in an optional hash of maven jnlp families and specifying
|
235
|
+
# the versions of the jnlp urls to get for one family.
|
236
|
+
#
|
237
|
+
# mj = Jnlp::MavenJnlp.new('http://jnlp.concord.org', '/dev/org/concord/maven-jnlp/',
|
238
|
+
# { :families => {
|
239
|
+
# 'all-otrunk-snapshot' => { :versions => ['0.1.0-20100513.161426', '0.1.0-20100513.154925'] },
|
240
|
+
# 'gui-testing' => nil }
|
241
|
+
# })
|
242
|
+
# mjfs = mj.maven_jnlp_families
|
243
|
+
# [mjfs.length, mjfs[0].versions.length, mjfs[1].versions.length]
|
244
|
+
# => [2, 2, 50]
|
245
|
+
#
|
182
246
|
class MavenJnlp
|
183
247
|
#
|
184
248
|
# Contains the base_url for this MavenJnlp server
|
@@ -215,17 +279,34 @@ module Jnlp #:nodoc:
|
|
215
279
|
#
|
216
280
|
# base_url, maven_jnlp_path
|
217
281
|
#
|
218
|
-
def initialize(base_url, jnlp_families_path)
|
282
|
+
def initialize(base_url, jnlp_families_path, options={})
|
219
283
|
@base_url = base_url
|
220
284
|
@jnlp_families_path = jnlp_families_path
|
221
285
|
@jnlp_families_url = @base_url + @jnlp_families_path
|
222
286
|
@maven_jnlp_families = []
|
223
287
|
doc = Hpricot(open(@jnlp_families_url))
|
224
288
|
family_paths = doc.search("//a").find_all { |a|
|
225
|
-
a['href'][/#{@jnlp_families_path}/]
|
226
|
-
|
227
|
-
|
228
|
-
|
289
|
+
a['href'][/#{@jnlp_families_path}/]
|
290
|
+
}.collect { |a| a['href'] }
|
291
|
+
if options[:families]
|
292
|
+
case options[:families]
|
293
|
+
when Hash
|
294
|
+
options[:families].each do |family, versions|
|
295
|
+
family_path = family_paths.detect { |fp| family == File.basename(fp) }
|
296
|
+
if family_path
|
297
|
+
maven_jnlp_family = MavenJnlpFamily.new(@base_url, family_path, versions || {})
|
298
|
+
@maven_jnlp_families << maven_jnlp_family
|
299
|
+
end
|
300
|
+
end
|
301
|
+
when Array
|
302
|
+
family_paths = family_paths.select { |path|
|
303
|
+
options[:families].any? { |family| family == File.basename(path) }
|
304
|
+
}
|
305
|
+
family_paths.each do |family_path|
|
306
|
+
maven_jnlp_family = MavenJnlpFamily.new(@base_url, family_path)
|
307
|
+
@maven_jnlp_families << maven_jnlp_family
|
308
|
+
end
|
309
|
+
end
|
229
310
|
end
|
230
311
|
end
|
231
312
|
|