pg 0.9.0-x86-mingw32 → 0.11.0pre229-x86-mingw32

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.
data/rake/hg.rb CHANGED
@@ -22,6 +22,8 @@ unless defined?( HG_DOTDIR )
22
22
  ###
23
23
 
24
24
  module MercurialHelpers
25
+ require './helpers.rb' unless defined?( RakefileHelpers )
26
+ include RakefileHelpers
25
27
 
26
28
  ###############
27
29
  module_function
@@ -81,9 +83,18 @@ unless defined?( HG_DOTDIR )
81
83
  return paths
82
84
  end
83
85
 
86
+ ### Return the list of files which are not of status 'clean'
87
+ def get_uncommitted_files
88
+ list = read_command_output( 'hg', 'status', '-n', '--color', 'never' )
89
+ list = list.split( /\n/ )
90
+
91
+ trace "Changed files: %p" % [ list ]
92
+ return list
93
+ end
94
+
84
95
  ### Return the list of files which are of status 'unknown'
85
96
  def get_unknown_files
86
- list = read_command_output( 'hg', 'status', '-un', '--no-color' )
97
+ list = read_command_output( 'hg', 'status', '-un', '--color', 'never' )
87
98
  list = list.split( /\n/ )
88
99
 
89
100
  trace "New files: %p" % [ list ]
@@ -147,11 +158,21 @@ unless defined?( HG_DOTDIR )
147
158
 
148
159
  desc "Prepare for a new release"
149
160
  task :prep_release do
161
+ uncommitted_files = get_uncommitted_files()
162
+ unless uncommitted_files.empty?
163
+ log "Uncommitted files:\n",
164
+ *uncommitted_files.map {|fn| " #{fn}\n" }
165
+ ask_for_confirmation( "\nRelease anyway?", true ) do
166
+ log "Okay, releasing with uncommitted versions."
167
+ end
168
+ end
169
+
150
170
  tags = get_tags()
151
171
  rev = get_current_rev()
172
+ pkg_version_tag = "v#{PKG_VERSION}"
152
173
 
153
174
  # Look for a tag for the current release version, and if it exists abort
154
- if tags.include?( PKG_VERSION )
175
+ if tags.include?( pkg_version_tag )
155
176
  error "Version #{PKG_VERSION} already has a tag. Did you mean " +
156
177
  "to increment the version in #{VERSION_FILE}?"
157
178
  fail
@@ -162,8 +183,8 @@ unless defined?( HG_DOTDIR )
162
183
  run 'hg', 'sign'
163
184
 
164
185
  # Tag the current rev
165
- log "Tagging rev #{rev} as #{PKG_VERSION}"
166
- run 'hg', 'tag', PKG_VERSION
186
+ log "Tagging rev #{rev} as #{pkg_version_tag}"
187
+ run 'hg', 'tag', pkg_version_tag
167
188
 
168
189
  # Offer to push
169
190
  Rake::Task['hg:push'].invoke
@@ -213,13 +234,32 @@ unless defined?( HG_DOTDIR )
213
234
  paths = get_repo_paths()
214
235
  if origin_url = paths['default']
215
236
  ask_for_confirmation( "Pull and update from '#{origin_url}'?", false ) do
216
- run 'hg', 'pull', '-u'
237
+ Rake::Task['hg:pull_without_confirmation'].invoke
217
238
  end
218
239
  else
219
240
  trace "Skipping pull: No 'default' path."
220
241
  end
221
242
  end
222
243
 
244
+
245
+ desc "Pull and update without confirmation"
246
+ task :pull_without_confirmation do
247
+ run 'hg', 'pull', '-u'
248
+ end
249
+
250
+
251
+ desc "Update to tip"
252
+ task :update do
253
+ run 'hg', 'update'
254
+ end
255
+
256
+
257
+ desc "Clobber all changes (hg up -C)"
258
+ task :update_and_clobber do
259
+ run 'hg', 'update', '-C'
260
+ end
261
+
262
+
223
263
  desc "Check the current code in if tests pass"
224
264
  task :checkin => ['hg:pull', 'hg:newfiles', 'test', COMMIT_MSG_FILE] do
225
265
  targets = get_target_args()
@@ -240,13 +280,18 @@ unless defined?( HG_DOTDIR )
240
280
  paths = get_repo_paths()
241
281
  if origin_url = paths['default']
242
282
  ask_for_confirmation( "Push to '#{origin_url}'?", false ) do
243
- run 'hg', 'push'
283
+ Rake::Task['hg:push_without_confirmation'].invoke
244
284
  end
245
285
  else
246
286
  trace "Skipping push: No 'default' path."
247
287
  end
248
288
  end
249
289
 
290
+ desc "Push to the default repo without confirmation"
291
+ task :push_without_confirmation do
292
+ run 'hg', 'push'
293
+ end
294
+
250
295
  end
251
296
 
252
297
  if HG_DOTDIR.exist?
@@ -147,9 +147,14 @@ module Manual
147
147
 
148
148
  layout = self.config['layout'].sub( /\.page$/, '' )
149
149
  templatepath = @layouts_dir + "#{layout}.page"
150
- template = ERB.new( templatepath.read )
151
- page = self
150
+ template = nil
151
+ if Object.const_defined?( :Encoding )
152
+ template = ERB.new( templatepath.read(:encoding => 'UTF-8') )
153
+ else
154
+ template = ERB.new( templatepath.read )
155
+ end
152
156
 
157
+ page = self
153
158
  html = template.result( binding() )
154
159
 
155
160
  # Use Tidy to clean up the html if 'cleanup' is turned on, but remove the Tidy
@@ -565,7 +570,7 @@ module Manual
565
570
  manual_pages = setup_page_conversion_tasks( sourcedir, outputdir, catalog )
566
571
 
567
572
  desc "Build the manual"
568
- task :build => [ :rdoc, :copy_resources, :copy_apidocs, :generate_pages ]
573
+ task :build => [ :apidocs, :copy_resources, :copy_apidocs, :generate_pages ]
569
574
 
570
575
  task :clobber do
571
576
  RakeFileUtils.verbose( $verbose ) do
@@ -686,8 +691,8 @@ module Manual
686
691
  end
687
692
 
688
693
  desc "Copy API documentation to the manual output directory"
689
- task :copy_apidocs => :rdoc do
690
- cp_r( RDOCDIR, outputdir )
694
+ task :copy_apidocs => :apidocs do
695
+ cp_r( API_DOCSDIR, outputdir )
691
696
  end
692
697
 
693
698
  # Now group all the resource file tasks into a containing task
@@ -713,7 +718,7 @@ if MANUALDIR.exist?
713
718
 
714
719
  Manual::GenTask.new do |manual|
715
720
  manual.metadata.version = PKG_VERSION
716
- manual.metadata.api_dir = RDOCDIR
721
+ manual.metadata.api_dir = API_DOCSDIR
717
722
  manual.output_dir = MANUALOUTPUTDIR
718
723
  manual.base_dir = MANUALDIR
719
724
  manual.source_dir = 'src'
@@ -12,7 +12,13 @@ include Config
12
12
  ### Task: prerelease
13
13
  desc "Append the package build number to package versions"
14
14
  task :prerelease do
15
- GEMSPEC.version.version += ".#{PKG_BUILD}"
15
+ GEMSPEC.version.version << "pre#{PKG_BUILD}"
16
+ Rake::Task[:gem].clear
17
+
18
+ Gem::PackageTask.new( GEMSPEC ) do |pkg|
19
+ pkg.need_zip = true
20
+ pkg.need_tar = true
21
+ end
16
22
  end
17
23
 
18
24
 
@@ -5,6 +5,8 @@
5
5
  RELEASE_NOTES_FILE = 'release.notes'
6
6
  RELEASE_ANNOUNCE_FILE = 'release.ann'
7
7
 
8
+ GEM_PUBHOST = '' unless defined?( GEM_PUBHOST )
9
+
8
10
  require 'net/smtp'
9
11
  require 'net/protocol'
10
12
  require 'openssl'
@@ -13,6 +15,7 @@ $publish_privately = false
13
15
 
14
16
  ### Add SSL to Net::SMTP
15
17
  class Net::SMTP
18
+
16
19
  def ssl_start( helo='localhost.localdomain', user=nil, secret=nil, authtype=nil )
17
20
  if block_given?
18
21
  begin
@@ -93,6 +96,9 @@ begin
93
96
  require 'etc'
94
97
  require 'socket'
95
98
  require 'text/format'
99
+ require 'rubygems/gemcutter_utilities'
100
+
101
+ include Gem::GemcutterUtilities
96
102
 
97
103
  ### Generate a valid RFC822 message-id
98
104
  def gen_message_id
@@ -104,6 +110,48 @@ begin
104
110
  end
105
111
 
106
112
 
113
+ ### Fetch the rubygems API token if it hasn't been already.
114
+ def sign_in_to_rubygems
115
+ return if Gem.configuration.rubygems_api_key
116
+
117
+ log "Enter your RubyGems.org credentials."
118
+
119
+ email = prompt " Email: "
120
+ password = prompt_for_password( "Password: " )
121
+
122
+ response = rubygems_api_request( :get, "api/v1/api_key" ) do |request|
123
+ request.basic_auth( email, password )
124
+ end
125
+
126
+ with_response( response ) do |resp|
127
+ log "Signed in."
128
+ Gem.configuration.rubygems_api_key = resp.body
129
+ end
130
+ end
131
+
132
+
133
+ ### Push the gem at the specified +path+ to the rubygems server at +gemhost+.
134
+ def push_gem( path, gemhost )
135
+ ENV['RUBYGEMS_HOST'] = "http://#{gemhost}"
136
+
137
+ sign_in_to_rubygems()
138
+
139
+ response = rubygems_api_request( :post, "api/v1/gems" ) do |request|
140
+ request.body = Gem.read_binary( path )
141
+ request.add_field "Content-Length", request.body.size
142
+ request.add_field "Content-Type", "application/octet-stream"
143
+ request.add_field "Authorization", Gem.configuration.rubygems_api_key
144
+ end
145
+
146
+ case response
147
+ when Net::HTTPSuccess
148
+ log( response.body )
149
+ else
150
+ fail( response.body )
151
+ end
152
+ end
153
+
154
+
107
155
  namespace :release do
108
156
  task :default => [ :prep_release, :upload, :publish, :announce ]
109
157
 
@@ -133,120 +181,138 @@ begin
133
181
  end
134
182
  CLOBBER.include( RELEASE_NOTES_FILE )
135
183
 
136
-
137
- desc "Upload project documentation and packages to #{PROJECT_HOST}"
138
- task :upload => [ :upload_docs, :upload_packages ]
139
- task :project => :upload # the old name
140
-
141
- desc "Publish the project docs to #{PROJECT_HOST}"
142
- task :upload_docs => [ :rdoc ] do
143
- when_writing( "Publishing docs to #{PROJECT_SCPDOCURL}" ) do
144
- log "Uploading API documentation to %s:%s" % [ PROJECT_HOST, PROJECT_DOCDIR ]
145
- run 'ssh', PROJECT_HOST, "rm -rf #{PROJECT_DOCDIR}"
146
- run 'scp', '-qCr', RDOCDIR, PROJECT_SCPDOCURL
184
+ # Only define upload tasks if there's an upload host
185
+ if PROJECT_HOST.empty?
186
+ task :no_upload_host do
187
+ log "Skipping upload: no upload host."
188
+ end
189
+ task :upload => :no_upload_host
190
+ task :upload_docs => :no_upload_host
191
+ task :upload_packages => :no_upload_host
192
+ else
193
+ desc "Upload project documentation and packages to #{PROJECT_HOST}"
194
+ task :upload => [ :upload_docs, :upload_packages ]
195
+ task :project => :upload # the old name
196
+
197
+ desc "Publish the project docs to #{PROJECT_HOST}"
198
+ task :upload_docs => [ :apidocs ] do
199
+ when_writing( "Publishing docs to #{PROJECT_SCPDOCURL}" ) do
200
+ log "Uploading API documentation to %s:%s" % [ PROJECT_HOST, PROJECT_DOCDIR ]
201
+ run 'ssh', PROJECT_HOST, "rm -rf #{PROJECT_DOCDIR}"
202
+ run 'scp', '-qCr', API_DOCSDIR, PROJECT_SCPDOCURL
203
+ end
147
204
  end
148
- end
149
205
 
150
- desc "Publish the project packages to #{PROJECT_HOST}"
151
- task :upload_packages => [ :package ] do
152
- when_writing( "Uploading packages") do
153
- pkgs = Pathname.glob( PKGDIR + "#{PKG_FILE_NAME}.{gem,tar.gz,tar.bz2,zip}" )
154
- log "Uploading %d packages to #{PROJECT_SCPPUBURL}" % [ pkgs.length ]
155
- pkgs.each do |pkgfile|
156
- run 'scp', '-qC', pkgfile, PROJECT_SCPPUBURL
157
- end
158
- end
206
+ desc "Publish the project packages to #{PROJECT_HOST}"
207
+ task :upload_packages => [ :package ] do
208
+ when_writing( "Uploading packages") do
209
+ pkgs = Pathname.glob( PKGDIR + "#{PKG_FILE_NAME}.{gem,tar.gz,tar.bz2,zip}" )
210
+ log "Uploading %d packages to #{PROJECT_SCPPUBURL}" % [ pkgs.length ]
211
+ pkgs.each do |pkgfile|
212
+ run 'scp', '-qC', pkgfile, PROJECT_SCPPUBURL
213
+ end
214
+ end
215
+ end
159
216
  end
160
217
 
218
+ # Only define the announcement tasks if there are addresses to announce to
219
+ if RELEASE_ANNOUNCE_ADDRESSES.empty?
220
+ task :no_announce_addresses do
221
+ log "Skipping announcement: no announce addresses"
222
+ end
223
+ task :announce => :no_announce_addresses
161
224
 
162
- file RELEASE_ANNOUNCE_FILE => [RELEASE_NOTES_FILE] do |task|
163
- relnotes = File.read( RELEASE_NOTES_FILE )
164
- announce_body = %{
165
-
166
- Version #{PKG_VERSION} of #{PKG_NAME} has been released.
167
-
168
- #{Text::Format.new(:first_indent => 0).format_one_paragraph(GEMSPEC.description)}
225
+ else
226
+ file RELEASE_ANNOUNCE_FILE => [RELEASE_NOTES_FILE] do |task|
227
+ relnotes = File.read( RELEASE_NOTES_FILE )
228
+ announce_body = %{
169
229
 
170
- == Project Page
230
+ Version #{PKG_VERSION} of #{PKG_NAME} has been released.
171
231
 
172
- #{GEMSPEC.homepage}
232
+ #{Text::Format.new(:first_indent => 0).format_one_paragraph(GEMSPEC.description)}
173
233
 
174
- == Installation
234
+ == Project Page
175
235
 
176
- Via gems:
236
+ #{GEMSPEC.homepage}
177
237
 
178
- $ sudo gem install #{GEMSPEC.name}
238
+ == Installation
179
239
 
180
- or from source:
240
+ $ sudo gem install #{GEMSPEC.name}
181
241
 
182
- $ wget http://deveiate.org/code/#{PKG_FILE_NAME}.tar.gz
183
- $ tar -xzvf #{PKG_FILE_NAME}.tar.gz
184
- $ cd #{PKG_FILE_NAME}
185
- $ sudo rake install
242
+ == Changes
243
+ #{relnotes}
244
+ }.gsub( /^\t+/, '' )
186
245
 
187
- == Changes
188
- #{relnotes}
189
- }.gsub( /^\t+/, '' )
246
+ File.open( task.name, File::WRONLY|File::TRUNC|File::CREAT ) do |fh|
247
+ fh.print( announce_body )
248
+ end
190
249
 
191
- File.open( task.name, File::WRONLY|File::TRUNC|File::CREAT ) do |fh|
192
- fh.print( announce_body )
250
+ edit task.name
193
251
  end
252
+ CLOBBER.include( RELEASE_ANNOUNCE_FILE )
194
253
 
195
- edit task.name
196
- end
197
- CLOBBER.include( RELEASE_ANNOUNCE_FILE )
198
254
 
255
+ desc 'Send out a release announcement'
256
+ task :announce => [RELEASE_ANNOUNCE_FILE] do
257
+ email = TMail::Mail.new
199
258
 
200
- desc 'Send out a release announcement'
201
- task :announce => [RELEASE_ANNOUNCE_FILE] do
202
- email = TMail::Mail.new
259
+ if $publish_privately || RELEASE_ANNOUNCE_ADDRESSES.empty?
260
+ trace "Sending private announce mail"
261
+ email.to = 'rubymage@gmail.com'
262
+ else
263
+ trace "Sending public announce mail"
264
+ email.to = RELEASE_ANNOUNCE_ADDRESSES
265
+ email.bcc = 'rubymage@gmail.com'
266
+ end
203
267
 
204
- if $publish_privately || RELEASE_ANNOUNCE_ADDRESSES.empty?
205
- trace "Sending private announce mail"
206
- email.to = 'rubymage@gmail.com'
207
- else
208
- trace "Sending public announce mail"
209
- email.to = RELEASE_ANNOUNCE_ADDRESSES
210
- email.bcc = 'rubymage@gmail.com'
211
- end
212
- email.from = 'Michael Granger <mgranger@laika.com>'
213
- email.subject = "[ANN] #{PKG_NAME} #{PKG_VERSION}"
214
- email.body = File.read( RELEASE_ANNOUNCE_FILE )
215
- email.date = Time.new
216
-
217
- email.message_id = gen_message_id()
218
-
219
- log "About to send the following email:"
220
- puts '---',
221
- email.to_s,
222
- '---'
223
-
224
- ask_for_confirmation( "Will send via #{SMTP_HOST}." ) do
225
- pwent = Etc.getpwuid( Process.euid )
226
- curuser = pwent ? pwent.name : 'unknown'
227
- username = prompt_with_default( "SMTP user", curuser )
228
- password = prompt_for_password()
229
-
230
- trace "Creating SMTP connection to #{SMTP_HOST}:#{SMTP_PORT}"
231
- smtp = Net::SMTP.new( SMTP_HOST, SMTP_PORT )
232
- smtp.set_debug_output( $stdout )
233
- smtp.esmtp = true
234
-
235
- trace "connecting..."
236
- smtp.ssl_start( Socket.gethostname, username, password, :plain ) do |smtp|
237
- trace "sending message..."
238
- smtp.send_message( email.to_s, email.from, email.to )
268
+ from = prompt_with_default( "Send announcement as:",
269
+ 'Michael Granger <ged@FaerieMUD.org>' ) or fail
270
+
271
+ email.from = from
272
+ email.subject = "[ANN] #{PKG_NAME} #{PKG_VERSION}"
273
+ email.body = File.read( RELEASE_ANNOUNCE_FILE )
274
+ email.date = Time.new
275
+
276
+ email.message_id = gen_message_id()
277
+
278
+ log "About to send the following email:"
279
+ puts '---',
280
+ email.to_s,
281
+ '---'
282
+
283
+ ask_for_confirmation( "Will send via #{SMTP_HOST}." ) do
284
+ pwent = Etc.getpwuid( Process.euid )
285
+ curuser = pwent ? pwent.name : 'unknown'
286
+ username = prompt_with_default( "SMTP user", curuser )
287
+ password = prompt_for_password()
288
+
289
+ trace "Creating SMTP connection to #{SMTP_HOST}:#{SMTP_PORT}"
290
+ smtp = Net::SMTP.new( SMTP_HOST, SMTP_PORT )
291
+ smtp.set_debug_output( $stdout )
292
+ smtp.esmtp = true
293
+
294
+ trace "connecting..."
295
+ smtp.ssl_start( Socket.gethostname, username, password, :plain ) do |smtp|
296
+ trace "sending message..."
297
+ smtp.send_message( email.to_s, email.from, email.to )
298
+ end
299
+ trace "done."
239
300
  end
240
- trace "done."
241
301
  end
242
302
  end
243
303
 
244
-
245
- desc 'Publish the new release to Gemcutter'
246
- task :publish => [:clean, :gem, :notes] do |task|
247
- ask_for_confirmation( "Publish #{GEM_FILE_NAME} to Gemcutter?", false ) do
248
- gempath = PKGDIR + GEM_FILE_NAME
249
- sh 'gem', 'push', gempath
304
+ if GEM_PUBHOST.empty?
305
+ task :no_gem_host do
306
+ log "Skipping gem push: no gem publication host."
307
+ end
308
+ task :publish => :no_gem_host
309
+ else
310
+ desc 'Publish the new gem to #{GEM_PUBHOST}'
311
+ task :publish => [:clean, :gem, :notes] do |task|
312
+ ask_for_confirmation( "Publish #{GEM_FILE_NAME} to #{GEM_PUBHOST}?", false ) do
313
+ gempath = PKGDIR + GEM_FILE_NAME
314
+ push_gem( gempath, GEM_PUBHOST )
315
+ end
250
316
  end
251
317
  end
252
318
  end
@@ -262,6 +328,7 @@ rescue LoadError => err
262
328
  end
263
329
 
264
330
  task :release => :no_release_tasks
331
+ task "release:rerelease" => :no_release_tasks
265
332
  task "release:announce" => :no_release_tasks
266
333
  task "release:publish" => :no_release_tasks
267
334
  task "release:notes" => :no_release_tasks