linkparser 1.0.3 → 1.0.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,26 @@
1
+ # 1.9.1 fixes
2
+
3
+
4
+ # Make Pathname compatible with 1.8.7 Pathname.
5
+ unless Pathname.instance_methods.include?( :=~ )
6
+ class Pathname
7
+ def self::glob( *args ) # :yield: p
8
+ args = args.collect {|p| p.to_s }
9
+ if block_given?
10
+ Dir.glob(*args) {|f| yield self.new(f) }
11
+ else
12
+ Dir.glob(*args).map {|f| self.new(f) }
13
+ end
14
+ end
15
+
16
+ def =~( other )
17
+ self.to_s =~ other
18
+ end
19
+
20
+ def to_str
21
+ self.to_s
22
+ end
23
+ end
24
+ end
25
+
26
+
data/rake/helpers.rb CHANGED
@@ -1,9 +1,23 @@
1
+ # encoding: utf-8
1
2
  #####################################################################
2
3
  ### G L O B A L H E L P E R F U N C T I O N S
3
4
  #####################################################################
4
5
 
6
+
5
7
  require 'pathname'
6
- require 'readline'
8
+ require 'uri'
9
+ require 'open3'
10
+
11
+ begin
12
+ require 'readline'
13
+ include Readline
14
+ rescue LoadError
15
+ # Fall back to a plain prompt
16
+ def readline( text )
17
+ $stderr.print( text.chomp )
18
+ return $stdin.gets
19
+ end
20
+ end
7
21
 
8
22
  # Set some ANSI escape code constants (Shamelessly stolen from Perl's
9
23
  # Term::ANSIColor by Russ Allbery <rra@stanford.edu> and Zenin <zenin@best.com>
@@ -42,7 +56,7 @@ CLEAR_CURRENT_LINE = "\e[2K"
42
56
  ### Output a logging message
43
57
  def log( *msg )
44
58
  output = colorize( msg.flatten.join(' '), 'cyan' )
45
- $deferr.puts( output )
59
+ $stderr.puts( output )
46
60
  end
47
61
 
48
62
 
@@ -50,7 +64,7 @@ end
50
64
  def trace( *msg )
51
65
  return unless $trace
52
66
  output = colorize( msg.flatten.join(' '), 'yellow' )
53
- $deferr.puts( output )
67
+ $stderr.puts( output )
54
68
  end
55
69
 
56
70
 
@@ -66,7 +80,7 @@ def run( *cmd )
66
80
  end
67
81
 
68
82
  if $dryrun
69
- $deferr.puts "(dry run mode)"
83
+ $stderr.puts "(dry run mode)"
70
84
  else
71
85
  system( *cmd )
72
86
  unless $?.success?
@@ -91,7 +105,7 @@ def pipeto( *cmd )
91
105
  cmd.flatten!
92
106
  log( "Opening a pipe to: ", cmd.collect {|part| part =~ /\s/ ? part.inspect : part} )
93
107
  if $dryrun
94
- $deferr.puts "(dry run mode)"
108
+ $stderr.puts "(dry run mode)"
95
109
  else
96
110
  open( '|-', 'w+' ) do |io|
97
111
 
@@ -111,52 +125,35 @@ end
111
125
 
112
126
  ### Download the file at +sourceuri+ via HTTP and write it to +targetfile+.
113
127
  def download( sourceuri, targetfile=nil )
114
- oldsync = $defout.sync
115
- $defout.sync = true
116
- require 'net/http'
117
- require 'uri'
128
+ oldsync = $stdout.sync
129
+ $stdout.sync = true
130
+ require 'open-uri'
118
131
 
119
132
  targetpath = Pathname.new( targetfile )
120
133
 
121
134
  log "Downloading %s to %s" % [sourceuri, targetfile]
122
- targetpath.open( File::WRONLY|File::TRUNC|File::CREAT, 0644 ) do |ofh|
123
-
124
- url = sourceuri.is_a?( URI ) ? sourceuri : URI.parse( sourceuri )
125
- downloaded = false
126
- limit = 5
127
-
128
- until downloaded or limit.zero?
129
- Net::HTTP.start( url.host, url.port ) do |http|
130
- req = Net::HTTP::Get.new( url.path )
131
-
132
- http.request( req ) do |res|
133
- if res.is_a?( Net::HTTPSuccess )
134
- log "Downloading..."
135
- res.read_body do |buf|
136
- ofh.print( buf )
137
- end
138
- downloaded = true
139
- puts "done."
135
+ trace " connecting..."
136
+ ifh = open( sourceuri ) do |ifh|
137
+ trace " connected..."
138
+ targetpath.open( File::WRONLY|File::TRUNC|File::CREAT, 0644 ) do |ofh|
139
+ log "Downloading..."
140
+ buf = ''
140
141
 
141
- elsif res.is_a?( Net::HTTPRedirection )
142
- url = URI.parse( res['location'] )
143
- log "...following redirection to: %s" % [ url ]
144
- limit -= 1
145
- sleep 0.2
146
- next
147
-
148
- else
149
- res.error!
150
- end
142
+ while ifh.read( 16384, buf )
143
+ until buf.empty?
144
+ bytes = ofh.write( buf )
145
+ buf.slice!( 0, bytes )
151
146
  end
152
147
  end
148
+
149
+ log "Done."
153
150
  end
154
151
 
155
152
  end
156
153
 
157
154
  return targetpath
158
155
  ensure
159
- $defout.sync = oldsync
156
+ $stdout.sync = oldsync
160
157
  end
161
158
 
162
159
 
@@ -172,12 +169,12 @@ end
172
169
  def ansi_code( *attributes )
173
170
  attributes.flatten!
174
171
  attributes.collect! {|at| at.to_s }
175
- # $deferr.puts "Returning ansicode for TERM = %p: %p" %
172
+ # $stderr.puts "Returning ansicode for TERM = %p: %p" %
176
173
  # [ ENV['TERM'], attributes ]
177
174
  return '' unless /(?:vt10[03]|xterm(?:-color)?|linux|screen)/i =~ ENV['TERM']
178
175
  attributes = ANSI_ATTRIBUTES.values_at( *attributes ).compact.join(';')
179
176
 
180
- # $deferr.puts " attr is: %p" % [attributes]
177
+ # $stderr.puts " attr is: %p" % [attributes]
181
178
  if attributes.empty?
182
179
  return ''
183
180
  else
@@ -207,7 +204,7 @@ end
207
204
  ### Output the specified <tt>msg</tt> as an ANSI-colored error message
208
205
  ### (white on red).
209
206
  def error_message( msg, details='' )
210
- $deferr.puts colorize( 'bold', 'white', 'on_red' ) { msg } + details
207
+ $stderr.puts colorize( 'bold', 'white', 'on_red' ) { msg } + details
211
208
  end
212
209
  alias :error :error_message
213
210
 
@@ -229,7 +226,7 @@ def prompt( prompt_string, failure_msg="Try again." ) # :yields: response
229
226
 
230
227
  begin
231
228
  prompt = make_prompt_string( prompt_string )
232
- response = Readline.readline( prompt ) || ''
229
+ response = readline( prompt ) || ''
233
230
  response.strip!
234
231
  if block_given? && ! yield( response )
235
232
  error_message( failure_msg + "\n\n" )
@@ -280,7 +277,7 @@ def prompt_for_multiple_values( label, default=nil )
280
277
  result = nil
281
278
 
282
279
  begin
283
- result = Readline.readline( make_prompt_string("> ") )
280
+ result = readline( make_prompt_string("> ") )
284
281
  if result.nil? || result.empty?
285
282
  results << default if default && results.empty?
286
283
  else
@@ -365,6 +362,26 @@ def find_pattern_in_file( regexp, file )
365
362
  end
366
363
 
367
364
 
365
+ ### Search line-by-line in the output of the specified +cmd+ for the given +regexp+,
366
+ ### returning the first match, or nil if no match was found. If the +regexp+ has any
367
+ ### capture groups, those will be returned in an Array, else the whole matching line
368
+ ### is returned.
369
+ def find_pattern_in_pipe( regexp, *cmd )
370
+ output = []
371
+
372
+ log( cmd.collect {|part| part =~ /\s/ ? part.inspect : part} )
373
+ Open3.popen3( *cmd ) do |stdin, stdout, stderr|
374
+ stdin.close
375
+
376
+ output << stdout.gets until stdout.eof?
377
+ output << stderr.gets until stderr.eof?
378
+ end
379
+
380
+ result = output.find { |line| regexp.match(line) }
381
+ return $1 || result
382
+ end
383
+
384
+
368
385
  ### Invoke the user's editor on the given +filename+ and return the exit code
369
386
  ### from doing so.
370
387
  def edit( filename )
data/rake/manual.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  #
2
2
  # Manual-generation Rake tasks and classes
3
- # $Id: manual.rb 41 2008-08-28 16:46:09Z deveiant $
3
+ # $Id: manual.rb 95 2009-04-02 15:21:01Z deveiant $
4
4
  #
5
5
  # Authors:
6
6
  # * Michael Granger <ged@FaerieMUD.org>
@@ -292,7 +292,7 @@ module Manual
292
292
  # directory
293
293
  attr_reader :uri_index
294
294
 
295
- # The hierarchy of pages in the catalog, suitable for generating an on-page
295
+ # The hierarchy of pages in the catalog, suitable for generating an on-page index
296
296
  attr_reader :hierarchy
297
297
 
298
298
  # An Array of all Manual::Page objects found
@@ -356,21 +356,21 @@ module Manual
356
356
  if page_or_section[INDEX_PATH]
357
357
  idx = page_or_section[INDEX_PATH].config['index']
358
358
  trace "Index page's index for directory '%s' is: %p" % [ subpath, idx ]
359
- idx || subpath
359
+ idx.to_s || subpath.to_s
360
360
  else
361
361
  trace "Using the path for the sort of directory %p" % [ subpath ]
362
- subpath
362
+ subpath.to_s
363
363
  end
364
364
 
365
365
  # Page
366
366
  else
367
367
  if subpath == INDEX_PATH
368
368
  trace "Sort index for index page %p is 0" % [ subpath ]
369
- 0
369
+ '0'
370
370
  else
371
371
  idx = page_or_section.config['index']
372
372
  trace "Sort index for page %p is: %p" % [ subpath, idx ]
373
- idx || subpath
373
+ idx.to_s || subpath.to_s
374
374
  end
375
375
  end
376
376
 
@@ -384,12 +384,14 @@ module Manual
384
384
  ### for an index section and call it, then recurse into the section contents.
385
385
  def handle_section_callback( path, section, from=nil, &builder )
386
386
  from_current = false
387
+ trace "Section handler: path=%p, section keys=%p, from=%s" %
388
+ [ path, section.keys, from.sourcefile ]
387
389
 
388
390
  # Call the callback with :section -- determine the section title from
389
391
  # the 'index.page' file underneath it, or the directory name if no
390
392
  # index.page exists.
391
393
  if section.key?( INDEX_PATH )
392
- if section[INDEX_PATH] == from
394
+ if section[INDEX_PATH].sourcefile.dirname == from.sourcefile.dirname
393
395
  from_current = true
394
396
  builder.call( :current_section, section[INDEX_PATH].title, path )
395
397
  else
@@ -563,7 +565,7 @@ module Manual
563
565
  manual_pages = setup_page_conversion_tasks( sourcedir, outputdir, catalog )
564
566
 
565
567
  desc "Build the manual"
566
- task :build => [ :rdoc, :copy_resources, :generate_pages ]
568
+ task :build => [ :rdoc, :copy_resources, :copy_apidocs, :generate_pages ]
567
569
 
568
570
  task :clobber do
569
571
  RakeFileUtils.verbose( $verbose ) do
@@ -574,6 +576,25 @@ module Manual
574
576
 
575
577
  desc "Remove any previously-generated parts of the manual and rebuild it"
576
578
  task :rebuild => [ :clobber, self.name ]
579
+
580
+ desc "Watch for changes to the source files and rebuild when they change"
581
+ task :autobuild do
582
+ scope = [ self.name ]
583
+ loop do
584
+ t = Rake.application.lookup( :build, scope )
585
+ t.reenable
586
+ t.prerequisites.each do |pt|
587
+ if task = Rake.application.lookup( pt, scope )
588
+ task.reenable
589
+ else
590
+ trace "Hmmm... no %p task in scope %p?" % [ pt, scope ]
591
+ end
592
+ end
593
+ t.invoke
594
+ sleep 2
595
+ trace " waking up..."
596
+ end
597
+ end
577
598
  end
578
599
 
579
600
  end # def define
@@ -643,9 +664,10 @@ module Manual
643
664
  target = task.name
644
665
 
645
666
  when_writing do
646
- log " #{source} -> #{target}"
647
- mkpath File.dirname( target )
648
- cp source, target, :verbose => $trace
667
+ trace " #{source} -> #{target}"
668
+ mkpath File.dirname( target ), :verbose => $trace unless
669
+ File.directory?( File.dirname(target) )
670
+ install source, target, :mode => 0644, :verbose => $trace
649
671
  end
650
672
  end
651
673
 
@@ -663,9 +685,16 @@ module Manual
663
685
  file( targets[i] => [ outputdir.to_s, resource ], &copier )
664
686
  end
665
687
 
688
+ desc "Copy API documentation to the manual output directory"
689
+ task :copy_apidocs => :rdoc do
690
+ cp_r( RDOCDIR, outputdir )
691
+ end
692
+
666
693
  # Now group all the resource file tasks into a containing task
667
694
  desc "Copy manual resources to the output directory"
668
- task :copy_resources => targets
695
+ task :copy_resources => targets do
696
+ log "Copying manual resources"
697
+ end
669
698
  end
670
699
 
671
700
  end # class Manual::GenTask
@@ -690,9 +719,7 @@ if MANUALDIR.exist?
690
719
  manual.source_dir = 'src'
691
720
  end
692
721
 
693
- task :clobber_manual do
694
- rmtree( MANUALOUTPUTDIR, :verbose => true )
695
- end
722
+ CLOBBER.include( MANUALOUTPUTDIR.to_s )
696
723
 
697
724
  rescue LoadError => err
698
725
  task :no_manual do
data/rake/packaging.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  #
2
2
  # Packaging Rake Tasks
3
- # $Id: packaging.rb 21 2008-08-07 23:45:52Z deveiant $
3
+ # $Id: packaging.rb 102 2009-05-23 21:40:00Z deveiant $
4
4
  #
5
5
 
6
6
  require 'rbconfig'
@@ -16,8 +16,7 @@ Rake::PackageTask.new( PKG_NAME, PKG_VERSION ) do |task|
16
16
  task.need_tar_bz2 = true
17
17
  task.need_zip = true
18
18
  task.package_dir = PKGDIR.to_s
19
- task.package_files = RELEASE_FILES.
20
- collect {|f| f.relative_path_from(BASEDIR).to_s }
19
+ task.package_files = RELEASE_FILES.collect {|f| f.to_s }
21
20
  end
22
21
  task :package => [:gem]
23
22
 
@@ -36,9 +35,27 @@ file gempath.to_s => [PKGDIR.to_s] + GEMSPEC.files do
36
35
  end
37
36
  end
38
37
 
38
+ svnrev = get_svn_rev()
39
+ prerelease_gem_file_name = "#{PKG_FILE_NAME}.#{svnrev}.gem"
40
+ prerelease_gempath = PKGDIR + prerelease_gem_file_name
41
+
42
+ desc "Build a pre-release RubyGem package"
43
+ task :prerelease_gem => prerelease_gempath.to_s
44
+ file prerelease_gempath.to_s => [PKGDIR.to_s] + GEMSPEC.files do
45
+ when_writing( "Creating prerelease GEM" ) do
46
+ gemspec = GEMSPEC.clone
47
+ gemspec.version = Gem::Version.create( "%s.%d" % [GEMSPEC.version, svnrev] )
48
+ Gem::Builder.new( gemspec ).build
49
+ verbose( true ) do
50
+ mv prerelease_gem_file_name, prerelease_gempath
51
+ end
52
+ end
53
+ end
54
+
55
+
39
56
  ### Task: install
40
57
  desc "Install #{PKG_NAME} as a conventional library"
41
- task :install do
58
+ task :install => "spec:quiet" do
42
59
  log "Installing #{PKG_NAME} as a conventional library"
43
60
  sitelib = Pathname.new( CONFIG['sitelibdir'] )
44
61
  sitearch = Pathname.new( CONFIG['sitearchdir'] )
@@ -53,8 +70,10 @@ task :install do
53
70
  end
54
71
  end
55
72
  if EXTDIR.exist?
73
+ trace " looking for a binary extension (%s)" % [ EXTDIR + "*.#{Config::CONFIG['DLEXT']}" ]
56
74
  Dir.chdir( EXTDIR ) do
57
- Pathname.glob( EXTDIR + Config::CONFIG['DLEXT'] ) do |dl|
75
+ Pathname.glob( "*.#{Config::CONFIG['DLEXT']}" ) do |dl|
76
+ trace " found: #{dl}"
58
77
  target = sitearch + dl.basename
59
78
  FileUtils.install dl, target,
60
79
  :mode => 0755, :verbose => true, :noop => $dryrun
@@ -91,8 +110,10 @@ task :uninstall do
91
110
  end
92
111
  end
93
112
  if EXTDIR.exist?
113
+ trace " looking for a binary extension (%s)" % [ EXTDIR + "*.#{Config::CONFIG['DLEXT']}" ]
94
114
  Dir.chdir( EXTDIR ) do
95
- Pathname.glob( EXTDIR + Config::CONFIG['DLEXT'] ) do |dl|
115
+ Pathname.glob( "*.#{Config::CONFIG['DLEXT']}" ) do |dl|
116
+ trace " found: #{dl}"
96
117
  target = sitearch + dl.basename
97
118
  FileUtils.rm target, :verbose => true, :noop => $dryrun
98
119
  end
data/rake/publishing.rb CHANGED
@@ -26,8 +26,8 @@ class Net::SMTP
26
26
  return self
27
27
  end
28
28
  end
29
-
30
-
29
+
30
+
31
31
  #######
32
32
  private
33
33
  #######
@@ -100,10 +100,10 @@ begin
100
100
 
101
101
 
102
102
  namespace :release do
103
- task :default => [ 'svn:release', :publish, :announce, :project ]
103
+ task :default => [ 'svn:release', :upload, :publish, :announce ]
104
104
 
105
105
  desc "Re-publish the release with the current version number"
106
- task :rerelease => [ :publish, :announce, :project ]
106
+ task :rerelease => [ :upload, :publish, :announce ]
107
107
 
108
108
  desc "Re-run the publication tasks, but send notifications to debugging address"
109
109
  task :test do
@@ -111,7 +111,7 @@ begin
111
111
  $publish_privately = true
112
112
  Rake::Task['release:rerelease'].invoke
113
113
  end
114
-
114
+
115
115
 
116
116
  desc "Generate the release notes"
117
117
  task :notes => [RELEASE_NOTES_FILE]
@@ -130,14 +130,23 @@ begin
130
130
  edit task.name
131
131
  end
132
132
  CLOBBER.include( RELEASE_NOTES_FILE )
133
-
134
-
135
- desc "Publish the project documentation to #{PROJECT_HOST}"
136
- task :project => [ :rdoc ] do
133
+
134
+
135
+ desc "Upload project documentation and packages to #{PROJECT_HOST}"
136
+ task :upload => [ :upload_docs, :upload_packages ]
137
+ task :project => :upload # the old name
138
+
139
+ desc "Publish the project docs to #{PROJECT_HOST}"
140
+ task :upload_docs => [ :rdoc ] do
137
141
  when_writing( "Publishing docs to #{PROJECT_SCPDOCURL}" ) do
142
+ log "Uploading API documentation to %s:%s" % [ PROJECT_HOST, PROJECT_DOCDIR ]
138
143
  run 'ssh', PROJECT_HOST, "rm -rf #{PROJECT_DOCDIR}"
139
144
  run 'scp', '-qCr', RDOCDIR, PROJECT_SCPDOCURL
140
145
  end
146
+ end
147
+
148
+ desc "Publish the project packages to #{PROJECT_HOST}"
149
+ task :upload_packages => [ :package ] do
141
150
  when_writing( "Uploading packages") do
142
151
  pkgs = Pathname.glob( PKGDIR + "#{PKG_FILE_NAME}.{gem,tar.gz,tar.bz2,zip}" )
143
152
  log "Uploading %d packages to #{PROJECT_SCPPUBURL}" % [ pkgs.length ]
@@ -147,7 +156,7 @@ begin
147
156
  end
148
157
  end
149
158
 
150
-
159
+
151
160
  file RELEASE_ANNOUNCE_FILE => [RELEASE_NOTES_FILE] do |task|
152
161
  relnotes = File.read( RELEASE_NOTES_FILE )
153
162
  announce_body = %{
@@ -163,7 +172,7 @@ begin
163
172
  == Installation
164
173
 
165
174
  Via gems:
166
-
175
+
167
176
  $ sudo gem install #{GEMSPEC.name}
168
177
 
169
178
  or from source:
@@ -176,7 +185,7 @@ begin
176
185
  == Changes
177
186
  #{relnotes}
178
187
  }.gsub( /^\t+/, '' )
179
-
188
+
180
189
  File.open( task.name, File::WRONLY|File::TRUNC|File::CREAT ) do |fh|
181
190
  fh.print( announce_body )
182
191
  end
@@ -184,8 +193,8 @@ begin
184
193
  edit task.name
185
194
  end
186
195
  CLOBBER.include( RELEASE_ANNOUNCE_FILE )
187
-
188
-
196
+
197
+
189
198
  desc 'Send out a release announcement'
190
199
  task :announce => [RELEASE_ANNOUNCE_FILE] do
191
200
  email = TMail::Mail.new
@@ -208,13 +217,13 @@ begin
208
217
  puts '---',
209
218
  email.to_s,
210
219
  '---'
211
-
220
+
212
221
  ask_for_confirmation( "Will send via #{SMTP_HOST}." ) do
213
222
  pwent = Etc.getpwuid( Process.euid )
214
223
  curuser = pwent ? pwent.name : 'unknown'
215
224
  username = prompt_with_default( "SMTP user", curuser )
216
225
  password = prompt_for_password()
217
-
226
+
218
227
  trace "Creating SMTP connection to #{SMTP_HOST}:#{SMTP_PORT}"
219
228
  smtp = Net::SMTP.new( SMTP_HOST, SMTP_PORT )
220
229
  smtp.set_debug_output( $stdout )
@@ -228,73 +237,77 @@ begin
228
237
  trace "done."
229
238
  end
230
239
  end
231
-
232
-
240
+
241
+
233
242
  desc 'Publish the new release to RubyForge'
234
243
  task :publish => [:clean, :package, :notes] do |task|
235
244
  project = GEMSPEC.rubyforge_project
236
245
 
237
- rf = RubyForge.new
238
- log "Loading RubyForge config"
239
- rf.configure
240
-
241
- group_id = rf.autoconfig['group_ids'][RUBYFORGE_GROUP] or
242
- fail "Your configuration doesn't have a group id for '#{RUBYFORGE_GROUP}'"
243
-
244
- # If this project doesn't yet exist, create it
245
- unless rf.autoconfig['package_ids'].key?( project )
246
- ask_for_confirmation( "Package '#{project}' doesn't exist on RubyForge. Create it?" ) do
247
- log "Creating new package '#{project}'"
248
- rf.create_package( group_id, project )
249
- end
250
- end
251
-
252
- package_id = rf.autoconfig['package_ids'][ project ]
253
-
254
- # Make sure this release doesn't already exist
255
- releases = rf.autoconfig['release_ids']
256
- if releases.key?( GEMSPEC.name ) && releases[ GEMSPEC.name ].key?( PKG_VERSION )
257
- log "Rubyforge seems to already have #{ PKG_FILE_NAME }"
246
+ if $publish_privately
247
+ log "Skipping push of release files to RubyForge"
258
248
  else
259
- config = rf.userconfig or
260
- fail "You apparently haven't set up your RubyForge credentials on this machine."
261
- config['release_notes'] = GEMSPEC.description
262
- config['release_changes'] = File.read( RELEASE_NOTES_FILE )
263
-
264
- files = FileList[ PKGDIR + GEM_FILE_NAME ]
265
- files.include PKGDIR + "#{PKG_FILE_NAME}.tar.gz"
266
- files.include PKGDIR + "#{PKG_FILE_NAME}.tar.bz2"
267
- files.include PKGDIR + "#{PKG_FILE_NAME}.zip"
268
-
269
- log "Releasing #{PKG_FILE_NAME}"
270
- when_writing do
271
- log "Publishing to RubyForge: \n",
272
- "\tproject: #{RUBYFORGE_GROUP}\n",
273
- "\tpackage: #{PKG_NAME.downcase}\n",
274
- "\tpackage version: #{PKG_VERSION}\n",
275
- "\tfiles: " + files.collect {|f| f.to_s }.join(', ') + "\n"
276
-
277
- ask_for_confirmation( "Publish to RubyForge?" ) do
278
- log 'Logging in...'
279
- rf.login
280
- log "Adding the new release to the '#{project}' project"
281
- rf.add_release( group_id, package_id, PKG_VERSION, *files )
249
+ rf = RubyForge.new
250
+ log "Loading RubyForge config"
251
+ rf.configure
252
+
253
+ group_id = rf.autoconfig['group_ids'][RUBYFORGE_GROUP] or
254
+ fail "Your configuration doesn't have a group id for '#{RUBYFORGE_GROUP}'"
255
+
256
+ # If this project doesn't yet exist, create it
257
+ unless rf.autoconfig['package_ids'].key?( project )
258
+ ask_for_confirmation( "Package '#{project}' doesn't exist on RubyForge. Create it?" ) do
259
+ log "Creating new package '#{project}'"
260
+ rf.create_package( group_id, project )
261
+ end
262
+ end
263
+
264
+ package_id = rf.autoconfig['package_ids'][ project ]
265
+
266
+ # Make sure this release doesn't already exist
267
+ releases = rf.autoconfig['release_ids']
268
+ if releases.key?( GEMSPEC.name ) && releases[ GEMSPEC.name ].key?( PKG_VERSION )
269
+ log "Rubyforge seems to already have #{ PKG_FILE_NAME }"
270
+ else
271
+ config = rf.userconfig or
272
+ fail "You apparently haven't set up your RubyForge credentials on this machine."
273
+ config['release_notes'] = GEMSPEC.description
274
+ config['release_changes'] = File.read( RELEASE_NOTES_FILE )
275
+
276
+ files = FileList[ PKGDIR + GEM_FILE_NAME ]
277
+ files.include PKGDIR + "#{PKG_FILE_NAME}.tar.gz"
278
+ files.include PKGDIR + "#{PKG_FILE_NAME}.tar.bz2"
279
+ files.include PKGDIR + "#{PKG_FILE_NAME}.zip"
280
+
281
+ log "Releasing #{PKG_FILE_NAME}"
282
+ when_writing do
283
+ log "Publishing to RubyForge: \n",
284
+ "\tproject: #{RUBYFORGE_GROUP}\n",
285
+ "\tpackage: #{PKG_NAME.downcase}\n",
286
+ "\tpackage version: #{PKG_VERSION}\n",
287
+ "\tfiles: " + files.collect {|f| f.to_s }.join(', ') + "\n"
288
+
289
+ ask_for_confirmation( "Publish to RubyForge?" ) do
290
+ log 'Logging in...'
291
+ rf.login
292
+ log "Adding the new release to the '#{project}' project"
293
+ rf.add_release( group_id, package_id, PKG_VERSION, *files )
294
+ end
282
295
  end
283
296
  end
284
297
  end
285
298
  end
286
299
  end
287
-
300
+
288
301
  rescue LoadError => err
289
302
  if !Object.const_defined?( :Gem )
290
303
  require 'rubygems'
291
304
  retry
292
305
  end
293
-
306
+
294
307
  task :no_release_tasks do
295
308
  fail "Release tasks not defined: #{err.message}"
296
309
  end
297
-
310
+
298
311
  task :release => :no_release_tasks
299
312
  task "release:announce" => :no_release_tasks
300
313
  task "release:publish" => :no_release_tasks