Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update rake tasks #137

Merged
merged 1 commit into from
Oct 28, 2014
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 76 additions & 2 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -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)
Expand All @@ -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}"
Expand All @@ -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