wordnet 0.0.5

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,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,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
+ trace "Will publish privately"
110
+ $publish_privately = true
111
+ Rake::Task['release:rerelease'].invoke
112
+ end
113
+
114
+
115
+ desc "Generate the release notes"
116
+ task :notes => [RELEASE_NOTES_FILE]
117
+ file RELEASE_NOTES_FILE do |task|
118
+ last_rel_tag = get_latest_release_tag() or
119
+ fail ">>> No releases tagged! Try running 'rake svn:release' first"
120
+ trace "Last release tag is: %p" % [ last_rel_tag ]
121
+ start = get_last_changed_rev( last_rel_tag ) || 1
122
+ trace "Starting rev is: %p" % [ start ]
123
+ log_output = make_svn_log( '.', start, 'HEAD' )
124
+
125
+ File.open( task.name, File::WRONLY|File::TRUNC|File::CREAT ) do |fh|
126
+ fh.print( log_output )
127
+ end
128
+
129
+ edit task.name
130
+ end
131
+ CLOBBER.include( RELEASE_NOTES_FILE )
132
+
133
+
134
+ task :project => [ :rdoc ] do
135
+ when_writing( "Publishing docs to #{PROJECT_SCPDOCURL}" ) do
136
+ run 'ssh', PROJECT_HOST, "rm -rf #{PROJECT_DOCDIR}"
137
+ run 'scp', '-qCr', 'docs/html', PROJECT_SCPDOCURL
138
+ end
139
+ when_writing( "Uploading packages") do
140
+ pkgs = Pathname.glob( PKGDIR + "#{PKG_FILE_NAME}.{gem,tar.gz,tar.bz2,zip}" )
141
+ log "Uploading %d packages to #{PROJECT_SCPPUBURL}" % [ pkgs.length ]
142
+ pkgs.each do |pkgfile|
143
+ run 'scp', '-qC', pkgfile, PROJECT_SCPPUBURL
144
+ end
145
+ end
146
+ end
147
+
148
+
149
+ file RELEASE_ANNOUNCE_FILE => [RELEASE_NOTES_FILE] do |task|
150
+ relnotes = File.read( RELEASE_NOTES_FILE )
151
+ announce_body = %{
152
+
153
+ Version #{PKG_VERSION} of #{PKG_NAME} has been released.
154
+
155
+ #{Text::Format.new(:first_indent => 0).format_one_paragraph(GEMSPEC.description)}
156
+
157
+ == Project Page
158
+
159
+ #{GEMSPEC.homepage}
160
+
161
+ == Installation
162
+
163
+ Via gems:
164
+
165
+ $ sudo gem install #{GEMSPEC.name}
166
+
167
+ or from source:
168
+
169
+ $ wget http://deveiate.org/code/#{PKG_FILE_NAME}.tar.gz
170
+ $ tar -xzvf #{PKG_FILE_NAME}.tar.gz
171
+ $ cd #{PKG_FILE_NAME}
172
+ $ sudo rake install
173
+
174
+ == Changes
175
+ #{relnotes}
176
+ }.gsub( /^\t+/, '' )
177
+
178
+ File.open( task.name, File::WRONLY|File::TRUNC|File::CREAT ) do |fh|
179
+ fh.print( announce_body )
180
+ end
181
+
182
+ edit task.name
183
+ end
184
+ CLOBBER.include( RELEASE_ANNOUNCE_FILE )
185
+
186
+
187
+ desc 'Send out a release announcement'
188
+ task :announce => [RELEASE_ANNOUNCE_FILE] do
189
+ email = TMail::Mail.new
190
+ if $publish_privately
191
+ trace "Sending private announce mail"
192
+ email.to = 'rubymage@gmail.com'
193
+ else
194
+ trace "Sending public announce mail"
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 => [:clean, :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,35 @@
1
+ #
2
+ # RDoc Rake tasks for ThingFish
3
+ # $Id: rdoc.rb 40 2008-08-27 21:58:00Z deveiant $
4
+ #
5
+
6
+ require 'rake/rdoctask'
7
+ $have_darkfish = false
8
+
9
+ # Append docs/lib to the load path if it exists for a locally-installed Darkfish
10
+ DOCSLIB = DOCSDIR + 'lib'
11
+ $LOAD_PATH.unshift( DOCSLIB.to_s ) if DOCSLIB.exist?
12
+
13
+ begin
14
+ require 'darkfish-rdoc'
15
+ $have_darkfish = true
16
+ rescue LoadError => err
17
+ unless Object.const_defined?( :Gem )
18
+ require 'rubygems'
19
+ gem 'darkfish-rdoc'
20
+ retry
21
+ end
22
+
23
+ log "No DarkFish: %s: %s" % [ err.class.name, err.message ]
24
+ trace "Backtrace:\n %s" % [ err.backtrace.join("\n ") ]
25
+ end
26
+
27
+ Rake::RDocTask.new do |rdoc|
28
+ rdoc.rdoc_dir = RDOCDIR.expand_path.relative_path_from( Pathname.pwd ).to_s
29
+ rdoc.title = "#{PKG_NAME} - #{PKG_SUMMARY}"
30
+ rdoc.options += RDOC_OPTIONS + [ '-f', 'darkfish' ] if $have_darkfish
31
+
32
+ rdoc.rdoc_files.include 'README'
33
+ rdoc.rdoc_files.include LIB_FILES.collect {|f| f.to_s }
34
+ rdoc.rdoc_files.include EXT_FILES.collect {|f| f.to_s }
35
+ end