guard-jekyll-plus 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +1 -1
- data/README.md +9 -6
- data/lib/guard/jekyll/version.rb +1 -1
- data/lib/guard/jekyll.rb +60 -12
- data/test/Guardfile +4 -1
- data/test/_config.yml +1 -0
- data/test/_override.yml +2 -0
- metadata +2 -1
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -4,8 +4,10 @@ A Guard plugin for smarter Jekyll watching.
|
|
4
4
|
|
5
5
|
Features:
|
6
6
|
|
7
|
-
-
|
8
|
-
-
|
7
|
+
- Changing static files won't trigger a jekyll build! Files are copied/removed instead.
|
8
|
+
- Batched processing! (Adding a directory of `n` files triggers a single build)
|
9
|
+
- Reads options from your YAML config file(s)
|
10
|
+
- Supports multiple config files (Jekyll 1.0)
|
9
11
|
|
10
12
|
## Installation
|
11
13
|
|
@@ -65,9 +67,10 @@ For the most part that's all you'll ever need to do. There are some things you c
|
|
65
67
|
This guard has two configurations.
|
66
68
|
|
67
69
|
| Config | Description | Default
|
68
|
-
|
69
|
-
| `extensions` | Array of file extensions to trigger Jekyll build | ['md','markdown','textile','html','haml','slim','xml'] |
|
70
|
-
| `config` | Array of configuration files | ['_config.yml']
|
70
|
+
|:-------------|:-------------------------------------------------|:---------------------------------------------------------------------------|
|
71
|
+
| `extensions` | Array of file extensions to trigger Jekyll build | ['md', 'mkd', 'markdown', 'textile', 'html', 'haml', 'slim', 'xml', 'yml'] |
|
72
|
+
| `config` | Array of configuration files | ['_config.yml'] |
|
73
|
+
| `serve` | Use Jekyll's build in WEBrick server | false |
|
71
74
|
|
72
75
|
**Note:** customizations to the `extensions` configuration are additive.
|
73
76
|
|
@@ -82,7 +85,7 @@ guard :jekyll, :extensions => ['txt'] do
|
|
82
85
|
end
|
83
86
|
```
|
84
87
|
|
85
|
-
Now Guard will be watching for changes to txt, md, markdown, textile, html, haml, slim, xml files. When these files change Guard will trigger a Jekyll build. Files
|
88
|
+
Now Guard will be watching for changes to txt, md, mkd, markdown, textile, html, haml, slim, xml, yml files. When these files change Guard will trigger a Jekyll build. Files
|
86
89
|
which don't match these extensions will be simply copied over to the destination directory when a change occurs, or deleted if appropriate.
|
87
90
|
|
88
91
|
### Configuring Jekyll config file
|
data/lib/guard/jekyll/version.rb
CHANGED
data/lib/guard/jekyll.rb
CHANGED
@@ -9,17 +9,19 @@ module Guard
|
|
9
9
|
def initialize (watchers=[], options={})
|
10
10
|
super
|
11
11
|
|
12
|
-
default_extensions = ['md','markdown','textile','html','haml','slim','xml','yml']
|
12
|
+
default_extensions = ['md','mkd','markdown','textile','html','haml','slim','xml','yml']
|
13
13
|
|
14
14
|
@options = {
|
15
15
|
:extensions => [],
|
16
|
-
:config => ['_config.yml']
|
16
|
+
:config => ['_config.yml'],
|
17
|
+
:serve => false
|
17
18
|
}.merge(options)
|
18
19
|
|
19
|
-
|
20
|
-
@
|
21
|
-
@
|
22
|
-
@
|
20
|
+
@pid = nil
|
21
|
+
@config = jekyll_config(@options)
|
22
|
+
@site = ::Jekyll::Site.new @config
|
23
|
+
@source = local_path @config['source']
|
24
|
+
@destination = local_path @config['destination']
|
23
25
|
|
24
26
|
extensions = @options[:extensions].concat(default_extensions).flatten.uniq
|
25
27
|
# Convert array of extensions into a regex for matching file extensions eg, /\.md$|\.markdown$|\.html$/i
|
@@ -27,14 +29,26 @@ module Guard
|
|
27
29
|
|
28
30
|
end
|
29
31
|
|
30
|
-
# Calls #run_all if the :all_on_start option is present.
|
31
32
|
def start
|
32
|
-
|
33
|
-
|
33
|
+
|
34
|
+
if @options[:serve]
|
35
|
+
start_server
|
36
|
+
|
37
|
+
UI.info "Guard::Jekyll is watching files and serving at #{@config['host']}:#{@config['port']}#{@config['baseurl']}".bold
|
38
|
+
else
|
39
|
+
build
|
40
|
+
UI.info "Guard::Jekyll is watching".bold
|
41
|
+
end
|
34
42
|
end
|
35
43
|
|
36
|
-
def
|
37
|
-
|
44
|
+
def restart
|
45
|
+
stop if alive?
|
46
|
+
start
|
47
|
+
end
|
48
|
+
|
49
|
+
|
50
|
+
def stop
|
51
|
+
stop_server
|
38
52
|
end
|
39
53
|
|
40
54
|
def run_all
|
@@ -67,7 +81,7 @@ module Guard
|
|
67
81
|
throw :task_has_failed
|
68
82
|
end
|
69
83
|
end
|
70
|
-
|
84
|
+
|
71
85
|
# Copy static files to destination directory
|
72
86
|
#
|
73
87
|
def copy(file)
|
@@ -155,6 +169,40 @@ module Guard
|
|
155
169
|
end
|
156
170
|
end
|
157
171
|
|
172
|
+
def server
|
173
|
+
proc{ Process.spawn "jekyll server --config #{@options[:config].join(',')}" }
|
174
|
+
end
|
175
|
+
|
176
|
+
def kill
|
177
|
+
proc{|pid| Process.kill("QUIT", pid)}
|
178
|
+
end
|
179
|
+
|
180
|
+
def start_server
|
181
|
+
return @pid if alive?
|
182
|
+
@pid = instance_eval &server
|
183
|
+
end
|
184
|
+
|
185
|
+
def stop_server
|
186
|
+
if alive?
|
187
|
+
instance_eval do
|
188
|
+
kill.call(@pid)
|
189
|
+
@pid = nil
|
190
|
+
end
|
191
|
+
end
|
192
|
+
end
|
193
|
+
|
194
|
+
def alive?
|
195
|
+
return false unless @pid
|
196
|
+
|
197
|
+
begin
|
198
|
+
Process.getpgid(@pid)
|
199
|
+
true
|
200
|
+
rescue Errno::ESRCH => e
|
201
|
+
false
|
202
|
+
end
|
203
|
+
end
|
204
|
+
|
205
|
+
|
158
206
|
end
|
159
207
|
end
|
160
208
|
|
data/test/Guardfile
CHANGED
@@ -1,8 +1,11 @@
|
|
1
1
|
# A sample Guardfile
|
2
2
|
# More info at https://github.com/guard/guard#readme
|
3
3
|
#
|
4
|
+
require 'guard/guard'
|
5
|
+
require 'jekyll'
|
4
6
|
|
5
|
-
guard :jekyll do
|
7
|
+
guard :jekyll, :config => ['_config.yml', '_override.yml'], :serve => true do
|
6
8
|
watch /.*/
|
7
9
|
ignore /^_site/
|
8
10
|
end
|
11
|
+
|
data/test/_config.yml
CHANGED
data/test/_override.yml
ADDED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: guard-jekyll-plus
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -67,6 +67,7 @@ files:
|
|
67
67
|
- test/_config.yml
|
68
68
|
- test/_layouts/default.html
|
69
69
|
- test/_layouts/post.html
|
70
|
+
- test/_override.yml
|
70
71
|
- test/_posts/2013-07-08-welcome-to-jekyll.markdown
|
71
72
|
- test/css/main.css
|
72
73
|
- test/css/syntax.css
|