Skip to content

Commit ac80261

Browse files
committed
Create a build script to concatenate and (optionaly) minify the files in the lib directory.
1 parent 2a1acc3 commit ac80261

File tree

7 files changed

+100
-2
lines changed

7 files changed

+100
-2
lines changed

Diff for: Gemfile

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
source :rubygems
2+
3+
gem 'rake'
4+
gem 'uglifier'

Diff for: Gemfile.lock

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
GEM
2+
remote: http://rubygems.org/
3+
specs:
4+
execjs (1.3.0)
5+
multi_json (~> 1.0)
6+
multi_json (1.1.0)
7+
rake (0.9.2.2)
8+
uglifier (1.2.3)
9+
execjs (>= 0.3.0)
10+
multi_json (>= 1.0.2)
11+
12+
PLATFORMS
13+
ruby
14+
15+
DEPENDENCIES
16+
rake
17+
uglifier

Diff for: README.md

+8
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,11 @@ You can draw your own shapes or images using the existing canvas API, add event
88

99
# Tutorials
1010
Check out the official [KineticJS Tutorials](http://www.html5canvastutorials.com/kineticjs/html5-canvas-events-tutorials-introduction-with-kineticjs/) hosted on [HTML5 Canvas Tutorials](http://www.html5canvastutorials.com/).
11+
12+
# Building the library
13+
To build the library, you need to have Ruby and Rubygems installed. After that, install the dependencies by running `bundle install`.
14+
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`.
16+
17+
# Adding a new file in the lib directory
18+
If you add a file in the lib directory, add into the array in the Rakefile.

Diff for: Rakefile

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# 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.
2+
FILES = [
3+
"Kinetic.js", "GlobalObject.js", "Node.js", "Container.js", "Stage.js",
4+
"Layer.js", "Group.js", "Shape.js", "Rect.js", "Circle.js", "Image.js",
5+
"Polygon.js", "RegularPolygon.js", "Star.js", "Text.js"
6+
]
7+
8+
def concatenate
9+
content = ""
10+
FILES.each do |file|
11+
content << IO.read(File.expand_path('lib/' + file)) << "\n"
12+
end
13+
14+
return content
15+
end
16+
17+
namespace :build do
18+
desc "Concatenate all the files in /lib into /dist/kinetic.js."
19+
task :dev do
20+
puts ":: Building the file /dist/kinetic.js..."
21+
File.open("dist/kinetic.js", "w") do |file|
22+
file.puts concatenate()
23+
end
24+
puts " -> Done!"
25+
end
26+
27+
desc "Concatenate all the files in /lib into /dist/kinetic.min.js and minify it."
28+
task :prod do
29+
puts ":: Building the file /dist/kinetic.min.js..."
30+
require 'uglifier'
31+
File.open("dist/kinetic.min.js", "w") do |file|
32+
file.puts Uglifier.compile(concatenate())
33+
end
34+
puts ":: Minifying the file /dist/kinetic.min.js..."
35+
puts " -> Done!"
36+
end
37+
end

Diff for: dist/kinetic.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
2626
* THE SOFTWARE.
2727
*/
28+
2829
///////////////////////////////////////////////////////////////////////
2930
// Global Object
3031
///////////////////////////////////////////////////////////////////////
@@ -120,6 +121,7 @@ window.requestAnimFrame = (function(callback){
120121
};
121122
})();
122123

124+
123125
///////////////////////////////////////////////////////////////////////
124126
// Node
125127
///////////////////////////////////////////////////////////////////////
@@ -1835,7 +1837,6 @@ Kinetic.Polygon.prototype = {
18351837
// extend Shape
18361838
Kinetic.GlobalObject.extend(Kinetic.Polygon, Kinetic.Shape);
18371839

1838-
18391840
///////////////////////////////////////////////////////////////////////
18401841
// RegularPolygon
18411842
///////////////////////////////////////////////////////////////////////
@@ -1889,7 +1890,6 @@ Kinetic.RegularPolygon.prototype = {
18891890
// extend Shape
18901891
Kinetic.GlobalObject.extend(Kinetic.RegularPolygon, Kinetic.Shape);
18911892

1892-
18931893
///////////////////////////////////////////////////////////////////////
18941894
// Star
18951895
///////////////////////////////////////////////////////////////////////
@@ -2098,3 +2098,4 @@ Kinetic.Text.prototype = {
20982098
};
20992099
// extend Shape
21002100
Kinetic.GlobalObject.extend(Kinetic.Text, Kinetic.Shape);
2101+

Diff for: dist/kinetic.min.js

+31
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: lib/GlobalObjet.js renamed to lib/GlobalObject.js

File renamed without changes.

0 commit comments

Comments
 (0)