guard-coffeescript 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +20 -0
- data/README.rdoc +64 -0
- data/lib/guard/coffeescript/inspector.rb +31 -0
- data/lib/guard/coffeescript/runner.rb +44 -0
- data/lib/guard/coffeescript/templates/Guardfile +3 -0
- data/lib/guard/coffeescript/version.rb +5 -0
- data/lib/guard/coffeescript.rb +28 -0
- metadata +139 -0
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2010 Michael Kessler, Thibaud Guillaume-Gentil
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,64 @@
|
|
1
|
+
= Guard::CoffeeScript
|
2
|
+
|
3
|
+
CoffeeScript guard allows to automatically & intelligently compile your CoffeeScripts when files are modified.
|
4
|
+
|
5
|
+
- Tested on Ruby 1.8.7 & 1.9.2.
|
6
|
+
|
7
|
+
== Install
|
8
|
+
|
9
|
+
Please be sure to have {guard}[http://github.com/guard/guard] installed before continue.
|
10
|
+
|
11
|
+
Install the gem:
|
12
|
+
|
13
|
+
gem install guard-coffeescript
|
14
|
+
|
15
|
+
Add it to your Gemfile (inside test group):
|
16
|
+
|
17
|
+
gem 'guard-coffeescript'
|
18
|
+
|
19
|
+
Add guard definition to your Guardfile by running this command:
|
20
|
+
|
21
|
+
guard init coffeescript
|
22
|
+
|
23
|
+
== Dependencies
|
24
|
+
|
25
|
+
Since CoffeeScripts is no more a Ruby gem it cannot be installed with Bundler, so you have to install it on your own.
|
26
|
+
Please consult the {CoffeeScript documentation}[http://jashkenas.github.com/coffee-script/] for more information about
|
27
|
+
how to install the latest CoffeeScript version.
|
28
|
+
|
29
|
+
== Usage
|
30
|
+
|
31
|
+
Please read {guard usage doc}[http://github.com/guard/guard#readme]
|
32
|
+
|
33
|
+
== Guardfile
|
34
|
+
|
35
|
+
CoffeeScript guard can be really be adapated to all kind of projects.
|
36
|
+
Please read {guard doc}[http://github.com/guard/guard#readme] for more info about Guardfile DSL.
|
37
|
+
|
38
|
+
=== Standard ruby gems
|
39
|
+
|
40
|
+
guard 'coffee-script' do
|
41
|
+
watch('^coffeescripts/(.*)\.coffee')
|
42
|
+
end
|
43
|
+
|
44
|
+
=== Rails app
|
45
|
+
|
46
|
+
guard 'coffee-script', :output => 'public/javascripts/compiled' do
|
47
|
+
watch('^app/coffeescripts/(.*)\.coffee')
|
48
|
+
end
|
49
|
+
|
50
|
+
== Development
|
51
|
+
|
52
|
+
- Source hosted at {GitHub}[http://github.com/netzpirat/guard-coffeescript]
|
53
|
+
- Report issues/Questions/Feature requests on {GitHub Issues}[http://github.com/netzpirat/guard-coffeescript/issues]
|
54
|
+
|
55
|
+
Pull requests are very welcome! Make sure your patches are well tested.
|
56
|
+
|
57
|
+
== Authors
|
58
|
+
|
59
|
+
{Michael Kessler}[http://github.com/netzpirat]
|
60
|
+
|
61
|
+
== Kudo
|
62
|
+
|
63
|
+
Many thanks to {Thibaud Guillaume-Gentil}[http://github.com/thibaudgg] for creating the excellent {guard}[http://github.com/guard/guard]
|
64
|
+
gem.
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module Guard
|
2
|
+
class CoffeeScript
|
3
|
+
module Inspector
|
4
|
+
class << self
|
5
|
+
|
6
|
+
def clean(paths)
|
7
|
+
paths.uniq!
|
8
|
+
paths.compact!
|
9
|
+
paths = paths.select { |p| coffee_file?(p) }
|
10
|
+
clear_coffee_files_list
|
11
|
+
paths
|
12
|
+
end
|
13
|
+
|
14
|
+
private
|
15
|
+
|
16
|
+
def coffee_file?(path)
|
17
|
+
coffee_files.include?(path)
|
18
|
+
end
|
19
|
+
|
20
|
+
def coffee_files
|
21
|
+
@coffee_files ||= Dir.glob('**/*.coffee')
|
22
|
+
end
|
23
|
+
|
24
|
+
def clear_coffee_files_list
|
25
|
+
@coffee_files = nil
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
module Guard
|
2
|
+
class CoffeeScript
|
3
|
+
module Runner
|
4
|
+
class << self
|
5
|
+
|
6
|
+
def run(paths, options = {})
|
7
|
+
if coffee_executable_exists?
|
8
|
+
message = options[:message] || "Running: #{paths.join(' ')}"
|
9
|
+
::Guard::UI.info message, :reset => true
|
10
|
+
|
11
|
+
out = `#{ coffee_script_command(paths, options) } 2>&1`
|
12
|
+
if $?.to_i == 0
|
13
|
+
message = message.gsub(/Running:/, 'Successful compiled')
|
14
|
+
::Guard::Notifier.notify(message, :title => 'CoffeeScript results')
|
15
|
+
else
|
16
|
+
message = out.split("\n").select { |line| line =~ /^Error:/ }.join("\n")
|
17
|
+
::Guard::Notifier.notify(message, :title => 'CoffeeScript results', :image => :failed)
|
18
|
+
end
|
19
|
+
|
20
|
+
else
|
21
|
+
::Guard::UI.error "Command 'coffee' not found. Please install CoffeeScript."
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
def coffee_script_command(paths, options)
|
28
|
+
cmd_parts = []
|
29
|
+
cmd_parts << 'coffee'
|
30
|
+
cmd_parts << '-c'
|
31
|
+
cmd_parts << '--no-wrap' if options[:nowrap]
|
32
|
+
cmd_parts << "-o #{ options[:output] }"
|
33
|
+
cmd_parts << paths.join(' ')
|
34
|
+
cmd_parts.join(' ')
|
35
|
+
end
|
36
|
+
|
37
|
+
def coffee_executable_exists?
|
38
|
+
system('which coffee > /dev/null 2>/dev/null')
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'guard'
|
2
|
+
require 'guard/guard'
|
3
|
+
require 'guard/watcher'
|
4
|
+
|
5
|
+
module Guard
|
6
|
+
class CoffeeScript < Guard
|
7
|
+
|
8
|
+
autoload :Runner, 'guard/coffeescript/runner'
|
9
|
+
autoload :Inspector, 'guard/coffeescript/inspector'
|
10
|
+
|
11
|
+
def initialize(watchers = [], options = {})
|
12
|
+
@watchers, @options = watchers, options
|
13
|
+
@options[:output] ||= 'javascripts'
|
14
|
+
@options[:nowrap] ||= false
|
15
|
+
end
|
16
|
+
|
17
|
+
def run_all
|
18
|
+
paths = Inspector.clean(Watcher.match_files(self, Dir.glob(File.join('**', '*.coffee'))))
|
19
|
+
Runner.run(paths, options.merge(:message => 'Generate all CoffeeScripts')) unless paths.empty?
|
20
|
+
end
|
21
|
+
|
22
|
+
def run_on_change(paths)
|
23
|
+
paths = Inspector.clean(paths)
|
24
|
+
Runner.run(paths, options) unless paths.empty?
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
28
|
+
end
|
metadata
ADDED
@@ -0,0 +1,139 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: guard-coffeescript
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 27
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 1
|
9
|
+
- 0
|
10
|
+
version: 0.1.0
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Michael Kessler
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2010-10-26 00:00:00 +02:00
|
19
|
+
default_executable:
|
20
|
+
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
22
|
+
name: guard
|
23
|
+
prerelease: false
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
hash: 23
|
30
|
+
segments:
|
31
|
+
- 0
|
32
|
+
- 2
|
33
|
+
- 0
|
34
|
+
version: 0.2.0
|
35
|
+
type: :runtime
|
36
|
+
version_requirements: *id001
|
37
|
+
- !ruby/object:Gem::Dependency
|
38
|
+
name: rspec
|
39
|
+
prerelease: false
|
40
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ~>
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
hash: 13
|
46
|
+
segments:
|
47
|
+
- 2
|
48
|
+
- 0
|
49
|
+
- 1
|
50
|
+
version: 2.0.1
|
51
|
+
type: :development
|
52
|
+
version_requirements: *id002
|
53
|
+
- !ruby/object:Gem::Dependency
|
54
|
+
name: guard-rspec
|
55
|
+
prerelease: false
|
56
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
hash: 19
|
62
|
+
segments:
|
63
|
+
- 0
|
64
|
+
- 1
|
65
|
+
- 4
|
66
|
+
version: 0.1.4
|
67
|
+
type: :development
|
68
|
+
version_requirements: *id003
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: bundler
|
71
|
+
prerelease: false
|
72
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ">="
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
hash: 19
|
78
|
+
segments:
|
79
|
+
- 1
|
80
|
+
- 0
|
81
|
+
- 2
|
82
|
+
version: 1.0.2
|
83
|
+
type: :development
|
84
|
+
version_requirements: *id004
|
85
|
+
description: Guard::CoffeeScript automatically generates your JavaScripts from your CoffeeScripts
|
86
|
+
email:
|
87
|
+
- michi@netzpiraten.ch
|
88
|
+
executables: []
|
89
|
+
|
90
|
+
extensions: []
|
91
|
+
|
92
|
+
extra_rdoc_files: []
|
93
|
+
|
94
|
+
files:
|
95
|
+
- lib/guard/coffeescript/inspector.rb
|
96
|
+
- lib/guard/coffeescript/runner.rb
|
97
|
+
- lib/guard/coffeescript/templates/Guardfile
|
98
|
+
- lib/guard/coffeescript/version.rb
|
99
|
+
- lib/guard/coffeescript.rb
|
100
|
+
- LICENSE
|
101
|
+
- README.rdoc
|
102
|
+
has_rdoc: true
|
103
|
+
homepage: http://rubygems.org/gems/guard-coffeescript
|
104
|
+
licenses: []
|
105
|
+
|
106
|
+
post_install_message:
|
107
|
+
rdoc_options: []
|
108
|
+
|
109
|
+
require_paths:
|
110
|
+
- lib
|
111
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
112
|
+
none: false
|
113
|
+
requirements:
|
114
|
+
- - ">="
|
115
|
+
- !ruby/object:Gem::Version
|
116
|
+
hash: 3
|
117
|
+
segments:
|
118
|
+
- 0
|
119
|
+
version: "0"
|
120
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
121
|
+
none: false
|
122
|
+
requirements:
|
123
|
+
- - ">="
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
hash: 23
|
126
|
+
segments:
|
127
|
+
- 1
|
128
|
+
- 3
|
129
|
+
- 6
|
130
|
+
version: 1.3.6
|
131
|
+
requirements: []
|
132
|
+
|
133
|
+
rubyforge_project: guard-coffeescript
|
134
|
+
rubygems_version: 1.3.7
|
135
|
+
signing_key:
|
136
|
+
specification_version: 3
|
137
|
+
summary: Guard gem for CoffeeScript
|
138
|
+
test_files: []
|
139
|
+
|