mirror of
https://github.com/moparisthebest/android.moparisthebest.org
synced 2024-12-25 17:08:48 -05:00
Updated Rakefile to handle Octopress::Configuration as a class.
This commit is contained in:
parent
153ce83527
commit
4dfc4237d3
34
Rakefile
34
Rakefile
@ -9,7 +9,6 @@ require 'rake/minify'
|
||||
require 'time'
|
||||
require 'yaml'
|
||||
require 'octopress'
|
||||
require 'rake/testtask'
|
||||
|
||||
### Configuring Octopress:
|
||||
### Under _config/ you will find:
|
||||
@ -19,7 +18,8 @@ require 'rake/testtask'
|
||||
### Please do not change anything below if you want help --
|
||||
### otherwise, you're on your own ;-)
|
||||
|
||||
configuration = Octopress::Configuration.read_configuration
|
||||
configurator = Octopress::Configuration.new
|
||||
configuration = configurator.read_configuration
|
||||
full_stash_dir = "#{configuration[:source]}/#{configuration[:stash_dir]}"
|
||||
|
||||
desc "Initial setup for Octopress: copies the default theme into the path of Jekyll's generator. Rake install defaults to rake install[classic] to install a different theme run rake install[some_theme_name]"
|
||||
@ -46,14 +46,14 @@ desc "Generate jekyll site"
|
||||
task :generate, :no_future do |t, args|
|
||||
future = args.no_future
|
||||
raise "### You haven't set anything up yet. First run `rake install` to set up an Octopress theme." unless File.directory?(configuration[:source])
|
||||
Octopress::Configuration.write_configs_for_generation
|
||||
configurator.write_configs_for_generation
|
||||
puts "## Generating Site with Jekyll"
|
||||
system "compass compile --css-dir #{configuration[:source]}/stylesheets"
|
||||
Rake::Task['minify_and_combine'].execute
|
||||
system "jekyll --no-server --no-auto #{'--no-future' if future.nil?}"
|
||||
unpublished = get_unpublished(Dir.glob("#{configuration[:source]}/#{configuration[:posts_dir]}/*.*"), {no_future: future.nil?, message: "\nThese posts were not generated:"})
|
||||
puts unpublished unless unpublished.empty?
|
||||
Octopress::Configuration.remove_configs_for_generation
|
||||
configurator.remove_configs_for_generation
|
||||
end
|
||||
|
||||
Rake::Minify.new(:minify_and_combine) do
|
||||
@ -94,7 +94,7 @@ desc "Watch the site and regenerate when it changes"
|
||||
task :watch, :show_future do |t, args|
|
||||
future = args.show_future
|
||||
raise "### You haven't set anything up yet. First run `rake install` to set up an Octopress theme." unless File.directory?(configuration[:source])
|
||||
Octopress::Configuration.write_configs_for_generation
|
||||
configurator.write_configs_for_generation
|
||||
puts "Starting to watch source with Jekyll and Compass."
|
||||
system "compass compile --css-dir #{configuration[:source]}/stylesheets"
|
||||
Rake::Task['minify_and_combine'].execute
|
||||
@ -102,7 +102,7 @@ task :watch, :show_future do |t, args|
|
||||
compassPid = Process.spawn("compass watch")
|
||||
trap("INT") {
|
||||
[jekyllPid, compassPid].each { |pid| Process.kill(9, pid) rescue Errno::ESRCH }
|
||||
Octopress::Configuration.remove_configs_for_generation
|
||||
configurator.remove_configs_for_generation
|
||||
exit 0
|
||||
}
|
||||
[jekyllPid, compassPid].each { |pid| Process.wait(pid) }
|
||||
@ -112,7 +112,7 @@ desc "preview the site in a web browser."
|
||||
task :preview, :show_future do |t, args|
|
||||
future = args.show_future
|
||||
raise "### You haven't set anything up yet. First run `rake install` to set up an Octopress theme." unless File.directory?(configuration[:source])
|
||||
Octopress::Configuration.write_configs_for_generation
|
||||
configurator.write_configs_for_generation
|
||||
puts "Starting to watch source with Jekyll and Compass. Starting Rack, serving to http://#{configuration[:server_host]}:#{configuration[:server_port]}"
|
||||
system "compass compile --css-dir #{configuration[:source]}/stylesheets"
|
||||
jekyllPid = Process.spawn("jekyll --auto #{'--no-future' if future.nil?}")
|
||||
@ -121,7 +121,7 @@ task :preview, :show_future do |t, args|
|
||||
|
||||
trap("INT") {
|
||||
[jekyllPid, compassPid, rackupPid].each { |pid| Process.kill(9, pid) rescue Errno::ESRCH }
|
||||
Octopress::Configuration.remove_configs_for_generation
|
||||
configurator.remove_configs_for_generation
|
||||
exit 0
|
||||
}
|
||||
|
||||
@ -349,11 +349,11 @@ task :set_root_dir, :dir do |t, args|
|
||||
dir = "/" + args.dir.sub(/(\/*)(.+)/, "\\2").sub(/\/$/, '');
|
||||
end
|
||||
# update personal configuration
|
||||
site_configs = Octopress::Configuration.read_config('site.yml')
|
||||
site_configs = configurator.read_config('site.yml')
|
||||
site_configs[:destination] = "public#{dir}"
|
||||
site_configs[:subscribe_rss] = "#{dir}/atom.xml"
|
||||
site_configs[:root] = "/#{dir.sub(/^\//, '')}"
|
||||
Octopress::Configuration.write_config('site.yml', site_configs)
|
||||
configurator.write_config('site.yml', site_configs)
|
||||
|
||||
rm_rf configuration[:destination]
|
||||
mkdir_p site_configs[:destination]
|
||||
@ -417,17 +417,17 @@ task :setup_github_pages, :repo do |t, args|
|
||||
end
|
||||
|
||||
# Configure deployment setup in deploy.yml
|
||||
deploy_configuration = Octopress::Configuration.read_config('deploy.yml')
|
||||
deploy_configuration = configurator.read_config('deploy.yml')
|
||||
deploy_configuration[:deploy_default] = "push"
|
||||
deploy_configuration[:deploy_branch] = branch
|
||||
deploy_configuration = Octopress::Configuration.read_config('defaults/deploy/gh_pages.yml').deep_merge(deploy_configuration)
|
||||
deploy_configuration = configurator.read_config('defaults/deploy/gh_pages.yml').deep_merge(deploy_configuration)
|
||||
puts deploy_configuration
|
||||
Octopress::Configuration.write_config('deploy.yml', deploy_configuration)
|
||||
configurator.write_config('deploy.yml', deploy_configuration)
|
||||
|
||||
# Configure published url
|
||||
site_configuration = Octopress::Configuration.read_config('site.yml')
|
||||
site_configuration = configurator.read_config('site.yml')
|
||||
site_configuration[:url] = url if site_configuration.has_key?(:url) && site_configuration[:url] == 'http://yoursite.com'
|
||||
site_configuration = Octopress::Configuration.read_config('defaults/jekyll.yml').deep_merge(site_configuration)
|
||||
site_configuration = configurator.read_config('defaults/jekyll.yml').deep_merge(site_configuration)
|
||||
|
||||
puts "\n========================================================"
|
||||
has_cname = File.exists?("#{configuration[:source]}/CNAME")
|
||||
@ -526,7 +526,3 @@ task :list do
|
||||
puts "Tasks: #{(Rake::Task.tasks - [Rake::Task[:list]]).join(', ')}"
|
||||
puts "(type rake -T for more detail)\n\n"
|
||||
end
|
||||
|
||||
Rake::TestTask.new do |t|
|
||||
t.pattern = "spec/**/*_spec.rb"
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user