jnlp 0.7.3 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 6c33d798b24f4f92dd32d9f9d5b3b12d9808641e
4
+ data.tar.gz: e4226eb182d0e4b7cd265fd9f27bcb996682746f
5
+ SHA512:
6
+ metadata.gz: f557631722dbc7c482648504b105e545137b39a95c19d9f94448177c5de33cac6f2be7dfa48b820e3cb3879fa1b6c97fde1586dd5149d6993b4c62a48e136deb
7
+ data.tar.gz: 791f1026ce0ed38c0aa5b202d2501b8ea151ac216ad204ddb6b6dcb8182058634b656b65db8940deb97f76a2d63b396c57b0b958b639bf9f97483df0eb4e6058
@@ -1,3 +1,7 @@
1
+ == 0.7.4 2012-10-14
2
+
3
+ Refactor classes into their own files. Thanks scytacki!
4
+
1
5
  == 0.7.3 2011-08-28
2
6
 
3
7
  Extend support for Nokogiri to include 1.5.x series
@@ -98,31 +98,40 @@ the versions of the jnlp urls to get for one family.
98
98
 
99
99
  === The source code
100
100
 
101
- The source code for the jnlp gem is on github[http://github.com/stepheneb/jnlp/tree/master].
101
+ The source code for the jnlp gem is on github[http://github.com/stepheneb/jnlp/tree/master] and the gem dependencies are managed with [bundler](http://gembundler.com/)
102
102
 
103
103
  git clone git://github.com/stepheneb/jnlp.git
104
+ cd jnlp
105
+ gem install nokogiri
106
+ bundle install
107
+
108
+ Bundler should install nokogiri but can't because of this bug: {can't find gem specified in gemspec with a range}[https://github.com/carlhuda/bundler/issues/1397]
104
109
 
105
110
  === Runtime dependencies
106
111
 
107
- nokogiri '~> 1.4.0'
112
+ nokogiri ">= 1.4.4", "<= 1.5"
108
113
 
109
114
  === Development dependencies
110
115
 
116
+ rake
111
117
  rspec '~> 2.5.0'
112
118
  ci_reporter '~> 1.6.4'
119
+ rdoc '~> 3.9.4'
120
+ yard '~> 0.7.2'
113
121
 
114
122
  === rake tasks
115
123
 
116
- $ rake -T
117
- rake doc:clobber_rdoc # Remove RDoc HTML files
118
- rake doc:rdoc # Build RDoc HTML files
119
- rake doc:rerdoc # Rebuild RDoc HTML files
120
- rake doc:yard # Generate YARD Documentation
121
- rake hudson:spec # run the spec tests and generate JUnit XML reports (for integrating with a Hudson CIS server)
122
- rake package # generate the gem package: pkg/jnlp-0.7.0.gem
123
- rake release # push the packaged gem: jnlp-0.7.0.gem to rubygems.org
124
- rake spec # run spec tests (the default task)
125
-
124
+ $ bundle exec rake -T
125
+ rake build # Build jnlp-0.7.3.gem into the pkg directory
126
+ rake clobber_rdoc # Remove RDoc HTML files
127
+ rake hudson:spec # run the spec tests and generate JUnit XML reports (for integrating with a Hudson CIS server)
128
+ rake install # Build and install jnlp-0.7.3.gem into system gems
129
+ rake rdoc # Build RDoc HTML files
130
+ rake release # Create tag v0.7.3 and build and push jnlp-0.7.3.gem to Rubygems
131
+ rake rerdoc # Rebuild RDoc HTML files
132
+ rake spec # Run RSpec
133
+ rake yard # Generate YARD Documentation
134
+
126
135
  === Running the tests
127
136
 
128
137
  JRuby:
@@ -131,11 +140,11 @@ JRuby:
131
140
 
132
141
  MRI:
133
142
 
134
- rake spec
143
+ bundle exec rake spec
135
144
 
136
145
  Generating JUnit XML output for integrating with the Hudson CIS server:
137
146
 
138
- rake hudson:spec
147
+ bundle exec rake hudson:spec
139
148
 
140
149
  === Running adhoc tests using the source code directly
141
150
 
@@ -144,13 +153,12 @@ Run an adhoc test in the file sample.rb in the same top-level directory as this
144
153
 
145
154
  === Building and installing the gem locally
146
155
 
147
- rake package
156
+ bundle exec rake build
148
157
  gem install pkg/jnlp-<version>.gem
149
158
 
150
159
  === Releasing a new version to http://rubygems.org/
151
160
 
152
- rake package
153
- gem push pkg/jnlp-<version>.gem
161
+ bundle exec rake release
154
162
 
155
163
  === TODO
156
164
 
@@ -158,3 +166,9 @@ Add tests for:
158
166
  * MavenJnlp features.
159
167
  * downloading and caching jars
160
168
  * re-generating original and local jnlps
169
+
170
+ === Changes
171
+
172
+ * June 22, 2015 (NP) – Version 0.8.0
173
+ Nokogiri dependency has been updated to ~> 1.6.4.
174
+ As of Nokogiri 1.6.4 libxml2 and libxslt are bundled with nokogiri, for simpler installs.
@@ -3,9 +3,13 @@ $:.unshift(File.dirname(__FILE__)) unless
3
3
 
4
4
  require 'rubygems'
5
5
 
6
- gem 'nokogiri', '>= 1.4.4', "<= 1.5"
6
+ gem 'nokogiri', '>= 1.4.4'
7
7
 
8
8
  module Jnlp
9
+ require 'jnlp/property.rb'
10
+ require 'jnlp/j2se.rb'
11
+ require 'jnlp/icon.rb'
12
+ require 'jnlp/resource.rb'
9
13
  require 'jnlp/jnlp.rb'
10
14
  require 'jnlp/otrunk.rb'
11
15
  require 'jnlp/maven_jnlp.rb'
@@ -0,0 +1,48 @@
1
+ module Jnlp #:nodoc:
2
+
3
+ #
4
+ # Icon objects encapsulate the <icon> element optionally present in
5
+ # the Java Web Start jnlp <information> element.
6
+ #
7
+ class Icon
8
+ #
9
+ # Contains the Hpricot element parsed from the orginal Jnlp
10
+ # that was used to create the Icon
11
+ #
12
+ attr_reader :icon
13
+ #
14
+ # Contains the href attribute of the <icon> element.
15
+ #
16
+ # Example:
17
+ #
18
+ # "http://itsi.concord.org/images/itsi-logo-64x64.png"
19
+ #
20
+ attr_reader :href
21
+ #
22
+ # Contains the height attribute of the <icon> element
23
+ #
24
+ # Example:
25
+ #
26
+ # 64
27
+ #
28
+ attr_reader :height
29
+ #
30
+ # Contains the width attribute of the <icon> element
31
+ #
32
+ # Example:
33
+ #
34
+ # 64
35
+ #
36
+ attr_reader :width
37
+ #
38
+ # Creates a new Icon object
39
+ # * _icon_: pass in a Hpricot parse of the <icon> element
40
+ #
41
+ def initialize(icon)
42
+ @icon = icon
43
+ @href = icon.attr('href').value
44
+ @height = icon.attr('height').value.to_i
45
+ @width = icon.attr('width').value.to_i
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,79 @@
1
+ module Jnlp
2
+ class J2se
3
+ #
4
+ # Contains the Hpricot element parsed from the orginal Jnlp
5
+ # that was used to create the Property
6
+ #
7
+ attr_reader :j2se
8
+ #
9
+ # Contains the version of the J2SE element:
10
+ #
11
+ # Example:
12
+ #
13
+ # "1.5+"
14
+ #
15
+ attr_reader :version
16
+ #
17
+ # Contains the max-heap-size specified in the J2SE element:
18
+ #
19
+ # Example:
20
+ #
21
+ # "128m"
22
+ #
23
+ attr_reader :max_heap_size
24
+ #
25
+ # Contains the initial-heap-size specified in the J2SE element:
26
+ #
27
+ # Example:
28
+ #
29
+ # "32m"
30
+ #
31
+ attr_reader :initial_heap_size
32
+ #
33
+ # Contains the value of the optional java-vm-args attribute in
34
+ # in the J2SE element, the value is nil if not present:
35
+ #
36
+ # Example:
37
+ #
38
+ # "-d32"
39
+ #
40
+ attr_reader :java_vm_args
41
+ #
42
+ # Contains the value of the os attribute in the
43
+ # parent <resources> element that contains this property
44
+ # if the attribute was set in the parent. The attribute is normalized
45
+ # by converting to lowercase and changing ' ' characters to '_'
46
+ #
47
+ # Example:
48
+ #
49
+ # "Mac OS X" => "mac_os_x"
50
+ #
51
+ attr_reader :os
52
+ #
53
+ # Contains the value of the arch attribute in the
54
+ # parent <resources> element that contains this property
55
+ # if the attribute was set in the parent.The attribute is normalized
56
+ # by converting to lowercase and changing ' ' characters to '_'
57
+ #
58
+ # Examples:
59
+ #
60
+ # "ppc i386" => "ppc_i386"
61
+ # "x86_64" => "x86_64"
62
+ #
63
+ attr_reader :arch
64
+ #
65
+ # Creates a new Jnlp::Property object.
66
+ # * _prop_: the Hpricot parsing of the specific jnlp/resources/property element
67
+ # * _os_: optional: include it if the resources parent element that contains the property has this attribute set
68
+ #
69
+ def initialize(j2se, os=nil, arch=nil)
70
+ @j2se = j2se
71
+ @version = j2se['version']
72
+ @max_heap_size = j2se['max-heap-size']
73
+ @initial_heap_size = j2se['initial-heap-size']
74
+ @java_vm_args = j2se['java-vm-args']
75
+ @os = os
76
+ @arch = arch
77
+ end
78
+ end
79
+ end
@@ -38,606 +38,13 @@ unless Net::HTTP::Get.new('/')['User-Agent'] # unless a 'User-Agent' is already
38
38
  end
39
39
 
40
40
  module Jnlp #:nodoc:
41
- #
42
- # Property objects encapsulate <property> elements present in a
43
- # Java Web Start Jnlp <resources> element.
44
41
  #
45
- class Property
46
- #
47
- # Contains the Hpricot element parsed from the orginal Jnlp
48
- # that was used to create the Property
49
- #
50
- attr_reader :property
51
- #
52
- # Contains the name of the Property
53
- #
54
- #
55
- # Example:
56
- #
57
- # "maven.jnlp.version"
58
- #
59
- attr_reader :name
60
- #
61
- # Contains the value of the Property
62
- #
63
- #
64
- # Example:
65
- #
66
- # "all-otrunk-snapshot-0.1.0-20080310.211515"
67
- #
68
- attr_reader :value
69
- #
70
- # Contains the value of the os attribute in the
71
- # parent <resources> element that contains this property
72
- # if the attribute was set in the parent.
73
- # Example:
74
- #
75
- # "Mac OS X"
76
- #
77
- attr_reader :os
78
- #
79
- # Creates a new Jnlp::Property object.
80
- # * _prop_: the Hpricot parsing of the specific jnlp/resources/property element
81
- # * _os_: optional: include it if the resources parent element that contains the property has this attribute set
82
- #
83
- def initialize(prop, os=nil)
84
- @property = prop
85
- @name = prop['name']
86
- @value = prop['value']
87
- @os = os
88
- end
89
- end
90
-
91
- class J2se
92
- #
93
- # Contains the Hpricot element parsed from the orginal Jnlp
94
- # that was used to create the Property
95
- #
96
- attr_reader :j2se
97
- #
98
- # Contains the version of the J2SE element:
99
- #
100
- # Example:
101
- #
102
- # "1.5+"
103
- #
104
- attr_reader :version
105
- #
106
- # Contains the max-heap-size specified in the J2SE element:
107
- #
108
- # Example:
109
- #
110
- # "128m"
111
- #
112
- attr_reader :max_heap_size
113
- #
114
- # Contains the initial-heap-size specified in the J2SE element:
115
- #
116
- # Example:
117
- #
118
- # "32m"
119
- #
120
- attr_reader :initial_heap_size
121
- #
122
- # Contains the value of the optional java-vm-args attribute in
123
- # in the J2SE element, the value is nil if not present:
124
- #
125
- # Example:
126
- #
127
- # "-d32"
128
- #
129
- attr_reader :java_vm_args
130
- #
131
- # Contains the value of the os attribute in the
132
- # parent <resources> element that contains this property
133
- # if the attribute was set in the parent. The attribute is normalized
134
- # by converting to lowercase and changing ' ' characters to '_'
135
- #
136
- # Example:
137
- #
138
- # "Mac OS X" => "mac_os_x"
139
- #
140
- attr_reader :os
141
- #
142
- # Contains the value of the arch attribute in the
143
- # parent <resources> element that contains this property
144
- # if the attribute was set in the parent.The attribute is normalized
145
- # by converting to lowercase and changing ' ' characters to '_'
146
- #
147
- # Examples:
148
- #
149
- # "ppc i386" => "ppc_i386"
150
- # "x86_64" => "x86_64"
151
- #
152
- attr_reader :arch
153
- #
154
- # Creates a new Jnlp::Property object.
155
- # * _prop_: the Hpricot parsing of the specific jnlp/resources/property element
156
- # * _os_: optional: include it if the resources parent element that contains the property has this attribute set
157
- #
158
- def initialize(j2se, os=nil, arch=nil)
159
- @j2se = j2se
160
- @version = j2se['version']
161
- @max_heap_size = j2se['max-heap-size']
162
- @initial_heap_size = j2se['initial-heap-size']
163
- @java_vm_args = j2se['java-vm-args']
164
- @os = os
165
- @arch = arch
166
- end
167
- end
168
-
169
- #
170
- # Icon objects encapsulate the <icon> element optionally present in
171
- # the Java Web Start jnlp <information> element.
172
- #
173
- class Icon
174
- #
175
- # Contains the Hpricot element parsed from the orginal Jnlp
176
- # that was used to create the Icon
177
- #
178
- attr_reader :icon
179
- #
180
- # Contains the href attribute of the <icon> element.
181
- #
182
- # Example:
183
- #
184
- # "http://itsi.concord.org/images/itsi-logo-64x64.png"
185
- #
186
- attr_reader :href
187
- #
188
- # Contains the height attribute of the <icon> element
189
- #
190
- # Example:
191
- #
192
- # 64
193
- #
194
- attr_reader :height
195
- #
196
- # Contains the width attribute of the <icon> element
197
- #
198
- # Example:
199
- #
200
- # 64
201
- #
202
- attr_reader :width
203
- #
204
- # Creates a new Icon object
205
- # * _icon_: pass in a Hpricot parse of the <icon> element
206
- #
207
- def initialize(icon)
208
- @icon = icon
209
- @href = icon.attr('href').value
210
- @height = icon.attr('height').value.to_i
211
- @width = icon.attr('width').value.to_i
212
- end
213
- end
214
- #
215
- # Jnlp::Resource objects encapsulate both jar and nativelib elements present in a
216
- # Java Web Start Jnlp <resources> element.
217
- #
218
- class Resource
219
- #
220
- # Contains the Hpricot element parsed from the orginal Jnlp
221
- # that was used to create the resource
222
- #
223
- attr_reader :resource
224
- #
225
- # Contains the path to the resource taken from the href attribute
226
- #
227
- # Example:
228
- #
229
- # "org/concord/httpclient/" || ""
230
- #
231
- attr_reader :href_path
232
- #
233
- # Contains the kind of the resource
234
- #
235
- # Example:
236
- #
237
- # "jar" || "nativelib"
238
- #
239
- attr_reader :kind
240
- #
241
- # Contains the base name of the resource
242
- #
243
- # Example:
244
- #
245
- # "httpclient"
246
- #
247
- attr_reader :name
248
- #
249
- # Contains the Java Web Start specification of the OS for
250
- # the <resources> parent of this resource if the attribute
251
- # value exists
252
- #
253
- # Example:
254
- #
255
- # ""
256
- #
257
- attr_reader :os
258
- #
259
- # Contains the href attribute of the resource
260
- #
261
- # Example:
262
- #
263
- # "net/sf/sail/webstart-proxy/jetty-proxy/jetty-proxy.jar"
264
- #
265
- attr_reader :main
266
- #
267
- # Contains a boolean that repesents whether the main_class for this
268
- # jnlp is contained within this jar.
269
- # This attribute is optional in a jnlp and if present should
270
- # only be present and set to true on one jar resource in a jnlp.
271
- #
272
- attr_reader :href
273
- #
274
- # Contains the url reference to the resource
275
- #
276
- # Example:
277
- #
278
- # "http://jnlp.concord.org/dev/org/concord/httpclient/httpclient.jar?version-id=0.1.0-20071212.220020-17"
279
- #
280
- attr_reader :url
281
- #
282
- # Contains the url reference to the gzipped pack200 version of the resource
283
- #
284
- # Example:
285
- #
286
- # "http://jnlp.concord.org/dev/org/concord/httpclient/httpclient__V0.1.0-20071212.220020-17.jar.pack.gz"
287
- #
288
- attr_reader :url_pack_gz
289
- #
290
- # Contains the filename of the resource
291
- #
292
- # Example:
293
- #
294
- # "httpclient__V0.1.0-20071212.220020-17.jar"
295
- #
296
- attr_reader :suffix
297
- #
298
- # Contains the suffix of the resource
299
- #
300
- # Example:
301
- #
302
- # "__V0.1.0.jar"
303
- #
304
- attr_reader :filename
305
- #
306
- # Contains the filename of the gzipped pack200 version of the resource
307
- #
308
- # Example:
309
- #
310
- # "httpclient__V0.1.0-20071212.220020-17.jar.pack.gz"
311
- #
312
- attr_reader :filename_pack
313
- #
314
- # Contains the filename of the pack200 version of the resource
315
- #
316
- # Example:
317
- #
318
- # "httpclient__V0.1.0-20071212.220020-17.jar.pack"
319
- #
320
- attr_reader :filename_pack_gz
321
- #
322
- # Contains the size of the resource
323
- #
324
- # Example:
325
- #
326
- # 294248
327
- #
328
- attr_reader :size
329
- #
330
- # Contains the size of the gzipped pack200 version of the resource
331
- #
332
- # Example:
333
- #
334
- # 112213
335
- #
336
- attr_reader :size_pack_gz
337
- #
338
- # Contains boolean value indicating whether the signature of the
339
- # cached local copy of the resource verified successfully
340
- #
341
- # The value is nil if no local cache has been created.
342
- #
343
- # Example:
344
- #
345
- # true || false || nil
346
- #
347
- attr_reader :signature_verified
348
- #
349
- # Contains the absolute local path of cache directory
350
- #
351
- # Example:
352
- #
353
- # "/Users/stephen/dev/jetty-jnlp-proxy/cache"
354
- #
355
- attr_reader :local_cache_dir
356
- #
357
- # Contains the relative local path of the resource
358
- #
359
- # Example:
360
- #
361
- # "net/sf/sail/webstart-proxy/jetty-proxy/jetty-proxy__V0.1.0-20080318.093629-72.jar"
362
- #
363
- attr_reader :relative_local_path
364
- #
365
- # Contains the absolute local path of the resource
366
- #
367
- # Example:
368
- #
369
- # "/Users/stephen/dev/jetty-jnlp-proxy/cache/net/sf/sail/webstart-proxy/jetty-proxy/jetty-proxy__V0.1.0-20080318.093629-72.jar"
370
- #
371
- attr_reader :local_path
372
- #
373
- # Contains the relative local path of the packed, gzipped resource
374
- #
375
- # Example:
376
- #
377
- # "net/sf/sail/webstart-proxy/jetty-proxy/jetty-proxy__V0.1.0-20080318.093629-72.jar.pack.gz"
378
- #
379
- attr_reader :relative_local_path_pack_gz
380
- #
381
- # Contains the absolute local path of the resource
382
- #
383
- # Example:
384
- #
385
- # "/Users/stephen/dev/jetty-jnlp-proxy/cache/net/sf/sail/webstart-proxy/jetty-proxy/jetty-proxy__V0.1.0-20080318.093629-72.jar.pack.gz"
386
- #
387
- attr_reader :local_path_pack_gz
388
- #
389
- # Contains the version string of the resource
390
- #
391
- # Example:
392
- #
393
- # "0.1.0-20080318.093629-72"
394
- #
395
- attr_reader :version_str
396
- #
397
- # Contains the version of the resource
398
- #
399
- # Example:
400
- #
401
- # "0.1.0"
402
- #
403
- attr_reader :version
404
- #
405
- # Contains the date string of the resource
406
- #
407
- # Example:
408
- #
409
- # "20080318.093629"
410
- #
411
- attr_reader :date_str
412
- #
413
- # Contains a Ruby DateTime object representation of the resource's date string
414
- #
415
- # Example:
416
- #
417
- # #<DateTime: 85338394589/86400,0,2299161>
418
- #
419
- attr_reader :date_time
420
- #
421
- # Contains the revision of the resource
422
- #
423
- # Example:
424
- #
425
- # 72
426
- #
427
- attr_reader :revision
428
- #
429
- # Contains the certificate version of the resource
430
- # if one exists, otherwize it is nil
431
- #
432
- # Example:
433
- #
434
- # "s1"
435
- #
436
- attr_reader :certificate_version
437
- #
438
- def initialize(res, codebase, os)
439
- @resource = res
440
- @kind = res.name
441
- @main = res['main'] && res['main'] == 'true'
442
- @href = res['href']
443
- @href_path = File.dirname(@href)
444
- if @href_path == '.'
445
- @href_path = ''
446
- else
447
- @href_path = @href_path + '/'
448
- end
449
- @name = File.basename(@href).chomp('.jar')
450
- @version_str = res['version']
451
- if @version_str
452
- @suffix = "__V#{@version_str}.jar"
453
- else
454
- @suffix = ".jar"
455
- end
456
- @filename = "#{@name}#{@suffix}"
457
- @filename_pack = @filename + ".pack"
458
- @filename_pack_gz = @filename_pack + ".gz"
459
-
460
- @url = "#{codebase}/#{@href_path}#{@name}.jar"
461
- @url << "?version-id=#{@version_str}" if @version_str
462
- # example: data-util__V0.1.0-20070926.155656-107.jar.pack
463
- # @url_pack = "#{codebase}/#{@href_path}#{@filename}.pack"
464
- # example: data-util__V0.1.0-20070926.155656-107.jar.pack.gz
465
- @url_pack_gz = "#{codebase}/#{@href_path}#{@filename}.pack.gz"
466
- @version, @revision, @date_str, @date_time, @certificate_version = parse_version_str(@version_str)
467
- @os = os
468
- end
469
- #
470
- # parse_version_str
471
- #
472
- # input examples:
473
- #
474
- # "0.1.0-20070926.155656-107"
475
- #
476
- # or a newer example:
477
- #
478
- # "0.1.0-20090618.143130-890-s1"
479
- #
480
- # but ... some version strings just look like this:
481
- #
482
- # "0.1.0"
483
- #
484
- # or this:
485
- #
486
- # "2.1.7-r2"
487
- #
488
- # results:
489
- #
490
- # version # => '0.1.0'
491
- # revision # => 20
492
- # date_str # => '20070926.155656'
493
- # date_time # => #<DateTime: 10673317777/10800,0,2299161>
494
- # certificate_version # => 's1'
495
- #
496
- def parse_version_str(version_str)
497
- version = date_str = certificate_version = ''
498
- revision = date_time = nil
499
- if version_str && version_str.length > 0
500
- if md = version_str.match(/(\d|\.)+/)
501
- version = md[0]
502
- # date_str
503
- if md2 = md.post_match.match(/-([\d]{8}.[\d]{6})(-|$)/)
504
- date_str = md2[1]
505
- d, t = date_str.scan(/\d+/) # => ["20070926", "155656"]
506
- d1 = "#{d[0..3]}-#{d[4..5]}-#{d[6..7]}" # => "2007-09-26"
507
- t1 = "#{t[0..1]}:#{t[2..3]}:#{t[4..5]}" # => "15:56:56"
508
- dt = "#{d1}T#{t1}Z" # => "2007-09-26T15:56:56Z"
509
- date_time = DateTime.parse(dt) # => #<DateTime: 10673317777/10800,0,2299161>
510
- # revision
511
- if md3 = md2.post_match.match(/\d+/)
512
- revision = md3[0].to_i
513
- end
514
- else
515
- if match = md.post_match[/\d+/]
516
- revision = match.to_i
517
- end
518
- end
519
- # certificate_version
520
- if match = md.post_match[/-(s\d+)/, 1]
521
- certificate_version = match
522
- end
523
- end
524
- end
525
- [version, revision, date_str, date_time, certificate_version]
526
- end
527
- #
528
- # Set's up the local cache directory references
529
- #
530
- def local_cache_dir=(dir_path)
531
- @local_cache_dir = File.expand_path(dir_path)
532
- @relative_local_path = "#{@href_path}#{@filename}"
533
- @local_path = "#{@local_cache_dir}/#{@relative_local_path}"
534
- end
535
- #
536
- # Copies the file referenced in _source_ to _destination_
537
- # _source_ can be a url or local file path
538
- # _destination_ must be a local path
539
- #
540
- # Will copy file if the file does not exists
541
- # OR if the the file exists but the signature has
542
- # not been successfully verified.
543
- #
544
- # Returns file size if cached succesfully, false otherwise.
545
- #
546
- def update_cache(source=@url, destination=@local_path, options={})
547
- unless destination
548
- raise ArgumentError, "Must specify destination directory when updatng resource", caller
549
- end
550
- file_exists = File.exists?(destination)
551
- if file_exists && @signature_verified == nil
552
- verify_signature
553
- end
554
- unless file_exists && @signature_verified
555
- FileUtils.mkdir_p(File.dirname(destination))
556
- puts "reading: #{source}" if options[:verbose]
557
- tried_to_read = 0
558
- begin
559
- jarfile = open(source)
560
- rescue OpenURI::HTTPError => e
561
- puts e
562
- if tried_to_read < 1
563
- tried_to_read += 1
564
- retry
565
- end
566
- end
567
- if jarfile.class == Tempfile
568
- FileUtils.cp(jarfile.path, destination)
569
- puts "copying to: #{destination}" if options[:verbose]
570
- else
571
- File.open(destination, 'w') {|f| f.write jarfile.read }
572
- puts "writing to: #{destination}" if options[:verbose]
573
- end
574
- puts "#{jarfile.size} bytes written" if options[:verbose]
575
- verify_signature ? jarfile.size : false
576
- else
577
- File.size(destination)
578
- end
579
- end
580
- #
581
- # Verifies signature of locallly cached resource
582
- #
583
- # Returns boolean value indicating whether the signature of the
584
- # cached local copy of the resource verified successfully
585
- #
586
- # The value return is nil if no local cache has been created.
587
- #
588
- # Example:
589
- #
590
- # true || false || nil
591
- #
592
- def verify_signature
593
- if @local_path
594
- if RUBY_PLATFORM =~ /java/
595
- begin
596
- jarfile = java.util.jar.JarInputStream.new(FileInputStream.new(@local_path), true)
597
- @signature_verified = true
598
- rescue NativeException
599
- @signature_verified = false
600
- end
601
- else
602
- # Use IO.popen instead of system() to absorb
603
- # jarsigners messages to $stdout
604
- response = IO.popen("jarsigner -verify #{@local_path}"){|io| io.gets}
605
- @signature_verified = ($?.exitstatus == 0)
606
- end
607
- else
608
- nil
609
- end
610
- end
611
- #
612
- # Copies the resource referenced in Resource#url
613
- # to the local cache.
614
- #
615
- # If the resource is successully cached locally and the
616
- # signature is verified the size of the resource is retured.
617
- #
618
- # If the signature is not verified then false is returned.
619
- #
620
- def cache_resource(dest_dir=@local_cache_dir, options={})
621
- unless dest_dir
622
- raise ArgumentError, "Must specify destination directory when creating resource", caller
623
- end
624
- self.local_cache_dir=dest_dir
625
- @size = update_cache(@url, @local_path, options)
626
- if options[:include_pack_gz]
627
- @relative_local_path_pack_gz = "#{@relative_local_path}.pack.gz"
628
- @local_path_pack_gz = "#{dest_dir}/#{@relative_local_path_pack_gz}"
629
- @size_pack_gz = update_cache(@url_pack_gz, @local_path_pack_gz, options)
630
- end
631
- @signature_verified ? @size : @signature_verified
632
- end
633
- end
634
- #
635
42
  #
636
43
  # == Jnlp
637
44
  #
638
45
  # A gem for encapsulating the content and resources referenced by Java Web Start jnlps
639
46
  #
640
- # For more information about the structure of Java Web Start see:
47
+ # For more information about the structure of Java Web Start see:
641
48
  # * http://java.sun.com/javase/6/docs/technotes/guides/javaws/developersguide/contents.html
642
49
  #
643
50
  # To create a new Jnlp call Jnlp#new with a string that contains either a local path or a url.
@@ -652,15 +59,15 @@ module Jnlp #:nodoc:
652
59
  # Once the Jnlp object is created you can call Jnlp#cache_resources to create a local
653
60
  # cache of all the jar and nativelib resources. The structure of the cache directory
654
61
  # and the naming using for the jar and nativelib files is the same as that used
655
- # by the Java Web Start Download Servlet, see:
62
+ # by the Java Web Start Download Servlet, see:
656
63
  # * http://java.sun.com/javase/6/docs/technotes/guides/javaws/developersguide/downloadservletguide.html
657
- #
64
+ #
658
65
  # === Example: Creating an jnlp object and caching all the resources
659
- #
66
+ #
660
67
  # j = Jnlp::Jnlp.new("http://jnlp.concord.org/dev/org/concord/maven-jnlp/otrunk-sensor/otrunk-sensor.jnlp", 'web_start_cache')
661
68
  #
662
69
  # Will populate the local directory: web_start_cache with the following files:
663
- #
70
+ #
664
71
  # avalon-framework/avalon-framework/avalon-framework__V4.1.3.jar
665
72
  # commons-beanutils/commons-beanutils/commons-beanutils__V1.7.0.jar
666
73
  # commons-collections/commons-collections/commons-collections__V3.1.jar
@@ -728,10 +135,10 @@ module Jnlp #:nodoc:
728
135
  #
729
136
  # The jnlp gem has a dependency on hpricot version 0.6.164.
730
137
  # The most recent version of hpricot, version 0.7.0 does not yet work with JRuby.
731
- #
138
+ #
732
139
  class Jnlp
733
140
  #
734
- # Sets the Java Classpath delimiter used when generating
141
+ # Sets the Java Classpath delimiter used when generating
735
142
  # a Classpath string
736
143
  CLASSPATH_DELIMETER = ':' unless defined? CLASSPATH_DELIMETER
737
144
  #
@@ -787,7 +194,7 @@ module Jnlp #:nodoc:
787
194
  #
788
195
  attr_reader :version_str
789
196
  #
790
- # Contains the local file-based href attribute of the
197
+ # Contains the local file-based href attribute of the
791
198
  # local jnlp if it has been created.
792
199
  #
793
200
  # Example:
@@ -796,7 +203,7 @@ module Jnlp #:nodoc:
796
203
  #
797
204
  attr_reader :local_jnlp_href
798
205
  #
799
- # Contains the local file-based name attribute of the
206
+ # Contains the local file-based name attribute of the
800
207
  # of the local jnlp if it has been created.
801
208
  #
802
209
  # Example:
@@ -804,7 +211,7 @@ module Jnlp #:nodoc:
804
211
  # otrunk-sensor.jnlp"
805
212
  #
806
213
  attr_reader :local_jnlp_name
807
- #
214
+ #
808
215
  # Contains the relative path to local cache directory if it has been set
809
216
  #
810
217
  # Example:
@@ -812,7 +219,7 @@ module Jnlp #:nodoc:
812
219
  # "cache"
813
220
  #
814
221
  attr_reader :relative_local_cache_dir
815
- #
222
+ #
816
223
  # Contains the absolute path to the local cache directory if it has been set
817
224
  #
818
225
  # Example:
@@ -820,7 +227,7 @@ module Jnlp #:nodoc:
820
227
  # "/Users/stephen/dev/jetty-jnlp-proxy/cache"
821
228
  #
822
229
  attr_reader :local_cache_dir
823
- #
230
+ #
824
231
  # Contains a boolean value indicating if the signatures of all
825
232
  # resources copied to local cache have been verified.
826
233
  #
@@ -832,88 +239,88 @@ module Jnlp #:nodoc:
832
239
  #
833
240
  attr_accessor :local_resource_signatures_verified
834
241
  #
835
- # contans the boolean attribute determining whether
836
- # gzipped pack200 resources should be copied to the
242
+ # contans the boolean attribute determining whether
243
+ # gzipped pack200 resources should be copied to the
837
244
  # local cache when the cache is updated
838
245
  #
839
246
  attr_accessor :include_pack_gz
840
247
  #
841
- # Contains the spec attribute in the jnlp element
842
- # Example:
248
+ # Contains the spec attribute in the jnlp element
249
+ # Example:
843
250
  #
844
251
  # "1.0+"
845
252
  #
846
253
  attr_reader :spec
847
254
  #
848
- # Contains the codebase attribute in the jnlp element
849
- # Example:
255
+ # Contains the codebase attribute in the jnlp element
256
+ # Example:
850
257
  #
851
258
  # "http://jnlp.concord.org/dev"
852
259
  #
853
260
  attr_reader :codebase
854
261
  #
855
- # Contains the href attribute in the jnlp element
856
- # Example:
262
+ # Contains the href attribute in the jnlp element
263
+ # Example:
857
264
  #
858
265
  # "http://jnlp.concord.org/dev/org/concord/maven-jnlp/all-otrunk-snapshot/all-otrunk-snapshot.jnlp"
859
266
  #
860
267
  attr_reader :href
861
268
  #
862
269
  # Contains the value of the jnlp/information/title element
863
- # Example:
270
+ # Example:
864
271
  #
865
272
  # "All OTrunk snapshot"
866
273
  #
867
274
  attr_reader :title
868
275
  #
869
276
  # Contains the value of the jnlp/information/vendor element
870
- # Example:
277
+ # Example:
871
278
  #
872
279
  # "Concord Consortium"
873
280
  #
874
281
  attr_reader :vendor
875
282
  #
876
283
  # Contains the value of the href attribute in the jnlp/information/homepage element
877
- # Example:
284
+ # Example:
878
285
  #
879
286
  # "http://www.concord.org"
880
287
  #
881
288
  attr_reader :homepage
882
289
  #
883
290
  # Contains the value of the jnlp/information/description element
884
- # Example:
291
+ # Example:
885
292
  #
886
293
  # "http://www.concord.org"
887
294
  #
888
295
  attr_reader :description
889
296
  #
890
297
  # Contains a Jnlp::Icon object encapsulating the
891
- # jnlp/information/icon element if it exists in the
298
+ # jnlp/information/icon element if it exists in the
892
299
  # original jnlp
893
300
  #
894
301
  attr_reader :icon
895
302
  #
896
- # Contains a boolean value indictating the presence of the
303
+ # Contains a boolean value indictating the presence of the
897
304
  # jnlp/information/offline-allowed element
898
305
  #
899
306
  attr_reader :offline_allowed
900
307
  #
901
- # Contains an array of Jnlp::J2se objects encapsulating
308
+ # Contains an array of Jnlp::J2se objects encapsulating
902
309
  # jnlp/resources/j2se elements
903
310
  #
904
311
  attr_reader :j2ses
905
312
  #
906
- # Contains an array of Jnlp::Property objects encapsulating
313
+ # Contains an array of Jnlp::Property objects encapsulating
907
314
  # jnlp/resources/property elements
908
315
  #
909
316
  attr_reader :properties
910
317
  #
911
- # Contains an array of Jnlp::Resource objects encapsulating
318
+ # Contains an array of Jnlp::Resource objects encapsulating
912
319
  # jnlp/resources/jar elements
913
320
  #
914
321
  attr_reader :jars
915
322
  #
916
- # Contains an array of Jnlp::Resource objects encapsulating
323
+ # Contains an array of Jnlp::Resource objects encapsulating
917
324
  # jnlp/resources/nativelib elements
918
325
  #
919
326
  attr_reader :nativelibs
@@ -927,7 +334,7 @@ module Jnlp #:nodoc:
927
334
  # Example: "http://www.concord.org"
928
335
  #
929
336
  attr_reader :argument
930
- #
337
+ #
931
338
  # Create a new Jnlp by loading and parsing the Java Web Start
932
339
  # Jnlp located at url -- url can be a local path or a url.
933
340
  # * if you include _cache_dir_ then the jnlp resources will be cached locally when the object is created
@@ -944,28 +351,28 @@ module Jnlp #:nodoc:
944
351
  @verbose = options[:verbose]
945
352
  import_jnlp(@url) unless @url.empty?
946
353
  end
947
-
354
+
948
355
  def j2se_version(os=nil, arch=nil)
949
356
  j2se = j2ses.detect { |j2se| j2se.os == os && j2se.arch == arch}
950
357
  j2se ? j2se.version : nil
951
358
  end
952
-
359
+
953
360
  def max_heap_size(os=nil, arch=nil)
954
361
  j2se = j2ses.detect { |j2se| j2se.os == os && j2se.arch == arch }
955
- j2se ? j2se.max_heap_size : nil
362
+ j2se ? j2se.max_heap_size : nil
956
363
  end
957
-
364
+
958
365
  def initial_heap_size(os=nil, arch=nil)
959
366
  j2se = j2ses.detect { |j2se| j2se.os == os && j2se.arch == arch }
960
- j2se ? j2se.initial_heap_size : nil
367
+ j2se ? j2se.initial_heap_size : nil
961
368
  end
962
369
 
963
370
  def java_vm_args(os=nil, arch=nil)
964
371
  j2se = j2ses.detect { |j2se| j2se.os == os && j2se.arch == arch }
965
- j2se ? j2se.java_vm_args : nil
372
+ j2se ? j2se.java_vm_args : nil
966
373
  end
967
-
968
-
374
+
375
+
969
376
  #
970
377
  # Saves a YAML version of the jnlp object.
971
378
  #
@@ -975,7 +382,7 @@ module Jnlp #:nodoc:
975
382
  #
976
383
  def save(filename="saved_jnlp_object")
977
384
  File.open(filename, 'w') {|f| f.write YAML.dump(self)}
978
- end
385
+ end
979
386
  #
980
387
  # set
981
388
  #
@@ -1000,19 +407,19 @@ module Jnlp #:nodoc:
1000
407
  @name = File.basename(url)
1001
408
  #
1002
409
  # @local_jnlp_href and @local_jnlp_name are only placeholders
1003
- # values so far-- they will become valid when a local jnlp file
410
+ # values so far-- they will become valid when a local jnlp file
1004
411
  # is written to the filesystem with this method:
1005
412
  #
1006
413
  # Jnlp#write_local_jnlp
1007
- #
414
+ #
1008
415
  @local_jnlp_name = "local-#{@name}"
1009
- @local_jnlp_href = File.expand_path("#{Dir.pwd}/#{@local_jnlp_name}")
416
+ @local_jnlp_href = File.expand_path("#{Dir.pwd}/#{@local_jnlp_name}")
1010
417
  @jnlp = Nokogiri::XML(open(url).read)
1011
418
  @spec = (@jnlp/"jnlp").attr('spec').value
1012
419
  @codebase = (@jnlp/"jnlp").attr('codebase').value
1013
420
  @path = @url.gsub(@codebase, '')
1014
421
  @family = File.basename(File.dirname(@path))
1015
- @href = (@jnlp/"jnlp").attr('href').value
422
+ @href = (@jnlp/"jnlp").attr('href').value unless (@jnlp/"jnlp").attr('href').nil?
1016
423
  @title, @vendor, @homepage, @description, @icon = nil, nil, nil, nil, nil
1017
424
  unless (info = (@jnlp/"information")).empty?
1018
425
  @title = (info/"title").inner_html.strip
@@ -1051,7 +458,7 @@ module Jnlp #:nodoc:
1051
458
  # Copy all the jars and nativelib resources referenced in the Jnlp to
1052
459
  # a local cache dir passed in _dest_dir_. The structure of the cache directory
1053
460
  # and the naming using for the jar and nativelib files is the same as that used
1054
- # by the Java Web Start Download Servlet, see:
461
+ # by the Java Web Start Download Servlet, see:
1055
462
  # * http://java.sun.com/javase/6/docs/technotes/guides/javaws/developersguide/downloadservletguide.html
1056
463
  #
1057
464
  def cache_resources(dest_dir=@local_cache_dir, options=@options)
@@ -1077,7 +484,7 @@ module Jnlp #:nodoc:
1077
484
  #
1078
485
  def generate_local_jnlp(options={})
1079
486
  #
1080
- # get a copy of the existing jnlp
487
+ # get a copy of the existing jnlp
1081
488
  # (it should be easier than this)
1082
489
  #
1083
490
  @local_jnlp = Nokogiri::XML(@jnlp.to_s)
@@ -1089,7 +496,7 @@ module Jnlp #:nodoc:
1089
496
  # set the new codebase
1090
497
  #
1091
498
  jnlp_elem[:codebase] = "file:#{@local_cache_dir}"
1092
- #
499
+ #
1093
500
  # set the new href
1094
501
  #
1095
502
  jnlp_elem[:href] = @local_jnlp_href
@@ -1120,14 +527,14 @@ module Jnlp #:nodoc:
1120
527
  # Returns an array containing all the local paths for this jnlp's resources.
1121
528
  #
1122
529
  # Pass in the options hash: (:remove_jruby => true) and
1123
- # the first resource that contains the string /jruby/ will
530
+ # the first resource that contains the string /jruby/ will
1124
531
  # be removed from the returned array.
1125
532
  #
1126
533
  # Example:
1127
534
  #
1128
535
  # resource_paths(:remove_jruby => true)
1129
536
  #
1130
- # This is useful when the jruby-complete jar has been included
537
+ # This is useful when the jruby-complete jar has been included
1131
538
  # in the jnlp and you don't want to require that jruby into this
1132
539
  # specific instance which is already running jruby.
1133
540
  #
@@ -1149,7 +556,7 @@ module Jnlp #:nodoc:
1149
556
  resources = cp_jars + cp_nativelibs
1150
557
  end
1151
558
  #
1152
- # FIXME: this should probably be more discriminatory
559
+ # FIXME: this should probably be more discriminatory
1153
560
  #
1154
561
  if options[:remove_jruby]
1155
562
  resources = resources.reject {|r| r =~ /\/jruby\//}
@@ -1158,11 +565,11 @@ module Jnlp #:nodoc:
1158
565
  end
1159
566
  #
1160
567
  # Returns a string in Java classpath format for all the jars for this jnlp
1161
- # The delimiter used is the ':' which is valid for MacOS X and Linux.
568
+ # The delimiter used is the ':' which is valid for MacOS X and Linux.
1162
569
  # Windows uses the ';' as a delimeter.
1163
570
  #
1164
571
  # Pass in the optional hash: (:remove_jruby => true) and
1165
- # the first resource that contains the string /jruby/ will
572
+ # the first resource that contains the string /jruby/ will
1166
573
  # be removed from the returned classapath string.
1167
574
  #
1168
575
  # Example:
@@ -1174,15 +581,15 @@ module Jnlp #:nodoc:
1174
581
  end
1175
582
  #
1176
583
  # Writes a shell script to the local filesystem
1177
- # that will export a modified CLASSPATH environmental
584
+ # that will export a modified CLASSPATH environmental
1178
585
  # variable with the paths to the resources used by
1179
586
  # this jnlp.
1180
587
  #
1181
- # Writes a jnlp to current working directory
588
+ # Writes a jnlp to current working directory
1182
589
  # using name of original jnlp.
1183
- #
590
+ #
1184
591
  # Pass in the optional hash: (:remove_jruby => true) and
1185
- # the first resource that contains the string /jruby/ will
592
+ # the first resource that contains the string /jruby/ will
1186
593
  # be removed from the classapath shell script.
1187
594
  #
1188
595
  # Example:
@@ -1207,7 +614,7 @@ module Jnlp #:nodoc:
1207
614
  end
1208
615
  #
1209
616
  # returns the local file-based jnlp as a string
1210
- #
617
+ #
1211
618
  def to_local_jnlp
1212
619
  @local_jnlp.to_s
1213
620
  end
@@ -1230,7 +637,7 @@ module Jnlp #:nodoc:
1230
637
  # In addition a duplicate of the versioned jnlp is written without the version string as a snapshot
1231
638
  # jnlp and the version string is written to this file:
1232
639
  #
1233
- # jnlp-name-CURRENT_VERSION.txt
640
+ # jnlp-name-CURRENT_VERSION.txt
1234
641
  #
1235
642
  def write_jnlp(options={})
1236
643
  dir = options[:dir] || '.'
@@ -1249,9 +656,9 @@ module Jnlp #:nodoc:
1249
656
  #
1250
657
  # Writes a local file-based jnlp.
1251
658
  #
1252
- # Will write jnlp to current working directory
659
+ # Will write jnlp to current working directory
1253
660
  # using name of original jnlp with "local-" prefix.
1254
- #
661
+ #
1255
662
  def write_local_jnlp(filename=@local_jnlp_name)
1256
663
  destination = File.expand_path(filename)
1257
664
  unless @local_jnlp_href == destination
@@ -1264,8 +671,8 @@ module Jnlp #:nodoc:
1264
671
  #
1265
672
  # This will add all the jars for this jnlp to the effective
1266
673
  # classpath for this Java process.
1267
- #
1268
- # *If* you are already running in JRuby *AND* the jnlp references a
674
+ #
675
+ # *If* you are already running in JRuby *AND* the jnlp references a
1269
676
  # JRuby resource the JRuby resource will not be required.
1270
677
  #
1271
678
  def require_resources