lib/zen/task/build.rake in zen-0.2.8 vs lib/zen/task/build.rake in zen-0.3b

- old
+ new

@@ -1,38 +1,25 @@ -require 'open3' - -# Task group used for building various elements such as the Gem and the -# documentation. namespace :build do desc 'Builds the documentation using YARD' - task :doc do - zen_path = File.expand_path('../../../../', __FILE__) - command = "yard doc #{zen_path}/lib -m markdown -M rdiscount -o #{zen_path}/doc " - command += "-r #{zen_path}/README.md --private --protected" + task :doc => ['clean:yard'] do + root = File.expand_path('../../../../', __FILE__) + Dir.chdir(root) - sh(command) + sh('yard doc') end desc 'Builds a new Gem' task :gem do - zen_path = __DIR__('../../../') - gemspec_path = File.join( - zen_path, - "#{Zen::Gemspec.name}-#{Zen::Gemspec.version.version}.gem" - ) + root = File.expand_path('../../../../', __FILE__) + name = "#{Zen::Gemspec.name}-#{Zen::Gemspec.version.version}.gem" + path = File.join(root, name) + pkg = File.join(root, 'pkg', name) - pkg_path = File.join( - zen_path, - 'pkg', - "#{Zen::Gemspec.name}-#{Zen::Gemspec.version.version}.gem" - ) - # Build and install the gem - - sh('gem', 'build' , File.join(zen_path, 'zen.gemspec')) - sh('mv' , gemspec_path, pkg_path) - sh('gem', 'install' , pkg_path) + sh('gem', 'build', File.join(root, 'zen.gemspec')) + sh('mv' , path, pkg) + sh('gem', 'install', pkg) end # Stolen from Ramaze desc 'Builds a list of all the people that have contributed to Zen' task :authors do @@ -44,11 +31,44 @@ File.open('AUTHORS', 'w+') do |io| io.puts "Following persons have contributed to Zen." io.puts '(Sorted by number of submitted patches, then alphabetically)' io.puts '' - authors.sort_by{|(n,e),c| [-c, n.downcase] }.each do |(name, email), count| + authors.sort_by { |(n,e),c| [-c, n.downcase] }.each do |(name, email), count| io.puts("%6d %s <%s>" % [count, name, email]) end end end -end # namespace :build + + desc 'Builds a list of changes since a given Git tag and outputs it' + task :changes, [:tag] do |t, args| + args.with_defaults(:tag => `git tag`.split(/\n/)[-1]) + + stop = `git log -1 --pretty=oneline --color=never`.split(/\s+/)[0] + start = `git show #{args[:tag]} --pretty=oneline --color=never` \ + .split(/\s+/)[0] + + log = `git --no-pager log --color=never --pretty=oneline \ + #{start}..#{stop}`.split(/\n/) + + log.each do |line| + line = line.split(/\s+/, 2)[1].strip + wrapped = '* ' + chars = 0 + + # Wrap the string + line.split(/\s+/).each do |chunk| + length = chunk.length + + if ( chars + length ) <= ( 80 - length ) + wrapped += "#{chunk} " + chars += length + else + wrapped += "\n #{chunk} " + chars = 0 + end + end + + puts wrapped + end + end +end