Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 52 lines (41 sloc) 1.39 kB
8392c08 @mroderick Adding jQuery plugin support via rake task
authored
1 require 'rake'
2 require 'rake/clean'
3
4 # Creates a task that uses the various template wrappers to make a wrapped
5 # output file. There is some extra complexity because Dojo and YUI use
6 # different final locations.
7 def templated_build(name, opts={})
8 short = name.downcase
9 source = File.join("wrappers", short)
10 dependencies = ["src/pubsub.js"] + Dir.glob("#{source}/*.tpl.*")
11 target_js = opts[:location] ? "pubsub.js" : "#{short}.pubsub.js"
12
13 CLEAN.include(opts[:location] ? opts[:location] : target_js)
14
15 desc "Package for #{name}"
16 task short.to_sym => dependencies do
17 puts "Packaging for #{name}"
18
19 mkdir_p opts[:location] if opts[:location]
20
21 files = [
22 "#{source}/pubsub.js.pre.txt",
23 'src/pubsub.js',
24 "#{source}/pubsub.js.post.txt"
25 ]
26
27 open("#{opts[:location] || '.'}/#{target_js}", 'w') do |f|
28 files.each {|file| f << File.read(file) }
29 end
30
31 puts "Done, see #{opts[:location] || '.'}/#{target_js}"
32 end
33 end
34
35 templated_build "jQuery"
36 # templated_build "MooTools"
37 # templated_build "Dojo", :location => "dojox/string"
38 # templated_build "YUI3", :location => "yui3/pubsub"
39 # templated_build "RequireJS"
40 # templated_build "qooxdoo"
41
42 task :default do
43 end
44
45 task :minify do
46 # npm install uglify-js
47 mmjs = "pubsub.min.js"
48 # `echo "/*! Version: 1.0.4-dev */" > #{mmjs}`
49 `uglifyjs pubsub.js >> #{mmjs}`
50 puts "Created #{mmjs}"
51 end
Something went wrong with that request. Please try again.