libxml-fixed-jruby 1.0.0-jruby

Sign up to get free protection for your applications and to get access to all the features.
Files changed (92) hide show
  1. data/History.txt +4 -0
  2. data/Manifest.txt +91 -0
  3. data/README.txt +50 -0
  4. data/Rakefile +40 -0
  5. data/lib/libxml-jruby.rb +84 -0
  6. data/lib/libxml-jruby/xml.rb +1 -0
  7. data/lib/libxml-jruby/xml/attr.rb +46 -0
  8. data/lib/libxml-jruby/xml/attributes.rb +68 -0
  9. data/lib/libxml-jruby/xml/document.rb +52 -0
  10. data/lib/libxml-jruby/xml/dtd.rb +25 -0
  11. data/lib/libxml-jruby/xml/node.rb +285 -0
  12. data/lib/libxml-jruby/xml/ns.rb +19 -0
  13. data/lib/libxml-jruby/xml/parser.rb +121 -0
  14. data/lib/libxml-jruby/xml/xpath.rb +98 -0
  15. data/lib/libxml.rb +1 -0
  16. data/lib/xml.rb +13 -0
  17. data/lib/xml/libxml.rb +8 -0
  18. data/script/benchmark/depixelate.rb +633 -0
  19. data/script/benchmark/hamlet.xml +9055 -0
  20. data/script/benchmark/sock_entries.xml +507 -0
  21. data/script/benchmark/throughput.rb +40 -0
  22. data/script/benchmark/xml_benchmarks.rb +228 -0
  23. data/script/test +6 -0
  24. data/tasks/ann.rake +81 -0
  25. data/tasks/bones.rake +21 -0
  26. data/tasks/gem.rake +126 -0
  27. data/tasks/git.rake +41 -0
  28. data/tasks/manifest.rake +49 -0
  29. data/tasks/notes.rake +28 -0
  30. data/tasks/post_load.rake +39 -0
  31. data/tasks/rdoc.rake +51 -0
  32. data/tasks/rubyforge.rake +57 -0
  33. data/tasks/setup.rb +268 -0
  34. data/tasks/spec.rake +55 -0
  35. data/tasks/svn.rake +48 -0
  36. data/tasks/test.rake +38 -0
  37. data/test/etc_doc_to_s.rb +19 -0
  38. data/test/ets_copy_bug.rb +21 -0
  39. data/test/ets_copy_bug3.rb +38 -0
  40. data/test/ets_doc_file.rb +15 -0
  41. data/test/ets_doc_to_s.rb +21 -0
  42. data/test/ets_gpx.rb +26 -0
  43. data/test/ets_node_gc.rb +21 -0
  44. data/test/ets_test.xml +2 -0
  45. data/test/ets_tsr.rb +9 -0
  46. data/test/model/books.xml +147 -0
  47. data/test/model/default_validation_bug.rb +0 -0
  48. data/test/model/merge_bug_data.xml +58 -0
  49. data/test/model/rubynet.xml +78 -0
  50. data/test/model/rubynet_project +1 -0
  51. data/test/model/saxtest.xml +5 -0
  52. data/test/model/shiporder.rnc +28 -0
  53. data/test/model/shiporder.rng +86 -0
  54. data/test/model/shiporder.xml +23 -0
  55. data/test/model/shiporder.xsd +31 -0
  56. data/test/model/simple.xml +7 -0
  57. data/test/model/soap.xml +27 -0
  58. data/test/model/xinclude.xml +5 -0
  59. data/test/tc_attributes.rb +110 -0
  60. data/test/tc_deprecated_require.rb +13 -0
  61. data/test/tc_document.rb +97 -0
  62. data/test/tc_document_write.rb +139 -0
  63. data/test/tc_dtd.rb +70 -0
  64. data/test/tc_html_parser.rb +63 -0
  65. data/test/tc_node.rb +108 -0
  66. data/test/tc_node_attr.rb +176 -0
  67. data/test/tc_node_cdata.rb +51 -0
  68. data/test/tc_node_comment.rb +32 -0
  69. data/test/tc_node_copy.rb +40 -0
  70. data/test/tc_node_edit.rb +98 -0
  71. data/test/tc_node_set.rb +24 -0
  72. data/test/tc_node_set2.rb +37 -0
  73. data/test/tc_node_text.rb +17 -0
  74. data/test/tc_node_xlink.rb +28 -0
  75. data/test/tc_ns.rb +18 -0
  76. data/test/tc_parser.rb +308 -0
  77. data/test/tc_parser_context.rb +126 -0
  78. data/test/tc_properties.rb +37 -0
  79. data/test/tc_reader.rb +112 -0
  80. data/test/tc_relaxng.rb +39 -0
  81. data/test/tc_sax_parser.rb +113 -0
  82. data/test/tc_schema.rb +39 -0
  83. data/test/tc_traversal.rb +220 -0
  84. data/test/tc_well_formed.rb +11 -0
  85. data/test/tc_xinclude.rb +26 -0
  86. data/test/tc_xpath.rb +130 -0
  87. data/test/tc_xpath_context.rb +72 -0
  88. data/test/tc_xpointer.rb +78 -0
  89. data/test/test_libxml-jruby.rb +0 -0
  90. data/test/test_suite.rb +31 -0
  91. data/test/ts_working.rb +31 -0
  92. metadata +146 -0
@@ -0,0 +1,40 @@
1
+ $:.unshift(Dir.pwd + "/lib")
2
+ require 'rubygems'
3
+ require 'hpricot'
4
+ require 'xml'
5
+ require 'rexml/document'
6
+
7
+ ITERATIONS = 10
8
+ NESTED_ITERATIONS = 5
9
+
10
+ def bm(name, filename, &block)
11
+ text = File.open(filename).read
12
+ length = text.length / 1024.0 / 1024.0
13
+ puts "#{filename}: #{name} (#{(length * 1024).round} kb)"
14
+ for j in 0 .. NESTED_ITERATIONS
15
+ s = Time.now.to_f
16
+ for i in 0 .. ITERATIONS
17
+ block.call(text)
18
+ end
19
+ timer = Time.now.to_f - s
20
+ puts "\t#{length * ITERATIONS / timer} MB/s"
21
+ end
22
+ end
23
+
24
+ def bm_suite(filenames)
25
+ filenames.each do |filename|
26
+ bm("LIBXML THROUGHPUT:", filename) do |text|
27
+ XML::Parser.string(text).parse
28
+ end
29
+
30
+ bm("HPRICOT THROUGHPUT:", filename) do |text|
31
+ Hpricot.XML(text)
32
+ end
33
+
34
+ bm("REXML THROUGHPUT:", filename) do |text|
35
+ REXML::Document.new(text)
36
+ end
37
+ end
38
+ end
39
+
40
+ bm_suite("script/benchmark/hamlet.xml")
@@ -0,0 +1,228 @@
1
+ # From: https://svn.concord.org/svn/projects/trunk/common/ruby/xml_benchmarks/
2
+ #
3
+ # Each test has an XML Parser open a 98k XML document
4
+ # and count one type of leaf element (466 entries).
5
+ # This is repeated a total of 50 time sfor each Parser.
6
+ #
7
+ # These results were produced on:
8
+ # MacBook Pro
9
+ # 2.33 GHz Intel Core 2 Duo
10
+ # 4 GB memory
11
+ # running MacOS X 10.5.2
12
+ #
13
+ # Ruby versions tested:
14
+ # MRI: ruby 1.8.6 (2007-09-24 patchlevel 111) [universal-darwin9.0]
15
+ # JRuby: ruby 1.8.6 (2008-03-20 rev 6255) [i386-jruby1.1RC3] on Java 1.5.0_13
16
+ # JRuby: ruby 1.8.6 (2008-03-20 rev 6255) [i386-jruby1.1RC3] on Java 1.6.0_03 (Soylatte)
17
+ #
18
+ # Library versions MRI:
19
+ # libxml-ruby 0.5.2.0
20
+ # hpricot 0.6
21
+ #
22
+ # Library versions JRuby:
23
+ # hpricot 0.6.161
24
+ # jrexml 0.5.3
25
+ #
26
+ # Summary data: 100 iterations, timings from second set
27
+ #
28
+ # Platform and method total time
29
+ # -----------------------------------------------------------
30
+ # JRuby (Java 1.6.0) jdom_document_builder 0.363
31
+ # MRI: libxml 0.389
32
+ # JRuby (Java 1.6.0 server) jdom_document_builder 0.412
33
+ # JRuby (server) jdom_document_builder 0.617
34
+ # JRuby: jdom_document_builder 1.451
35
+ # MRI: hpricot 2.056
36
+ # JRuby (Java 1.6.0 server) hpricot 2.272
37
+ # JRuby (Java 1.6.0) hpricot 2.273
38
+ # JRuby (server) hpricot 3.447
39
+ # JRuby: hpricot 6.198
40
+ # JRuby (Java 1.6.0 server) rexml 6.251
41
+ # JRuby (Java 1.6.0) rexml 6.356
42
+ # MRI: rexml 7.624
43
+ # JRuby (server) rexml 9.609
44
+ # JRuby: rexml 12.944
45
+ #
46
+ # Detailed data:
47
+ #
48
+ # $ ruby ./xml_benchmarks.rb
49
+ #
50
+ # Ruby version: MRI 1.8.6 (2007-09-24 rev 111), platform: universal-darwin9.0
51
+ #
52
+ # 100 times: Open 98k XML document and count one type of leaf element (466 entries)
53
+ #
54
+ # Rehearsal -------------------------------------------
55
+ # rexml 7.650000 0.040000 7.690000 ( 7.692767)
56
+ # hpricot 2.100000 0.030000 2.130000 ( 2.133564)
57
+ # libxml 0.390000 0.030000 0.420000 ( 0.419391)
58
+ # --------------------------------- total: 10.240000sec
59
+ #
60
+ # user system total real
61
+ # rexml 7.600000 0.010000 7.610000 ( 7.624436)
62
+ # hpricot 2.040000 0.020000 2.060000 ( 2.056690)
63
+ # libxml 0.380000 0.010000 0.390000 ( 0.389298)
64
+ #
65
+ # $ jruby ./xml_benchmarks.rb
66
+ #
67
+ # Ruby version: JRuby 1.8.6 (2008-03-20 rev 6255) [i386-jruby1.1RC3], platform: Java: version: 1.5.0_13
68
+ #
69
+ # 100 times: Open 98k XML document and count one type of leaf element (466 entries)
70
+ #
71
+ # Rehearsal ---------------------------------------------------------
72
+ # rexml 14.063000 0.000000 14.063000 ( 14.063000)
73
+ # hpricot 6.579000 0.000000 6.579000 ( 6.579000)
74
+ # jdom_document_builder 2.211000 0.000000 2.211000 ( 2.211000)
75
+ # ----------------------------------------------- total: 22.853000sec
76
+ #
77
+ # user system total real
78
+ # rexml 12.944000 0.000000 12.944000 ( 12.944000)
79
+ # hpricot 6.198000 0.000000 6.198000 ( 6.198000)
80
+ # jdom_document_builder 1.450000 0.000000 1.450000 ( 1.451000)
81
+ #
82
+ # $ jruby -J-server ./xml_benchmarks.rb
83
+ #
84
+ # Ruby version: JRuby 1.8.6 (2008-03-20 rev 6255) [i386-jruby1.1RC3], platform: Java: version: 1.5.0_13
85
+ #
86
+ # 100 times: Open 98k XML document and count one type of leaf element (466 entries)
87
+ #
88
+ # Rehearsal ---------------------------------------------------------
89
+ # rexml 13.212000 0.000000 13.212000 ( 13.212000)
90
+ # hpricot 6.992000 0.000000 6.992000 ( 6.993000)
91
+ # jdom_document_builder 1.873000 0.000000 1.873000 ( 1.873000)
92
+ # ----------------------------------------------- total: 22.077000sec
93
+ #
94
+ # user system total real
95
+ # rexml 9.611000 0.000000 9.611000 ( 9.609000)
96
+ # hpricot 3.446000 0.000000 3.446000 ( 3.447000)
97
+ # jdom_document_builder 0.616000 0.000000 0.616000 ( 0.617000)
98
+ #
99
+ #
100
+ # *** Now using: Java 1.6.0_03 (Soylatte) ***
101
+ #
102
+ # $ jruby ./xml_benchmarks.rb
103
+ #
104
+ # Ruby version: JRuby 1.8.6 (2008-03-20 rev 6255) [i386-jruby1.1RC3], platform: Java: version: 1.6.0_03-p3
105
+ #
106
+ # 100 times: Open 98k XML document and count one type of leaf element (466 entries)
107
+ #
108
+ # Rehearsal ---------------------------------------------------------
109
+ # rexml 9.976000 0.000000 9.976000 ( 9.976000)
110
+ # hpricot 4.129000 0.000000 4.129000 ( 4.129000)
111
+ # jdom_document_builder 2.287000 0.000000 2.287000 ( 2.287000)
112
+ # ----------------------------------------------- total: 16.392000sec
113
+ #
114
+ # user system total real
115
+ # rexml 6.357000 0.000000 6.357000 ( 6.356000)
116
+ # hpricot 2.274000 0.000000 2.274000 ( 2.273000)
117
+ # jdom_document_builder 0.363000 0.000000 0.363000 ( 0.363000)
118
+ #
119
+ # $ jruby -J-server ./xml_benchmarks.rb
120
+ #
121
+ # Ruby version: JRuby 1.8.6 (2008-03-20 rev 6255) [i386-jruby1.1RC3], platform: Java: version: 1.6.0_03-p3
122
+ #
123
+ # 100 times: Open 98k XML document and count one type of leaf element (466 entries)
124
+ #
125
+ # Rehearsal ---------------------------------------------------------
126
+ # rexml 9.936000 0.000000 9.936000 ( 9.935000)
127
+ # hpricot 4.074000 0.000000 4.074000 ( 4.074000)
128
+ # jdom_document_builder 1.355000 0.000000 1.355000 ( 1.355000)
129
+ # ----------------------------------------------- total: 15.365000sec
130
+ #
131
+ # user system total real
132
+ # rexml 6.251000 0.000000 6.251000 ( 6.251000)
133
+ # hpricot 2.273000 0.000000 2.273000 ( 2.272000)
134
+ # jdom_document_builder 0.412000 0.000000 0.412000 ( 0.412000)
135
+ #
136
+
137
+ $:.unshift 'lib'
138
+ $:.unshift 'ext/libxml'
139
+
140
+ __DIR__ = File.dirname(__FILE__)
141
+
142
+ require 'benchmark'
143
+ require 'rexml/document'
144
+ require 'hpricot'
145
+
146
+ if RUBY_PLATFORM =~ /java/
147
+ include Java
148
+ import javax.xml.parsers.DocumentBuilder
149
+ import javax.xml.parsers.DocumentBuilderFactory
150
+ @dbf = DocumentBuilderFactory.new_instance
151
+ @ruby_info = "Ruby version: JRuby #{RUBY_VERSION} (#{RUBY_RELEASE_DATE} rev #{RUBY_PATCHLEVEL}) [i386-jruby#{JRUBY_VERSION}]"
152
+ @ruby_info << ", platform: Java, version #{java.lang.System.getProperty('java.version')}"
153
+ else
154
+ require 'xml'
155
+ @xml_parser = XML::Parser.new
156
+ @ruby_info = "Ruby version: MRI #{RUBY_VERSION} (#{RUBY_RELEASE_DATE}"# rev #{RUBY_PATCHLEVEL})"
157
+ @ruby_info << ", platform: #{RUBY_PLATFORM}"
158
+ end
159
+
160
+ @bundle_with_466_sock_entries = File.read(File.join(__DIR__,"sock_entries.xml"))
161
+
162
+ def rexml_count_socks
163
+ doc = REXML::Document.new(@bundle_with_466_sock_entries).root
164
+ socks = doc.elements.to_a('./sockEntries').length
165
+ end
166
+
167
+ unless RUBY_PLATFORM =~ /java/
168
+ def libxml_count_socks
169
+ @xml_parser.string = @bundle_with_466_sock_entries
170
+ doc = @xml_parser.parse.root
171
+ socks = doc.find('//sockEntries').length
172
+ end
173
+ end
174
+
175
+ def hpricot_count_socks
176
+ doc = Hpricot.XML(@bundle_with_466_sock_entries)
177
+ socks = doc.search("//sockEntries").length
178
+ end
179
+
180
+ if RUBY_PLATFORM =~ /java/
181
+ def jdom_document_builder_count_socks
182
+ doc = @dbf.new_document_builder.parse("bundle_with_466_sock_entries.xml").get_document_element
183
+ socks = doc.getElementsByTagName("sockEntries")
184
+ socks.get_length
185
+ end
186
+ end
187
+
188
+ n = 100
189
+ test_iterations = ARGV.first.to_i
190
+ test_iterations = 1 unless test_iterations > 1
191
+ puts
192
+ puts @ruby_info
193
+ puts
194
+ puts "#{n} times: Open 98k XML document and count one type of leaf element (466 entries)"
195
+ puts
196
+ print "running benchmark "
197
+ if test_iterations == 1
198
+ puts "once.\n\n"
199
+ else
200
+ puts "#{test_iterations} times.\n\n"
201
+ end
202
+ test_iterations.times do
203
+ Benchmark.bmbm do |x|
204
+ x.report("libxml") { n.times {libxml_count_socks} } unless RUBY_PLATFORM =~ /java/
205
+ x.report("hpricot") { n.times {hpricot_count_socks} }
206
+ x.report("rexml") { n.times {rexml_count_socks} }
207
+ x.report("jdom_document_builder") { n.times {jdom_document_builder_count_socks} } if RUBY_PLATFORM =~ /java/
208
+ end
209
+ puts
210
+ end
211
+
212
+ #
213
+ # jrexml doesn't appear to have any speedup in this test
214
+ #
215
+ # if RUBY_PLATFORM =~ /java/
216
+ # require 'jrexml'
217
+ # def rexml_with_jrexml_count_socks
218
+ # doc = REXML::Document.new(@bundle_with_466_sock_entries).root
219
+ # socks = doc.elements.to_a('./sockEntries').length
220
+ # end
221
+ #
222
+ # puts "\nNow add in JREXML to see if it speeds up rexml\n"
223
+ # Benchmark.bmbm do |x|
224
+ # x.report("rexml+jrexml") { n.times {rexml_with_jrexml_count_socks} }
225
+ # end
226
+ # puts
227
+ # end
228
+
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ %w{test lib ext/libxml}.each{ |path| $LOAD_PATH.unshift(path) }
4
+
5
+ load './test/test_suite.rb'
6
+
@@ -0,0 +1,81 @@
1
+ # $Id$
2
+
3
+ begin
4
+ require 'bones/smtp_tls'
5
+ rescue LoadError
6
+ require 'net/smtp'
7
+ end
8
+ require 'time'
9
+
10
+ namespace :ann do
11
+
12
+ # A prerequisites task that all other tasks depend upon
13
+ task :prereqs
14
+
15
+ file PROJ.ann.file do
16
+ ann = PROJ.ann
17
+ puts "Generating #{ann.file}"
18
+ File.open(ann.file,'w') do |fd|
19
+ fd.puts("#{PROJ.name} version #{PROJ.version}")
20
+ fd.puts(" by #{Array(PROJ.authors).first}") if PROJ.authors
21
+ fd.puts(" #{PROJ.url}") if PROJ.url.valid?
22
+ fd.puts(" (the \"#{PROJ.release_name}\" release)") if PROJ.release_name
23
+ fd.puts
24
+ fd.puts("== DESCRIPTION")
25
+ fd.puts
26
+ fd.puts(PROJ.description)
27
+ fd.puts
28
+ fd.puts(PROJ.changes.sub(%r/^.*$/, '== CHANGES'))
29
+ fd.puts
30
+ ann.paragraphs.each do |p|
31
+ fd.puts "== #{p.upcase}"
32
+ fd.puts
33
+ fd.puts paragraphs_of(PROJ.readme_file, p).join("\n\n")
34
+ fd.puts
35
+ end
36
+ fd.puts ann.text if ann.text
37
+ end
38
+ end
39
+
40
+ desc "Create an announcement file"
41
+ task :announcement => ['ann:prereqs', PROJ.ann.file]
42
+
43
+ desc "Send an email announcement"
44
+ task :email => ['ann:prereqs', PROJ.ann.file] do
45
+ ann = PROJ.ann
46
+ from = ann.email[:from] || PROJ.email
47
+ to = Array(ann.email[:to])
48
+
49
+ ### build a mail header for RFC 822
50
+ rfc822msg = "From: #{from}\n"
51
+ rfc822msg << "To: #{to.join(',')}\n"
52
+ rfc822msg << "Subject: [ANN] #{PROJ.name} #{PROJ.version}"
53
+ rfc822msg << " (#{PROJ.release_name})" if PROJ.release_name
54
+ rfc822msg << "\n"
55
+ rfc822msg << "Date: #{Time.new.rfc822}\n"
56
+ rfc822msg << "Message-Id: "
57
+ rfc822msg << "<#{"%.8f" % Time.now.to_f}@#{ann.email[:domain]}>\n\n"
58
+ rfc822msg << File.read(ann.file)
59
+
60
+ params = [:server, :port, :domain, :acct, :passwd, :authtype].map do |key|
61
+ ann.email[key]
62
+ end
63
+
64
+ params[3] = PROJ.email if params[3].nil?
65
+
66
+ if params[4].nil?
67
+ STDOUT.write "Please enter your e-mail password (#{params[3]}): "
68
+ params[4] = STDIN.gets.chomp
69
+ end
70
+
71
+ ### send email
72
+ Net::SMTP.start(*params) {|smtp| smtp.sendmail(rfc822msg, from, to)}
73
+ end
74
+ end # namespace :ann
75
+
76
+ desc 'Alias to ann:announcement'
77
+ task :ann => 'ann:announcement'
78
+
79
+ CLOBBER << PROJ.ann.file
80
+
81
+ # EOF
@@ -0,0 +1,21 @@
1
+ # $Id$
2
+
3
+ if HAVE_BONES
4
+
5
+ namespace :bones do
6
+
7
+ desc 'Show the PROJ open struct'
8
+ task :debug do |t|
9
+ atr = if t.application.top_level_tasks.length == 2
10
+ t.application.top_level_tasks.pop
11
+ end
12
+
13
+ if atr then Bones::Debug.show_attr(PROJ, atr)
14
+ else Bones::Debug.show PROJ end
15
+ end
16
+
17
+ end # namespace :bones
18
+
19
+ end # HAVE_BONES
20
+
21
+ # EOF
@@ -0,0 +1,126 @@
1
+ # $Id$
2
+
3
+ require 'rake/gempackagetask'
4
+
5
+ namespace :gem do
6
+
7
+ PROJ.gem._spec = Gem::Specification.new do |s|
8
+ s.name = PROJ.name
9
+ s.version = PROJ.version
10
+ s.summary = PROJ.summary
11
+ s.authors = Array(PROJ.authors)
12
+ s.email = PROJ.email
13
+ s.homepage = Array(PROJ.url).first
14
+ s.rubyforge_project = PROJ.rubyforge.name
15
+
16
+ s.description = PROJ.description
17
+
18
+ PROJ.gem.dependencies.each do |dep|
19
+ s.add_dependency(*dep)
20
+ end
21
+
22
+ s.files = PROJ.gem.files
23
+ s.executables = PROJ.gem.executables.map {|fn| File.basename(fn)}
24
+ s.extensions = PROJ.gem.files.grep %r/extconf\.rb$/
25
+
26
+ s.bindir = 'bin'
27
+ dirs = Dir["{#{PROJ.libs.join(',')}}"]
28
+ s.require_paths = dirs unless dirs.empty?
29
+
30
+ incl = Regexp.new(PROJ.rdoc.include.join('|'))
31
+ excl = PROJ.rdoc.exclude.dup.concat %w[\.rb$ ^(\.\/|\/)?ext]
32
+ excl = Regexp.new(excl.join('|'))
33
+ rdoc_files = PROJ.gem.files.find_all do |fn|
34
+ case fn
35
+ when excl; false
36
+ when incl; true
37
+ else false end
38
+ end
39
+ s.rdoc_options = PROJ.rdoc.opts + ['--main', PROJ.rdoc.main]
40
+ s.extra_rdoc_files = rdoc_files
41
+ s.has_rdoc = true
42
+
43
+ if test ?f, PROJ.test.file
44
+ s.test_file = PROJ.test.file
45
+ else
46
+ s.test_files = PROJ.test.files.to_a
47
+ end
48
+
49
+ # Do any extra stuff the user wants
50
+ PROJ.gem.extras.each do |msg, val|
51
+ case val
52
+ when Proc
53
+ val.call(s.send(msg))
54
+ else
55
+ s.send "#{msg}=", val
56
+ end
57
+ end
58
+ end # Gem::Specification.new
59
+
60
+ # A prerequisites task that all other tasks depend upon
61
+ task :prereqs
62
+
63
+ desc 'Show information about the gem'
64
+ task :debug => 'gem:prereqs' do
65
+ puts PROJ.gem._spec.to_ruby
66
+ end
67
+
68
+ pkg = Rake::PackageTask.new(PROJ.name, PROJ.version) do |pkg|
69
+ pkg.need_tar = PROJ.gem.need_tar
70
+ pkg.need_zip = PROJ.gem.need_zip
71
+ pkg.package_files += PROJ.gem._spec.files
72
+ end
73
+ Rake::Task['gem:package'].instance_variable_set(:@full_comment, nil)
74
+
75
+ gem_file = if PROJ.gem._spec.platform == Gem::Platform::RUBY
76
+ "#{pkg.package_name}.gem"
77
+ else
78
+ "#{pkg.package_name}-#{PROJ.gem._spec.platform}.gem"
79
+ end
80
+
81
+ desc "Build the gem file #{gem_file}"
82
+ task :package => ['gem:prereqs', "#{pkg.package_dir}/#{gem_file}"]
83
+
84
+ file "#{pkg.package_dir}/#{gem_file}" => [pkg.package_dir] + PROJ.gem._spec.files do
85
+ when_writing("Creating GEM") {
86
+ Gem::Builder.new(PROJ.gem._spec).build
87
+ verbose(true) {
88
+ mv gem_file, "#{pkg.package_dir}/#{gem_file}"
89
+ }
90
+ }
91
+ end
92
+
93
+ desc 'Install the gem'
94
+ task :install => [:clobber, 'gem:package'] do
95
+ sh "#{SUDO} #{GEM} install --local pkg/#{PROJ.gem._spec.full_name}"
96
+
97
+ # use this version of the command for rubygems > 1.0.0
98
+ #sh "#{SUDO} #{GEM} install --no-update-sources pkg/#{PROJ.gem._spec.full_name}"
99
+ end
100
+
101
+ desc 'Uninstall the gem'
102
+ task :uninstall do
103
+ installed_list = Gem.source_index.find_name(PROJ.name)
104
+ if installed_list and installed_list.collect { |s| s.version.to_s}.include?(PROJ.version) then
105
+ sh "#{SUDO} #{GEM} uninstall --version '#{PROJ.version}' --ignore-dependencies --executables #{PROJ.name}"
106
+ end
107
+ end
108
+
109
+ desc 'Reinstall the gem'
110
+ task :reinstall => [:uninstall, :install]
111
+
112
+ desc 'Cleanup the gem'
113
+ task :cleanup do
114
+ sh "#{SUDO} #{GEM} cleanup #{PROJ.gem._spec.name}"
115
+ end
116
+
117
+ end # namespace :gem
118
+
119
+ desc 'Alias to gem:package'
120
+ task :gem => 'gem:package'
121
+
122
+ task :clobber => 'gem:clobber_package'
123
+
124
+ remove_desc_for_task %w(gem:clobber_package)
125
+
126
+ # EOF