From eacd74f4a9113813d1e85ee89bfa60a06af7a17e Mon Sep 17 00:00:00 2001 From: Samuel Tonini Date: Tue, 28 Oct 2014 08:18:46 +0100 Subject: [PATCH] update rake tasks --- Rakefile | 78 ++++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 76 insertions(+), 2 deletions(-) diff --git a/Rakefile b/Rakefile index 491ee295..2145594c 100644 --- a/Rakefile +++ b/Rakefile @@ -1,8 +1,12 @@ +EMACS = "emacs" +CASK = "cask" + +task default: %w[test] + desc "Create a new release." task 'release' do current_version = run('git tag').split(/\n/).last.strip[1..-1] - print "What version do you want to release? (current: #{current_version}): " - version = STDIN.gets.strip + version = ask("What version do you want to release? (current: #{current_version}): ") version_tag = "v%s" % version if run('git tag').split(/\n/).include?(version_tag) @@ -16,6 +20,30 @@ task 'release' do git_changes(version, version_tag) end +desc "Installed Emacs information" +task 'info' do + process_info "Install Emacs information" + say "" + say "PATH: ", :green, false + system "which #{EMACS}" + say "VERSION: ", :green, false + system "#{CASK} exec #{EMACS} --version | head -1" +end + +desc "Run the test suite" +task "test" do + process_info "Install package dependencies" + say "" + say "#{indent(3)}Command: ", :yellow, false + sh "cask install" + say "" + + process_info "Run test suite" + say "" + system "#{CASK} exec ert-runner" + say "" +end + def git_changes(version, version_tag) run "git commit -a -m \"prepare #{version}\"" run "git tag -a -m \"Version #{version}\" #{version_tag}" @@ -27,6 +55,52 @@ def update_version(content, from, to) content = content.gsub("Version: #{from}", "Version: #{to}") end +def ansi + { + green: "\e[32m", + red: "\e[31m", + white: "\e[37m", + bold: "\e[1m", + on_green: "\e[42m", + ending: "\e[0m" + } +end + def run(command) `#{command}` end + +def say(message, type=:white, newline=true) + message = "#{ansi[type]}#{message}#{ansi[:ending]}" + if newline + puts message + else + print message + end +end + +def process_info(message) + puts "#{ansi[:on_green]}#{ansi[:red]}#{message}#{ansi[:ending]}#{ansi[:ending]}" +end + +def info(message) + puts "#{ansi[:green]}#{ansi[:bold]}#{message}#{ansi[:ending]}#{ansi[:ending]}" +end + +def ask(question, type=:white) + say(question, type, false) + answer = STDIN.gets.chomp + if answer == "" || answer.nil? + return nil + else + return answer + end +end + +def indent(count) + " " * count +end + +def colorize(string, color) + "#{ansi[color]}#{string}#{ansi[:ending]}" +end