Skip to content

Commit 286b726

Browse files
committed
Change the Rakefile for a Thorfile.
1 parent 3c140ca commit 286b726

File tree

5 files changed

+60
-46
lines changed

5 files changed

+60
-46
lines changed

Gemfile

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
source :rubygems
22

3-
gem 'json-pure'
4-
gem 'rake'
3+
gem 'json_pure'
4+
gem 'thor'
55
gem 'uglifier'

Gemfile.lock

+4-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@ GEM
33
specs:
44
execjs (1.3.0)
55
multi_json (~> 1.0)
6+
json_pure (1.6.5)
67
multi_json (1.1.0)
7-
rake (0.9.2.2)
8+
thor (0.14.6)
89
uglifier (1.2.3)
910
execjs (>= 0.3.0)
1011
multi_json (>= 1.0.2)
@@ -13,5 +14,6 @@ PLATFORMS
1314
ruby
1415

1516
DEPENDENCIES
16-
rake
17+
json_pure
18+
thor
1719
uglifier

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Check out the official [KineticJS Tutorials](http://www.html5canvastutorials.com
1212
# Building the library
1313
To build the library, you need to have Ruby and Rubygems installed. After that, install the dependencies by running `bundle install`.
1414

15-
To build a development version of the library, run `rake build:dev`. To build a minify version of the library, run `rake build:prod`.
15+
To build a development version of the library, run `thor build:dev`. To build a minify version of the library, run `thor build:prod`.
1616

1717
# Adding a new file in the src directory
18-
If you add a file in the src directory, add into the array in the Rakefile.
18+
If you add a file in the src directory, add into the array in the Thorfile.

Rakefile

-40
This file was deleted.

Thorfile

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
require 'json/pure'
2+
3+
class Build < Thor
4+
include Thor::Actions
5+
# include Thor::Shell::Basic
6+
7+
# 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.
8+
FILES = [
9+
"license.js", "src/GlobalObject.js", "src/Node.js", "src/Container.js", "src/Stage.js",
10+
"src/Layer.js", "src/Group.js", "src/geometries/Shape.js", "src/geometries/Rect.js", "src/geometries/Circle.js", "src/geometries/Image.js",
11+
"src/geometries/Polygon.js", "src/geometries/RegularPolygon.js", "src/geometries/Star.js", "src/geometries/Text.js"
12+
]
13+
14+
desc "dev", "Concatenate all the js files into /dist/kinetic.js."
15+
def dev
16+
puts ":: Building the file /dist/kinetic.js..."
17+
File.open("dist/kinetic.js", "w") do |file|
18+
file.puts concatenate()
19+
end
20+
puts " -> Done!"
21+
end
22+
23+
desc "prod", "Concatenate all the js files in into /dist/kinetic.min.js and minify it."
24+
def prod
25+
puts ":: Building the file /dist/kinetic.min.js..."
26+
require 'json/pure'
27+
require 'uglifier'
28+
File.open("dist/kinetic.min.js", "w") do |file|
29+
file.puts Uglifier.compile(concatenate())
30+
end
31+
puts ":: Minifying the file /dist/kinetic.min.js..."
32+
puts " -> Done!"
33+
end
34+
35+
desc "all", "Build the development and the production files."
36+
def all
37+
invoke :dev
38+
invoke :prod
39+
end
40+
41+
private
42+
43+
def concatenate
44+
content = ""
45+
FILES.each do |file|
46+
content << IO.read(File.expand_path(file)) << "\n"
47+
end
48+
49+
return content
50+
end
51+
end
52+

0 commit comments

Comments
 (0)