Rakefile in opal-0.3.20 vs Rakefile in opal-0.3.21
- old
+ new
@@ -2,22 +2,25 @@
require 'bundler'
Bundler.setup
require 'opal'
require 'opal/version'
+require 'opal/rake_task'
-Opal::BuilderTask.new do |t|
- t.name = 'opal'
- t.files = []
- t.dependencies = %w[opal-spec opal-dom]
+Opal::RakeTask.new do |t|
+ t.dependencies = %w(opal-spec opal-dom)
t.specs_dir = 'test'
+ t.files = [] # we handle this by Opal.runtime instead
end
-desc "Build opal.js runtime into ./build"
-task :build do
- File.open('build/opal.js', 'w+') do |o|
- o.write Opal::Builder.runtime
+desc "Build minified runtime, dependencies and specs"
+task :min => :opal do
+ %w(opal opal-dom opal-spec specs).each do |f|
+ File.open("build/#{f}.min.js", 'w+') do |o|
+ puts " * build/#{f}.min.js"
+ o.write uglify(File.read "build/#{f}.js")
+ end
end
end
desc "Check file sizes for opal.js runtime"
task :sizes do
@@ -50,17 +53,56 @@
i.close_write
return i.read
end
end
-# Rubygems
-namespace :gem do
- desc "Build opal-#{Opal::VERSION}.gem"
+# Test
+require 'rspec/core/rake_task'
+RSpec::Core::RakeTask.new :default
+
+namespace :docs do
+ desc "Clone repo"
+ task :clone do
+ if File.exists? 'gh-pages'
+ Dir.chdir('gh-pages') { sh 'git pull origin gh-pages' }
+ else
+ FileUtils.mkdir_p 'gh-pages'
+ Dir.chdir('gh-pages') do
+ sh 'git clone git@github.com:/adambeynon/opal.git .'
+ sh 'git checkout gh-pages'
+ end
+ end
+ end
+
+ desc "Build README.md => index.html"
task :build do
- sh "gem build opal.gemspec"
+ require 'redcarpet'
+ require 'albino'
+
+ klass = Class.new(Redcarpet::Render::HTML) do
+ def block_code(code, language)
+ Albino.new(code, language || :text).colorize
+ end
+ end
+
+ puts 'gh-pages/index.html'
+ markdown = Redcarpet::Markdown.new(klass, :fenced_code_blocks => true)
+
+ File.open('gh-pages/index.html', 'w+') do |o|
+ o.write File.read('docs/pre.html')
+ o.write markdown.render(File.read "README.md")
+ o.write File.read('docs/post.html')
+ end
+
+ puts "gh-pages/opal.js"
+ FileUtils.cp 'build/opal.js', 'gh-pages/opal.js'
end
- desc "Release opal-#{Opal::VERSION}.gem"
- task :release do
- puts "Need to release opal-#{Opal::VERSION}.gem"
+ desc "commit and push"
+ task :push do
+ Dir.chdir('gh-pages') do
+ sh "git add ."
+ sh "git commit -a -m \"Documentation update #{Time.new}\""
+ sh "git push origin gh-pages"
+ end
end
-end
\ No newline at end of file
+end