sidekick 0.6.5 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.sidekick +2 -0
- data/VERSION +1 -1
- data/lib/sidekick/actions/compile.rb +42 -5
- data/lib/sidekick/actions/triggers.rb +2 -2
- data/lib/sidekick/template +5 -0
- metadata +4 -4
data/.sidekick
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.7.0
|
@@ -2,21 +2,42 @@
|
|
2
2
|
|
3
3
|
module Sidekick::Actions::Compile
|
4
4
|
|
5
|
-
#
|
5
|
+
# write a file to disk
|
6
|
+
def write_file(path, data)
|
7
|
+
File.open(path, 'w') {|f| f.write(data) }
|
8
|
+
end
|
6
9
|
|
10
|
+
# Compile a template using the `tilt` gem.
|
7
11
|
def compile(source, target)
|
8
12
|
needs 'tilt', 'to compile templates'
|
9
13
|
handling Exception, source do
|
10
|
-
|
11
|
-
|
14
|
+
write_file target, Tilt.new(source).render
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
# compress a file using a suitable compressor for that
|
19
|
+
# file type.
|
20
|
+
def compress(source, target, opts={})
|
21
|
+
handling Exception, source do
|
22
|
+
case fmt = source.match(/\.[^\.]+$/).to_s
|
23
|
+
when '.js'
|
24
|
+
needs 'uglifier', 'to compress javascript'
|
25
|
+
write_file target, Uglifier.new(opts).compile(File.read(source))
|
26
|
+
else raise "Does not know how to compress #{fmt} files."
|
12
27
|
end
|
13
28
|
end
|
14
29
|
end
|
15
30
|
|
31
|
+
# Concatenate a bunch of files, preserving order
|
32
|
+
def concat(target, *sources)
|
33
|
+
write_file target, sources.map {|p| File.read(p) }.join("\n")
|
34
|
+
end
|
35
|
+
|
16
36
|
|
17
|
-
# watches for changes matching the `source` glob, and compiles to
|
37
|
+
# watches for changes matching the `source` glob, and compiles to
|
38
|
+
# `target`, replacing ':name' in `target` with the basename of the
|
39
|
+
# changed file.
|
18
40
|
def auto_compile(source, target)
|
19
|
-
|
20
41
|
watch(source) do |files|
|
21
42
|
files.each do |file|
|
22
43
|
if File.exists?(file)
|
@@ -28,4 +49,20 @@ module Sidekick::Actions::Compile
|
|
28
49
|
end
|
29
50
|
end
|
30
51
|
|
52
|
+
|
53
|
+
|
54
|
+
# Watch for changes to several source files, concatenating to `target_base.concat.type`
|
55
|
+
# and then compressing as per file type.
|
56
|
+
def auto_compress(target, *sources)
|
57
|
+
fmt = target.match(/\.[^\.]+$/).to_s
|
58
|
+
cat_path = target.sub(/#{fmt}$/, '.concat' + fmt)
|
59
|
+
|
60
|
+
watch(*sources) do |files|
|
61
|
+
concat(cat_path, *sources)
|
62
|
+
compress(cat_path, target)
|
63
|
+
log "compress => #{target}"
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
|
31
68
|
end
|
@@ -3,12 +3,12 @@
|
|
3
3
|
module Sidekick::Actions::Triggers
|
4
4
|
|
5
5
|
|
6
|
-
def watch(
|
6
|
+
def watch(*globs)
|
7
7
|
needs 'em-dir-watcher', 'to watch file changes'
|
8
8
|
|
9
9
|
EMDirWatcher.watch(
|
10
10
|
File.expand_path('.'),
|
11
|
-
:include_only =>
|
11
|
+
:include_only => globs,
|
12
12
|
:grace_period => 0.2
|
13
13
|
) do |paths|
|
14
14
|
log_trigger "watch #{paths.inspect}"
|
data/lib/sidekick/template
CHANGED
@@ -22,6 +22,11 @@ stop "File generated. Now please fill it in."
|
|
22
22
|
# auto_compile 'assets/css/*.sass', 'public/css/:name.css'
|
23
23
|
# auto_compile 'assets/js/*.coffee', 'public/js/:name.js'
|
24
24
|
|
25
|
+
# auto_compress( 'public/package.js',
|
26
|
+
# 'public/vendor/jquery.js',
|
27
|
+
# 'public/js/*.js'
|
28
|
+
# )
|
29
|
+
|
25
30
|
# passenger_server 3002
|
26
31
|
|
27
32
|
|
metadata
CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
|
|
4
4
|
prerelease: false
|
5
5
|
segments:
|
6
6
|
- 0
|
7
|
-
-
|
8
|
-
-
|
9
|
-
version: 0.
|
7
|
+
- 7
|
8
|
+
- 0
|
9
|
+
version: 0.7.0
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Jostein Berre Eliassen,
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2011-04-
|
17
|
+
date: 2011-04-11 00:00:00 +02:00
|
18
18
|
default_executable: sidekick
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|