Skip to content

Commit

Permalink
updating rake tasks to Mr Bones 2.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
TwP committed Mar 12, 2008
1 parent 5a86225 commit 0262a67
Show file tree
Hide file tree
Showing 12 changed files with 221 additions and 215 deletions.
4 changes: 2 additions & 2 deletions Manifest.txt
Expand Up @@ -100,12 +100,12 @@ spec/spec.opts
spec/spec_helper.rb
spec/webby/resources/file_spec.rb
tasks/ann.rake
tasks/annotations.rake
tasks/bones.rake
tasks/doc.rake
tasks/gem.rake
tasks/manifest.rake
tasks/notes.rake
tasks/post_load.rake
tasks/rdoc.rake
tasks/rubyforge.rake
tasks/setup.rb
tasks/spec.rake
Expand Down
21 changes: 11 additions & 10 deletions Rakefile
Expand Up @@ -13,23 +13,24 @@ PROJ.authors = 'Tim Pease'
PROJ.email = 'tim.pease@gmail.com'
PROJ.url = 'http://webby.rubyforge.org/'
PROJ.description = paragraphs_of('README.txt', 3).join("\n\n")
PROJ.rubyforge_name = 'webby'
PROJ.rdoc_dir = 'doc/rdoc'
PROJ.rdoc_remote_dir = 'rdoc'
PROJ.rubyforge.name = 'webby'
PROJ.version = Webby::VERSION
PROJ.release_name = 'Wandering Wookie'

PROJ.exclude << %w(^examples/[^/]+/output ^tasks/archive ^tags$)
PROJ.rdoc_exclude << %w(^data ^examples)

PROJ.svn = true
PROJ.spec_opts << '--color'
PROJ.rdoc.dir = 'doc/rdoc'
PROJ.rdoc.remote_dir = 'rdoc'
PROJ.rdoc.exclude << %w(^data ^examples)

PROJ.ann_email[:to] << 'webby-forum@googlegroups.com'
PROJ.ann_email[:server] = 'smtp.gmail.com'
PROJ.ann_email[:port] = 587
PROJ.svn.path = ''
PROJ.spec.opts << '--color'

PROJ.ann_text = <<-ANN
PROJ.ann.email[:to] << 'webby-forum@googlegroups.com'
PROJ.ann.email[:server] = 'smtp.gmail.com'
PROJ.ann.email[:port] = 587

PROJ.ann.text = <<-ANN
== FUN FACT
A Boeing 747's wingspan is longer than the Wright brothers first flight.
Expand Down
28 changes: 15 additions & 13 deletions tasks/ann.rake
Expand Up @@ -9,9 +9,10 @@ require 'time'

namespace :ann do

file PROJ.ann_file do
puts "Generating #{PROJ.ann_file}"
File.open(PROJ.ann_file,'w') do |fd|
file PROJ.ann.file do
ann = PROJ.ann
puts "Generating #{ann.file}"
File.open(ann.file,'w') do |fd|
fd.puts("#{PROJ.name} version #{PROJ.version}")
fd.puts(" by #{Array(PROJ.authors).first}") if PROJ.authors
fd.puts(" #{PROJ.url}") if PROJ.url
Expand All @@ -23,23 +24,24 @@ namespace :ann do
fd.puts
fd.puts(PROJ.changes.sub(%r/^.*$/, '== CHANGES'))
fd.puts
PROJ.ann_paragraphs.each do |p|
ann.paragraphs.each do |p|
fd.puts "== #{p.upcase}"
fd.puts
fd.puts paragraphs_of(PROJ.readme_file, p).join("\n\n")
fd.puts
end
fd.puts PROJ.ann_text if PROJ.ann_text
fd.puts ann.text if ann.text
end
end

desc "Create an announcement file"
task :announcement => PROJ.ann_file
task :announcement => PROJ.ann.file

desc "Send an email announcement"
task :email => PROJ.ann_file do
from = PROJ.ann_email[:from] || PROJ.email
to = Array(PROJ.ann_email[:to])
task :email => PROJ.ann.file do
ann = PROJ.ann
from = ann.email[:from] || PROJ.email
to = Array(ann.email[:to])

### build a mail header for RFC 822
rfc822msg = "From: #{from}\n"
Expand All @@ -49,11 +51,11 @@ namespace :ann do
rfc822msg << "\n"
rfc822msg << "Date: #{Time.new.rfc822}\n"
rfc822msg << "Message-Id: "
rfc822msg << "<#{"%.8f" % Time.now.to_f}@#{PROJ.ann_email[:domain]}>\n\n"
rfc822msg << File.read(PROJ.ann_file)
rfc822msg << "<#{"%.8f" % Time.now.to_f}@#{ann.email[:domain]}>\n\n"
rfc822msg << File.read(ann.file)

params = [:server, :port, :domain, :acct, :passwd, :authtype].map do |key|
PROJ.ann_email[key]
ann.email[key]
end

params[3] = PROJ.email if params[3].nil?
Expand All @@ -71,6 +73,6 @@ end # namespace :ann
desc 'Alias to ann:announcement'
task :ann => 'ann:announcement'

CLOBBER << PROJ.ann_file
CLOBBER << PROJ.ann.file

# EOF
29 changes: 5 additions & 24 deletions tasks/bones.rake
@@ -1,7 +1,6 @@
# $Id$

require 'pp'
require 'stringio'
if HAVE_BONES

namespace :bones do

Expand All @@ -10,31 +9,13 @@ namespace :bones do
atr = if ARGV.length == 2
t.application.top_level_tasks.pop
end
sio = StringIO.new
sep = "\n" + ' '*27
fmt = "%23s => %s"

if atr
PP.pp(PROJ.send(atr.to_sym), sio, 49)
sio.seek 0
val = sio.read
val = val.split("\n").join(sep)

puts fmt % [atr, val]
else
h = PROJ.instance_variable_get(:@table)
h.keys.map {|k| k.to_s}.sort.each do |k|
sio.truncate 0
PP.pp(h[k.to_sym], sio, 49)
sio.seek 0
val = sio.read
val = val.split("\n").join(sep)

puts fmt % [k, val]
end
end
if atr then Bones::Debug.show_attr(PROJ, atr)
else Bones::Debug.show PROJ end
end

end # namespace :bones

end # HAVE_BONES

# EOF
56 changes: 23 additions & 33 deletions tasks/gem.rake
Expand Up @@ -4,84 +4,74 @@ require 'rake/gempackagetask'

namespace :gem do

PROJ.spec = Gem::Specification.new do |s|
PROJ.gem.spec = Gem::Specification.new do |s|
s.name = PROJ.name
s.version = PROJ.version
s.summary = PROJ.summary
s.authors = Array(PROJ.authors)
s.email = PROJ.email
s.homepage = Array(PROJ.url).first
s.rubyforge_project = PROJ.rubyforge_name
s.post_install_message = PROJ.post_install_message
s.rubyforge_project = PROJ.rubyforge.name
s.post_install_message = PROJ.gem.post_install_message

s.description = PROJ.description

PROJ.dependencies.each do |dep|
PROJ.gem.dependencies.each do |dep|
s.add_dependency(*dep)
end

s.files = PROJ.files
s.executables = PROJ.executables.map {|fn| File.basename(fn)}
s.extensions = PROJ.files.grep %r/extconf\.rb$/
s.files = PROJ.gem.files
s.executables = PROJ.gem.executables.map {|fn| File.basename(fn)}
s.extensions = PROJ.gem.files.grep %r/extconf\.rb$/

s.bindir = 'bin'
dirs = Dir["{#{PROJ.libs.join(',')}}"]
s.require_paths = dirs unless dirs.empty?

incl = Regexp.new(PROJ.rdoc_include.join('|'))
excl = PROJ.rdoc_exclude.dup.concat %w[\.rb$ ^(\.\/|\/)?ext]
incl = Regexp.new(PROJ.rdoc.include.join('|'))
excl = PROJ.rdoc.exclude.dup.concat %w[\.rb$ ^(\.\/|\/)?ext]
excl = Regexp.new(excl.join('|'))
rdoc_files = PROJ.files.find_all do |fn|
rdoc_files = PROJ.gem.files.find_all do |fn|
case fn
when excl; false
when incl; true
else false end
end
s.rdoc_options = PROJ.rdoc_opts + ['--main', PROJ.rdoc_main]
s.rdoc_options = PROJ.rdoc.opts + ['--main', PROJ.rdoc.main]
s.extra_rdoc_files = rdoc_files
s.has_rdoc = true

if test ?f, PROJ.test_file
s.test_file = PROJ.test_file
if test ?f, PROJ.test.file
s.test_file = PROJ.test.file
else
s.test_files = PROJ.tests.to_a
s.test_files = PROJ.test.files.to_a
end

# Do any extra stuff the user wants
# spec_extras.each do |msg, val|
# case val
# when Proc
# val.call(s.send(msg))
# else
# s.send "#{msg}=", val
# end
# end
end

desc 'Show information about the gem'
task :debug do
puts PROJ.spec.to_ruby
puts PROJ.gem.spec.to_ruby
end

pkg = Rake::PackageTask.new(PROJ.name, PROJ.version) do |pkg|
pkg.need_tar = PROJ.need_tar
pkg.need_zip = PROJ.need_zip
pkg.package_files += PROJ.spec.files
pkg.need_tar = PROJ.gem.need_tar
pkg.need_zip = PROJ.gem.need_zip
pkg.package_files += PROJ.gem.spec.files
end
Rake::Task['gem:package'].instance_variable_set(:@full_comment, nil)

gem_file = if PROJ.spec.platform == Gem::Platform::RUBY
gem_file = if PROJ.gem.spec.platform == Gem::Platform::RUBY
"#{pkg.package_name}.gem"
else
"#{pkg.package_name}-#{PROJ.spec.platform}.gem"
"#{pkg.package_name}-#{PROJ.gem.spec.platform}.gem"
end

desc "Build the gem file #{gem_file}"
task :package => "#{pkg.package_dir}/#{gem_file}"

file "#{pkg.package_dir}/#{gem_file}" => [pkg.package_dir] + PROJ.spec.files do
file "#{pkg.package_dir}/#{gem_file}" => [pkg.package_dir] + PROJ.gem.spec.files do
when_writing("Creating GEM") {
Gem::Builder.new(PROJ.spec).build
Gem::Builder.new(PROJ.gem.spec).build
verbose(true) {
mv gem_file, "#{pkg.package_dir}/#{gem_file}"
}
Expand All @@ -90,7 +80,7 @@ namespace :gem do

desc 'Install the gem'
task :install => [:clobber, :package] do
sh "#{SUDO} #{GEM} install pkg/#{PROJ.spec.full_name}"
sh "#{SUDO} #{GEM} install pkg/#{PROJ.gem.spec.full_name}"
end

desc 'Uninstall the gem'
Expand Down
4 changes: 2 additions & 2 deletions tasks/annotations.rake → tasks/notes.rake
Expand Up @@ -5,11 +5,11 @@ if HAVE_BONES
desc "Enumerate all annotations"
task :notes do
Bones::AnnotationExtractor.enumerate(
PROJ, PROJ.annotation_tags.join('|'), :tag => true)
PROJ, PROJ.notes.tags.join('|'), :tag => true)
end

namespace :notes do
PROJ.annotation_tags.each do |tag|
PROJ.notes.tags.each do |tag|
desc "Enumerate all #{tag} annotations"
task tag.downcase.to_sym do
Bones::AnnotationExtractor.enumerate(PROJ, tag)
Expand Down
27 changes: 16 additions & 11 deletions tasks/post_load.rake
Expand Up @@ -3,30 +3,35 @@
# This file does not define any rake tasks. It is used to load some project
# settings if they are not defined by the user.

PROJ.rdoc_exclude << "^#{Regexp.escape(PROJ.manifest_file)}$"
PROJ.exclude << "^#{Regexp.escape(PROJ.ann_file)}$"

PROJ.instance_variable_get(:@table).each do |key,val|
next unless val.instance_of? Array
next if key == :dependencies
val.flatten!
end
PROJ.rdoc.exclude << "^#{Regexp.escape(PROJ.manifest_file)}$"
PROJ.exclude << "^#{Regexp.escape(PROJ.ann.file)}$"

flatten_arrays = lambda do |this,os|
os.instance_variable_get(:@table).each do |key,val|
next if key == :dependencies
case val
when Array; val.flatten!
when OpenStruct; this.call(this,val)
end
end
end
flatten_arrays.call(flatten_arrays,PROJ)

PROJ.changes ||= paragraphs_of(PROJ.history_file, 0..1).join("\n\n")

PROJ.description ||= paragraphs_of(PROJ.readme_file, 'description').join("\n\n")

PROJ.summary ||= PROJ.description.split('.').first

PROJ.files ||=
PROJ.gem.files ||=
if test(?f, PROJ.manifest_file)
files = File.readlines(PROJ.manifest_file).map {|fn| fn.chomp.strip}
files.delete ''
files
else [] end

PROJ.executables ||= PROJ.files.find_all {|fn| fn =~ %r/^bin/}
PROJ.gem.executables ||= PROJ.gem.files.find_all {|fn| fn =~ %r/^bin/}

PROJ.rdoc_main ||= PROJ.readme_file
PROJ.rdoc.main ||= PROJ.readme_file

# EOF
15 changes: 8 additions & 7 deletions tasks/doc.rake → tasks/rdoc.rake
Expand Up @@ -6,12 +6,13 @@ namespace :doc do

desc 'Generate RDoc documentation'
Rake::RDocTask.new do |rd|
rd.main = PROJ.rdoc_main
rd.rdoc_dir = PROJ.rdoc_dir
rdoc = PROJ.rdoc
rd.main = rdoc.main
rd.rdoc_dir = rdoc.dir

incl = Regexp.new(PROJ.rdoc_include.join('|'))
excl = Regexp.new(PROJ.rdoc_exclude.join('|'))
files = PROJ.files.find_all do |fn|
incl = Regexp.new(rdoc.include.join('|'))
excl = Regexp.new(rdoc.exclude.join('|'))
files = PROJ.gem.files.find_all do |fn|
case fn
when excl; false
when incl; true
Expand All @@ -20,10 +21,10 @@ namespace :doc do
rd.rdoc_files.push(*files)

title = "#{PROJ.name}-#{PROJ.version} Documentation"
title = "#{PROJ.rubyforge_name}'s " + title if PROJ.rubyforge_name != title
title = "#{PROJ.rubyforge.name}'s " + title if PROJ.rubyforge.name != title

rd.options << "-t #{title}"
rd.options.concat(PROJ.rdoc_opts)
rd.options.concat(rdoc.opts)
end

desc 'Generate ri locally for testing'
Expand Down

0 comments on commit 0262a67

Please sign in to comment.