darkfish-rdoc 1.1.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,112 @@
1
+ #
2
+ # Packaging Rake Tasks
3
+ # $Id: packaging.rb 21 2008-08-07 23:45:52Z deveiant $
4
+ #
5
+
6
+ require 'rbconfig'
7
+ require 'rake/packagetask'
8
+ require 'rake/gempackagetask'
9
+
10
+ include Config
11
+
12
+ ### Task: gem
13
+ ### Task: package
14
+ Rake::PackageTask.new( PKG_NAME, PKG_VERSION ) do |task|
15
+ task.need_tar_gz = true
16
+ task.need_tar_bz2 = true
17
+ task.need_zip = true
18
+ task.package_dir = PKGDIR.to_s
19
+ task.package_files = RELEASE_FILES.
20
+ collect {|f| f.relative_path_from(BASEDIR).to_s }
21
+ end
22
+ task :package => [:gem]
23
+
24
+
25
+ ### Task: gem
26
+ gempath = PKGDIR + GEM_FILE_NAME
27
+
28
+ desc "Build a RubyGem package (#{GEM_FILE_NAME})"
29
+ task :gem => gempath.to_s
30
+ file gempath.to_s => [PKGDIR.to_s] + GEMSPEC.files do
31
+ when_writing( "Creating GEM" ) do
32
+ Gem::Builder.new( GEMSPEC ).build
33
+ verbose( true ) do
34
+ mv GEM_FILE_NAME, gempath
35
+ end
36
+ end
37
+ end
38
+
39
+ ### Task: install
40
+ desc "Install #{PKG_NAME} as a conventional library"
41
+ task :install do
42
+ log "Installing #{PKG_NAME} as a conventional library"
43
+ sitelib = Pathname.new( CONFIG['sitelibdir'] )
44
+ sitearch = Pathname.new( CONFIG['sitearchdir'] )
45
+ Dir.chdir( LIBDIR ) do
46
+ LIB_FILES.each do |libfile|
47
+ relpath = libfile.relative_path_from( LIBDIR )
48
+ target = sitelib + relpath
49
+ FileUtils.mkpath target.dirname,
50
+ :mode => 0755, :verbose => true, :noop => $dryrun unless target.dirname.directory?
51
+ FileUtils.install relpath, target,
52
+ :mode => 0644, :verbose => true, :noop => $dryrun
53
+ end
54
+ end
55
+ if EXTDIR.exist?
56
+ Dir.chdir( EXTDIR ) do
57
+ Pathname.glob( EXTDIR + Config::CONFIG['DLEXT'] ) do |dl|
58
+ target = sitearch + dl.basename
59
+ FileUtils.install dl, target,
60
+ :mode => 0755, :verbose => true, :noop => $dryrun
61
+ end
62
+ end
63
+ end
64
+ end
65
+
66
+
67
+
68
+ ### Task: install_gem
69
+ desc "Install #{PKG_NAME} from a locally-built gem"
70
+ task :install_gem => [:package] do
71
+ $stderr.puts
72
+ installer = Gem::Installer.new( %{pkg/#{PKG_FILE_NAME}.gem} )
73
+ installer.install
74
+ end
75
+
76
+
77
+ ### Task: uninstall
78
+ desc "Uninstall #{PKG_NAME} if it's been installed as a conventional library"
79
+ task :uninstall do
80
+ log "Uninstalling conventionally-installed #{PKG_NAME} library files"
81
+ sitelib = Pathname.new( CONFIG['sitelibdir'] )
82
+ sitearch = Pathname.new( CONFIG['sitearchdir'] )
83
+
84
+ Dir.chdir( LIBDIR ) do
85
+ LIB_FILES.each do |libfile|
86
+ relpath = libfile.relative_path_from( LIBDIR )
87
+ target = sitelib + relpath
88
+ FileUtils.rm_f target, :verbose => true, :noop => $dryrun
89
+ FileUtils.rm_rf( target.dirname, :verbose => true, :noop => $dryrun ) if
90
+ target.dirname.entries.empty?
91
+ end
92
+ end
93
+ if EXTDIR.exist?
94
+ Dir.chdir( EXTDIR ) do
95
+ Pathname.glob( EXTDIR + Config::CONFIG['DLEXT'] ) do |dl|
96
+ target = sitearch + dl.basename
97
+ FileUtils.rm target, :verbose => true, :noop => $dryrun
98
+ end
99
+ end
100
+ end
101
+ end
102
+
103
+
104
+ ### Task: uninstall_gem
105
+ desc "Install the #{PKG_NAME} gem"
106
+ task :uninstall_gem => [:clean] do
107
+ uninstaller = Gem::Uninstaller.new( PKG_FILE_NAME )
108
+ uninstaller.uninstall
109
+ end
110
+
111
+
112
+
@@ -0,0 +1,301 @@
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
+ task :test do
105
+ $publish_privately = true
106
+ end
107
+ task :test => [ 'svn:release', :publish, :announce, :project ]
108
+
109
+ desc "Re-publish the release with the current version number"
110
+ task :rerelease => [ :publish, :announce, :project ]
111
+
112
+
113
+ desc "Generate the release notes"
114
+ task :notes => [RELEASE_NOTES_FILE]
115
+ file RELEASE_NOTES_FILE do |task|
116
+ last_rel_tag = get_latest_release_tag() or
117
+ fail ">>> No releases tagged! Try running 'rake svn:release' first"
118
+ trace "Last release tag is: %p" % [ last_rel_tag ]
119
+ start = get_last_changed_rev( last_rel_tag ) || 1
120
+ trace "Starting rev is: %p" % [ start ]
121
+ log_output = make_svn_log( '.', start, 'HEAD' )
122
+
123
+ File.open( task.name, File::WRONLY|File::TRUNC|File::CREAT ) do |fh|
124
+ fh.print( log_output )
125
+ end
126
+
127
+ edit task.name
128
+ end
129
+
130
+
131
+ task :project => [ :rdoc ] do
132
+ when_writing( "Publishing docs to #{PROJECT_SCPURL}" ) do
133
+ run 'ssh', PROJECT_HOST, "rm -rf #{PROJECT_DOCDIR}"
134
+ run 'scp', '-qCr', 'docs', PROJECT_SCPURL
135
+ end
136
+ when_writing( "Uploading packages") do
137
+ pkgs = Pathname.glob( PKGDIR + "#{PKG_FILE_NAME}.{gem,tar.gz,tar.bz2,zip}" )
138
+ log "Uploading %d packages to #{PROJECT_PUBURL}" % [ pkgs.length ]
139
+ pkgs.each do |pkgfile|
140
+ run 'scp', '-qC', pkgfile, PROJECT_PUBURL
141
+ end
142
+ end
143
+ end
144
+
145
+
146
+ file RELEASE_ANNOUNCE_FILE => [RELEASE_NOTES_FILE] do |task|
147
+ relnotes = File.read( RELEASE_NOTES_FILE )
148
+ announce_body = %{
149
+
150
+ Version #{PKG_VERSION} of #{PKG_NAME} has been released.
151
+
152
+ #{Text::Format.new(:first_indent => 0).format_one_paragraph(GEMSPEC.description)}
153
+
154
+ == Project Page
155
+
156
+ #{GEMSPEC.homepage}
157
+
158
+ == Installation
159
+
160
+ Via gems:
161
+
162
+ $ sudo gem install #{GEMSPEC.name}
163
+
164
+ or from source:
165
+
166
+ $ wget http://deveiate.org/code/#{PKG_FILE_NAME}.tar.gz
167
+ $ tar -xzvf #{PKG_FILE_NAME}.tar.gz
168
+ $ cd #{PKG_FILE_NAME}
169
+ $ sudo rake install
170
+
171
+ == Changes
172
+ #{relnotes}
173
+ }.gsub( /^\t+/, '' )
174
+
175
+ File.open( task.name, File::WRONLY|File::TRUNC|File::CREAT ) do |fh|
176
+ fh.print( announce_body )
177
+ end
178
+
179
+ edit task.name
180
+ end
181
+
182
+
183
+ desc 'Send out a release announcement'
184
+ task :announce => [RELEASE_ANNOUNCE_FILE] do
185
+ email = TMail::Mail.new
186
+ if $publish_privately
187
+ trace "Sending private announce mail"
188
+ email.to = 'rubymage@gmail.com'
189
+ else
190
+ trace "Sending public announce mail"
191
+ email.to = 'rubymage@gmail.com'
192
+ # email.to = 'Ruby-Talk List <ruby-talk@ruby-lang.org>'
193
+ # email.bcc = 'rubymage@gmail.com'
194
+ end
195
+ email.from = GEMSPEC.email
196
+ email.subject = "[ANN] #{PKG_NAME} #{PKG_VERSION}"
197
+ email.body = File.read( RELEASE_ANNOUNCE_FILE )
198
+ email.date = Time.new
199
+
200
+ email.message_id = gen_message_id()
201
+
202
+ log "About to send the following email:"
203
+ puts '---',
204
+ email.to_s,
205
+ '---'
206
+
207
+ ask_for_confirmation( "Will send via #{SMTP_HOST}." ) do
208
+ pwent = Etc.getpwuid( Process.euid )
209
+ curuser = pwent ? pwent.name : 'unknown'
210
+ username = prompt_with_default( "SMTP user", curuser )
211
+ password = prompt_for_password()
212
+
213
+ trace "Creating SMTP connection to #{SMTP_HOST}:#{SMTP_PORT}"
214
+ smtp = Net::SMTP.new( SMTP_HOST, SMTP_PORT )
215
+ smtp.set_debug_output( $stdout )
216
+ smtp.esmtp = true
217
+
218
+ trace "connecting..."
219
+ smtp.ssl_start( Socket.gethostname, username, password, :plain ) do |smtp|
220
+ trace "sending message..."
221
+ smtp.send_message( email.to_s, email.from, email.to )
222
+ end
223
+ trace "done."
224
+ end
225
+ end
226
+
227
+
228
+ desc 'Publish the new release to RubyForge'
229
+ task :publish => [:clobber, :package, :notes] do |task|
230
+ project = GEMSPEC.rubyforge_project
231
+
232
+ rf = RubyForge.new
233
+ log "Loading RubyForge config"
234
+ rf.configure
235
+
236
+ group_id = rf.autoconfig['group_ids'][RUBYFORGE_GROUP] or
237
+ fail "Your configuration doesn't have a group id for '#{RUBYFORGE_GROUP}'"
238
+
239
+ # If this project doesn't yet exist, create it
240
+ unless rf.autoconfig['package_ids'].key?( project )
241
+ ask_for_confirmation( "Package '#{project}' doesn't exist on RubyForge. Create it?" ) do
242
+ log "Creating new package '#{project}'"
243
+ rf.create_package( group_id, project )
244
+ end
245
+ end
246
+
247
+ package_id = rf.autoconfig['package_ids'][ project ]
248
+
249
+ # Make sure this release doesn't already exist
250
+ releases = rf.autoconfig['release_ids']
251
+ if releases.key?( GEMSPEC.name ) && releases[ GEMSPEC.name ].key?( PKG_VERSION )
252
+ fail "Rubyforge seems to already have #{ PKG_FILE_NAME }"
253
+ end
254
+
255
+ config = rf.userconfig or
256
+ fail "You apparently haven't set up your RubyForge credentials on this machine."
257
+ config['release_notes'] = GEMSPEC.description
258
+ config['release_changes'] = File.read( RELEASE_NOTES_FILE )
259
+ config['preformatted'] = true
260
+
261
+ files = FileList[ PKGDIR + GEM_FILE_NAME ]
262
+ files.include PKGDIR + "#{PKG_FILE_NAME}.tar.gz"
263
+ files.include PKGDIR + "#{PKG_FILE_NAME}.tar.bz2"
264
+ files.include PKGDIR + "#{PKG_FILE_NAME}.zip"
265
+
266
+ log "Releasing #{PKG_FILE_NAME}"
267
+ when_writing do
268
+ log "Publishing to RubyForge: \n",
269
+ "\tproject: #{RUBYFORGE_GROUP}\n",
270
+ "\tpackage: #{PKG_NAME.downcase}\n",
271
+ "\tpackage version: #{PKG_VERSION}\n",
272
+ "\tfiles: " + files.collect {|f| f.to_s }.join(', ') + "\n"
273
+
274
+ ask_for_confirmation( "Publish to RubyForge?" ) do
275
+ log 'Logging in...'
276
+ rf.login
277
+ log "Adding the new release to the '#{project}' project"
278
+ rf.add_release( group_id, package_id, PKG_VERSION, *files )
279
+ end
280
+ end
281
+ end
282
+ end
283
+
284
+ rescue LoadError => err
285
+ if !Object.const_defined?( :Gem )
286
+ require 'rubygems'
287
+ retry
288
+ end
289
+
290
+ task :no_release_tasks do
291
+ fail "Release tasks not defined: #{err.message}"
292
+ end
293
+
294
+ task :release => :no_release_tasks
295
+ task "release:announce" => :no_release_tasks
296
+ task "release:publish" => :no_release_tasks
297
+ task "release:notes" => :no_release_tasks
298
+ end
299
+
300
+ task :release => 'release:default'
301
+
@@ -0,0 +1,30 @@
1
+ #
2
+ # RDoc Rake tasks for ThingFish
3
+ # $Id: rdoc.rb 20 2008-08-07 15:50:54Z 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'
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
@@ -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
+