linkparser 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.
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,308 @@
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
+ desc "Re-run the publication tasks, but send notifications to debugging address"
109
+ task :test do
110
+ trace "Will publish privately"
111
+ $publish_privately = true
112
+ Rake::Task['release:rerelease'].invoke
113
+ end
114
+
115
+
116
+ desc "Generate the release notes"
117
+ task :notes => [RELEASE_NOTES_FILE]
118
+ file RELEASE_NOTES_FILE do |task|
119
+ last_rel_tag = get_latest_release_tag() or
120
+ fail ">>> No releases tagged! Try running 'rake svn:release' first"
121
+ trace "Last release tag is: %p" % [ last_rel_tag ]
122
+ start = get_last_changed_rev( last_rel_tag ) || 1
123
+ trace "Starting rev is: %p" % [ start ]
124
+ log_output = make_svn_log( '.', start, 'HEAD' )
125
+
126
+ File.open( task.name, File::WRONLY|File::TRUNC|File::CREAT ) do |fh|
127
+ fh.print( log_output )
128
+ end
129
+
130
+ edit task.name
131
+ end
132
+ CLOBBER.include( RELEASE_NOTES_FILE )
133
+
134
+
135
+ desc "Publish the project documentation to #{PROJECT_HOST}"
136
+ task :project => [ :rdoc ] do
137
+ when_writing( "Publishing docs to #{PROJECT_SCPDOCURL}" ) do
138
+ run 'ssh', PROJECT_HOST, "rm -rf #{PROJECT_DOCDIR}"
139
+ run 'scp', '-qCr', RDOCDIR, PROJECT_SCPDOCURL
140
+ end
141
+ when_writing( "Uploading packages") do
142
+ pkgs = Pathname.glob( PKGDIR + "#{PKG_FILE_NAME}.{gem,tar.gz,tar.bz2,zip}" )
143
+ log "Uploading %d packages to #{PROJECT_SCPPUBURL}" % [ pkgs.length ]
144
+ pkgs.each do |pkgfile|
145
+ run 'scp', '-qC', pkgfile, PROJECT_SCPPUBURL
146
+ end
147
+ end
148
+ end
149
+
150
+
151
+ file RELEASE_ANNOUNCE_FILE => [RELEASE_NOTES_FILE] do |task|
152
+ relnotes = File.read( RELEASE_NOTES_FILE )
153
+ announce_body = %{
154
+
155
+ Version #{PKG_VERSION} of #{PKG_NAME} has been released.
156
+
157
+ #{Text::Format.new(:first_indent => 0).format_one_paragraph(GEMSPEC.description)}
158
+
159
+ == Project Page
160
+
161
+ #{GEMSPEC.homepage}
162
+
163
+ == Installation
164
+
165
+ Via gems:
166
+
167
+ $ sudo gem install #{GEMSPEC.name}
168
+
169
+ or from source:
170
+
171
+ $ wget http://deveiate.org/code/#{PKG_FILE_NAME}.tar.gz
172
+ $ tar -xzvf #{PKG_FILE_NAME}.tar.gz
173
+ $ cd #{PKG_FILE_NAME}
174
+ $ sudo rake install
175
+
176
+ == Changes
177
+ #{relnotes}
178
+ }.gsub( /^\t+/, '' )
179
+
180
+ File.open( task.name, File::WRONLY|File::TRUNC|File::CREAT ) do |fh|
181
+ fh.print( announce_body )
182
+ end
183
+
184
+ edit task.name
185
+ end
186
+ CLOBBER.include( RELEASE_ANNOUNCE_FILE )
187
+
188
+
189
+ desc 'Send out a release announcement'
190
+ task :announce => [RELEASE_ANNOUNCE_FILE] do
191
+ email = TMail::Mail.new
192
+ if $publish_privately
193
+ trace "Sending private announce mail"
194
+ email.to = 'rubymage@gmail.com'
195
+ else
196
+ trace "Sending public announce mail"
197
+ email.to = 'Ruby-Talk List <ruby-talk@ruby-lang.org>'
198
+ email.bcc = 'rubymage@gmail.com'
199
+ end
200
+ email.from = GEMSPEC.email
201
+ email.subject = "[ANN] #{PKG_NAME} #{PKG_VERSION}"
202
+ email.body = File.read( RELEASE_ANNOUNCE_FILE )
203
+ email.date = Time.new
204
+
205
+ email.message_id = gen_message_id()
206
+
207
+ log "About to send the following email:"
208
+ puts '---',
209
+ email.to_s,
210
+ '---'
211
+
212
+ ask_for_confirmation( "Will send via #{SMTP_HOST}." ) do
213
+ pwent = Etc.getpwuid( Process.euid )
214
+ curuser = pwent ? pwent.name : 'unknown'
215
+ username = prompt_with_default( "SMTP user", curuser )
216
+ password = prompt_for_password()
217
+
218
+ trace "Creating SMTP connection to #{SMTP_HOST}:#{SMTP_PORT}"
219
+ smtp = Net::SMTP.new( SMTP_HOST, SMTP_PORT )
220
+ smtp.set_debug_output( $stdout )
221
+ smtp.esmtp = true
222
+
223
+ trace "connecting..."
224
+ smtp.ssl_start( Socket.gethostname, username, password, :plain ) do |smtp|
225
+ trace "sending message..."
226
+ smtp.send_message( email.to_s, email.from, email.to )
227
+ end
228
+ trace "done."
229
+ end
230
+ end
231
+
232
+
233
+ desc 'Publish the new release to RubyForge'
234
+ task :publish => [:clean, :package, :notes] do |task|
235
+ project = GEMSPEC.rubyforge_project
236
+
237
+ rf = RubyForge.new
238
+ log "Loading RubyForge config"
239
+ rf.configure
240
+
241
+ group_id = rf.autoconfig['group_ids'][RUBYFORGE_GROUP] or
242
+ fail "Your configuration doesn't have a group id for '#{RUBYFORGE_GROUP}'"
243
+
244
+ # If this project doesn't yet exist, create it
245
+ unless rf.autoconfig['package_ids'].key?( project )
246
+ ask_for_confirmation( "Package '#{project}' doesn't exist on RubyForge. Create it?" ) do
247
+ log "Creating new package '#{project}'"
248
+ rf.create_package( group_id, project )
249
+ end
250
+ end
251
+
252
+ package_id = rf.autoconfig['package_ids'][ project ]
253
+
254
+ # Make sure this release doesn't already exist
255
+ releases = rf.autoconfig['release_ids']
256
+ if releases.key?( GEMSPEC.name ) && releases[ GEMSPEC.name ].key?( PKG_VERSION )
257
+ log "Rubyforge seems to already have #{ PKG_FILE_NAME }"
258
+ else
259
+ config = rf.userconfig or
260
+ fail "You apparently haven't set up your RubyForge credentials on this machine."
261
+ config['release_notes'] = GEMSPEC.description
262
+ config['release_changes'] = File.read( RELEASE_NOTES_FILE )
263
+
264
+ files = FileList[ PKGDIR + GEM_FILE_NAME ]
265
+ files.include PKGDIR + "#{PKG_FILE_NAME}.tar.gz"
266
+ files.include PKGDIR + "#{PKG_FILE_NAME}.tar.bz2"
267
+ files.include PKGDIR + "#{PKG_FILE_NAME}.zip"
268
+
269
+ log "Releasing #{PKG_FILE_NAME}"
270
+ when_writing do
271
+ log "Publishing to RubyForge: \n",
272
+ "\tproject: #{RUBYFORGE_GROUP}\n",
273
+ "\tpackage: #{PKG_NAME.downcase}\n",
274
+ "\tpackage version: #{PKG_VERSION}\n",
275
+ "\tfiles: " + files.collect {|f| f.to_s }.join(', ') + "\n"
276
+
277
+ ask_for_confirmation( "Publish to RubyForge?" ) do
278
+ log 'Logging in...'
279
+ rf.login
280
+ log "Adding the new release to the '#{project}' project"
281
+ rf.add_release( group_id, package_id, PKG_VERSION, *files )
282
+ end
283
+ end
284
+ end
285
+ end
286
+ end
287
+
288
+ rescue LoadError => err
289
+ if !Object.const_defined?( :Gem )
290
+ require 'rubygems'
291
+ retry
292
+ end
293
+
294
+ task :no_release_tasks do
295
+ fail "Release tasks not defined: #{err.message}"
296
+ end
297
+
298
+ task :release => :no_release_tasks
299
+ task "release:announce" => :no_release_tasks
300
+ task "release:publish" => :no_release_tasks
301
+ task "release:notes" => :no_release_tasks
302
+ end
303
+
304
+ desc "Package up a release, publish it, and send out notifications"
305
+ task :release => 'release:default'
306
+ task :rerelease => 'release:rerelease'
307
+ task :testrelease => 'release:test'
308
+
data/rake/rdoc.rb ADDED
@@ -0,0 +1,47 @@
1
+ #
2
+ # RDoc Rake tasks for ThingFish
3
+ # $Id: rdoc.rb 78 2008-12-18 22:04:10Z deveiant $
4
+ #
5
+
6
+ gem 'rdoc'
7
+
8
+ require 'rdoc/rdoc'
9
+ require 'rake/clean'
10
+
11
+
12
+ if RDoc::RDoc::GENERATORS.key?( 'darkfish' )
13
+ $have_darkfish = true
14
+ else
15
+ trace "No darkfish generator."
16
+ $have_darkfish = false
17
+ end
18
+
19
+
20
+ # Append docs/lib to the load path if it exists for a locally-installed Darkfish
21
+ DOCSLIB = DOCSDIR + 'lib'
22
+ $LOAD_PATH.unshift( DOCSLIB.to_s ) if DOCSLIB.exist?
23
+
24
+ # Make relative string paths of all the stuff we need to generate docs for
25
+ DOCFILES = LIB_FILES + EXT_FILES + GEMSPEC.extra_rdoc_files
26
+
27
+
28
+ directory RDOCDIR.to_s
29
+ CLOBBER.include( RDOCDIR )
30
+
31
+ desc "Build API documentation in #{RDOCDIR}"
32
+ task :rdoc => [ Rake.application.rakefile, *DOCFILES ] do
33
+ args = RDOC_OPTIONS
34
+ args += [ '-o', RDOCDIR.to_s ]
35
+ args += [ '-f', 'darkfish' ] if $have_darkfish
36
+ args += DOCFILES.collect {|pn| pn.to_s }
37
+
38
+ trace "Building docs with arguments: %s" % [ args.join(' ') ]
39
+ RDoc::RDoc.new.document( args ) rescue nil
40
+ end
41
+
42
+ desc "Rebuild API documentation in #{RDOCDIR}"
43
+ task :rerdoc do
44
+ rm_r( RDOCDIR ) if RDOCDIR.exist?
45
+ Rake::Task[ :rdoc ].invoke
46
+ end
47
+