Sha256: 5e7031bfd3e09d7a2350dddf059632dbe6dc2d2569245cde3e011ff8241b1b08
Contents?: true
Size: 1.89 KB
Versions: 2
Compression:
Stored size: 1.89 KB
Contents
require 'rake' require 'rake/tasklib' class ContributorTasks < Rake::TaskLib def initialize define end def define desc "Update contributors list in README" task :update_contributors do if new_contributors? puts "New contributors!" new_contributors.each {|name| puts "- #{name}"} puts "" print "Updating the 'Contributors' section of README..." File.open("README.md", "w+") do |file| file.puts readme_without_contributors_section file.puts "## Contributors (sorted alphabetically)" file.puts "" committers.each {|name| file.puts "* #{name}"} end puts "done!" else puts "No new contributors." end end task :release do puts "#####################" puts "For the twitters" puts "#####################" puts "[ANN] chili_videos v#{ChiliVideos::VERSION} released. Changes: http://bit.ly/orxPzQ, Repo: http://bit.ly/hExlRR #chiliproject" puts "#####################" end end private def all_committers all_names = `git shortlog -s |cut -s -f2` all_names.gsub!(/\sand\s/, "\n").split("\n").uniq!.sort! end def committers excluded_committers = ["Tom Kersten"] @committers ||= all_committers - excluded_committers end def readme_file_contents @readme_contents ||= `cat README.md` end def existing_contributors existing_contributors = readme_file_contents[/## Contributors(.|\n)*/].strip.split("\n* ") existing_contributors.shift # remove "Contributors..." line existing_contributors end def new_contributors @new_contributors ||= committers - existing_contributors end def new_contributors? !new_contributors.empty? end def readme_without_contributors_section readme_file_contents.sub(/## Contributors(.|\n)*/, '') end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
chili_videos-0.2.2 | lib/tasks/contributor_tasks.rb |
chili_videos-0.2.1 | lib/tasks/contributor_tasks.rb |