Skip to content
Browse files

Refactor rake tasks and move support files for clarity

  • Loading branch information...
1 parent ff70489 commit 870f8d9c3bf49787c4d08614271a92ea23077de7 @sinisterchipmunk sinisterchipmunk committed
View
68 Rakefile
@@ -17,71 +17,9 @@ require 'rspec/core/rake_task'
require 'uglifier'
# helper module
-require File.expand_path('./lib/gl-matrix', File.dirname(__FILE__))
+require File.expand_path('./tasks/support/gl-matrix', File.dirname(__FILE__))
include GLMatrix
-# finally... rake tasks!
-desc "tag and release gl-matrix"
-task :release do
- require 'thor'
- Bundler.ui = Bundler::UI::Shell.new(Thor::Shell::Basic.new)
- Bundler.ui.debug! if ENV['DEBUG']
-
- # Sanity check: rebuild files just in case dev forgot to.
- # If so, files will change and release will abort since changes
- # were not checked in.
- Rake::Task['build'].invoke
-
- release do
- # Put other release-related stuff here, such as publishing docs;
- # if anything fails, gl-matrix will be untagged and not pushed.
- #
- # Example:
- #
- # Rake::Task['doc:publish'].invoke
- #
- end
-end
-
-desc "compile & minify sources into a single file"
-task :build do
- compile
- minify
-end
-
-desc "run test suite with node.js"
-task :node => :build do
- # make sure jasmine-node exists, and barf if it doesn't
- if %x['jasmine-node'] =~ /USAGE/
- unless system 'jasmine-node', base_path.join('spec').to_s
- raise "node.js tests failed"
- end
- else
- puts "jasmine-node is not available"
- puts
- puts "Please run:"
- puts " npm install -g jasmine-node"
- puts
- puts "...and then try again."
- puts
- exit
- end
+Dir[base_path.join './tasks/**/*.rake'].each do |f|
+ load f
end
-
-desc "Run continuous integration tests"
-RSpec::Core::RakeTask.new('jasmine:ci' => :build) do |t|
- t.rspec_opts = ["--colour", "--format", ENV['JASMINE_SPEC_FORMAT'] || "progress"]
- t.verbose = true
- t.rspec_opts += ["-r #{base_path.join('lib/gl-matrix')}"]
- t.pattern = [Jasmine.runner_filepath]
-end
-
-desc "Run specs via server"
-task :jasmine do
- port = ENV['JASMINE_PORT'] || 8888
- puts "your tests are here:"
- puts " http://localhost:#{port}/"
- Jasmine::Server.new(port).start
-end
-
-task :default => ['node', 'jasmine:ci']
View
1 VERSION
@@ -0,0 +1 @@
+2.0.0.rc0
View
8 lib/gl-matrix/version.rb
@@ -1,8 +0,0 @@
-module GLMatrix
- module Version
- MAJOR, MINOR, PATCH = 2, 0, 0
- STRING = [MAJOR, MINOR, PATCH].join '.'
- end
-
- VERSION = Version::STRING
-end
View
2 tasks/build.rake
@@ -0,0 +1,2 @@
+desc "compile & minify sources into a single file"
+task :build => ['build:compile', 'build:minify']
View
5 tasks/build/compile.rake
@@ -0,0 +1,5 @@
+namespace :build do
+ task :compile do
+ compile
+ end
+end
View
5 tasks/build/minify.rake
@@ -0,0 +1,5 @@
+namespace :build do
+ task :minify do
+ minify
+ end
+end
View
1 tasks/default.rake
@@ -0,0 +1 @@
+task :default => ['test:node', 'test:ci']
View
21 tasks/release.rake
@@ -0,0 +1,21 @@
+desc "tag and release gl-matrix v#{GLMatrix::VERSION}"
+task :release do
+ require 'thor'
+ Bundler.ui = Bundler::UI::Shell.new(Thor::Shell::Basic.new)
+ Bundler.ui.debug! if ENV['DEBUG']
+
+ # Sanity check: rebuild files just in case dev forgot to.
+ # If so, files will change and release will abort since changes
+ # were not checked in.
+ Rake::Task['build'].invoke
+
+ release do
+ # Put other release-related stuff here, such as publishing docs;
+ # if anything fails, gl-matrix will be untagged and not pushed.
+ #
+ # Example:
+ #
+ # Rake::Task['doc:publish'].invoke
+ #
+ end
+end
View
7 lib/gl-matrix.rb → tasks/support/gl-matrix.rb
@@ -17,8 +17,9 @@ def call(env)
end
module GLMatrix
- require 'gl-matrix/release_helper'
- require 'gl-matrix/version'
+ autoload :ReleaseHelper, 'gl-matrix/release_helper'
+ autoload :Version, 'gl-matrix/version'
+ autoload :VERSION, 'gl-matrix/version'
module_function
@@ -33,7 +34,7 @@ def sprockets
end
def base_path
- Pathname.new File.expand_path('..', File.dirname(__FILE__))
+ Pathname.new File.expand_path('../..', File.dirname(__FILE__))
end
# Compiles the source file to the dest file. If a block
View
0 lib/gl-matrix/release_helper.rb → tasks/support/gl-matrix/release_helper.rb
File renamed without changes.
View
8 tasks/support/gl-matrix/version.rb
@@ -0,0 +1,8 @@
+module GLMatrix
+ module Version
+ MAJOR, MINOR, PATCH, REL = *File.read(base_path.join 'VERSION').split(".")
+ STRING = [MAJOR, MINOR, PATCH, REL].compact.join '.'
+ end
+
+ VERSION = Version::STRING
+end
View
9 tasks/test/ci.rake
@@ -0,0 +1,9 @@
+namespace :test do
+ desc "Run continuous integration tests"
+ RSpec::Core::RakeTask.new('ci' => :build) do |t|
+ t.rspec_opts = ["--colour", "--format", ENV['JASMINE_SPEC_FORMAT'] || "progress"]
+ t.verbose = true
+ t.rspec_opts += ["-r #{base_path.join('tasks/support/gl-matrix')}"]
+ t.pattern = [Jasmine.runner_filepath]
+ end
+end
View
9 tasks/test/jasmine.rake
@@ -0,0 +1,9 @@
+namespace :test do
+ desc "Run specs via server"
+ task :jasmine do
+ port = ENV['JASMINE_PORT'] || 8888
+ puts "your tests are here:"
+ puts " http://localhost:#{port}/"
+ Jasmine::Server.new(port).start
+ end
+end
View
20 tasks/test/node.rake
@@ -0,0 +1,20 @@
+namespace :test do
+ desc "run test suite with node.js"
+ task :node => :build do
+ # make sure jasmine-node exists, and barf if it doesn't
+ if %x['jasmine-node'] =~ /USAGE/
+ unless system 'jasmine-node', base_path.join('spec').to_s
+ raise "node.js tests failed"
+ end
+ else
+ puts "jasmine-node is not available"
+ puts
+ puts "Please run:"
+ puts " npm install -g jasmine-node"
+ puts
+ puts "...and then try again."
+ puts
+ exit
+ end
+ end
+end

0 comments on commit 870f8d9

Please sign in to comment.
Something went wrong with that request. Please try again.