guard-jekyll-plus 2.0.1 → 2.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/README.md +13 -9
- data/lib/guard/jekyll-plus.rb +4 -0
- data/lib/guard/jekyll_plus.rb +5 -0
- data/lib/guard/jekyll_plus/builder/action.rb +10 -5
- data/lib/guard/jekyll_plus/config.rb +5 -1
- data/lib/guard/jekyll_plus/templates/Guardfile +4 -3
- data/lib/guard/jekyll_plus/version.rb +1 -1
- data/spec/lib/guard/jekyll_plus/builder/action_spec.rb +68 -0
- data/spec/lib/guard/{jekyll-plus → jekyll_plus}/builder/adder_spec.rb +2 -0
- data/spec/lib/guard/{jekyll-plus → jekyll_plus}/builder/modifier_spec.rb +3 -0
- data/spec/lib/guard/{jekyll-plus → jekyll_plus}/builder/rebuilder_spec.rb +0 -0
- data/spec/lib/guard/{jekyll-plus → jekyll_plus}/builder/remover_spec.rb +3 -0
- data/spec/lib/guard/{jekyll-plus → jekyll_plus}/builder_spec.rb +0 -0
- data/spec/lib/guard/{jekyll-plus → jekyll_plus}/config_spec.rb +22 -0
- data/spec/lib/guard/{jekyll-plus → jekyll_plus}/server_spec.rb +0 -0
- data/spec/lib/guard/{jekyll-plus_spec.rb → jekyll_plus_spec.rb} +0 -0
- metadata +13 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b4b2b693629d26271552853a0d20a61e86c57c9e
|
4
|
+
data.tar.gz: 78e039344f2b45b5eb5d3c311a4805f757d50c4b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5fdae4a7d830545255df9197f29ae4e82aa1facfbabcf86ba63a59a7edbafaa96da23b6194e03d0c1bc987232ac41ee27319ba1c60d7574147ac1ad79b7b0432
|
7
|
+
data.tar.gz: 940e42475d2420f3ccba64c619aabc436bc7a0c352458e5269f4f7ad21468aed3425ccb8314a513bf74c1d8f093c1e4bd9c14aa9e01142e86efd69e02fc91e3d
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -42,9 +42,10 @@ Navigate to your Jekyll project directory and create a Guardfile using:
|
|
42
42
|
Or if you already have a Guardfile, add a Jekyll guard.
|
43
43
|
|
44
44
|
```ruby
|
45
|
-
|
45
|
+
ignore /^_site/ # NOTE: this can interfere with Guard::LiveReload
|
46
|
+
|
47
|
+
guard "jekyll-plus" do
|
46
48
|
watch /.*/
|
47
|
-
ignore /^_site/
|
48
49
|
end
|
49
50
|
```
|
50
51
|
|
@@ -66,7 +67,7 @@ If your Jekyll project has a non-standard directory stucture like this:
|
|
66
67
|
You would do this instead:
|
67
68
|
|
68
69
|
```ruby
|
69
|
-
guard "
|
70
|
+
guard "jekyll-plus" do
|
70
71
|
watch /^source/
|
71
72
|
watch /_config.yml/
|
72
73
|
end
|
@@ -97,9 +98,10 @@ This guard has these configurations.
|
|
97
98
|
To use Jekyll's built-in server, simply set `:serve => true` in your rack options
|
98
99
|
|
99
100
|
```ruby
|
100
|
-
|
101
|
+
ignore /^_site/ # NOTE: this can interfere with Guard::LiveReload
|
102
|
+
|
103
|
+
guard "jekyll-plus", :serve => true do
|
101
104
|
watch /.*/
|
102
|
-
ignore /^_site/
|
103
105
|
end
|
104
106
|
```
|
105
107
|
|
@@ -115,9 +117,10 @@ If you wish to use your own rack server configuration, simply drop a `config.ru`
|
|
115
117
|
Here's how you would add `txt` to the list of file extensions which triggers a Jekyll build.
|
116
118
|
|
117
119
|
```ruby
|
118
|
-
|
120
|
+
ignore /^_site/ # NOTE: this can interfere with Guard::LiveReload
|
121
|
+
|
122
|
+
guard "jekyll-plus", :extensions => ['txt'] do
|
119
123
|
watch /.*/
|
120
|
-
ignore /^_site/
|
121
124
|
end
|
122
125
|
```
|
123
126
|
|
@@ -129,9 +132,10 @@ which don't match these extensions will be simply copied over to the destination
|
|
129
132
|
Here's how you might tell Jekyll to read from multiple configuration files.
|
130
133
|
|
131
134
|
```ruby
|
132
|
-
|
135
|
+
ignore /^_site/ # NOTE: this can interfere with Guard::LiveReload
|
136
|
+
|
137
|
+
guard "jekyll-plus", :config => ['settings.yml', 'override.yml'] do
|
133
138
|
watch /.*/
|
134
|
-
ignore /^_site/
|
135
139
|
end
|
136
140
|
```
|
137
141
|
|
data/lib/guard/jekyll_plus.rb
CHANGED
@@ -58,11 +58,16 @@ module Guard
|
|
58
58
|
end
|
59
59
|
|
60
60
|
def destination_path(file)
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
61
|
+
src_abs_path = Pathname(@config.source).expand_path
|
62
|
+
|
63
|
+
abs_path = Pathname(file).expand_path
|
64
|
+
rel_path = begin
|
65
|
+
abs_path.relative_path_from(src_abs_path)
|
66
|
+
rescue ArgumentError # probably happens only on Windows
|
67
|
+
raise "File not in Jekyll source dir: #{file}"
|
68
|
+
end
|
69
|
+
|
70
|
+
(Pathname(@config.destination) + rel_path).to_s
|
66
71
|
end
|
67
72
|
|
68
73
|
def build_was_needed(paths)
|
@@ -91,6 +91,10 @@ module Guard
|
|
91
91
|
@jekyll_config['exclude'].any? { |glob| File.fnmatch?(glob, path) }
|
92
92
|
end
|
93
93
|
|
94
|
+
def watch_regexp
|
95
|
+
%r{^(?!#{destination}\/).*}
|
96
|
+
end
|
97
|
+
|
94
98
|
private
|
95
99
|
|
96
100
|
def silent?
|
@@ -123,7 +127,7 @@ module Guard
|
|
123
127
|
if path == ''
|
124
128
|
'./'
|
125
129
|
else
|
126
|
-
path.sub(
|
130
|
+
path.sub(%r{^/}, '')
|
127
131
|
end
|
128
132
|
end
|
129
133
|
end
|
@@ -0,0 +1,68 @@
|
|
1
|
+
require 'guard/jekyll_plus/builder/action'
|
2
|
+
module Guard
|
3
|
+
RSpec.describe JekyllPlus::Builder::Action do
|
4
|
+
let(:site) { instance_double(Jekyll::Site) }
|
5
|
+
let(:config) { instance_double(JekyllPlus::Config) }
|
6
|
+
|
7
|
+
subject { described_class.new(config, site) }
|
8
|
+
|
9
|
+
describe '#destination_path' do
|
10
|
+
let(:source) { '/foo/project' }
|
11
|
+
|
12
|
+
before do
|
13
|
+
allow(config).to receive(:destination).and_return(destination)
|
14
|
+
allow(config).to receive(:source).and_return(source)
|
15
|
+
allow_any_instance_of(Pathname).to receive(:expand_path) do |path|
|
16
|
+
case path
|
17
|
+
when Pathname('/foo/project')
|
18
|
+
Pathname('/foo/project')
|
19
|
+
when Pathname('bar/file.html')
|
20
|
+
Pathname('/foo/project/bar/file.html')
|
21
|
+
when Pathname('/foo/project/bar/file.html')
|
22
|
+
Pathname('/foo/project/bar/file.html')
|
23
|
+
else
|
24
|
+
fail "Unexpected path: #{path.inspect}"
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
context 'when destination is absolute ' do
|
30
|
+
let(:destination) { '/foo/project/public' }
|
31
|
+
let(:expected) { '/foo/project/public/bar/file.html' }
|
32
|
+
|
33
|
+
context 'when file is absolute' do
|
34
|
+
let(:file) { '/foo/project/bar/file.html' }
|
35
|
+
it 'is absolute' do
|
36
|
+
expect(subject.destination_path(file)).to eq expected
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
context 'when file is relative' do
|
41
|
+
let(:file) { 'bar/file.html' }
|
42
|
+
it 'is absolute' do
|
43
|
+
expect(subject.destination_path(file)).to eq expected
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
context 'when destination is relative' do
|
49
|
+
let(:destination) { 'public' }
|
50
|
+
let(:expected) { 'public/bar/file.html' }
|
51
|
+
|
52
|
+
context 'when file is absolute' do
|
53
|
+
let(:file) { '/foo/project/bar/file.html' }
|
54
|
+
it 'is relative ' do
|
55
|
+
expect(subject.destination_path(file)).to eq expected
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
context 'when file is relative' do
|
60
|
+
let(:file) { 'bar/file.html' }
|
61
|
+
it 'is relative ' do
|
62
|
+
expect(subject.destination_path(file)).to eq expected
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
@@ -31,6 +31,7 @@ module Guard
|
|
31
31
|
context 'when assets change' do
|
32
32
|
before do
|
33
33
|
allow(config).to receive(:destination).and_return('bar/')
|
34
|
+
allow(config).to receive(:source).and_return('.')
|
34
35
|
allow(config).to receive(:excluded?).with('foo.jpg').and_return(false)
|
35
36
|
end
|
36
37
|
|
@@ -70,6 +71,7 @@ module Guard
|
|
70
71
|
context 'when an error happens' do
|
71
72
|
before do
|
72
73
|
allow(config).to receive(:destination).and_return('bar/')
|
74
|
+
allow(config).to receive(:source).and_return('.')
|
73
75
|
allow(FileUtils).to receive(:cp).and_raise(Errno::ENOENT, 'foo')
|
74
76
|
allow(config).to receive(:error)
|
75
77
|
allow(config).to receive(:excluded?).with('foo').and_return(false)
|
@@ -31,6 +31,7 @@ module Guard
|
|
31
31
|
context 'when assets change' do
|
32
32
|
before do
|
33
33
|
allow(config).to receive(:destination).and_return('bar/')
|
34
|
+
allow(config).to receive(:source).and_return('.')
|
34
35
|
allow(config).to receive(:excluded?).with('foo.jpg').and_return(false)
|
35
36
|
end
|
36
37
|
|
@@ -43,6 +44,7 @@ module Guard
|
|
43
44
|
context 'when excluded file changes' do
|
44
45
|
before do
|
45
46
|
allow(config).to receive(:destination).and_return('bar/')
|
47
|
+
allow(config).to receive(:source).and_return('.')
|
46
48
|
allow(config).to receive(:excluded?).with('foo.jpg').and_return(true)
|
47
49
|
end
|
48
50
|
|
@@ -89,6 +91,7 @@ module Guard
|
|
89
91
|
context 'when an error happens' do
|
90
92
|
before do
|
91
93
|
allow(config).to receive(:destination).and_return('bar/')
|
94
|
+
allow(config).to receive(:source).and_return('.')
|
92
95
|
allow(FileUtils).to receive(:cp).and_raise(Errno::ENOENT, 'foo')
|
93
96
|
allow(config).to receive(:error)
|
94
97
|
allow(config).to receive(:excluded?).with('foo').and_return(false)
|
File without changes
|
@@ -23,6 +23,7 @@ module Guard
|
|
23
23
|
context 'when asset files are deleted' do
|
24
24
|
before do
|
25
25
|
allow(config).to receive(:destination).and_return('bar/')
|
26
|
+
allow(config).to receive(:source).and_return('.')
|
26
27
|
|
27
28
|
# non existing src file
|
28
29
|
allow(File).to receive(:exist?).with('foo.jpg').and_return(false)
|
@@ -59,6 +60,8 @@ module Guard
|
|
59
60
|
context 'when an error happens' do
|
60
61
|
before do
|
61
62
|
allow(config).to receive(:destination).and_return('bar/')
|
63
|
+
allow(config).to receive(:source).and_return('.')
|
64
|
+
|
62
65
|
allow(config).to receive(:error)
|
63
66
|
allow(File).to receive(:exist?).with('foo').and_return(false)
|
64
67
|
|
File without changes
|
@@ -135,4 +135,26 @@ RSpec.describe Guard::JekyllPlus::Config do
|
|
135
135
|
end
|
136
136
|
end
|
137
137
|
end
|
138
|
+
|
139
|
+
describe '#watch_regexp' do
|
140
|
+
context 'with a destination' do
|
141
|
+
let(:jekyll_config) do
|
142
|
+
valid_jekyll_options.merge('destination' => 'public')
|
143
|
+
end
|
144
|
+
|
145
|
+
it 'matches files outside destination' do
|
146
|
+
expect(subject.watch_regexp).to match('foo')
|
147
|
+
expect(subject.watch_regexp).to match('foo/bar')
|
148
|
+
expect(subject.watch_regexp).to match('foo/public/bar')
|
149
|
+
expect(subject.watch_regexp).to match('foo/public')
|
150
|
+
expect(subject.watch_regexp).to match('publics/bar')
|
151
|
+
end
|
152
|
+
|
153
|
+
it 'does not match files in destination' do
|
154
|
+
expect(subject.watch_regexp).to_not match('public/foo')
|
155
|
+
expect(subject.watch_regexp).to_not match('public/foo/bar')
|
156
|
+
expect(subject.watch_regexp).to_not match('public/foo/public')
|
157
|
+
end
|
158
|
+
end
|
159
|
+
end
|
138
160
|
end
|
File without changes
|
File without changes
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: guard-jekyll-plus
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brandon Mathis
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-05-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: guard
|
@@ -134,6 +134,7 @@ files:
|
|
134
134
|
- README.md
|
135
135
|
- Rakefile
|
136
136
|
- guard-jekyll-plus.gemspec
|
137
|
+
- lib/guard/jekyll-plus.rb
|
137
138
|
- lib/guard/jekyll_plus.rb
|
138
139
|
- lib/guard/jekyll_plus/builder.rb
|
139
140
|
- lib/guard/jekyll_plus/builder/action.rb
|
@@ -146,14 +147,15 @@ files:
|
|
146
147
|
- lib/guard/jekyll_plus/templates/Guardfile
|
147
148
|
- lib/guard/jekyll_plus/version.rb
|
148
149
|
- lib/rack/config.ru
|
149
|
-
- spec/lib/guard/
|
150
|
-
- spec/lib/guard/
|
151
|
-
- spec/lib/guard/
|
152
|
-
- spec/lib/guard/
|
153
|
-
- spec/lib/guard/
|
154
|
-
- spec/lib/guard/
|
155
|
-
- spec/lib/guard/
|
156
|
-
- spec/lib/guard/
|
150
|
+
- spec/lib/guard/jekyll_plus/builder/action_spec.rb
|
151
|
+
- spec/lib/guard/jekyll_plus/builder/adder_spec.rb
|
152
|
+
- spec/lib/guard/jekyll_plus/builder/modifier_spec.rb
|
153
|
+
- spec/lib/guard/jekyll_plus/builder/rebuilder_spec.rb
|
154
|
+
- spec/lib/guard/jekyll_plus/builder/remover_spec.rb
|
155
|
+
- spec/lib/guard/jekyll_plus/builder_spec.rb
|
156
|
+
- spec/lib/guard/jekyll_plus/config_spec.rb
|
157
|
+
- spec/lib/guard/jekyll_plus/server_spec.rb
|
158
|
+
- spec/lib/guard/jekyll_plus_spec.rb
|
157
159
|
- spec/spec_helper.rb
|
158
160
|
- test/.gitignore
|
159
161
|
- test/404.html
|
@@ -191,7 +193,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
191
193
|
version: '0'
|
192
194
|
requirements: []
|
193
195
|
rubyforge_project:
|
194
|
-
rubygems_version: 2.
|
196
|
+
rubygems_version: 2.4.6
|
195
197
|
signing_key:
|
196
198
|
specification_version: 4
|
197
199
|
summary: A Guard plugin for Jekyll which intelligently handles changes to static and
|