pluginfactory 1.0.7 → 1.0.8

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,129 +0,0 @@
1
- #####################################################################
2
- ### P A C K A G I N G T A S K S
3
- #####################################################################
4
-
5
- require 'rbconfig'
6
- require 'pathname'
7
- require 'rubygems/package_task'
8
-
9
-
10
- include Config
11
-
12
- ### Task: prerelease
13
- desc "Append the package build number to package versions"
14
- task :prerelease do
15
- GEMSPEC.version.version << ".#{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
22
- end
23
-
24
-
25
- ### Task: gem
26
- ### Task: package
27
- Rake::PackageTask.new( PKG_NAME, PKG_VERSION ) do |task|
28
- task.need_tar_gz = true
29
- task.need_tar_bz2 = true
30
- task.need_zip = true
31
- task.package_dir = PKGDIR.to_s
32
- task.package_files = RELEASE_FILES.collect {|f| f.to_s }
33
- end
34
- task :package => [:gem]
35
-
36
-
37
- Gem::PackageTask.new( GEMSPEC ) do |pkg|
38
- pkg.need_zip = true
39
- pkg.need_tar = true
40
- end
41
-
42
-
43
- ### Task: install
44
- desc "Install #{PKG_NAME} as a conventional library"
45
- task :install => "spec:quiet" do
46
- log "Installing #{PKG_NAME} as a conventional library"
47
- sitelib = Pathname.new( CONFIG['sitelibdir'] )
48
- sitearch = Pathname.new( CONFIG['sitearchdir'] )
49
- Dir.chdir( LIBDIR ) do
50
- LIB_FILES.collect {|path| Pathname(path) }.each do |libfile|
51
- relpath = libfile.relative_path_from( LIBDIR )
52
- target = sitelib + relpath
53
- FileUtils.mkpath target.dirname,
54
- :mode => 0755, :verbose => true, :noop => $dryrun unless target.dirname.directory?
55
- FileUtils.install relpath, target,
56
- :mode => 0644, :verbose => true, :noop => $dryrun
57
- end
58
- end
59
- if EXTDIR.exist?
60
- trace " looking for a binary extension (%s)" % [ EXTDIR + "*.#{Config::CONFIG['DLEXT']}" ]
61
- Dir.chdir( EXTDIR ) do
62
- Pathname.glob( "*.#{Config::CONFIG['DLEXT']}" ) do |dl|
63
- trace " found: #{dl}"
64
- target = sitearch + dl.basename
65
- FileUtils.install dl, target,
66
- :mode => 0755, :verbose => true, :noop => $dryrun
67
- end
68
- end
69
- end
70
- end
71
-
72
-
73
-
74
- ### Task: install_gem
75
- desc "Install #{PKG_NAME} from a locally-built gem"
76
- task :install_gem => [:package] do
77
- $stderr.puts
78
- installer = Gem::Installer.new( %{pkg/#{PKG_FILE_NAME}.gem} )
79
- installer.install
80
- end
81
-
82
-
83
- ### Task: uninstall
84
- desc "Uninstall #{PKG_NAME} if it's been installed as a conventional library"
85
- task :uninstall do
86
- log "Uninstalling conventionally-installed #{PKG_NAME} library files"
87
- sitelib = Pathname.new( CONFIG['sitelibdir'] )
88
- sitearch = Pathname.new( CONFIG['sitearchdir'] )
89
-
90
- Dir.chdir( LIBDIR ) do
91
- LIB_FILES.collect {|path| Pathname(path) }.each do |libfile|
92
- relpath = libfile.relative_path_from( LIBDIR )
93
- target = sitelib + relpath
94
- FileUtils.rm_f target, :verbose => true, :noop => $dryrun
95
- FileUtils.rm_rf( target.dirname, :verbose => true, :noop => $dryrun ) if
96
- target.dirname.entries.empty?
97
- end
98
- end
99
- if EXTDIR.exist?
100
- trace " looking for a binary extension (%s)" % [ EXTDIR + "*.#{Config::CONFIG['DLEXT']}" ]
101
- Dir.chdir( EXTDIR ) do
102
- Pathname.glob( "*.#{Config::CONFIG['DLEXT']}" ) do |dl|
103
- trace " found: #{dl}"
104
- target = sitearch + dl.basename
105
- FileUtils.rm target, :verbose => true, :noop => $dryrun
106
- end
107
- end
108
- end
109
- end
110
-
111
-
112
- ### Task: uninstall_gem
113
- desc "Install the #{PKG_NAME} gem"
114
- task :uninstall_gem => [:clean] do
115
- uninstaller = Gem::Uninstaller.new( PKG_FILE_NAME )
116
- uninstaller.uninstall
117
- end
118
-
119
-
120
-
121
- desc "Add development depdendencies to the gemspec -- this is meant to be chained " +
122
- "together with :gem"
123
- task :include_dev_dependencies do
124
- DEVELOPMENT_DEPENDENCIES.each do |name, version|
125
- version = '>= 0' if version.length.zero?
126
- GEMSPEC.add_development_dependency( name, version )
127
- end
128
- end
129
-
@@ -1,348 +0,0 @@
1
- #####################################################################
2
- ### P U B L I C A T I O N T A S K S
3
- #####################################################################
4
-
5
- RELEASE_NOTES_FILE = 'release.notes'
6
- RELEASE_ANNOUNCE_FILE = 'release.ann'
7
-
8
- require 'net/smtp'
9
- require 'net/protocol'
10
- require 'openssl'
11
-
12
- $publish_privately = false
13
-
14
- ### Add SSL to Net::SMTP
15
- class Net::SMTP
16
-
17
- def ssl_start( helo='localhost.localdomain', user=nil, secret=nil, authtype=nil )
18
- if block_given?
19
- begin
20
- do_ssl_start( helo, user, secret, authtype )
21
- return yield( self )
22
- ensure
23
- do_finish
24
- end
25
- else
26
- do_ssl_start( helo, user, secret, authtype )
27
- return self
28
- end
29
- end
30
-
31
-
32
- #######
33
- private
34
- #######
35
-
36
- def do_ssl_start( helodomain, user, secret, authtype )
37
- raise IOError, 'SMTP session already started' if @started
38
- if user or secret
39
- if self.method( :check_auth_args ).arity == 3
40
- check_auth_args( user, secret, authtype )
41
- else
42
- check_auth_args( user, secret )
43
- end
44
- end
45
-
46
- # Open the connection
47
- @debug_output << "opening connection to #{@address}...\n" if @debug_output
48
- sock = timeout( @open_timeout ) { TCPsocket.new(@address, @port) }
49
-
50
- # Wrap it in the SSL layer
51
- ssl_context = OpenSSL::SSL::SSLContext.new
52
- ssl_context.verify_mode = OpenSSL::SSL::VERIFY_NONE
53
- ssl_sock = OpenSSL::SSL::SSLSocket.new( sock, ssl_context )
54
- ssl_sock.sync_close = true
55
- ssl_sock.connect
56
-
57
- # Wrap it in the message-oriented IO layer
58
- sslmsgio = Net::InternetMessageIO.new( ssl_sock )
59
- sslmsgio.read_timeout = @read_timeout
60
- sslmsgio.debug_output = @debug_output
61
-
62
- @socket = sslmsgio
63
-
64
- check_response(critical { recv_response() })
65
- begin
66
- if @esmtp
67
- ehlo helodomain
68
- else
69
- helo helodomain
70
- end
71
- rescue ProtocolError
72
- if @esmtp
73
- @esmtp = false
74
- @error_occured = false
75
- retry
76
- end
77
- raise
78
- end
79
- authenticate user, secret, authtype if user
80
- @started = true
81
- ensure
82
- @socket.close if not @started and @socket and not @socket.closed?
83
- end
84
- end
85
-
86
-
87
- begin
88
- gem 'text-format'
89
-
90
- require 'time'
91
- require 'rake/tasklib'
92
- require 'tmail'
93
- require 'net/smtp'
94
- require 'etc'
95
- require 'socket'
96
- require 'text/format'
97
- require 'rubygems/gemcutter_utilities'
98
-
99
- include Gem::GemcutterUtilities
100
-
101
- ### Generate a valid RFC822 message-id
102
- def gen_message_id
103
- return "<%s.%s@%s>" % [
104
- (Time.now.to_f * 10000).to_i.to_s( 36 ),
105
- (rand( 2 ** 64 - 1 )).to_s( 36 ),
106
- Socket.gethostname
107
- ]
108
- end
109
-
110
-
111
- ### Fetch the rubygems API token if it hasn't been already.
112
- def sign_in_to_rubygems
113
- return if Gem.configuration.rubygems_api_key
114
-
115
- log "Enter your RubyGems.org credentials."
116
-
117
- email = prompt " Email: "
118
- password = prompt_for_password( "Password: " )
119
-
120
- response = rubygems_api_request( :get, "api/v1/api_key" ) do |request|
121
- request.basic_auth( email, password )
122
- end
123
-
124
- with_response( response ) do |resp|
125
- log "Signed in."
126
- Gem.configuration.rubygems_api_key = resp.body
127
- end
128
- end
129
-
130
-
131
- ### Push the gem at the specified +path+ to the rubygems server at +gemhost+.
132
- def push_gem( path, gemhost )
133
- ENV['RUBYGEMS_HOST'] = "http://#{gemhost}"
134
-
135
- sign_in_to_rubygems()
136
-
137
- response = rubygems_api_request( :post, "api/v1/gems" ) do |request|
138
- request.body = Gem.read_binary( path )
139
- request.add_field "Content-Length", request.body.size
140
- request.add_field "Content-Type", "application/octet-stream"
141
- request.add_field "Authorization", Gem.configuration.rubygems_api_key
142
- end
143
-
144
- case response
145
- when Net::HTTPSuccess
146
- log( response.body )
147
- else
148
- fail( response.body )
149
- end
150
- end
151
-
152
-
153
- namespace :release do
154
- task :default => [ :prep_release, :upload, :publish, :announce ]
155
-
156
- desc "Re-publish the release with the current version number"
157
- task :rerelease => [ :upload, :publish, :announce ]
158
-
159
- desc "Re-run the publication tasks, but send notifications to debugging address"
160
- task :test do
161
- trace "Will publish privately"
162
- $publish_privately = true
163
- Rake::Task['release:rerelease'].invoke
164
- end
165
-
166
-
167
- desc "Generate the release notes"
168
- task :notes => [RELEASE_NOTES_FILE]
169
- file RELEASE_NOTES_FILE do |task|
170
- last_tag = MercurialHelpers.get_tags.grep( /\d+\.\d+\.\d+/ ).
171
- collect {|ver| vvec(ver) }.sort.last.unpack( 'N*' ).join('.')
172
-
173
- File.open( task.name, File::WRONLY|File::TRUNC|File::CREAT ) do |fh|
174
- fh.puts "Release Notes for #{PKG_VERSION}",
175
- "--------------------------------", '', ''
176
- end
177
-
178
- edit task.name
179
- end
180
- CLOBBER.include( RELEASE_NOTES_FILE )
181
-
182
- # Only define upload tasks if there's an upload host
183
- if PROJECT_HOST.empty?
184
- task :no_upload_host do
185
- log "Skipping upload: no upload host."
186
- end
187
- task :upload => :no_upload_host
188
- task :upload_docs => :no_upload_host
189
- task :upload_packages => :no_upload_host
190
- else
191
- desc "Upload project documentation and packages to #{PROJECT_HOST}"
192
- task :upload => [ :upload_docs, :upload_packages ]
193
- task :project => :upload # the old name
194
-
195
- desc "Publish the project docs to #{PROJECT_HOST}"
196
- task :upload_docs => [ :apidocs ] do
197
- when_writing( "Publishing docs to #{PROJECT_SCPDOCURL}" ) do
198
- log "Uploading API documentation to %s:%s" % [ PROJECT_HOST, PROJECT_DOCDIR ]
199
- run 'ssh', PROJECT_HOST, "rm -rf #{PROJECT_DOCDIR}"
200
- run 'scp', '-qCr', API_DOCSDIR, PROJECT_SCPDOCURL
201
- end
202
- end
203
-
204
- desc "Publish the project packages to #{PROJECT_HOST}"
205
- task :upload_packages => [ :package ] do
206
- when_writing( "Uploading packages") do
207
- pkgs = Pathname.glob( PKGDIR + "#{PKG_FILE_NAME}.{gem,tar.gz,tar.bz2,zip}" )
208
- log "Uploading %d packages to #{PROJECT_SCPPUBURL}" % [ pkgs.length ]
209
- pkgs.each do |pkgfile|
210
- run 'scp', '-qC', pkgfile, PROJECT_SCPPUBURL
211
- end
212
- end
213
- end
214
- end
215
-
216
- # Only define the announcement tasks if there are addresses to announce to
217
- if RELEASE_ANNOUNCE_ADDRESSES.empty?
218
- task :no_announce_addresses do
219
- log "Skipping announcement: no announce addresses"
220
- end
221
- task :announce => :no_announce_addresses
222
-
223
- else
224
- file RELEASE_ANNOUNCE_FILE => [RELEASE_NOTES_FILE] do |task|
225
- relnotes = File.read( RELEASE_NOTES_FILE )
226
- announce_body = %{
227
-
228
- Version #{PKG_VERSION} of #{PKG_NAME} has been released.
229
-
230
- #{Text::Format.new(:first_indent => 0).format_one_paragraph(GEMSPEC.description)}
231
-
232
- == Project Page
233
-
234
- #{GEMSPEC.homepage}
235
-
236
- == Installation
237
-
238
- Via gems:
239
-
240
- $ sudo gem install #{GEMSPEC.name}
241
-
242
- or from source:
243
-
244
- $ wget http://deveiate.org/code/#{PKG_FILE_NAME}.tar.gz
245
- $ tar -xzvf #{PKG_FILE_NAME}.tar.gz
246
- $ cd #{PKG_FILE_NAME}
247
- $ sudo rake install
248
-
249
- == Changes
250
- #{relnotes}
251
- }.gsub( /^\t+/, '' )
252
-
253
- File.open( task.name, File::WRONLY|File::TRUNC|File::CREAT ) do |fh|
254
- fh.print( announce_body )
255
- end
256
-
257
- edit task.name
258
- end
259
- CLOBBER.include( RELEASE_ANNOUNCE_FILE )
260
-
261
-
262
- desc 'Send out a release announcement'
263
- task :announce => [RELEASE_ANNOUNCE_FILE] do
264
- email = TMail::Mail.new
265
-
266
- if $publish_privately || RELEASE_ANNOUNCE_ADDRESSES.empty?
267
- trace "Sending private announce mail"
268
- email.to = 'rubymage@gmail.com'
269
- else
270
- trace "Sending public announce mail"
271
- email.to = RELEASE_ANNOUNCE_ADDRESSES
272
- email.bcc = 'rubymage@gmail.com'
273
- end
274
-
275
- from = prompt_with_default( "Send announcement as:",
276
- 'Michael Granger <ged@FaerieMUD.org>' ) or fail
277
-
278
- email.from = from
279
- email.subject = "[ANN] #{PKG_NAME} #{PKG_VERSION}"
280
- email.body = File.read( RELEASE_ANNOUNCE_FILE )
281
- email.date = Time.new
282
-
283
- email.message_id = gen_message_id()
284
-
285
- log "About to send the following email:"
286
- puts '---',
287
- email.to_s,
288
- '---'
289
-
290
- ask_for_confirmation( "Will send via #{SMTP_HOST}." ) do
291
- pwent = Etc.getpwuid( Process.euid )
292
- curuser = pwent ? pwent.name : 'unknown'
293
- username = prompt_with_default( "SMTP user", curuser )
294
- password = prompt_for_password()
295
-
296
- trace "Creating SMTP connection to #{SMTP_HOST}:#{SMTP_PORT}"
297
- smtp = Net::SMTP.new( SMTP_HOST, SMTP_PORT )
298
- smtp.set_debug_output( $stdout )
299
- smtp.esmtp = true
300
-
301
- trace "connecting..."
302
- smtp.ssl_start( Socket.gethostname, username, password, :plain ) do |smtp|
303
- trace "sending message..."
304
- smtp.send_message( email.to_s, email.from, email.to )
305
- end
306
- trace "done."
307
- end
308
- end
309
- end
310
-
311
- if GEM_PUBHOST.empty?
312
- task :no_gem_host do
313
- log "Skipping gem push: no gem publication host."
314
- end
315
- task :publish => :no_gem_host
316
- else
317
- desc 'Publish the new gem to #{GEM_PUBHOST}'
318
- task :publish => [:clean, :gem, :notes] do |task|
319
- ask_for_confirmation( "Publish #{GEM_FILE_NAME} to #{GEM_PUBHOST}?", false ) do
320
- gempath = PKGDIR + GEM_FILE_NAME
321
- push_gem( gempath, GEM_PUBHOST )
322
- end
323
- end
324
- end
325
- end
326
-
327
- rescue LoadError => err
328
- if !Object.const_defined?( :Gem )
329
- require 'rubygems'
330
- retry
331
- end
332
-
333
- task :no_release_tasks do
334
- fail "Release tasks not defined: #{err.message}"
335
- end
336
-
337
- task :release => :no_release_tasks
338
- task "release:rerelease" => :no_release_tasks
339
- task "release:announce" => :no_release_tasks
340
- task "release:publish" => :no_release_tasks
341
- task "release:notes" => :no_release_tasks
342
- end
343
-
344
- desc "Package up a release, publish it, and send out notifications"
345
- task :release => 'release:default'
346
- task :rerelease => 'release:rerelease'
347
- task :testrelease => 'release:test'
348
-