jekyll-watch 2.1.2 → 2.2.1

This diff has not been reviewed by any users.
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: dda724abafdf9fc5f34aac080d4c6e77319f4dae189ef0a28ca3bce7faf2d655
4
- data.tar.gz: 6af86020a15252b2116ed64b8c93b7d75f9293a32c78a4c7f2bbc2989052bdf2
3
+ metadata.gz: 53f200cbdc7896048b0b6c113e6f839e0366755fc267f9a9ef89d6e91cea8c4b
4
+ data.tar.gz: 3d8dc1bf483aa05ca7dbd77b83047cd2957aff25235dd36aea80804dff1e1e1c
5
5
  SHA512:
6
- metadata.gz: fb27525b7571140af739402ad8d4dd1178d07a2574a813e0afd3368d4f46c139c2e3b57576526a9931b4a989d4022fee551283cd190d565fea9e9d50d99b30f1
7
- data.tar.gz: 80f9cefcf191d4bd4f9bbe7a7b1365c52a029d90fe7475cbc61de04f61698c90126d1b8f23700efcc090d49aad521cf358d49b8748d00c8b516029dd83718bce
6
+ metadata.gz: a8af1a4494b66f55c177e75da957167ca1a9076580f4069f0f759dd1e3dfcc592d31fd64cce41ebc00c00faf8003a40d2bd8cbc2cdb082fd9ff3ba63aa078674
7
+ data.tar.gz: 93ae2cd3a37995549186eb78c12a3513c2fc880a702edd9cb40c6a639d5510faa9c3676511f6c9f429e6f0ba73b02b0c36a779209a71b6862f18f12b8e1fdaca
@@ -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"
@@ -1,7 +1,7 @@
1
- # frozen_string_literal: true
2
-
3
- module Jekyll
4
- module Watch
5
- VERSION = "2.1.2"
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
@@ -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 custom_excludes(options)
69
- Array(options["exclude"]).map { |e| Jekyll.sanitized_path(options["source"], e) }
70
- end
71
-
72
- def config_files(options)
73
- %w(yml yaml toml).map do |ext|
74
- Jekyll.sanitized_path(options["source"], "_config.#{ext}")
75
- end
76
- end
77
-
78
- def to_exclude(options)
79
- [
80
- config_files(options),
81
- options["destination"],
82
- custom_excludes(options),
83
- ].flatten
84
- end
85
-
86
- # Paths to ignore for the watch option
87
- #
88
- # options - A Hash of options passed to the command
89
- #
90
- # Returns a list of relative paths from source that should be ignored
91
- def listen_ignore_paths(options)
92
- source = Pathname.new(options["source"]).expand_path
93
- paths = to_exclude(options)
94
-
95
- paths.map do |p|
96
- absolute_path = Pathname.new(p).expand_path
97
- next unless absolute_path.exist?
98
-
99
- begin
100
- relative_path = absolute_path.relative_path_from(source).to_s
101
- unless relative_path.start_with?("../")
102
- path_to_ignore = Regexp.new(Regexp.escape(relative_path))
103
- Jekyll.logger.debug "Watcher:", "Ignoring #{path_to_ignore}"
104
- path_to_ignore
105
- end
106
- rescue ArgumentError
107
- # Could not find a relative path
108
- end
109
- end.compact + [%r!\.jekyll\-metadata!]
110
- end
111
-
112
- def sleep_forever
113
- loop { sleep 1000 }
114
- end
115
-
116
- def process(site, time)
117
- begin
118
- site.process
119
- Jekyll.logger.info "", "...done in #{Time.now - time} seconds."
120
- rescue => e
121
- Jekyll.logger.warn "Error:", e.message
122
- Jekyll.logger.warn "Error:", "Run jekyll build --trace for more information."
123
- end
124
- Jekyll.logger.info ""
125
- end
126
- end
127
- end
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.2
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: 2018-10-17 00:00:00.000000000 Z
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: '1.15'
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: '1.15'
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.2'
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.2'
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.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.