jekyll-watch 2.1.2 → 2.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/jekyll-watch.rb +5 -5
- data/lib/jekyll-watch/version.rb +7 -7
- data/lib/jekyll/commands/watch.rb +18 -18
- data/lib/jekyll/watcher.rb +137 -127
- metadata +17 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 53f200cbdc7896048b0b6c113e6f839e0366755fc267f9a9ef89d6e91cea8c4b
|
4
|
+
data.tar.gz: 3d8dc1bf483aa05ca7dbd77b83047cd2957aff25235dd36aea80804dff1e1e1c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a8af1a4494b66f55c177e75da957167ca1a9076580f4069f0f759dd1e3dfcc592d31fd64cce41ebc00c00faf8003a40d2bd8cbc2cdb082fd9ff3ba63aa078674
|
7
|
+
data.tar.gz: 93ae2cd3a37995549186eb78c12a3513c2fc880a702edd9cb40c6a639d5510faa9c3676511f6c9f429e6f0ba73b02b0c36a779209a71b6862f18f12b8e1fdaca
|
data/lib/jekyll-watch.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "jekyll-watch/version"
|
4
|
-
require_relative "jekyll/watcher"
|
5
|
-
require_relative "jekyll/commands/watch"
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "jekyll-watch/version"
|
4
|
+
require_relative "jekyll/watcher"
|
5
|
+
require_relative "jekyll/commands/watch"
|
data/lib/jekyll-watch/version.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Jekyll
|
4
|
-
module Watch
|
5
|
-
VERSION = "2.1
|
6
|
-
end
|
7
|
-
end
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Jekyll
|
4
|
+
module Watch
|
5
|
+
VERSION = "2.2.1"
|
6
|
+
end
|
7
|
+
end
|
@@ -1,18 +1,18 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Jekyll
|
4
|
-
module Commands
|
5
|
-
module Watch
|
6
|
-
extend self
|
7
|
-
|
8
|
-
def init_with_program(prog); end
|
9
|
-
|
10
|
-
# Build your jekyll site
|
11
|
-
# Continuously watch if `watch` is set to true in the config.
|
12
|
-
def process(options)
|
13
|
-
Jekyll.logger.log_level = :error if options["quiet"]
|
14
|
-
Jekyll::Watcher.watch(options) if options["watch"]
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Jekyll
|
4
|
+
module Commands
|
5
|
+
module Watch
|
6
|
+
extend self
|
7
|
+
|
8
|
+
def init_with_program(prog); end
|
9
|
+
|
10
|
+
# Build your jekyll site
|
11
|
+
# Continuously watch if `watch` is set to true in the config.
|
12
|
+
def process(options)
|
13
|
+
Jekyll.logger.log_level = :error if options["quiet"]
|
14
|
+
Jekyll::Watcher.watch(options) if options["watch"]
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
data/lib/jekyll/watcher.rb
CHANGED
@@ -1,127 +1,137 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "listen"
|
4
|
-
|
5
|
-
module Jekyll
|
6
|
-
module Watcher
|
7
|
-
extend self
|
8
|
-
|
9
|
-
# Public: Continuously watch for file changes and rebuild the site
|
10
|
-
# whenever a change is detected.
|
11
|
-
#
|
12
|
-
# If the optional site argument is populated, that site instance will be
|
13
|
-
# reused and the options Hash ignored. Otherwise, a new site instance will
|
14
|
-
# be instantiated from the options Hash and used.
|
15
|
-
#
|
16
|
-
# options - A Hash containing the site configuration
|
17
|
-
# site - The current site instance (populated starting with Jekyll 3.2)
|
18
|
-
# (optional, default: nil)
|
19
|
-
#
|
20
|
-
# Returns nothing.
|
21
|
-
def watch(options, site = nil)
|
22
|
-
ENV["LISTEN_GEM_DEBUGGING"] ||= "1" if options["verbose"]
|
23
|
-
|
24
|
-
site ||= Jekyll::Site.new(options)
|
25
|
-
listener = build_listener(site, options)
|
26
|
-
listener.start
|
27
|
-
|
28
|
-
Jekyll.logger.info "Auto-regeneration:", "enabled for '#{options["source"]}'"
|
29
|
-
|
30
|
-
unless options["serving"]
|
31
|
-
trap("INT") do
|
32
|
-
listener.stop
|
33
|
-
Jekyll.logger.info "", "Halting auto-regeneration."
|
34
|
-
exit 0
|
35
|
-
end
|
36
|
-
|
37
|
-
sleep_forever
|
38
|
-
end
|
39
|
-
rescue ThreadError
|
40
|
-
# You pressed Ctrl-C, oh my!
|
41
|
-
end
|
42
|
-
|
43
|
-
private
|
44
|
-
|
45
|
-
def build_listener(site, options)
|
46
|
-
Listen.to(
|
47
|
-
options["source"],
|
48
|
-
:ignore => listen_ignore_paths(options),
|
49
|
-
:force_polling => options["force_polling"],
|
50
|
-
&listen_handler(site)
|
51
|
-
)
|
52
|
-
end
|
53
|
-
|
54
|
-
def listen_handler(site)
|
55
|
-
proc do |modified, added, removed|
|
56
|
-
t = Time.now
|
57
|
-
c = modified + added + removed
|
58
|
-
n = c.length
|
59
|
-
|
60
|
-
Jekyll.logger.info "Regenerating:",
|
61
|
-
"#{n} file(s) changed at #{t.strftime("%Y-%m-%d %H:%M:%S")}"
|
62
|
-
|
63
|
-
c.each { |path| Jekyll.logger.info "", path["#{site.source}/".length..-1] }
|
64
|
-
process(site, t)
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
68
|
-
def
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "listen"
|
4
|
+
|
5
|
+
module Jekyll
|
6
|
+
module Watcher
|
7
|
+
extend self
|
8
|
+
|
9
|
+
# Public: Continuously watch for file changes and rebuild the site
|
10
|
+
# whenever a change is detected.
|
11
|
+
#
|
12
|
+
# If the optional site argument is populated, that site instance will be
|
13
|
+
# reused and the options Hash ignored. Otherwise, a new site instance will
|
14
|
+
# be instantiated from the options Hash and used.
|
15
|
+
#
|
16
|
+
# options - A Hash containing the site configuration
|
17
|
+
# site - The current site instance (populated starting with Jekyll 3.2)
|
18
|
+
# (optional, default: nil)
|
19
|
+
#
|
20
|
+
# Returns nothing.
|
21
|
+
def watch(options, site = nil)
|
22
|
+
ENV["LISTEN_GEM_DEBUGGING"] ||= "1" if options["verbose"]
|
23
|
+
|
24
|
+
site ||= Jekyll::Site.new(options)
|
25
|
+
listener = build_listener(site, options)
|
26
|
+
listener.start
|
27
|
+
|
28
|
+
Jekyll.logger.info "Auto-regeneration:", "enabled for '#{options["source"]}'"
|
29
|
+
|
30
|
+
unless options["serving"]
|
31
|
+
trap("INT") do
|
32
|
+
listener.stop
|
33
|
+
Jekyll.logger.info "", "Halting auto-regeneration."
|
34
|
+
exit 0
|
35
|
+
end
|
36
|
+
|
37
|
+
sleep_forever
|
38
|
+
end
|
39
|
+
rescue ThreadError
|
40
|
+
# You pressed Ctrl-C, oh my!
|
41
|
+
end
|
42
|
+
|
43
|
+
private
|
44
|
+
|
45
|
+
def build_listener(site, options)
|
46
|
+
Listen.to(
|
47
|
+
options["source"],
|
48
|
+
:ignore => listen_ignore_paths(options),
|
49
|
+
:force_polling => options["force_polling"],
|
50
|
+
&listen_handler(site)
|
51
|
+
)
|
52
|
+
end
|
53
|
+
|
54
|
+
def listen_handler(site)
|
55
|
+
proc do |modified, added, removed|
|
56
|
+
t = Time.now
|
57
|
+
c = modified + added + removed
|
58
|
+
n = c.length
|
59
|
+
|
60
|
+
Jekyll.logger.info "Regenerating:",
|
61
|
+
"#{n} file(s) changed at #{t.strftime("%Y-%m-%d %H:%M:%S")}"
|
62
|
+
|
63
|
+
c.each { |path| Jekyll.logger.info "", path["#{site.source}/".length..-1] }
|
64
|
+
process(site, t)
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
def normalize_encoding(obj, desired_encoding)
|
69
|
+
case obj
|
70
|
+
when Array
|
71
|
+
obj.map { |entry| entry.encode!(desired_encoding, entry.encoding) }
|
72
|
+
when String
|
73
|
+
obj.encode!(desired_encoding, obj.encoding)
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
def custom_excludes(options)
|
78
|
+
Array(options["exclude"]).map { |e| Jekyll.sanitized_path(options["source"], e) }
|
79
|
+
end
|
80
|
+
|
81
|
+
def config_files(options)
|
82
|
+
%w(yml yaml toml).map do |ext|
|
83
|
+
Jekyll.sanitized_path(options["source"], "_config.#{ext}")
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
def to_exclude(options)
|
88
|
+
[
|
89
|
+
config_files(options),
|
90
|
+
options["destination"],
|
91
|
+
custom_excludes(options),
|
92
|
+
].flatten
|
93
|
+
end
|
94
|
+
|
95
|
+
# Paths to ignore for the watch option
|
96
|
+
#
|
97
|
+
# options - A Hash of options passed to the command
|
98
|
+
#
|
99
|
+
# Returns a list of relative paths from source that should be ignored
|
100
|
+
def listen_ignore_paths(options)
|
101
|
+
source = Pathname.new(options["source"]).expand_path
|
102
|
+
paths = to_exclude(options)
|
103
|
+
|
104
|
+
paths.map do |p|
|
105
|
+
absolute_path = Pathname.new(normalize_encoding(p, options["source"].encoding)).expand_path
|
106
|
+
next unless absolute_path.exist?
|
107
|
+
|
108
|
+
begin
|
109
|
+
relative_path = absolute_path.relative_path_from(source).to_s
|
110
|
+
relative_path = File.join(relative_path, "") if absolute_path.directory?
|
111
|
+
unless relative_path.start_with?("../")
|
112
|
+
path_to_ignore = %r!^#{Regexp.escape(relative_path)}!
|
113
|
+
Jekyll.logger.debug "Watcher:", "Ignoring #{path_to_ignore}"
|
114
|
+
path_to_ignore
|
115
|
+
end
|
116
|
+
rescue ArgumentError
|
117
|
+
# Could not find a relative path
|
118
|
+
end
|
119
|
+
end.compact + [%r!^\.jekyll\-metadata!]
|
120
|
+
end
|
121
|
+
|
122
|
+
def sleep_forever
|
123
|
+
loop { sleep 1000 }
|
124
|
+
end
|
125
|
+
|
126
|
+
def process(site, time)
|
127
|
+
begin
|
128
|
+
site.process
|
129
|
+
Jekyll.logger.info "", "...done in #{Time.now - time} seconds."
|
130
|
+
rescue StandardError => e
|
131
|
+
Jekyll.logger.warn "Error:", e.message
|
132
|
+
Jekyll.logger.warn "Error:", "Run jekyll build --trace for more information."
|
133
|
+
end
|
134
|
+
Jekyll.logger.info ""
|
135
|
+
end
|
136
|
+
end
|
137
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jekyll-watch
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.1
|
4
|
+
version: 2.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Parker Moore
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-03-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: listen
|
@@ -28,30 +28,36 @@ dependencies:
|
|
28
28
|
name: bundler
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - "
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - "
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
40
|
+
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: jekyll
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - "
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '3.6'
|
48
|
+
- - "<"
|
49
|
+
- !ruby/object:Gem::Version
|
50
|
+
version: '5.0'
|
48
51
|
type: :development
|
49
52
|
prerelease: false
|
50
53
|
version_requirements: !ruby/object:Gem::Requirement
|
51
54
|
requirements:
|
52
|
-
- - "
|
55
|
+
- - ">="
|
53
56
|
- !ruby/object:Gem::Version
|
54
57
|
version: '3.6'
|
58
|
+
- - "<"
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '5.0'
|
55
61
|
- !ruby/object:Gem::Dependency
|
56
62
|
name: rake
|
57
63
|
requirement: !ruby/object:Gem::Requirement
|
@@ -86,14 +92,14 @@ dependencies:
|
|
86
92
|
requirements:
|
87
93
|
- - "~>"
|
88
94
|
- !ruby/object:Gem::Version
|
89
|
-
version: '0.
|
95
|
+
version: '0.5'
|
90
96
|
type: :development
|
91
97
|
prerelease: false
|
92
98
|
version_requirements: !ruby/object:Gem::Requirement
|
93
99
|
requirements:
|
94
100
|
- - "~>"
|
95
101
|
- !ruby/object:Gem::Version
|
96
|
-
version: '0.
|
102
|
+
version: '0.5'
|
97
103
|
description:
|
98
104
|
email:
|
99
105
|
- parkrmoore@gmail.com
|
@@ -125,7 +131,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
125
131
|
version: '0'
|
126
132
|
requirements: []
|
127
133
|
rubyforge_project:
|
128
|
-
rubygems_version: 2.7.
|
134
|
+
rubygems_version: 2.7.9
|
129
135
|
signing_key:
|
130
136
|
specification_version: 4
|
131
137
|
summary: Rebuild your Jekyll site when a file changes with the `--watch` switch.
|