guard-stitch-plus 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/.gitignore +2 -0
- data/CHANGELOG.md +9 -0
- data/README.md +102 -5
- data/lib/guard/stitch-plus.rb +39 -5
- data/lib/guard/stitch-plus/templates/Guardfile +14 -2
- data/lib/guard/stitch-plus/version.rb +1 -1
- data/test/Gemfile +6 -3
- data/test/Guardfile +16 -2
- data/test/_config.yml +15 -0
- data/test/_layouts/default.html +12 -0
- data/test/_plugins/stitch-plus.rb +1 -0
- data/test/index.html +13 -0
- data/test/{javascripts/dependencies → js/lib}/foo.coffee +0 -0
- data/test/{javascripts/dependencies → js/lib}/test.js +0 -0
- data/test/{javascripts → js}/modules/test-module.js +0 -0
- metadata +10 -6
- data/test/stitch.yml +0 -5
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
ZjQ4NjZhNzM4NDM5NTMyNzkxMTI4ZTY3MmRkZmViYzQyNjc2ZDUxYQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
OTk0NDNhZjhhZmNlZWJhMTUzOGU3MWE2OGMxYTI5M2ZiMjc1NDllYg==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
YTc2MTUyYmM5NmFhOTE5ZmExYWU4YTIxOTAxMWU1MGE0YTA4MjE3OTY2OTg5
|
10
|
+
MjBjN2YwMjMxNTdiY2E0ZWMwN2JjOWJiMGVjNzI1NDYwNjJmYmE3ZWNmNjY5
|
11
|
+
OWRlNDBkNWZiODYyMjZhMmQzM2YzMmMyZmEyZDIxNjkxOGQxYjE=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
NzQzNWVkYjdlZWM0MmJmMzliNDQ2Yzg5ZmM2ODZkNDM3MWJiMmViNGQ4Yjhh
|
14
|
+
MzIyMmI4OWVjOTA3YTE4NmQ4NjkyNjI5NGQ4ZmY2Mzk4OTMyN2JjN2YyMjI3
|
15
|
+
NmE5MmVjNTg3MTc2NmM0MDdjMmEyZDE0NDEyMjFkYWNhNmIzYjc=
|
data/.gitignore
CHANGED
data/CHANGELOG.md
ADDED
data/README.md
CHANGED
@@ -1,12 +1,12 @@
|
|
1
|
-
# Guard
|
1
|
+
# Guard Stitch Plus
|
2
2
|
|
3
|
-
|
3
|
+
A guard compiling and uglifying javascripts, powered by [stitch-plus](https://github.com/imathis/stitch-plus).
|
4
4
|
|
5
5
|
## Installation
|
6
6
|
|
7
7
|
Add this line to your application's Gemfile:
|
8
8
|
|
9
|
-
gem 'guard-
|
9
|
+
gem 'guard-stitch-plus'
|
10
10
|
|
11
11
|
And then execute:
|
12
12
|
|
@@ -14,11 +14,82 @@ And then execute:
|
|
14
14
|
|
15
15
|
Or install it yourself as:
|
16
16
|
|
17
|
-
$ gem install guard-
|
17
|
+
$ gem install guard-stitch-plus
|
18
18
|
|
19
19
|
## Usage
|
20
20
|
|
21
|
-
|
21
|
+
Add this guard to your Guardfile with `guard init stitch-plus`. Here's a sample Guardfile.
|
22
|
+
|
23
|
+
```ruby
|
24
|
+
stitch_config = {
|
25
|
+
output: 'javascripts/site.js',
|
26
|
+
dependencies: [
|
27
|
+
'javascripts/lib/jquery.js',
|
28
|
+
'javascripts/lib'
|
29
|
+
],
|
30
|
+
paths: ['javascripts/modules'],
|
31
|
+
fingerprint: true,
|
32
|
+
uglify: true
|
33
|
+
}
|
34
|
+
|
35
|
+
guard 'stitch-plus', stitch_config do
|
36
|
+
watch /^javascripts/
|
37
|
+
end
|
38
|
+
```
|
39
|
+
|
40
|
+
Whenever the guard is loaded or when a javascript file changes which is being watched, stitch-plus will:
|
41
|
+
|
42
|
+
1. Add jquery.js, followed by any other javascript or coffeescript file in `javascripts/lib/`.
|
43
|
+
2. Add a Require function and wrap all files in `javascripts/modules` in a CommonJS wrapper.
|
44
|
+
3. Uglify the compiled javascript.
|
45
|
+
4. Write it to a fingerprinted file at `javascripts/site-f1408932717b4b16eb97969d34961213.js`.
|
46
|
+
|
47
|
+
### Using this with Jekyll?
|
48
|
+
|
49
|
+
If you're using Jekyll, be sure to check out [jekyll-stitch-plus](https://github.com/octopress/jekyll-stitch-plus) which integrates smoothly with jekyll and also plays
|
50
|
+
nicely with this guard plugin. In that case be sure to add your stitch-plus configuration to your Jekyll config file (usually _config.yml) and point your guard to that
|
51
|
+
file as well.
|
52
|
+
|
53
|
+
Your Jekyll YAML config file might look like this.
|
54
|
+
|
55
|
+
```yaml
|
56
|
+
stitch:
|
57
|
+
output: 'javascripts/site.js'
|
58
|
+
dependencies:
|
59
|
+
- 'javascripts/lib/jquery.js'
|
60
|
+
- 'javascripts/lib'
|
61
|
+
paths: ['javascripts/modules']
|
62
|
+
fingerprint: true
|
63
|
+
uglify: true
|
64
|
+
```
|
65
|
+
|
66
|
+
Then your Guardfile would look like this.
|
67
|
+
|
68
|
+
```ruby
|
69
|
+
guard 'stitch-plus', config: '_config.yml' do
|
70
|
+
watch /^(javascripts|_config.yml)/
|
71
|
+
end
|
72
|
+
```
|
73
|
+
|
74
|
+
Notice that the guard is also watching the Jekyll config file.
|
75
|
+
|
76
|
+
## Configuration
|
77
|
+
|
78
|
+
Configure stitch-plus by passing a hash of options or pointing it to a YAML config file.
|
79
|
+
|
80
|
+
| Config | Description | Default |
|
81
|
+
|:-----------------|:---------------------------------------------------------------------------|:------------|
|
82
|
+
| `config` | A path to a YAML file containing stitch configurations | nil |
|
83
|
+
| `dependencies` | Array of files/directories to be added first as global javascripts | nil |
|
84
|
+
| `paths` | Array of directories where javascripts will be wrapped as CommonJS modules | nil |
|
85
|
+
| `output` | A path to write the compiled javascript | 'all.js' |
|
86
|
+
| `fingerprint` | Add a fingerprint to the file name for super cache busting power | false |
|
87
|
+
| `cleanup` | Automatically remove previously compiled files | true |
|
88
|
+
| `uglify` | Smash javascript using the Uglifier gem | false |
|
89
|
+
| `uglify_options` | Options for the Uglifier gem. See the [Uglifier docs](https://github.com/lautis/uglifier#usage) for details. | {} |
|
90
|
+
|
91
|
+
Note: You can configure from the hash and a yaml file, but configurations loaded from a YAML file will override any settings in your config hash. For example, `{config: 'stitch.yml', uglify: false}` will be overwritten if the yaml file sets `uglify: true`.
|
92
|
+
|
22
93
|
|
23
94
|
## Contributing
|
24
95
|
|
@@ -27,3 +98,29 @@ Write usage instructions here
|
|
27
98
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
28
99
|
4. Push to the branch (`git push origin my-new-feature`)
|
29
100
|
5. Create new Pull Request
|
101
|
+
|
102
|
+
## License
|
103
|
+
|
104
|
+
Copyright (c) 2013 Brandon Mathis
|
105
|
+
|
106
|
+
MIT License
|
107
|
+
|
108
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
109
|
+
a copy of this software and associated documentation files (the
|
110
|
+
"Software"), to deal in the Software without restriction, including
|
111
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
112
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
113
|
+
permit persons to whom the Software is furnished to do so, subject to
|
114
|
+
the following conditions:
|
115
|
+
|
116
|
+
The above copyright notice and this permission notice shall be
|
117
|
+
included in all copies or substantial portions of the Software.
|
118
|
+
|
119
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
120
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
121
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
122
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
123
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
124
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
125
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
126
|
+
|
data/lib/guard/stitch-plus.rb
CHANGED
@@ -6,23 +6,57 @@ module Guard
|
|
6
6
|
|
7
7
|
def initialize (watchers=[], options={})
|
8
8
|
super
|
9
|
-
@
|
9
|
+
@options = options
|
10
10
|
end
|
11
11
|
|
12
12
|
def start
|
13
|
-
@stitcher.
|
13
|
+
@stitcher = ::StitchPlus.new(@options.merge({guard: true}))
|
14
|
+
ENV['GUARD_STITCH_PLUS'] = 'true'
|
15
|
+
@stitch_files = stitch_files
|
16
|
+
write
|
14
17
|
end
|
15
18
|
|
16
19
|
def reload
|
17
|
-
|
20
|
+
write
|
18
21
|
end
|
19
22
|
|
20
23
|
def run_all
|
21
|
-
|
24
|
+
write
|
22
25
|
end
|
23
26
|
|
24
|
-
def
|
27
|
+
def run_on_removals(paths)
|
28
|
+
if (paths & @stitch_files).size > 0
|
29
|
+
write
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def run_on_additions(paths)
|
34
|
+
@stitch_files = stitch_files
|
35
|
+
if (paths & @stitch_files).size > 0
|
36
|
+
write
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def run_on_changes(paths)
|
41
|
+
@stitch_files = stitch_files
|
42
|
+
if @options[:config] and paths.include? @options[:config]
|
43
|
+
start
|
44
|
+
elsif (paths & @stitch_files).size > 0
|
45
|
+
write
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
def write
|
25
50
|
@stitcher.write
|
51
|
+
ENV['GUARD_STITCH_PLUS_OUTPUT'] = @stitcher.last_write
|
52
|
+
end
|
53
|
+
|
54
|
+
private
|
55
|
+
|
56
|
+
def stitch_files
|
57
|
+
all_files = @stitcher.all_files
|
58
|
+
ENV['GUARD_STITCH_PLUS_FILES'] = all_files.join(',')
|
59
|
+
all_files
|
26
60
|
end
|
27
61
|
end
|
28
62
|
end
|
@@ -1,4 +1,16 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
# Read more about stitch-plus configuration at https://github.com/imathis/guard-stitch-plus
|
2
|
+
#
|
3
|
+
stitch_config = {
|
4
|
+
dependencies: [
|
5
|
+
'javascripts/lib/jquery.js',
|
6
|
+
'javascripts/lib'
|
7
|
+
],
|
8
|
+
paths: ['javascripts/modules'],
|
9
|
+
output: 'javascripts/site.js',
|
10
|
+
uglify: true
|
11
|
+
}
|
12
|
+
|
13
|
+
guard 'stitch-plus', stitch_config do
|
14
|
+
watch /javascripts/
|
3
15
|
end
|
4
16
|
|
data/test/Gemfile
CHANGED
@@ -1,6 +1,9 @@
|
|
1
1
|
source 'https://rubygems.org'
|
2
2
|
|
3
|
-
gem '
|
4
|
-
gem '
|
3
|
+
gem 'jekyll'
|
4
|
+
gem 'guard-jekyll-plus'
|
5
|
+
gem 'jekyll-stitch-plus'
|
6
|
+
gem 'guard-stitch-plus', path: '../'
|
5
7
|
gem 'uglifier'
|
6
|
-
|
8
|
+
gem 'coffee-script'
|
9
|
+
gem 'redcarpet'
|
data/test/Guardfile
CHANGED
@@ -1,7 +1,21 @@
|
|
1
1
|
# A sample Guardfile
|
2
2
|
# More info at https://github.com/guard/guard#readme
|
3
3
|
|
4
|
-
|
5
|
-
|
4
|
+
|
5
|
+
# Add
|
6
|
+
stitch_config = {
|
7
|
+
dependencies: ['js/lib'],
|
8
|
+
paths: ['js/modules'],
|
9
|
+
output: 'js/site.js',
|
10
|
+
uglify: true
|
11
|
+
}
|
12
|
+
guard 'stitch-plus', stitch_config do
|
13
|
+
watch /js/
|
14
|
+
end
|
15
|
+
|
16
|
+
|
17
|
+
guard "jekyll-plus" do
|
18
|
+
watch /.*/
|
19
|
+
ignore %r{^_site/}
|
6
20
|
end
|
7
21
|
|
data/test/_config.yml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
name: Your New Jekyll Site
|
2
|
+
markdown: redcarpet
|
3
|
+
pygments: true
|
4
|
+
|
5
|
+
env: 'production'
|
6
|
+
|
7
|
+
stitch:
|
8
|
+
dependencies:
|
9
|
+
- 'js/lib/jquery.js'
|
10
|
+
- 'js/lib/underscore.js'
|
11
|
+
- 'js/lib' # globs the js/lib dir
|
12
|
+
paths: 'js/modules' # globs the js/modules dir
|
13
|
+
output: 'js/site.js'
|
14
|
+
#fingerprint: true
|
15
|
+
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'jekyll-stitch-plus'
|
data/test/index.html
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
---
|
2
|
+
layout: default
|
3
|
+
title: Your New Jekyll Site
|
4
|
+
---
|
5
|
+
|
6
|
+
<div id="home">
|
7
|
+
<h1>Blog Posts</h1>
|
8
|
+
<ul class="posts">
|
9
|
+
{% for post in site.posts %}
|
10
|
+
<li><span>{{ post.date | date_to_string }}</span> » <a href="{{ post.url }}">{{ post.title }}</a></li>
|
11
|
+
{% endfor %}
|
12
|
+
</ul>
|
13
|
+
</div>
|
File without changes
|
File without changes
|
File without changes
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: guard-stitch-plus
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brandon Mathis
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-08-
|
11
|
+
date: 2013-08-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: guard
|
@@ -46,6 +46,7 @@ extensions: []
|
|
46
46
|
extra_rdoc_files: []
|
47
47
|
files:
|
48
48
|
- .gitignore
|
49
|
+
- CHANGELOG.md
|
49
50
|
- Gemfile
|
50
51
|
- LICENSE.txt
|
51
52
|
- README.md
|
@@ -56,10 +57,13 @@ files:
|
|
56
57
|
- lib/guard/stitch-plus/version.rb
|
57
58
|
- test/Gemfile
|
58
59
|
- test/Guardfile
|
59
|
-
- test/
|
60
|
-
- test/
|
61
|
-
- test/
|
62
|
-
- test/
|
60
|
+
- test/_config.yml
|
61
|
+
- test/_layouts/default.html
|
62
|
+
- test/_plugins/stitch-plus.rb
|
63
|
+
- test/index.html
|
64
|
+
- test/js/lib/foo.coffee
|
65
|
+
- test/js/lib/test.js
|
66
|
+
- test/js/modules/test-module.js
|
63
67
|
homepage: https://github.com/imathis/guard-stitch-plus
|
64
68
|
licenses:
|
65
69
|
- MIT
|