Rakefile in opal-0.2.2 vs Rakefile in opal-0.3.0
- old
+ new
@@ -1,163 +1,86 @@
-require 'rubygems'
-require 'rake'
require 'yard'
-begin
- require 'jeweler'
- Jeweler::Tasks.new do |gemspec|
- gemspec.name = "opal"
- gemspec.summary = "Ruby compiler and runtime for the browser"
- gemspec.description = "Ruby compiler and runtime for the browser."
- gemspec.email = "adam@adambeynon.com"
- gemspec.homepage = "http://opalscript.org"
- gemspec.authors = ["Adam Beynon"]
- gemspec.files.include 'opals/opal/**/*'
- end
- Jeweler::GemcutterTasks.new
-rescue LoadError
- puts "Jeweler not available. Install it with: sudo gem install jeweler"
+OPAL_DOC_ROOT = "doc"
+OPAL_DOC_GEMS = "doc/gems"
+OPAL_GIT_REPO = "git@github.com:adambeynon/opal.git"
+
+desc "Rebuild ruby_parser.rb for opal build tools"
+task :parser do
+ %x{racc -E -l lib/opal/ruby/ruby_parser.y -o lib/opal/ruby/ruby_parser.rb}
end
+desc "Requires this development version of opal (not installed one)"
+task :opal do
+ $:.unshift File.join(__FILE__, '..', 'lib')
+ require 'opal'
+end
+desc "Builds standalone opal.js file (opal + core + rquery) for the browser"
+task :browser => :opal do
+ gem = Opal::Gem.new File.join(__FILE__, '..', 'gems', 'rquery')
-desc "Simple task to require opal gem. Uses local, not installed."
-task :opal_gem do
- require File.join(File.dirname(__FILE__), 'lib', 'opal')
+ content = gem.bundle :to => 'tmp/opal.js'
end
+desc "Builds spec runner for core lib"
+task :opal_spec => :opal do
+ gem = Opal::Gem.new File.join(__FILE__, '..', 'gems', 'opal')
+ content = gem.bundle
+ File.open('tmp/opal_spec.js', 'w+') { |out| out.write content }
+end
+desc "Building example for a simple builder"
+task :simple => :opal do
+ builder = Opal::Builder.new :project_dir => File.join(Dir.getwd, 'tmp'),
+ :files => 'testing.rb',
+ :out => 'testing.js'
-desc "Rebuild ruby parser (using racc)"
-task :ruby_parser do
- %x{racc -E lib/vienna/builders/ruby/ruby_parser.rb.y -o lib/vienna/builders/ruby/ruby_parser.rb}
+ builder.build
end
+desc "Rebuilds the documentation"
+task :doc => ['doc:clean', 'doc:opal', 'doc:gems']
-
namespace :doc do
-
- # rebuild demos
- desc "Rebuild demos"
- task :demos => :opal_gem do
- # every demo uses an index.html file inside of the demos folder
- base = File.join(File.dirname(__FILE__), 'demos')
- demos = File.join(base, '**', 'index.html')
- # we build all demos to vienna/doc/demos
- Dir.glob(demos).each do |demo|
- puts "building demo: #{demo}"
- # path will be (demos/)path(/index.html)
- path = /^#{Regexp.escape base}\/(.*)\/index\.html$/.match(demo)[1]
-
- build_root = File.join(File.dirname(__FILE__), 'doc', 'demos', path)
-
- puts build_root
- project = Vienna::Project.new File.dirname(demo),
- :build_root => build_root
-
- # FIXME: maybe only set options if no Opalfile... some of the CherryKit
- # apps may want to include some css etc etc, so dont overwrite them?
- project.options :lib_directories => [""],
- :javascripts_prefix => "",
- :copy_html => true
- project.build!
- project.clean!
- # puts project
- end
- end
-
- # opal/runtime docs
+ # Opal documentation
YARD::Rake::YardocTask.new(:opal) do |t|
- t.files = ['opals/runtime/**/*.rb']
- t.files += ['opals/opal/spec/core/**/*.rb']
- t.files += ['-', 'opals/runtime/docs/**/*.md']
- t.options = ['-o./doc/opal/']
- t.options += ['-r./opals/runtime/README.md']
- t.options += ['-mmarkdown']
- t.options += ['--title', 'Opal Documentation']
+ t.files = ['lib/**/*.rb']
+ t.options = ['--title', 'Documentation for Opal', '--markup', 'markdown']
end
-
- # browser docs
- YARD::Rake::YardocTask.new(:browser) do |t|
- t.files = ['opals/browser/**/*.rb']
- t.options = ['-o./doc/browser/']
- t.options += ['-r./opals/browser/README.md']
- t.options += ['-mmarkdown']
- t.options += ['--title', 'Browser Documentation']
+
+ desc "Clean doc dir ready for rebuilding"
+ task :clean do
+ rm_rf OPAL_DOC_ROOT
end
-
- # all specs
- namespace :spec do
-
- %w{opal browser}.each do |opal|
- desc "rebuild spec for #{opal}"
- task opal.to_sym => :opal_gem do
- opal_root = File.join(File.dirname(__FILE__), 'opals', opal)
- build_root = File.join(File.dirname(__FILE__), 'doc', opal, 'spec')
- project = Vienna::Project.new opal_root, :build_root => build_root, :build_mode => :spec
-
- project.options :javascript_name => "spec.js",
- :stylesheet_name => "spec.css",
- :build_prefix => ""
-
- project.build!
- project.clean!
-
- # spec html file
- from = File.join(File.dirname(__FILE__), 'opals', 'spec', 'resources', 'index.html')
-
- FileUtils.copy from, File.join(build_root, 'index.html')
+
+ desc "Generate documentation for opal and all gems"
+ task :gems do
+ Dir.mkdir OPAL_DOC_GEMS unless File.exists? OPAL_DOC_GEMS
+
+ %w[core].each do |gem|
+ gem_root = File.join Dir.getwd, 'gems', gem
+ doc_root = File.join gem_root, 'doc'
+ new_doc_root = File.join OPAL_DOC_GEMS, gem
+
+ puts " **#{gem}**"
+ Dir.chdir(gem_root) do
+ system "rake yard"
end
+
+ mv doc_root, new_doc_root
end
end
-end
-desc "Rebuild opal.js for deployment"
-task :opal => :opal_gem do
- opal_root = File.join(File.dirname(__FILE__), 'opals', 'opal', 'browser')
- build_root = File.join(File.dirname(__FILE__), 'doc')
-
- # debug build
- project = Vienna::Project.new opal_root, :build_mode => :debug,
- :build_root => build_root
-
- project.options :javascripts_prefix => '',
- :javascript_name => 'opal.debug.js',
- :bin_file => nil
- project.build!
- project.clean!
-
- # release build
- project = Vienna::Project.new opal_root, :build_mode => :release,
- :build_root => build_root
-
- project.options :javascripts_prefix => '',
- :javascript_name => 'opal.js',
- :bin_file => nil
- project.build!
- project.clean!
-
- # minify!
- %x{java -jar extras/compiler.jar --js=doc/opal.js --js_output_file=doc/opal.min.js}
-
-
- # Also place all three into gen directory
- %w{opal.min.js opal.debug.js}.each do |src|
- FileUtils.copy "doc/#{src}", "gen/browser/__PROJECT_NAME__/javascripts/#{src}"
+ desc "Push changes to gh-pages branch"
+ task :pages do
+ Dir.chdir(OPAL_DOC_ROOT) do
+ system "git init"
+ system "git add ."
+ system "git commit -a -m 'Update docs for #{Time.now.asctime}'"
+ system "git remote add origin #{OPAL_GIT_REPO}"
+ system "git checkout -b gh-pages"
+ system "git push -f origin gh-pages"
+ end
end
end
-task :doc => ['doc:browser', 'doc:opal', 'doc:demos'] do
- # go through each set of generated docs, and replace the style.css file
- %w{browser opal}.each do |opal|
- from = File.join(File.dirname(__FILE__), 'yard', 'style.css')
- to = File.join(File.dirname(__FILE__), 'doc', opal, 'css', 'style.css')
- FileUtils.copy from, to
- end
-
- # copy our index.html and its necessary css files
- %w{index.html style.css}.each do |resource|
- from = File.join File.dirname(__FILE__), 'yard', resource
- to = File.join(File.dirname(__FILE__), 'doc')
- FileUtils.copy from, to
- end
-end