tasks/github-gem.rake in request-log-analyzer-1.0.4 vs tasks/github-gem.rake in request-log-analyzer-1.1.0

- old
+ new

@@ -27,21 +27,28 @@ task(:manifest) { manifest_task } desc "Releases a new version of #{@name}" task(:build => [:manifest]) { build_task } + + release_dependencies = [:check_clean_master_branch, :version, :build, :create_tag] + release_dependencies.push 'doc:publish' if has_rdoc? + release_dependencies.unshift 'test' if has_tests? + release_dependencies.unshift 'spec' if has_specs? + desc "Releases a new version of #{@name}" - task(:release => [:check_clean_master_branch, :version, :build]) { release_task } + task(:release => release_dependencies) { release_task } # helper task for releasing task(:check_clean_master_branch) { verify_clean_status('master') } task(:check_version) { verify_version(ENV['VERSION'] || @specification.version) } - task(:version => [:check_version]) { set_gem_version! } + task(:version => [:check_version]) { set_gem_version! } + task(:create_tag) { create_version_tag! } end # Register RDoc tasks - if @specification.has_rdoc + if has_rdoc? require 'rake/rdoctask' namespace(:doc) do desc 'Generate documentation for request-log-analyzer' Rake::RDocTask.new(:compile) do |rdoc| @@ -49,25 +56,35 @@ rdoc.title = @name rdoc.options += @specification.rdoc_options rdoc.rdoc_files.include(@specification.extra_rdoc_files) rdoc.rdoc_files.include('lib/**/*.rb') end + + desc "Publish RDoc files for #{@name} to Github" + task(:publish => :compile) do + sh 'git checkout gh-pages' + sh 'git pull origin gh-pages' + sh 'cp -rf doc/* .' + sh "git commit -am \"Publishing newest RDoc documentation for #{@name}\"" + sh "git push origin gh-pages" + sh "git checkout master" + end end end # Setup :spec task if RSpec files exist - if Dir['spec/**/*_spec.rb'].any? + if has_specs? require 'spec/rake/spectask' desc "Run all specs for #{@name}" Spec::Rake::SpecTask.new(:spec) do |t| t.spec_files = FileList['spec/**/*_spec.rb'] end end # Setup :test task if unit test files exist - if Dir['test/**/*_test.rb'].any? + if has_tests? require 'rake/testtask' desc "Run all unit tests for #{@name}" Rake::TestTask.new(:test) do |t| t.pattern = 'test/**/*_test.rb' @@ -77,10 +94,22 @@ end end protected + def has_rdoc? + @specification.has_rdoc + end + + def has_specs? + Dir['spec/**/*_spec.rb'].any? + end + + def has_tests? + Dir['test/**/*_test.rb'].any? + end + def reload_gemspec! raise "No gemspec file found!" if gemspec_file.nil? spec = File.read(gemspec_file) @specification = eval(spec) @name = specification.name @@ -199,16 +228,21 @@ def uninstall_task raise "#{name} .gem file not found" unless File.exist?("pkg/#{name}-#{specification.version}.gem") sh "gem uninstall #{name}" end - def release_task + def create_version_tag! # commit the gemspec file git_commit_file(gemspec_file, "Updated #{gemspec_file} for release of version #{@specification.version}") if git_modified?(gemspec_file) # create tag and push changes git_create_tag("#{@name}-#{@specification.version}", "Tagged version #{@specification.version}") - git_push('origin', 'master', [:tags]) + git_push('origin', 'master', [:tags]) + end + + def release_task + puts + puts "Released #{@name} - version#{@specification.version}" end end end Rake::GithubGem.define_tasks! \ No newline at end of file