OLD | NEW |
(Empty) | |
| 1 $:.unshift File.expand_path('.', File.dirname(__FILE__)) |
| 2 require 'sprockets' |
| 3 require 'jasmine' |
| 4 |
| 5 class Jasmine::Config |
| 6 def simple_config_file |
| 7 File.expand_path GLMatrix.base_path.join('spec/jasmine.yml') |
| 8 end |
| 9 end |
| 10 |
| 11 class Rack::Jasmine::Runner |
| 12 alias_method :jasmine_call, :call |
| 13 def call(env) |
| 14 GLMatrix.compile |
| 15 jasmine_call env |
| 16 end |
| 17 end |
| 18 |
| 19 module GLMatrix |
| 20 autoload :ReleaseHelper, 'gl-matrix/release_helper' |
| 21 autoload :Version, 'gl-matrix/version' |
| 22 autoload :VERSION, 'gl-matrix/version' |
| 23 |
| 24 module_function |
| 25 |
| 26 def release(&block) |
| 27 GLMatrix::ReleaseHelper.release &block |
| 28 end |
| 29 |
| 30 def sprockets |
| 31 env = Sprockets::Environment.new base_path |
| 32 env.append_path base_path.join('src') |
| 33 env |
| 34 end |
| 35 |
| 36 def base_path |
| 37 Pathname.new File.expand_path('../..', File.dirname(__FILE__)) |
| 38 end |
| 39 |
| 40 # Compiles the source file to the dest file. If a block |
| 41 # is given, the source file is yielded and replaced with |
| 42 # the result. Returns the destination as a Pathname. |
| 43 def compile(source = 'gl-matrix.js', dest = 'dist/gl-matrix.js') |
| 44 dest = base_path.join dest |
| 45 js = sprockets[source] |
| 46 js = yield js if block_given? |
| 47 |
| 48 File.open dest, "w" do |f| |
| 49 f.puts js |
| 50 end |
| 51 |
| 52 puts "compiled #{source} to #{dest.relative_path_from base_path}" |
| 53 dest |
| 54 end |
| 55 |
| 56 def minify(source = 'gl-matrix.js', dest = 'dist/gl-matrix-min.js') |
| 57 dest = compile source, dest do |js| |
| 58 Uglifier.compile js |
| 59 end |
| 60 |
| 61 puts "minified #{source} to #{dest.relative_path_from base_path}" |
| 62 end |
| 63 |
| 64 end |
OLD | NEW |