guard-jekyll 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/guard/jekyll.rb +24 -16
- data/lib/guard/jekyll/version.rb +1 -1
- metadata +1 -1
data/lib/guard/jekyll.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
1
3
|
require 'guard'
|
2
4
|
require 'guard/guard'
|
3
5
|
|
@@ -6,17 +8,14 @@ require 'jekyll'
|
|
6
8
|
module Guard
|
7
9
|
class Jekyll < Guard
|
8
10
|
|
9
|
-
def initialize(watchers=[], options={})
|
11
|
+
def initialize(watchers = [], options = {})
|
10
12
|
super
|
11
|
-
@
|
12
|
-
options['source'] ||
|
13
|
-
File.dirname("."))
|
13
|
+
@source = options[:source] || File.dirname('.')
|
14
14
|
end
|
15
15
|
|
16
16
|
def start
|
17
|
-
UI.info
|
18
|
-
|
19
|
-
true
|
17
|
+
UI.info 'Guard::Jekyll is watching for file changes'
|
18
|
+
create_site(@source)
|
20
19
|
end
|
21
20
|
|
22
21
|
def run_all
|
@@ -27,30 +26,39 @@ module Guard
|
|
27
26
|
jekyll!
|
28
27
|
end
|
29
28
|
|
30
|
-
def
|
29
|
+
def run_on_additions(paths)
|
30
|
+
jekyll!
|
31
|
+
end
|
32
|
+
|
33
|
+
def run_on_modifications(paths)
|
34
|
+
jekyll!
|
35
|
+
end
|
36
|
+
|
37
|
+
def run_on_removals(paths)
|
31
38
|
jekyll!
|
32
39
|
end
|
33
40
|
|
34
41
|
private
|
35
42
|
|
36
43
|
def jekyll!
|
37
|
-
UI.info
|
44
|
+
UI.info 'Guard::Jekyll running'
|
38
45
|
|
39
|
-
create_site
|
40
46
|
@jekyll_site.process
|
41
47
|
|
42
|
-
UI.info
|
48
|
+
UI.info 'Guard::Jekyll complete'
|
43
49
|
rescue Exception => e
|
44
50
|
UI.error "Guard::Jekyll failed: #{e}"
|
45
51
|
throw :task_has_failed
|
46
52
|
end
|
47
53
|
|
48
|
-
def create_site
|
49
|
-
|
54
|
+
def create_site(source)
|
55
|
+
working_path = File.expand_path(source)
|
56
|
+
|
57
|
+
options = {'source' => working_path}
|
50
58
|
|
51
|
-
unless File.exists? File.join(
|
52
|
-
options['destination'] = File.join(
|
53
|
-
options['plugins'] = File.join(
|
59
|
+
unless File.exists? File.join(working_path, '_config.yml')
|
60
|
+
options['destination'] = File.join(working_path, '_site')
|
61
|
+
options['plugins'] = File.join(working_path, '_plugins')
|
54
62
|
end
|
55
63
|
|
56
64
|
config = ::Jekyll.configuration(options)
|
data/lib/guard/jekyll/version.rb
CHANGED