guard-coffeescript 0.1.4 → 0.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.rdoc +1 -1
- data/lib/guard/coffeescript/runner.rb +21 -15
- data/lib/guard/coffeescript/version.rb +1 -1
- data/lib/guard/coffeescript.rb +11 -1
- metadata +4 -4
data/README.rdoc
CHANGED
@@ -75,7 +75,7 @@ will be compiled to
|
|
75
75
|
|
76
76
|
public/javascripts/compiled/ui/buttons/toggle_button.js
|
77
77
|
|
78
|
-
This behaviour can be switched off by passing the option ':shallow =>
|
78
|
+
This behaviour can be switched off by passing the option ':shallow => true' to the guard, so that all JavaScripts will
|
79
79
|
be compiled directly to the output directory.
|
80
80
|
|
81
81
|
== Development
|
@@ -4,10 +4,11 @@ module Guard
|
|
4
4
|
class << self
|
5
5
|
|
6
6
|
def run(files, watchers, options = {})
|
7
|
-
|
8
|
-
errors = compile_files(files, options, watchers)
|
9
|
-
notify_result(
|
10
|
-
|
7
|
+
notify_start(files, options)
|
8
|
+
changed_files, errors = compile_files(files, options, watchers)
|
9
|
+
notify_result(changed_files, errors)
|
10
|
+
|
11
|
+
changed_files
|
11
12
|
rescue LoadError
|
12
13
|
::Guard::UI.error "Command 'coffee' not found. Please install CoffeeScript."
|
13
14
|
end
|
@@ -17,22 +18,22 @@ module Guard
|
|
17
18
|
def notify_start(files, options)
|
18
19
|
message = options[:message] || "Compile #{ files.join(', ') }"
|
19
20
|
::Guard::UI.info message, :reset => true
|
20
|
-
message
|
21
21
|
end
|
22
22
|
|
23
23
|
def compile_files(files, options, watchers)
|
24
|
-
errors
|
25
|
-
|
24
|
+
errors = []
|
25
|
+
changed_files = []
|
26
|
+
directories = detect_nested_directories(watchers, files, options)
|
26
27
|
|
27
28
|
directories.each do |directory, scripts|
|
28
|
-
directory = File.expand_path(directory)
|
29
29
|
scripts.each do |file|
|
30
30
|
content, success = compile(file, options)
|
31
|
-
process_compile_result(content, file, directory, errors, success)
|
31
|
+
changed_file = process_compile_result(content, file, directory, errors, success)
|
32
|
+
changed_files << changed_file
|
32
33
|
end
|
33
34
|
end
|
34
35
|
|
35
|
-
errors
|
36
|
+
[changed_files.compact, errors]
|
36
37
|
end
|
37
38
|
|
38
39
|
def compile(file, options)
|
@@ -42,11 +43,16 @@ module Guard
|
|
42
43
|
|
43
44
|
def process_compile_result(content, file, directory, errors, success)
|
44
45
|
if success
|
45
|
-
FileUtils.mkdir_p(directory) if !File.directory?(directory)
|
46
|
-
File.
|
46
|
+
FileUtils.mkdir_p(File.expand_path(directory)) if !File.directory?(directory)
|
47
|
+
filename = File.join(directory, File.basename(file.gsub(/coffee$/, 'js')))
|
48
|
+
File.open(File.expand_path(filename), 'w') { |f| f.write(content) }
|
49
|
+
|
50
|
+
filename
|
47
51
|
else
|
48
52
|
errors << file + ': ' + content.split("\n").select { |line| line =~ /^Error:/ }.join("\n")
|
49
53
|
::Guard::UI.error(content)
|
54
|
+
|
55
|
+
nil
|
50
56
|
end
|
51
57
|
end
|
52
58
|
|
@@ -57,7 +63,7 @@ module Guard
|
|
57
63
|
|
58
64
|
watchers.product(files).each do |watcher, file|
|
59
65
|
if matches = file.match(watcher.pattern)
|
60
|
-
target = File.join(options[:output], File.dirname(matches[1]))
|
66
|
+
target = File.join(options[:output], File.dirname(matches[1])).gsub(/\/\.$/, '')
|
61
67
|
if directories[target]
|
62
68
|
directories[target] << file
|
63
69
|
else
|
@@ -69,9 +75,9 @@ module Guard
|
|
69
75
|
directories
|
70
76
|
end
|
71
77
|
|
72
|
-
def notify_result(
|
78
|
+
def notify_result(changed_files, errors)
|
73
79
|
if errors.empty?
|
74
|
-
message =
|
80
|
+
message = "Successfully generated #{ changed_files.join(', ') }"
|
75
81
|
::Guard::Notifier.notify(message, :title => 'CoffeeScript results')
|
76
82
|
else
|
77
83
|
::Guard::Notifier.notify(errors.join("\n"), :title => 'CoffeeScript results', :image => :failed)
|
data/lib/guard/coffeescript.rb
CHANGED
@@ -22,8 +22,18 @@ module Guard
|
|
22
22
|
end
|
23
23
|
|
24
24
|
def run_on_change(paths)
|
25
|
-
Runner.run(Inspector.clean(paths), watchers, options)
|
25
|
+
changed_files = Runner.run(Inspector.clean(paths), watchers, options)
|
26
|
+
notify changed_files
|
26
27
|
end
|
27
28
|
|
29
|
+
private
|
30
|
+
|
31
|
+
def notify changed_files
|
32
|
+
::Guard.guards.each do |guard|
|
33
|
+
paths = Watcher.match_files(guard, changed_files)
|
34
|
+
guard.run_on_change paths unless paths.empty?
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
28
38
|
end
|
29
39
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: guard-coffeescript
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 17
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 5
|
10
|
+
version: 0.1.5
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Michael Kessler
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-11-
|
18
|
+
date: 2010-11-12 00:00:00 +01:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|