configurability 1.0.0

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/packaging.rb ADDED
@@ -0,0 +1,129 @@
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
+
@@ -0,0 +1,278 @@
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
+ if user or secret
38
+ if self.method( :check_auth_args ).arity == 3
39
+ check_auth_args( user, secret, authtype )
40
+ else
41
+ check_auth_args( user, secret )
42
+ end
43
+ end
44
+
45
+ # Open the connection
46
+ @debug_output << "opening connection to #{@address}...\n" if @debug_output
47
+ sock = timeout( @open_timeout ) { TCPsocket.new(@address, @port) }
48
+
49
+ # Wrap it in the SSL layer
50
+ ssl_context = OpenSSL::SSL::SSLContext.new
51
+ ssl_context.verify_mode = OpenSSL::SSL::VERIFY_NONE
52
+ ssl_sock = OpenSSL::SSL::SSLSocket.new( sock, ssl_context )
53
+ ssl_sock.sync_close = true
54
+ ssl_sock.connect
55
+
56
+ # Wrap it in the message-oriented IO layer
57
+ sslmsgio = Net::InternetMessageIO.new( ssl_sock )
58
+ sslmsgio.read_timeout = @read_timeout
59
+ sslmsgio.debug_output = @debug_output
60
+
61
+ @socket = sslmsgio
62
+
63
+ check_response(critical { recv_response() })
64
+ begin
65
+ if @esmtp
66
+ ehlo helodomain
67
+ else
68
+ helo helodomain
69
+ end
70
+ rescue ProtocolError
71
+ if @esmtp
72
+ @esmtp = false
73
+ @error_occured = false
74
+ retry
75
+ end
76
+ raise
77
+ end
78
+ authenticate user, secret, authtype if user
79
+ @started = true
80
+ ensure
81
+ @socket.close if not @started and @socket and not @socket.closed?
82
+ end
83
+ end
84
+
85
+
86
+ begin
87
+ gem 'text-format'
88
+
89
+ require 'time'
90
+ require 'rake/tasklib'
91
+ require 'tmail'
92
+ require 'net/smtp'
93
+ require 'etc'
94
+ require 'socket'
95
+ require 'text/format'
96
+
97
+ ### Generate a valid RFC822 message-id
98
+ def gen_message_id
99
+ return "<%s.%s@%s>" % [
100
+ (Time.now.to_f * 10000).to_i.to_s( 36 ),
101
+ (rand( 2 ** 64 - 1 )).to_s( 36 ),
102
+ Socket.gethostname
103
+ ]
104
+ end
105
+
106
+
107
+ namespace :release do
108
+ task :default => [ :prep_release, :upload, :publish, :announce ]
109
+
110
+ desc "Re-publish the release with the current version number"
111
+ task :rerelease => [ :upload, :publish, :announce ]
112
+
113
+ desc "Re-run the publication tasks, but send notifications to debugging address"
114
+ task :test do
115
+ trace "Will publish privately"
116
+ $publish_privately = true
117
+ Rake::Task['release:rerelease'].invoke
118
+ end
119
+
120
+
121
+ desc "Generate the release notes"
122
+ task :notes => [RELEASE_NOTES_FILE]
123
+ file RELEASE_NOTES_FILE do |task|
124
+ last_tag = MercurialHelpers.get_tags.grep( /\d+\.\d+\.\d+/ ).
125
+ collect {|ver| vvec(ver) }.sort.last.unpack( 'N*' ).join('.')
126
+
127
+ File.open( task.name, File::WRONLY|File::TRUNC|File::CREAT ) do |fh|
128
+ fh.puts "Release Notes for #{PKG_VERSION}",
129
+ "--------------------------------", '', ''
130
+ end
131
+
132
+ edit task.name
133
+ end
134
+ CLOBBER.include( RELEASE_NOTES_FILE )
135
+
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 => [ :apidocs ] 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', API_DOCSDIR, PROJECT_SCPDOCURL
147
+ end
148
+ end
149
+
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
159
+ end
160
+
161
+
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)}
169
+
170
+ == Project Page
171
+
172
+ #{GEMSPEC.homepage}
173
+
174
+ == Installation
175
+
176
+ Via gems:
177
+
178
+ $ sudo gem install #{GEMSPEC.name}
179
+
180
+ or from source:
181
+
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
186
+
187
+ == Changes
188
+ #{relnotes}
189
+ }.gsub( /^\t+/, '' )
190
+
191
+ File.open( task.name, File::WRONLY|File::TRUNC|File::CREAT ) do |fh|
192
+ fh.print( announce_body )
193
+ end
194
+
195
+ edit task.name
196
+ end
197
+ CLOBBER.include( RELEASE_ANNOUNCE_FILE )
198
+
199
+
200
+ desc 'Send out a release announcement'
201
+ task :announce => [RELEASE_ANNOUNCE_FILE] do
202
+ email = TMail::Mail.new
203
+
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
+
213
+ from = prompt_with_default( "Send announcement as:",
214
+ 'Michael Granger <ged@FaerieMUD.org>' ) or fail
215
+
216
+ email.from = from
217
+ email.subject = "[ANN] #{PKG_NAME} #{PKG_VERSION}"
218
+ email.body = File.read( RELEASE_ANNOUNCE_FILE )
219
+ email.date = Time.new
220
+
221
+ email.message_id = gen_message_id()
222
+
223
+ log "About to send the following email:"
224
+ puts '---',
225
+ email.to_s,
226
+ '---'
227
+
228
+ ask_for_confirmation( "Will send via #{SMTP_HOST}." ) do
229
+ pwent = Etc.getpwuid( Process.euid )
230
+ curuser = pwent ? pwent.name : 'unknown'
231
+ username = prompt_with_default( "SMTP user", curuser )
232
+ password = prompt_for_password()
233
+
234
+ trace "Creating SMTP connection to #{SMTP_HOST}:#{SMTP_PORT}"
235
+ smtp = Net::SMTP.new( SMTP_HOST, SMTP_PORT )
236
+ smtp.set_debug_output( $stdout )
237
+ smtp.esmtp = true
238
+
239
+ trace "connecting..."
240
+ smtp.ssl_start( Socket.gethostname, username, password, :plain ) do |smtp|
241
+ trace "sending message..."
242
+ smtp.send_message( email.to_s, email.from, email.to )
243
+ end
244
+ trace "done."
245
+ end
246
+ end
247
+
248
+
249
+ desc 'Publish the new release to Gemcutter'
250
+ task :publish => [:clean, :gem, :notes] do |task|
251
+ ask_for_confirmation( "Publish #{GEM_FILE_NAME} to Gemcutter?", false ) do
252
+ gempath = PKGDIR + GEM_FILE_NAME
253
+ sh 'gem', 'push', gempath
254
+ end
255
+ end
256
+ end
257
+
258
+ rescue LoadError => err
259
+ if !Object.const_defined?( :Gem )
260
+ require 'rubygems'
261
+ retry
262
+ end
263
+
264
+ task :no_release_tasks do
265
+ fail "Release tasks not defined: #{err.message}"
266
+ end
267
+
268
+ task :release => :no_release_tasks
269
+ task "release:announce" => :no_release_tasks
270
+ task "release:publish" => :no_release_tasks
271
+ task "release:notes" => :no_release_tasks
272
+ end
273
+
274
+ desc "Package up a release, publish it, and send out notifications"
275
+ task :release => 'release:default'
276
+ task :rerelease => 'release:rerelease'
277
+ task :testrelease => 'release:test'
278
+
data/rake/style.rb ADDED
@@ -0,0 +1,62 @@
1
+ #
2
+ # Style Fixup Rake Tasks
3
+
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
+