guard-steering 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +67 -19
- data/lib/guard/steering.rb +26 -17
- data/lib/guard/steering/version.rb +1 -1
- metadata +9 -25
data/README.md
CHANGED
@@ -1,38 +1,56 @@
|
|
1
|
-
# Guard::Steering
|
1
|
+
# Guard::Steering [![Build Status](https://secure.travis-ci.org/daaain/guard-steering.png)](http://travis-ci.org/daaain/guard-steering) [![Dependency Status](https://gemnasium.com/daaain/guard-steering.png)](https://gemnasium.com/daaain/guard-steering) [![Code Climate](https://codeclimate.com/badge.png)](https://codeclimate.com/github/daaain/guard-steering)
|
2
2
|
|
3
|
-
|
3
|
+
## About
|
4
|
+
|
5
|
+
Lets you set up a [Guard](https://github.com/guard/guard) that will run [Steering](https://github.com/pixeltrix/steering) whenever a [Handlebars.js](https://github.com/wycats/handlebars.js) template is added / updated.
|
6
|
+
|
7
|
+
The reason this Gem was born is developing a HTML5 based desktop application which relies on static compilation. Still wanting to get the benefit of having fast Handlebars templating, precompilation is now done development time instead of loading the templates and letting the full runtime JS do the work.
|
4
8
|
|
5
9
|
## Usage
|
6
10
|
|
7
|
-
|
11
|
+
### Guardfile
|
12
|
+
|
13
|
+
For some comprehensive examples and explanation see [Guard-Steering-examples](https://github.com/daaain/guard-steering-examples) or in case you're familiar with Handlebars and Guard just read on.
|
14
|
+
|
15
|
+
Point the Guard watcher to your Handlebars template folder, set up the output folder in the options part and you're all set! Note: at the moment Guard::Steering won't rebuild your folder structure.
|
16
|
+
|
17
|
+
guard 'steering', :output_folder => "build/handlebars" do
|
18
|
+
watch(%r{^source/handlebars/.*\.handlebars$})
|
19
|
+
end
|
20
|
+
|
21
|
+
### Gemfile
|
8
22
|
|
9
23
|
source "http://rubygems.org"
|
10
24
|
gem "guard"
|
11
|
-
gem "steering"
|
12
|
-
|
13
|
-
:branch => 'master'
|
14
|
-
gem 'guard-steering'
|
25
|
+
gem "steering"
|
26
|
+
gem "guard-steering"
|
15
27
|
|
16
|
-
|
17
|
-
|
18
|
-
Then on your favourite shell type:
|
28
|
+
### Set up Guard and let it run
|
19
29
|
|
20
30
|
$ bundle install
|
21
|
-
$ bundle exec guard init
|
22
31
|
$ bundle exec guard init steering
|
23
32
|
$ bundle exec guard
|
24
33
|
|
25
|
-
##
|
34
|
+
## Todo
|
26
35
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
36
|
+
* Finish test suite
|
37
|
+
* Fix bug with empty template being generated for deleted file
|
38
|
+
* Add an example - WIP at https://github.com/daaain/guard-steering-sample
|
39
|
+
* Investigate supporting rebuilding of folder tree in output folder from inside source folder
|
40
|
+
* Add silent option
|
32
41
|
|
33
42
|
## Changelog
|
34
43
|
|
35
|
-
### 0.0.
|
44
|
+
### 0.0.3
|
45
|
+
* Got Travis working
|
46
|
+
* Set tests up (still need to cover actual functionality)
|
47
|
+
* Cleaned up documentation
|
48
|
+
* Now compatible with [Guard 1.1+](https://github.com/guard/guard/wiki/Upgrade-guide-for-existing-guards-to-Guard-v1.1) APIs
|
49
|
+
* Added 'register_partials' option, which automatically registers templates as partials too
|
50
|
+
* Made it work with [static Guard compilation](https://github.com/guard/guard/wiki/Guard-Cookbook), so can be used from Rake or even a simple Ruby script
|
51
|
+
* Fixed bug with 'run_at_start' option
|
52
|
+
|
53
|
+
### 0.0.2 – last version to support Guard 1.0.x
|
36
54
|
|
37
55
|
* Added versions to Gem dependencies.
|
38
56
|
* Removed 'handlebars' extension requirement, this is now left to Guard watch pattern to filter.
|
@@ -41,4 +59,34 @@ You can adapt your 'view' files like you want. Please read Guard doc for more in
|
|
41
59
|
|
42
60
|
### 0.0.1
|
43
61
|
|
44
|
-
Initial version.
|
62
|
+
Initial version.
|
63
|
+
|
64
|
+
## Sponsored by
|
65
|
+
<a href="http://ustwo.co.uk">![ustwo™](http://cache.ustwo.co.uk/wordpress/wp-content/themes/ustwo1.4/images/logo.png)</a>
|
66
|
+
|
67
|
+
ustwo™ design studios
|
68
|
+
|
69
|
+
## License
|
70
|
+
|
71
|
+
(The MIT License)
|
72
|
+
|
73
|
+
Copyright (c) 2012 Daniel Demmel, ustwo™
|
74
|
+
|
75
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
76
|
+
a copy of this software and associated documentation files (the
|
77
|
+
'Software'), to deal in the Software without restriction, including
|
78
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
79
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
80
|
+
permit persons to whom the Software is furnished to do so, subject to
|
81
|
+
the following conditions:
|
82
|
+
|
83
|
+
The above copyright notice and this permission notice shall be
|
84
|
+
included in all copies or substantial portions of the Software.
|
85
|
+
|
86
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
87
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
88
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
89
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
90
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
91
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
92
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/lib/guard/steering.rb
CHANGED
@@ -13,15 +13,21 @@ module Guard
|
|
13
13
|
super
|
14
14
|
@options = {
|
15
15
|
:run_at_start => true,
|
16
|
-
:output_folder => nil
|
16
|
+
:output_folder => nil,
|
17
|
+
:register_partials => false
|
17
18
|
}.update(options)
|
19
|
+
|
20
|
+
@output_folder = !@options[:output_folder].nil? && @options[:output_folder]
|
21
|
+
# FIXME: if :output_folder is not defined "TypeError: can't convert false into String'" happens on the next line
|
22
|
+
Dir.mkdir(@output_folder) if !File.directory?(@output_folder) && !@output_folder.nil?
|
18
23
|
end
|
19
24
|
|
20
25
|
# Call once when Guard starts. Please override initialize method to init stuff.
|
21
26
|
# @raise [:task_has_failed] when start has failed
|
22
27
|
def start
|
23
|
-
UI.info("Guard::Steering has started watching your files")
|
24
|
-
|
28
|
+
UI.info("Guard::Steering has started watching your files with output folder set to '#{@output_folder}' (in case of 'nil' templates will be compiled to the folder where they are)")
|
29
|
+
|
30
|
+
run_all if @options[:run_at_start]
|
25
31
|
end
|
26
32
|
|
27
33
|
# Called when `stop|quit|exit|s|q|e + enter` is pressed (when Guard quits).
|
@@ -33,7 +39,6 @@ module Guard
|
|
33
39
|
# This method should be mainly used for "reload" (really!) actions like reloading passenger/spork/bundler/...
|
34
40
|
# @raise [:task_has_failed] when reload has failed
|
35
41
|
def reload
|
36
|
-
run_all
|
37
42
|
end
|
38
43
|
|
39
44
|
# Called when just `enter` is pressed
|
@@ -42,30 +47,34 @@ module Guard
|
|
42
47
|
def run_all
|
43
48
|
paths = Dir.glob("**/*.*")
|
44
49
|
targets = Watcher.match_files(self, paths)
|
45
|
-
|
50
|
+
run_on_changes targets
|
46
51
|
end
|
47
52
|
|
48
|
-
# Called on file(s)
|
53
|
+
# Called on file(s) changes that the Guard watches.
|
49
54
|
# @param [Array<String>] paths the changes files or paths
|
50
|
-
# @raise [:task_has_failed] when
|
51
|
-
def
|
52
|
-
|
55
|
+
# @raise [:task_has_failed] when run_on_changes has failed
|
56
|
+
def run_on_changes(paths)
|
57
|
+
paths.each do |path|
|
58
|
+
# use output_folder or default back to watched file location
|
59
|
+
run_steering(path, @output_folder || File.dirname(path))
|
60
|
+
end
|
53
61
|
end
|
54
62
|
|
55
63
|
# Called on file(s) deletions that the Guard watches.
|
56
64
|
# @param [Array<String>] paths the deleted files or paths
|
57
65
|
# @raise [:task_has_failed] when run_on_change has failed
|
58
|
-
def
|
66
|
+
def run_on_removals(paths)
|
67
|
+
paths.each do |path|
|
68
|
+
output_folder = @output_folder || File.dirname(path)
|
69
|
+
File.exists?(output_folder + "/" + File.basename(path) + ".js")
|
70
|
+
UI.info "Steering deleted #{File.basename(path)}.js from #{output_folder}"
|
71
|
+
end
|
59
72
|
end
|
60
73
|
|
61
|
-
def run_steering(
|
74
|
+
def run_steering(path, output_folder)
|
62
75
|
begin
|
63
|
-
|
64
|
-
|
65
|
-
Dir.mkdir(output_folder) unless File.directory?(output_folder)
|
66
|
-
::Steering.compile_to_file(path, output_folder + "/" + File.basename(path) + ".js")
|
67
|
-
UI.info "Steering precompiled #{path} to #{output_folder}"
|
68
|
-
end
|
76
|
+
::Steering.compile_to_file(path, output_folder + "/" + File.basename(path) + ".js", {:extension => '.handlebars', :partial => @options[:register_partials]})
|
77
|
+
UI.info "Steering precompiled #{path} to #{output_folder}"
|
69
78
|
rescue Exception => e
|
70
79
|
UI.error "Steering precompilation failed: #{e}"
|
71
80
|
false
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: guard-steering
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,56 +9,40 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-09-20 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: guard
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
|
-
- -
|
19
|
+
- - ~>
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version: 1.
|
21
|
+
version: '1.2'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
24
|
version_requirements: !ruby/object:Gem::Requirement
|
25
25
|
none: false
|
26
26
|
requirements:
|
27
|
-
- -
|
27
|
+
- - ~>
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version: 1.
|
29
|
+
version: '1.2'
|
30
30
|
- !ruby/object:Gem::Dependency
|
31
31
|
name: steering
|
32
|
-
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
|
-
requirements:
|
35
|
-
- - ! '>='
|
36
|
-
- !ruby/object:Gem::Version
|
37
|
-
version: 1.1.0
|
38
|
-
type: :runtime
|
39
|
-
prerelease: false
|
40
|
-
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
|
-
requirements:
|
43
|
-
- - ! '>='
|
44
|
-
- !ruby/object:Gem::Version
|
45
|
-
version: 1.1.0
|
46
|
-
- !ruby/object:Gem::Dependency
|
47
|
-
name: rspec
|
48
32
|
requirement: !ruby/object:Gem::Requirement
|
49
33
|
none: false
|
50
34
|
requirements:
|
51
35
|
- - ~>
|
52
36
|
- !ruby/object:Gem::Version
|
53
|
-
version: 2.
|
54
|
-
type: :
|
37
|
+
version: 1.2.0
|
38
|
+
type: :runtime
|
55
39
|
prerelease: false
|
56
40
|
version_requirements: !ruby/object:Gem::Requirement
|
57
41
|
none: false
|
58
42
|
requirements:
|
59
43
|
- - ~>
|
60
44
|
- !ruby/object:Gem::Version
|
61
|
-
version: 2.
|
45
|
+
version: 1.2.0
|
62
46
|
description: Guard::Steering automatically runs the steering gem to precompile Handlebars.js
|
63
47
|
templates
|
64
48
|
email:
|