Permalink
Browse files

Change the Rakefile for a Thorfile.

  • Loading branch information...
1 parent 3c140ca commit 286b726823c47baa7a66b16472aa361d2d88211b @magicienap magicienap committed Mar 7, 2012
Showing with 60 additions and 46 deletions.
  1. +2 −2 Gemfile
  2. +4 −2 Gemfile.lock
  3. +2 −2 README.md
  4. +0 −40 Rakefile
  5. +52 −0 Thorfile
View
@@ -1,5 +1,5 @@
source :rubygems
-gem 'json-pure'
-gem 'rake'
+gem 'json_pure'
+gem 'thor'
gem 'uglifier'
View
@@ -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
View
@@ -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.
View
@@ -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
View
@@ -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
+

0 comments on commit 286b726

Please sign in to comment.