pluginfactory 1.0.2 → 1.0.3

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,303 @@
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
+ def ssl_start( helo='localhost.localdomain', user=nil, secret=nil, authtype=nil )
17
+ if block_given?
18
+ begin
19
+ do_ssl_start( helo, user, secret, authtype )
20
+ return yield( self )
21
+ ensure
22
+ do_finish
23
+ end
24
+ else
25
+ do_ssl_start( helo, user, secret, authtype )
26
+ return self
27
+ end
28
+ end
29
+
30
+
31
+ #######
32
+ private
33
+ #######
34
+
35
+ def do_ssl_start( helodomain, user, secret, authtype )
36
+ raise IOError, 'SMTP session already started' if @started
37
+ check_auth_args user, secret, authtype if user or secret
38
+
39
+ # Open the connection
40
+ @debug_output << "opening connection to #{@address}...\n" if @debug_output
41
+ sock = timeout( @open_timeout ) { TCPsocket.new(@address, @port) }
42
+
43
+ # Wrap it in the SSL layer
44
+ ssl_context = OpenSSL::SSL::SSLContext.new
45
+ ssl_context.verify_mode = OpenSSL::SSL::VERIFY_NONE
46
+ ssl_sock = OpenSSL::SSL::SSLSocket.new( sock, ssl_context )
47
+ ssl_sock.sync_close = true
48
+ ssl_sock.connect
49
+
50
+ # Wrap it in the message-oriented IO layer
51
+ sslmsgio = Net::InternetMessageIO.new( ssl_sock )
52
+ sslmsgio.read_timeout = @read_timeout
53
+ sslmsgio.debug_output = @debug_output
54
+
55
+ @socket = sslmsgio
56
+
57
+ check_response(critical { recv_response() })
58
+ begin
59
+ if @esmtp
60
+ ehlo helodomain
61
+ else
62
+ helo helodomain
63
+ end
64
+ rescue ProtocolError
65
+ if @esmtp
66
+ @esmtp = false
67
+ @error_occured = false
68
+ retry
69
+ end
70
+ raise
71
+ end
72
+ authenticate user, secret, authtype if user
73
+ @started = true
74
+ ensure
75
+ @socket.close if not @started and @socket and not @socket.closed?
76
+ end
77
+ end
78
+
79
+
80
+ begin
81
+ gem 'text-format'
82
+
83
+ require 'time'
84
+ require 'rake/tasklib'
85
+ require 'tmail'
86
+ require 'net/smtp'
87
+ require 'etc'
88
+ require 'rubyforge'
89
+ require 'socket'
90
+ require 'text/format'
91
+
92
+ ### Generate a valid RFC822 message-id
93
+ def gen_message_id
94
+ return "<%s.%s@%s>" % [
95
+ (Time.now.to_f * 10000).to_i.to_s( 36 ),
96
+ (rand( 2 ** 64 - 1 )).to_s( 36 ),
97
+ Socket.gethostname
98
+ ]
99
+ end
100
+
101
+
102
+ namespace :release do
103
+ task :default => [ 'svn:release', :publish, :announce, :project ]
104
+
105
+ desc "Re-publish the release with the current version number"
106
+ task :rerelease => [ :publish, :announce, :project ]
107
+
108
+ task :test do
109
+ $publish_privately = true
110
+ end
111
+ task :test => [ :rerelease ]
112
+
113
+
114
+ desc "Generate the release notes"
115
+ task :notes => [RELEASE_NOTES_FILE]
116
+ file RELEASE_NOTES_FILE do |task|
117
+ last_rel_tag = get_latest_release_tag() or
118
+ fail ">>> No releases tagged! Try running 'rake svn:release' first"
119
+ trace "Last release tag is: %p" % [ last_rel_tag ]
120
+ start = get_last_changed_rev( last_rel_tag ) || 1
121
+ trace "Starting rev is: %p" % [ start ]
122
+ log_output = make_svn_log( '.', start, 'HEAD' )
123
+
124
+ File.open( task.name, File::WRONLY|File::TRUNC|File::CREAT ) do |fh|
125
+ fh.print( log_output )
126
+ end
127
+
128
+ edit task.name
129
+ end
130
+ CLEAN.include( RELEASE_NOTES_FILE )
131
+
132
+
133
+ task :project => [ :rdoc ] do
134
+ when_writing( "Publishing docs to #{PROJECT_SCPURL}" ) do
135
+ run 'ssh', PROJECT_HOST, "rm -rf #{PROJECT_DOCDIR}"
136
+ run 'scp', '-qCr', 'docs', PROJECT_SCPURL
137
+ end
138
+ when_writing( "Uploading packages") do
139
+ pkgs = Pathname.glob( PKGDIR + "#{PKG_FILE_NAME}.{gem,tar.gz,tar.bz2,zip}" )
140
+ log "Uploading %d packages to #{PROJECT_SCPURL}" % [ pkgs.length ]
141
+ pkgs.each do |pkgfile|
142
+ run 'scp', '-qC', pkgfile, PROJECT_SCPURL
143
+ end
144
+ end
145
+ end
146
+
147
+
148
+ file RELEASE_ANNOUNCE_FILE => [RELEASE_NOTES_FILE] do |task|
149
+ relnotes = File.read( RELEASE_NOTES_FILE )
150
+ announce_body = %{
151
+
152
+ Version #{PKG_VERSION} of #{PKG_NAME} has been released.
153
+
154
+ #{Text::Format.new(:first_indent => 0).format_one_paragraph(GEMSPEC.description)}
155
+
156
+ == Project Page
157
+
158
+ #{GEMSPEC.homepage}
159
+
160
+ == Installation
161
+
162
+ Via gems:
163
+
164
+ $ sudo gem install #{GEMSPEC.name}
165
+
166
+ or from source:
167
+
168
+ $ wget http://deveiate.org/code/#{PKG_FILE_NAME}.tar.gz
169
+ $ tar -xzvf #{PKG_FILE_NAME}.tar.gz
170
+ $ cd #{PKG_FILE_NAME}
171
+ $ sudo rake install
172
+
173
+ == Changes
174
+ #{relnotes}
175
+ }.gsub( /^\t+/, '' )
176
+
177
+ File.open( task.name, File::WRONLY|File::TRUNC|File::CREAT ) do |fh|
178
+ fh.print( announce_body )
179
+ end
180
+
181
+ edit task.name
182
+ end
183
+ CLEAN.include( RELEASE_ANNOUNCE_FILE )
184
+
185
+
186
+ desc 'Send out a release announcement'
187
+ task :announce => [RELEASE_ANNOUNCE_FILE] do
188
+ email = TMail::Mail.new
189
+ if $publish_privately
190
+ trace "Sending private announce mail"
191
+ email.to = 'rubymage@gmail.com'
192
+ else
193
+ trace "Sending public announce mail"
194
+ email.to = 'rubymage@gmail.com'
195
+ # email.to = 'Ruby-Talk List <ruby-talk@ruby-lang.org>'
196
+ # email.bcc = 'rubymage@gmail.com'
197
+ end
198
+ email.from = GEMSPEC.email
199
+ email.subject = "[ANN] #{PKG_NAME} #{PKG_VERSION}"
200
+ email.body = File.read( RELEASE_ANNOUNCE_FILE )
201
+ email.date = Time.new
202
+
203
+ email.message_id = gen_message_id()
204
+
205
+ log "About to send the following email:"
206
+ puts '---',
207
+ email.to_s,
208
+ '---'
209
+
210
+ ask_for_confirmation( "Will send via #{SMTP_HOST}." ) do
211
+ pwent = Etc.getpwuid( Process.euid )
212
+ curuser = pwent ? pwent.name : 'unknown'
213
+ username = prompt_with_default( "SMTP user", curuser )
214
+ password = prompt_for_password()
215
+
216
+ trace "Creating SMTP connection to #{SMTP_HOST}:#{SMTP_PORT}"
217
+ smtp = Net::SMTP.new( SMTP_HOST, SMTP_PORT )
218
+ smtp.set_debug_output( $stdout )
219
+ smtp.esmtp = true
220
+
221
+ trace "connecting..."
222
+ smtp.ssl_start( Socket.gethostname, username, password, :plain ) do |smtp|
223
+ trace "sending message..."
224
+ smtp.send_message( email.to_s, email.from, email.to )
225
+ end
226
+ trace "done."
227
+ end
228
+ end
229
+
230
+
231
+ desc 'Publish the new release to RubyForge'
232
+ task :publish => [:clobber, :package, :notes] do |task|
233
+ project = GEMSPEC.rubyforge_project
234
+
235
+ rf = RubyForge.new
236
+ log "Loading RubyForge config"
237
+ rf.configure
238
+
239
+ group_id = rf.autoconfig['group_ids'][RUBYFORGE_GROUP] or
240
+ fail "Your configuration doesn't have a group id for '#{RUBYFORGE_GROUP}'"
241
+
242
+ # If this project doesn't yet exist, create it
243
+ unless rf.autoconfig['package_ids'].key?( project )
244
+ ask_for_confirmation( "Package '#{project}' doesn't exist on RubyForge. Create it?" ) do
245
+ log "Creating new package '#{project}'"
246
+ rf.create_package( group_id, project )
247
+ end
248
+ end
249
+
250
+ package_id = rf.autoconfig['package_ids'][ project ]
251
+
252
+ # Make sure this release doesn't already exist
253
+ releases = rf.autoconfig['release_ids']
254
+ if releases.key?( GEMSPEC.name ) && releases[ GEMSPEC.name ].key?( PKG_VERSION )
255
+ log "Rubyforge seems to already have #{ PKG_FILE_NAME }"
256
+ else
257
+ config = rf.userconfig or
258
+ fail "You apparently haven't set up your RubyForge credentials on this machine."
259
+ config['release_notes'] = GEMSPEC.description
260
+ config['release_changes'] = File.read( RELEASE_NOTES_FILE )
261
+
262
+ files = FileList[ PKGDIR + GEM_FILE_NAME ]
263
+ files.include PKGDIR + "#{PKG_FILE_NAME}.tar.gz"
264
+ files.include PKGDIR + "#{PKG_FILE_NAME}.tar.bz2"
265
+ files.include PKGDIR + "#{PKG_FILE_NAME}.zip"
266
+
267
+ log "Releasing #{PKG_FILE_NAME}"
268
+ when_writing do
269
+ log "Publishing to RubyForge: \n",
270
+ "\tproject: #{RUBYFORGE_GROUP}\n",
271
+ "\tpackage: #{PKG_NAME.downcase}\n",
272
+ "\tpackage version: #{PKG_VERSION}\n",
273
+ "\tfiles: " + files.collect {|f| f.to_s }.join(', ') + "\n"
274
+
275
+ ask_for_confirmation( "Publish to RubyForge?" ) do
276
+ log 'Logging in...'
277
+ rf.login
278
+ log "Adding the new release to the '#{project}' project"
279
+ rf.add_release( group_id, package_id, PKG_VERSION, *files )
280
+ end
281
+ end
282
+ end
283
+ end
284
+ end
285
+
286
+ rescue LoadError => err
287
+ if !Object.const_defined?( :Gem )
288
+ require 'rubygems'
289
+ retry
290
+ end
291
+
292
+ task :no_release_tasks do
293
+ fail "Release tasks not defined: #{err.message}"
294
+ end
295
+
296
+ task :release => :no_release_tasks
297
+ task "release:announce" => :no_release_tasks
298
+ task "release:publish" => :no_release_tasks
299
+ task "release:notes" => :no_release_tasks
300
+ end
301
+
302
+ task :release => 'release:default'
303
+
data/rake/rdoc.rb ADDED
@@ -0,0 +1,30 @@
1
+ #
2
+ # RDoc Rake tasks for ThingFish
3
+ # $Id: rdoc.rb 28 2008-08-13 04:50:05Z deveiant $
4
+ #
5
+
6
+ require 'rake/rdoctask'
7
+ $have_darkfish = false
8
+
9
+ begin
10
+ require 'darkfish-rdoc'
11
+ $have_darkfish = true
12
+ rescue LoadError => err
13
+ unless Object.const_defined?( :Gem )
14
+ require 'rubygems'
15
+ gem 'darkfish-rdoc'
16
+ retry
17
+ end
18
+
19
+ log "No DarkFish: %s: %s" % [ err.class.name, err.message ]
20
+ trace "Backtrace:\n %s" % [ err.backtrace.join("\n ") ]
21
+ end
22
+
23
+ Rake::RDocTask.new do |rdoc|
24
+ rdoc.rdoc_dir = 'docs/html'
25
+ rdoc.title = "#{PKG_NAME} - #{PKG_SUMMARY}"
26
+ rdoc.options += RDOC_OPTIONS + [ '-f', 'darkfish' ] if $have_darkfish
27
+
28
+ rdoc.rdoc_files.include 'README'
29
+ rdoc.rdoc_files.include LIB_FILES.collect {|f| f.to_s }
30
+ end
data/rake/style.rb ADDED
@@ -0,0 +1,62 @@
1
+ #
2
+ # Style Fixup Rake Tasks
3
+ # $Id: style.rb 10 2008-07-18 15:52:48Z deveiant $
4
+ #
5
+ # Authors:
6
+ # * Michael Granger <ged@FaerieMUD.org>
7
+ #
8
+
9
+
10
+ ### Coding style checks and fixes
11
+ namespace :style do
12
+
13
+ BLANK_LINE = /^\s*$/
14
+ GOOD_INDENT = /^(\t\s*)?\S/
15
+
16
+ # A list of the files that have legitimate leading whitespace, etc.
17
+ PROBLEM_FILES = [ SPECDIR + 'config_spec.rb' ]
18
+
19
+ desc "Check source files for inconsistent indent and fix them"
20
+ task :fix_indent do
21
+ files = LIB_FILES + SPEC_FILES
22
+
23
+ badfiles = Hash.new {|h,k| h[k] = [] }
24
+
25
+ trace "Checking files for indentation"
26
+ files.each do |file|
27
+ if PROBLEM_FILES.include?( file )
28
+ trace " skipping problem file #{file}..."
29
+ next
30
+ end
31
+
32
+ trace " #{file}"
33
+ linecount = 0
34
+ file.each_line do |line|
35
+ linecount += 1
36
+
37
+ # Skip blank lines
38
+ next if line =~ BLANK_LINE
39
+
40
+ # If there's a line with incorrect indent, note it and skip to the
41
+ # next file
42
+ if line !~ GOOD_INDENT
43
+ trace " Bad line %d: %p" % [ linecount, line ]
44
+ badfiles[file] << [ linecount, line ]
45
+ end
46
+ end
47
+ end
48
+
49
+ if badfiles.empty?
50
+ log "No indentation problems found."
51
+ else
52
+ log "Found incorrect indent in #{badfiles.length} files:\n "
53
+ badfiles.each do |file, badlines|
54
+ log " #{file}:\n" +
55
+ " " + badlines.collect {|badline| "%5d: %p" % badline }.join( "\n " )
56
+ end
57
+ end
58
+ end
59
+
60
+ end
61
+
62
+