Skip to content

Commit

Permalink
Builds now auto-check the manifest
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinrutherford committed Apr 5, 2009
1 parent 51d1379 commit 6d52fc4
Show file tree
Hide file tree
Showing 6 changed files with 157 additions and 91 deletions.
3 changes: 1 addition & 2 deletions History.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

=== Major enhancements:

* Place *.reek files in source folder to configure smell detection behaviour
* Use *.reek files in source tree to configure Reek's behaviour
* Added -f option to configure report format
* --sort_order replaced by -f, -c and -s
* Matchers provided for rspec; eg. foo.should_not reek
Expand All @@ -17,7 +17,6 @@

* Corrected false reports of long arg lists to yield
* A method can now be a UtilityFunction only when it includes a call
* Removed the website from the gem [#12]

== 0.3.1 2008-11-17

Expand Down
1 change: 1 addition & 0 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ PKG_DIR = "#{BUILD_DIR}/pkg"; directory PKG_DIR
RDOC_DIR = "#{BUILD_DIR}/rdoc"; directory RDOC_DIR

GEM_MANIFEST = "Manifest.txt"
VERSION_FILE = 'lib/reek.rb'

CLOBBER.include("#{BUILD_DIR}/*")

Expand Down
23 changes: 23 additions & 0 deletions tasks/build.rake
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@

namespace :build do
Rake::GemPackageTask.new($gemspec) do |task|
task.package_dir = PKG_DIR
task.need_tar = true
task.need_zip = false
end

task :gem => [MANIFEST_CHECKED, 'rspec:all']

Rake::RDocTask.new do |rd|
rd.main = 'README.txt'
rd.rdoc_dir = RDOC_DIR
files = $gemspec.files.grep(/^(lib|bin|ext)|txt|rdoc$/)
files -= [GEM_MANIFEST]
rd.rdoc_files.push(*files)
title = "#{PROJECT_NAME}-#{::Reek::VERSION} Documentation"
rd.options << "-t #{title}"
end

task :rdoc => [RDOC_DIR, MANIFEST_CHECKED]
task :all => ['build:package', 'build:rdoc']
end
193 changes: 113 additions & 80 deletions tasks/deployment.rake
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,13 @@ begin
rescue Gem::LoadError
end

GEMSPEC = "#{PROJECT_NAME}.$gemspec"
HISTORY_FILE = 'History.txt'

NEWS_FILE = "#{BUILD_DIR}/news.txt"
RELEASE_TIMESTAMP = "#{BUILD_DIR}/.last-release"
MANIFEST_CHECKED = "#{BUILD_DIR}/.manifest-checked"

$gemspec = Gem::Specification.new do |s|
s.name = PROJECT_NAME
s.version = ::Reek::VERSION
Expand All @@ -31,135 +38,161 @@ For more information on reek, see http://wiki.github.com/kevinrutherford/reek
'
end

class File
def self.touch(path, text)
File.open(path, 'w') { |ios| ios.puts text }
end
end

class String
def rdoc_to_markdown
self.gsub(/^(=+)/) { "#" * $1.size }
end
end

def changes
File.read("History.txt").split(/^(== .*)/)[2].strip
def touch(text = DateTime.now)
File.touch(self, text)
end
end

def announcement
subject = "#{PROJECT_NAME} #{::Reek::VERSION} Released"
title = "#{PROJECT_NAME} version #{::Reek::VERSION} has been released!"
body = "#{$gemspec.description}\n\nChanges:\n\n#{changes}".rdoc_to_markdown
urls = <<EOU
* http://wiki.github.com/kevinrutherford/reek
* http://reek.rubyforge.org/rdoc/
EOU
return subject, title, body, urls
end
class Description

desc 'Post announcement to rubyforge'
task :post_news do
subject, title, body, urls = announcement
rf = RubyForge.new.configure
rf.login
rf.post_news(PROJECT_NAME, subject, "#{title}\n\n#{body}")
puts "Posted to rubyforge"
end
def description
"Reek detects smells in Ruby code. It can be used as a stand-alone
command, or as a Rake task, or as an expectation in Rspec examples."
end

desc 'Generate email announcement'
task :email do
subject, title, body, urls = announcement
email = <<EOM
Subject: [ANN] #{subject}
def changes
File.read("History.txt").split(/^(== .*)/)[2].strip
end

#{title}
def subject
"#{PROJECT_NAME} #{::Reek::VERSION} released"
end
def title
"#{PROJECT_NAME} version #{::Reek::VERSION} has been released!"
end
def body
"#{$gemspec.description}\n\n## Changes:\n\n#{changes}".rdoc_to_markdown
end
def urls
result = <<EOR
* http://wiki.github.com/kevinrutherford/#{PROJECT_NAME}
* http://#{PROJECT_NAME}.rubyforge.org/rdoc/
EOR
result
end

#{urls}
def news
news = <<-EOM
#{title}
#{body}
#{description}
#{urls}
EOM
puts email
end
## Changes in this release:
class ::Rake::SshDirPublisher
attr_reader :host, :remote_dir, :local_dir
end
#{changes.rdoc_to_markdown}
GEMSPEC = "#{PROJECT_NAME}.$gemspec"
## More information:
file GEMSPEC => [GEM_MANIFEST, 'lib/reek.rb', __FILE__] do
puts "Generating #{GEMSPEC}"
File.open(GEMSPEC, 'w') do |file|
file.puts $gemspec.to_ruby
#{urls}
EOM
return news
end
end

namespace :build do
Rake::GemPackageTask.new($gemspec) do |task|
task.package_dir = PKG_DIR
task.need_tar = true
task.need_zip = false
end
def email
result = <<EOM
"Subject: [ANN] #{subject}"
task :gem => ['rspec:all']
"#{title}"
Rake::RDocTask.new do |rd|
rd.main = 'README.txt'
rd.rdoc_dir = RDOC_DIR
files = $gemspec.files.grep(/^(lib|bin|ext)|txt|rdoc$/)
files -= [GEM_MANIFEST]
rd.rdoc_files.push(*files)
title = "#{PROJECT_NAME}-#{::Reek::VERSION} Documentation"
rd.options << "-t #{title}"
"#{urls}"
"#{body}"
"#{urls}"
EOM
result
end
end

file NEWS_FILE => [HISTORY_FILE] do
NEWS_FILE.touch(Description.new.news)
end
#
#file VERSION_FILE => [RELEASE_TIMESTAMP] do
# abort "Version #{::Reek::VERSION} has already been released!"
#end

task :rdoc => [RDOC_DIR]
task :all => ['build:package', 'build:rdoc']
class ::Rake::SshDirPublisher
attr_reader :host, :remote_dir, :local_dir
end

file GEMSPEC => [GEM_MANIFEST, VERSION_FILE, __FILE__] do
GEMSPEC.touch($gemspec.to_ruby)
end

namespace :release do
task :version_bumped do
#abort 'Version not bumped!'
end

desc 'Minor release on github only'
task :minor => ['version_bumped', 'build:package', 'rubyforge:rdoc'] do
task :minor => [VERSION_FILE, 'build:package', 'rubyforge:rdoc'] do
puts <<-EOS
1) git commit -a -m "Release #{Reek::VERSION}"
2) git tag -a "v#{Reek::VERSION}" -m "Release #{Reek::VERSION}"
3) git push
4) git push --tags
EOS
RELEASE_TIMESTAMP.touch(::Reek::VERSION)
end

desc 'Major release (github+rubyforge) with news'
task :major do
task :major => ['release:minor', NEWS_FILE, 'rubyforge:news'] do

end
end

def pkg_files
require 'find'
result = []
Find.find '.' do |path|
next unless File.file? path
next if path =~ /\.git|build/
result << path[2..-1]
end
result
end

$package_files = pkg_files

def display_manifest_diff
f = "Manifest.tmp"
f.touch(pkg_files.sort.join("\n"))
system "diff -du #{GEM_MANIFEST} #{f}"
rm f
end

namespace :test do
desc 'Install the gem locally'
task :install => [:clean, 'build:all'] do
gem = Dir["#{PKG_DIR}/*.gem"].first
sh "sudo gem install --local #{gem}"
end

desc 'Verify the manifest'
task :manifest => [:clobber] do
f = "Manifest.tmp"
require 'find'
files = []
Find.find '.' do |path|
next unless File.file? path
next if path =~ /\.git|build/
files << path[2..-1]
end
files = files.sort.join "\n"
File.open(f, 'w') do |fp| fp.puts files end
system "diff -du #{GEM_MANIFEST} #{f}"
rm f
end

desc 'Show the gemspec'
task :gemspec do
puts $gemspec.to_ruby
end
end

def query(msg)
print msg
$stdin.gets
end

file MANIFEST_CHECKED => $package_files do
display_manifest_diff
if query('Is this manifest good to go? [yN]') =~ /y/i
MANIFEST_CHECKED.touch
else
abort 'Check the manifest and try again'
end
end
1 change: 0 additions & 1 deletion tasks/develop.rake
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ CLOBBER.include(CONFIG_DIR)

directory CONFIG_DIR

desc 'creates the default config file'
file CONFIG_FILE => [CONFIG_DIR] do
config = {}
Reek::SmellConfig::SMELL_CLASSES.each do |klass|
Expand Down
27 changes: 19 additions & 8 deletions tasks/rubyforge.rake
Original file line number Diff line number Diff line change
Expand Up @@ -8,29 +8,40 @@ def user_at_host
"#{config["username"]}@rubyforge.org"
end

def rsync(local, remote)
sh %{rsync -av --delete --ignore-errors #{local}/ #{user_at_host}:#{remote}}
end

namespace :rubyforge do
desc 'Upload website files to rubyforge'
task :website do
sh %{rsync -av --delete --ignore-errors website/ #{user_at_host}:#{REMOTE_PROJECT_DIR}}
rsync('website', REMOTE_PROJECT_DIR)
end

desc 'Upload the gem to rubyforge'
task :gem => ['clean', 'build:package'] do |t|
task :gem => ['build:package'] do |t|
pkg = "#{PKG_DIR}/#{PROJECT_NAME}-#{::Reek::VERSION}"
rf = RubyForge.new.configure
puts "Logging in"
rf.login
c = rf.userconfig
c["release_notes"] = @description if @description # TODO!!
c["release_changes"] = changes if changes
proj = Description.new
c["release_notes"] = proj.description
c["release_changes"] = proj.changes
c["preformatted"] = true
files = ["#{pkg}.tgz", "#{pkg}.gem"].compact
puts "Releasing #{PROJECT_NAME} v. #{::Reek::VERSION}"
rf.add_release(PROJECT_NAME, PROJECT_NAME, ::Reek::VERSION, *files)
end

desc 'Upload the rdoc to rubyforge'
task :rdoc => ['clean', 'build:rdoc'] do
sh %{rsync -av --delete --ignore-errors #{RDOC_DIR}/ #{user_at_host}:#{REMOTE_PROJECT_DIR}/rdoc}
task :rdoc => ['build:rdoc'] do
rsync(RDOC_DIR, "#{REMOTE_PROJECT_DIR}/rdoc")
end

desc 'Post news announcement to rubyforge'
task :news do
proj = Description.new
rf = RubyForge.new.configure
rf.login
puts "rf.post_news(#{PROJECT_NAME}, #{proj.subject}, #{proj.news})"
end
end

0 comments on commit 6d52fc4

Please sign in to comment.