appease rubocop

This commit is contained in:
Frank Taillandier 2017-01-14 20:11:30 +01:00
parent 39b7af3732
commit 6f8bf2e950
3 changed files with 15 additions and 15 deletions

View File

@ -7,7 +7,7 @@
namespace :docs do namespace :docs do
desc "Release #{docs_name} v#{version}" desc "Release #{docs_name} v#{version}"
task :release => :build do task :release => :build do
unless `git branch` =~ /^\* master$/ unless `git branch` =~ %r!^\* master$!
puts "You must be on the master branch to release!" puts "You must be on the master branch to release!"
exit! exit!
end end

View File

@ -6,7 +6,7 @@
desc "Release #{name} v#{version}" desc "Release #{name} v#{version}"
task :release => :build do task :release => :build do
unless `git branch` =~ /^\* master$/ unless `git branch` =~ %r!^\* master$!
puts "You must be on the master branch to release!" puts "You must be on the master branch to release!"
exit! exit!
end end

View File

@ -13,7 +13,7 @@ namespace :site do
require "jekyll" require "jekyll"
browser_launched = false browser_launched = false
Jekyll::Hooks.register :site, :post_write do |site| Jekyll::Hooks.register :site, :post_write do |_site|
next if browser_launched next if browser_launched
browser_launched = true browser_launched = true
Jekyll.logger.info "Opening in browser..." Jekyll.logger.info "Opening in browser..."
@ -26,7 +26,7 @@ namespace :site do
"source" => File.expand_path(docs_folder), "source" => File.expand_path(docs_folder),
"destination" => File.expand_path("#{docs_folder}/_site"), "destination" => File.expand_path("#{docs_folder}/_site"),
"watch" => true, "watch" => true,
"serving" => true "serving" => true,
} }
Jekyll::Commands::Build.process(options) Jekyll::Commands::Build.process(options)
Jekyll::Commands::Serve.process(options) Jekyll::Commands::Serve.process(options)
@ -38,7 +38,7 @@ namespace :site do
Jekyll::Commands::Build.process({ Jekyll::Commands::Build.process({
"profile" => true, "profile" => true,
"source" => File.expand_path(docs_folder), "source" => File.expand_path(docs_folder),
"destination" => File.expand_path("#{docs_folder}/_site") "destination" => File.expand_path("#{docs_folder}/_site"),
}) })
end end
task :build => :generate task :build => :generate
@ -48,7 +48,7 @@ namespace :site do
Dir.chdir("#{docs_folder}/_sass") do Dir.chdir("#{docs_folder}/_sass") do
sh 'curl "https://necolas.github.io/normalize.css/latest/normalize.css" -o "normalize.scss"' sh 'curl "https://necolas.github.io/normalize.css/latest/normalize.css" -o "normalize.scss"'
sh 'sass "normalize.scss":"_normalize.scss" --style compressed' sh 'sass "normalize.scss":"_normalize.scss" --style compressed'
rm ['normalize.scss', Dir.glob('*.map')].flatten rm ["normalize.scss", Dir.glob("*.map")].flatten
end end
end end
@ -60,40 +60,40 @@ namespace :site do
desc "Create a nicely formatted history page for the jekyll site based on the repo history." desc "Create a nicely formatted history page for the jekyll site based on the repo history."
task :history do task :history do
siteify_file('History.markdown', { "title" => "History" }) siteify_file("History.markdown", { "title" => "History" })
end end
desc "Copy the Code of Conduct" desc "Copy the Code of Conduct"
task :conduct do task :conduct do
front_matter = { front_matter = {
"redirect_from" => "/conduct/index.html", "redirect_from" => "/conduct/index.html",
"editable" => false "editable" => false,
} }
siteify_file('CONDUCT.markdown', front_matter) siteify_file("CONDUCT.markdown", front_matter)
end end
desc "Copy the contributing file" desc "Copy the contributing file"
task :contributing do task :contributing do
siteify_file('.github/CONTRIBUTING.markdown', "title" => "Contributing") siteify_file(".github/CONTRIBUTING.markdown", "title" => "Contributing")
end end
desc "Write the site latest_version.txt file" desc "Write the site latest_version.txt file"
task :version_file do task :version_file do
File.open("#{docs_folder}/latest_version.txt", 'wb') { |f| f.puts(version) } unless version =~ /(beta|rc|alpha)/i File.open("#{docs_folder}/latest_version.txt", "wb") { |f| f.puts(version) } unless version =~ %r!(beta|rc|alpha)!i
end end
namespace :releases do namespace :releases do
desc "Create new release post" desc "Create new release post"
task :new, :version do |t, args| task :new, :version do |_t, args|
raise "Specify a version: rake site:releases:new['1.2.3']" unless args.version raise "Specify a version: rake site:releases:new['1.2.3']" unless args.version
today = Time.new.strftime('%Y-%m-%d') today = Time.new.strftime("%Y-%m-%d")
release = args.version.to_s release = args.version.to_s
filename = "#{docs_folder}/_posts/#{today}-jekyll-#{release.split('.').join('-')}-released.markdown" filename = "#{docs_folder}/_posts/#{today}-jekyll-#{release.split(".").join("-")}-released.markdown"
File.open(filename, "wb") do |post| File.open(filename, "wb") do |post|
post.puts("---") post.puts("---")
post.puts("title: 'Jekyll #{release} Released'") post.puts("title: 'Jekyll #{release} Released'")
post.puts("date: #{Time.new.strftime('%Y-%m-%d %H:%M:%S %z')}") post.puts("date: #{Time.new.strftime("%Y-%m-%d %H:%M:%S %z")}")
post.puts("author: ") post.puts("author: ")
post.puts("version: #{release}") post.puts("version: #{release}")
post.puts("categories: [release]") post.puts("categories: [release]")