From 286b726823c47baa7a66b16472aa361d2d88211b Mon Sep 17 00:00:00 2001 From: Antoine Proulx Date: Wed, 7 Mar 2012 08:43:02 -0500 Subject: [PATCH] Change the Rakefile for a Thorfile. --- Gemfile | 4 ++-- Gemfile.lock | 6 ++++-- README.md | 4 ++-- Rakefile | 40 ---------------------------------------- Thorfile | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 60 insertions(+), 46 deletions(-) delete mode 100644 Rakefile create mode 100644 Thorfile diff --git a/Gemfile b/Gemfile index 6a168aa9..080b3646 100644 --- a/Gemfile +++ b/Gemfile @@ -1,5 +1,5 @@ source :rubygems -gem 'json-pure' -gem 'rake' +gem 'json_pure' +gem 'thor' gem 'uglifier' diff --git a/Gemfile.lock b/Gemfile.lock index c0ac0a8f..48ef0240 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -3,8 +3,9 @@ GEM specs: execjs (1.3.0) multi_json (~> 1.0) + json_pure (1.6.5) multi_json (1.1.0) - rake (0.9.2.2) + thor (0.14.6) uglifier (1.2.3) execjs (>= 0.3.0) multi_json (>= 1.0.2) @@ -13,5 +14,6 @@ PLATFORMS ruby DEPENDENCIES - rake + json_pure + thor uglifier diff --git a/README.md b/README.md index 87dbe23e..4c3138dc 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ Check out the official [KineticJS Tutorials](http://www.html5canvastutorials.com # Building the library To build the library, you need to have Ruby and Rubygems installed. After that, install the dependencies by running `bundle install`. -To build a development version of the library, run `rake build:dev`. To build a minify version of the library, run `rake build:prod`. +To build a development version of the library, run `thor build:dev`. To build a minify version of the library, run `thor build:prod`. # Adding a new file in the src directory -If you add a file in the src directory, add into the array in the Rakefile. +If you add a file in the src directory, add into the array in the Thorfile. diff --git a/Rakefile b/Rakefile deleted file mode 100644 index ba88dc90..00000000 --- a/Rakefile +++ /dev/null @@ -1,40 +0,0 @@ -require 'json/pure' - -# This is the list of files to concatenate. The first file will appear at the top of the final file. All files are relative to the lib directory. -FILES = [ - "license.js", "src/GlobalObject.js", "src/Node.js", "src/Container.js", "src/Stage.js", - "src/Layer.js", "src/Group.js", "src/geometries/Shape.js", "src/geometries/Rect.js", "src/geometries/Circle.js", "src/geometries/Image.js", - "src/geometries/Polygon.js", "src/geometries/RegularPolygon.js", "src/geometries/Star.js", "src/geometries/Text.js" -] - -def concatenate - content = "" - FILES.each do |file| - content << IO.read(File.expand_path(file)) << "\n" - end - - return content -end - -namespace :build do - desc "Concatenate all the js files into /dist/kinetic.js." - task :dev do - puts ":: Building the file /dist/kinetic.js..." - File.open("dist/kinetic.js", "w") do |file| - file.puts concatenate() - end - puts " -> Done!" - end - - desc "Concatenate all the js files in into /dist/kinetic.min.js and minify it." - task :prod do - puts ":: Building the file /dist/kinetic.min.js..." - require 'json/pure' - require 'uglifier' - File.open("dist/kinetic.min.js", "w") do |file| - file.puts Uglifier.compile(concatenate()) - end - puts ":: Minifying the file /dist/kinetic.min.js..." - puts " -> Done!" - end -end diff --git a/Thorfile b/Thorfile new file mode 100644 index 00000000..cfd8a0bc --- /dev/null +++ b/Thorfile @@ -0,0 +1,52 @@ +require 'json/pure' + +class Build < Thor + include Thor::Actions + # include Thor::Shell::Basic + + # This is the list of files to concatenate. The first file will appear at the top of the final file. All files are relative to the lib directory. + FILES = [ + "license.js", "src/GlobalObject.js", "src/Node.js", "src/Container.js", "src/Stage.js", + "src/Layer.js", "src/Group.js", "src/geometries/Shape.js", "src/geometries/Rect.js", "src/geometries/Circle.js", "src/geometries/Image.js", + "src/geometries/Polygon.js", "src/geometries/RegularPolygon.js", "src/geometries/Star.js", "src/geometries/Text.js" + ] + + desc "dev", "Concatenate all the js files into /dist/kinetic.js." + def dev + puts ":: Building the file /dist/kinetic.js..." + File.open("dist/kinetic.js", "w") do |file| + file.puts concatenate() + end + puts " -> Done!" + end + + desc "prod", "Concatenate all the js files in into /dist/kinetic.min.js and minify it." + def prod + puts ":: Building the file /dist/kinetic.min.js..." + require 'json/pure' + require 'uglifier' + File.open("dist/kinetic.min.js", "w") do |file| + file.puts Uglifier.compile(concatenate()) + end + puts ":: Minifying the file /dist/kinetic.min.js..." + puts " -> Done!" + end + + desc "all", "Build the development and the production files." + def all + invoke :dev + invoke :prod + end + + private + + def concatenate + content = "" + FILES.each do |file| + content << IO.read(File.expand_path(file)) << "\n" + end + + return content + end +end +