nanoc-live 1.0.0b4 → 1.0.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 65c330277cb02265c314785ef973bf0e093f346453f0cd6a4b4a844d3151c588
4
- data.tar.gz: 066044f894e764972f609fd987e547950c350706d94888bfe6d05c7a2a4f2ea4
3
+ metadata.gz: 1b877d4835b41771c810a276ffe99a7ae88780680520ee25e2a8e6f0590119d6
4
+ data.tar.gz: 6bd35d4f74a14fb778064b54cd9e8757b91caf14ba8ab8881f521d8ffd69ed77
5
5
  SHA512:
6
- metadata.gz: 6d502fd1be380e617fc84b46541b35417c442f65c081a9d4e3f32e3226391132de755b255ef6790db5378fda813d19226093e3b9fab8e2163d9629e7fdcb0ddc
7
- data.tar.gz: a3428b88a66d5299dbb2db8cdb4c95e5aeaaf517dcd2f540022d7e96d6a70087ab9bf7882ff0490b91c33824bcb6d716160e731cec354aae2fb18bc94c984232
6
+ metadata.gz: 4118180a0c80513acaff000d66fb1618dfcc81629fd4bd4c72ab117b6acea0ade8d9bc9f4089ef47f00783e895a4fcafde43e7ba2f4f4a63d89affde7903015b
7
+ data.tar.gz: 5fd19a25aa6eabbf8a84e3201887be88f3cc3da631ce3d070537472994e24db7b92eb962a1e8ae4466f792ba353ce9f8f4b4f0bca5c508a00c995217f8b9d790
data/NEWS.md CHANGED
@@ -1,35 +1,63 @@
1
1
  # Release notes for nanoc-live
2
2
 
3
+ ## 1.0.0 (2021-02-20)
4
+
5
+ Idential to 1.0.0b8.
6
+
7
+ ## 1.0.0b8 (2021-01-16)
8
+
9
+ Fixes:
10
+
11
+ - Fixed issue which could cause nanoc-live to keep running and use 100% CPU (#1538)
12
+
13
+ ## 1.0.0b7 (2021-01-01)
14
+
15
+ Enhancements:
16
+
17
+ - Added support for Ruby 3.x
18
+
19
+ ## 1.0.0b6 (2020-03-07)
20
+
21
+ Fixes:
22
+
23
+ - Restored compatibility with Nanoc 4.11.14.
24
+
25
+ ## 1.0.0b5 (2019-11-16)
26
+
27
+ Fixes:
28
+
29
+ - Restored compatibility with Nanoc 4.11.13.
30
+
3
31
  ## 1.0.0b4 (2019-04-30)
4
32
 
5
33
  Fixes:
6
34
 
7
- * Restored compatibility with most recent version of Nanoc.
35
+ - Restored compatibility with most recent version of Nanoc.
8
36
 
9
37
  ## 1.0.0b3 (2018-08-31)
10
38
 
11
39
  Fixes:
12
40
 
13
- * Fixed issue which required all command-line options to be specified
41
+ - Fixed issue which required all command-line options to be specified
14
42
 
15
43
  ## 1.0.0b2 (2018-06-10)
16
44
 
17
45
  Fixes:
18
46
 
19
- * Fixed issues that could cause nanoc-live to keep running in the background, using more and more memory and CPU
47
+ - Fixed issues that could cause nanoc-live to keep running in the background, using more and more memory and CPU
20
48
 
21
49
  ## 1.0.0b1 (2018-01-07)
22
50
 
23
51
  Changes:
24
52
 
25
- * Removed `--live-reload` (always enabled) (#1291)
53
+ - Removed `--live-reload` (always enabled) (#1291)
26
54
 
27
55
  ## 1.0.0a2 (2017-12-09)
28
56
 
29
57
  Fixes:
30
58
 
31
- * Added missing dependency on `adsf-live`
32
- * Fixed errors not being printed (#1271)
59
+ - Added missing dependency on `adsf-live`
60
+ - Fixed errors not being printed (#1271)
33
61
 
34
62
  ## 1.0.0a1 (2017-12-03)
35
63
 
data/README.md CHANGED
@@ -1,5 +1,3 @@
1
- # Nanoc::Live
2
-
3
- ⚠️ **Caution:** This project is currently experimental.
1
+ # nanoc-live
4
2
 
5
3
  The _nanoc-live_ gem provides a new `nanoc live` command, and is required to make the `nanoc compile --watch` option work.
data/lib/nanoc/live.rb CHANGED
@@ -3,7 +3,7 @@
3
3
  require 'adsf/live'
4
4
  require 'listen'
5
5
  require 'nanoc'
6
- require 'nanoc/cli'
6
+ require 'nanoc/orig_cli'
7
7
 
8
8
  module Nanoc
9
9
  module Live
@@ -12,9 +12,12 @@ end
12
12
 
13
13
  require_relative 'live/version'
14
14
  require_relative 'live/live_recompiler'
15
+ require_relative 'live/command_runners/live'
16
+
17
+ root = File.dirname(__FILE__)
18
+ live_command_path = File.join(root, 'live', 'commands', 'live.rb')
19
+ command = Cri::Command.load_file(live_command_path, infer_name: true)
15
20
 
16
21
  Nanoc::CLI.after_setup do
17
- root = File.dirname(__FILE__)
18
- live_command_path = File.join(root, 'live', 'commands', 'live.rb')
19
- Nanoc::CLI.add_command(Cri::Command.load_file(live_command_path, infer_name: true))
22
+ Nanoc::CLI.add_command(command)
20
23
  end
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Nanoc
4
+ module Live
5
+ module CommandRunners
6
+ class Live < ::Nanoc::CLI::CommandRunner
7
+ def run
8
+ if defined?(Guard::Nanoc)
9
+ $stderr.puts '-' * 40
10
+ $stderr.puts 'NOTE:'
11
+ $stderr.puts 'You are using the `nanoc live` command provided by `nanoc-live`, but the `guard-nanoc` gem is also installed, which also provides a `nanoc live` command.'
12
+ if defined?(Bundler)
13
+ $stderr.puts 'Recommendation: Remove `guard-nanoc` from your Gemfile.'
14
+ else
15
+ $stderr.puts 'Recommendation: Uninstall `guard-nanoc`.'
16
+ end
17
+ $stderr.puts '-' * 40
18
+ end
19
+
20
+ self.class.enter_site_dir
21
+
22
+ Thread.new do
23
+ Thread.current.abort_on_exception = true
24
+ if Thread.current.respond_to?(:report_on_exception)
25
+ Thread.current.report_on_exception = false
26
+ end
27
+
28
+ view_options = options.merge('live-reload': true)
29
+ Nanoc::CLI::Commands::View.new(view_options, [], self).run
30
+ end
31
+
32
+ Nanoc::Live::LiveRecompiler.new(command_runner: self).run
33
+ end
34
+ end
35
+ end
36
+ end
37
+ end
@@ -13,24 +13,4 @@ required :o, :host, 'specify the host to listen on (default: 127.0.0.1)', def
13
13
  required :p, :port, 'specify the port to listen on (default: 3000)', transform: Nanoc::CLI::Transform::Port, default: 3000
14
14
  no_params
15
15
 
16
- module Nanoc::Live::Commands
17
- class Live < ::Nanoc::CLI::CommandRunner
18
- def run
19
- self.class.enter_site_dir
20
-
21
- Thread.new do
22
- Thread.current.abort_on_exception = true
23
- if Thread.current.respond_to?(:report_on_exception)
24
- Thread.current.report_on_exception = false
25
- end
26
-
27
- view_options = options.merge('live-reload': true)
28
- Nanoc::CLI::Commands::View.new(view_options, [], self).run
29
- end
30
-
31
- Nanoc::Live::LiveRecompiler.new(command_runner: self).run
32
- end
33
- end
34
- end
35
-
36
- runner Nanoc::Live::Commands::Live
16
+ runner Nanoc::Live::CommandRunners::Live
@@ -1,135 +1,128 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module Nanoc::Live
4
- class LiveRecompiler
5
- def initialize(command_runner:)
6
- @command_runner = command_runner
7
- end
8
-
9
- def run
10
- run_parent do |site|
11
- handle_changes(site, @command_runner)
3
+ module Nanoc
4
+ module Live
5
+ class LiveRecompiler
6
+ def initialize(command_runner:)
7
+ @command_runner = command_runner
12
8
  end
13
- end
14
9
 
15
- private
16
-
17
- def gen_changes_for_child(site)
18
- changes = [
19
- site.data_source.item_changes,
20
- site.data_source.layout_changes,
21
- gen_config_and_rules_changes,
22
- ]
23
-
24
- SlowEnumeratorTools.batch(SlowEnumeratorTools.merge(changes))
25
- end
10
+ def run
11
+ run_parent do |site|
12
+ handle_changes(site, @command_runner)
13
+ end
14
+ end
26
15
 
27
- def run_child(pipe_write, pipe_read)
28
- pipe_write.close
16
+ private
29
17
 
30
- site = Nanoc::Int::SiteLoader.new.new_from_cwd
31
- changes_enum = gen_changes_for_child(site)
32
- yield(site)
18
+ def gen_changes_for_child(site)
19
+ changes = [
20
+ site.data_source.item_changes,
21
+ site.data_source.layout_changes,
22
+ gen_config_and_rules_changes,
23
+ ]
33
24
 
34
- quit = Object.new
35
- parent_enum = Enumerator.new do |y|
36
- pipe_read.read
37
- y << quit
25
+ SlowEnumeratorTools.batch(SlowEnumeratorTools.merge(changes))
38
26
  end
39
27
 
40
- puts 'Listening for site changes…'
41
- SlowEnumeratorTools.merge([parent_enum, changes_enum]).each do |e|
42
- break if quit.equal?(e)
43
-
44
- $stderr.print 'Reloading site… '
45
- $stderr.flush
46
- site_loader = Nanoc::Int::SiteLoader.new
47
- site = Nanoc::Core::Site.new(
48
- config: Nanoc::Int::ConfigLoader.new.new_from_cwd,
49
- data_source: site_loader.gen_data_source_for_config(site.config),
50
- code_snippets: site.code_snippets,
51
- )
52
- $stderr.puts 'done'
28
+ def run_child(pipe_write, pipe_read)
29
+ pipe_write.close
53
30
 
31
+ site = Nanoc::Core::SiteLoader.new.new_from_cwd
32
+ changes_enum = gen_changes_for_child(site)
54
33
  yield(site)
55
- end
56
-
57
- exit 0
58
- rescue Interrupt
59
- exit 0
60
- end
61
34
 
62
- def run_parent
63
- # create initial child
64
- pipe_read, pipe_write = IO.pipe
65
- fork { run_child(pipe_write, pipe_read) { |s| yield(s) } }
66
- pipe_read.close
67
-
68
- changes = gen_lib_changes
69
- puts 'Listening for lib/ changes…'
70
- changes.each do |_e|
71
- # stop child
72
- pipe_write.write('q')
73
- pipe_write.close
74
- Process.wait
35
+ quit = Object.new
36
+ parent_enum = Enumerator.new do |y|
37
+ pipe_read.read
38
+ y << quit
39
+ end
40
+
41
+ puts 'Listening for site changes…'
42
+ SlowEnumeratorTools.merge([parent_enum, changes_enum]).each do |e|
43
+ break if quit.equal?(e)
44
+
45
+ $stderr.print 'Reloading site… '
46
+ $stderr.flush
47
+ site_loader = Nanoc::Core::SiteLoader.new
48
+ site = Nanoc::Core::Site.new(
49
+ config: Nanoc::Core::ConfigLoader.new.new_from_cwd,
50
+ data_source: site_loader.gen_data_source_for_config(site.config),
51
+ code_snippets: site.code_snippets,
52
+ )
53
+ $stderr.puts 'done'
54
+
55
+ yield(site)
56
+ end
57
+
58
+ exit 0
59
+ rescue Interrupt
60
+ exit 0
61
+ end
75
62
 
76
- # create new child
63
+ def run_parent
64
+ # create initial child
77
65
  pipe_read, pipe_write = IO.pipe
78
66
  fork { run_child(pipe_write, pipe_read) { |s| yield(s) } }
79
67
  pipe_read.close
80
- end
81
- rescue Interrupt
82
- end
83
68
 
84
- def handle_changes(site, command_runner)
85
- Nanoc::CLI::ErrorHandler.handle_while(exit_on_error: false) do
86
- unsafe_handle_changes(site, command_runner)
69
+ changes = gen_lib_changes
70
+ puts 'Listening for lib/ changes…'
71
+ changes.each do |_e|
72
+ # stop child
73
+ pipe_write.write('q')
74
+ pipe_write.close
75
+ Process.wait
76
+
77
+ # create new child
78
+ pipe_read, pipe_write = IO.pipe
79
+ fork { run_child(pipe_write, pipe_read) { |s| yield(s) } }
80
+ pipe_read.close
81
+ end
82
+ rescue Interrupt
87
83
  end
88
- end
89
84
 
90
- def unsafe_handle_changes(site, command_runner)
91
- time_before = Time.now
92
-
93
- puts 'Compiling site…'
94
- compiler = Nanoc::Int::Compiler.new_for(site)
95
- listener = Nanoc::CLI::Commands::CompileListeners::Aggregate.new(
96
- command_runner: command_runner,
97
- site: site,
98
- compiler: compiler,
99
- )
100
- listener.run_while do
101
- compiler.run_until_end
85
+ def handle_changes(site, command_runner)
86
+ Nanoc::CLI::ErrorHandler.handle_while(exit_on_error: false) do
87
+ unsafe_handle_changes(site, command_runner)
88
+ end
102
89
  end
103
90
 
104
- time_after = Time.now
105
- puts "Site compiled in #{format('%.2f', time_after - time_before)}s."
106
- puts
107
- end
91
+ def unsafe_handle_changes(site, command_runner)
92
+ time_before = Time.now
108
93
 
109
- def gen_lib_changes
110
- Nanoc::ChangesStream.new do |cl|
111
- opts = {
112
- latency: 0.0,
113
- wait_for_delay: 0.0,
114
- }
94
+ puts 'Compiling site…'
95
+ compiler = Nanoc::Core::Compiler.new_for(site)
96
+ listener = Nanoc::CLI::CompileListeners::Aggregate.new(
97
+ command_runner: command_runner,
98
+ site: site,
99
+ compiler: compiler,
100
+ )
101
+ listener.run_while do
102
+ compiler.run_until_end
103
+ end
115
104
 
116
- listener = Listen.to('lib', opts) { |*| cl.lib }
117
- listener.start
118
- sleep
105
+ time_after = Time.now
106
+ puts "Site compiled in #{format('%.2f', time_after - time_before)}s."
107
+ puts
119
108
  end
120
- end
121
109
 
122
- def gen_config_and_rules_changes
123
- Nanoc::ChangesStream.new do |cl|
124
- opts = {
125
- only: /(\/|\A)(nanoc\.yaml|config\.yaml|rules|Rules|rules\.rb|Rules\.rb)\z/,
126
- latency: 0.0,
127
- wait_for_delay: 0.0,
128
- }
129
-
130
- listener = Listen.to('.', opts) { |*| cl.unknown }
131
- listener.start
132
- sleep
110
+ def gen_lib_changes
111
+ Nanoc::Core::ChangesStream.new do |cl|
112
+ listener = Listen.to('lib') { |*| cl.lib }
113
+ listener.start
114
+ sleep
115
+ end
116
+ end
117
+
118
+ def gen_config_and_rules_changes
119
+ Nanoc::Core::ChangesStream.new do |cl|
120
+ only = /(\/|\A)(nanoc\.yaml|config\.yaml|rules|Rules|rules\.rb|Rules\.rb)\z/
121
+
122
+ listener = Listen.to('.', only: only) { |*| cl.unknown }
123
+ listener.start
124
+ sleep
125
+ end
133
126
  end
134
127
  end
135
128
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Nanoc
4
4
  module Live
5
- VERSION = '1.0.0b4'
5
+ VERSION = '1.0.0'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nanoc-live
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0b4
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Denis Defreyne
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-04-30 00:00:00.000000000 Z
11
+ date: 2021-02-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: adsf-live
@@ -25,35 +25,41 @@ dependencies:
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.4'
27
27
  - !ruby/object:Gem::Dependency
28
- name: cri
28
+ name: listen
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '2.13'
33
+ version: '3.0'
34
34
  type: :runtime
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: '2.13'
40
+ version: '3.0'
41
41
  - !ruby/object:Gem::Dependency
42
- name: listen
42
+ name: nanoc-cli
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '3.0'
47
+ version: '4.11'
48
+ - - ">="
49
+ - !ruby/object:Gem::Version
50
+ version: 4.11.14
48
51
  type: :runtime
49
52
  prerelease: false
50
53
  version_requirements: !ruby/object:Gem::Requirement
51
54
  requirements:
52
55
  - - "~>"
53
56
  - !ruby/object:Gem::Version
54
- version: '3.0'
57
+ version: '4.11'
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ version: 4.11.14
55
61
  - !ruby/object:Gem::Dependency
56
- name: nanoc
62
+ name: nanoc-core
57
63
  requirement: !ruby/object:Gem::Requirement
58
64
  requirements:
59
65
  - - "~>"
@@ -61,7 +67,7 @@ dependencies:
61
67
  version: '4.11'
62
68
  - - ">="
63
69
  - !ruby/object:Gem::Version
64
- version: 4.11.5
70
+ version: 4.11.14
65
71
  type: :runtime
66
72
  prerelease: false
67
73
  version_requirements: !ruby/object:Gem::Requirement
@@ -71,7 +77,7 @@ dependencies:
71
77
  version: '4.11'
72
78
  - - ">="
73
79
  - !ruby/object:Gem::Version
74
- version: 4.11.5
80
+ version: 4.11.14
75
81
  description: Provides support for auto-recompiling Nanoc sites.
76
82
  email: denis+rubygems@denis.ws
77
83
  executables: []
@@ -81,6 +87,7 @@ files:
81
87
  - NEWS.md
82
88
  - README.md
83
89
  - lib/nanoc/live.rb
90
+ - lib/nanoc/live/command_runners/live.rb
84
91
  - lib/nanoc/live/commands/live.rb
85
92
  - lib/nanoc/live/live_recompiler.rb
86
93
  - lib/nanoc/live/version.rb
@@ -88,23 +95,23 @@ homepage: https://nanoc.ws/
88
95
  licenses:
89
96
  - MIT
90
97
  metadata: {}
91
- post_install_message:
98
+ post_install_message:
92
99
  rdoc_options: []
93
100
  require_paths:
94
101
  - lib
95
102
  required_ruby_version: !ruby/object:Gem::Requirement
96
103
  requirements:
97
- - - "~>"
104
+ - - ">="
98
105
  - !ruby/object:Gem::Version
99
- version: '2.4'
106
+ version: '2.5'
100
107
  required_rubygems_version: !ruby/object:Gem::Requirement
101
108
  requirements:
102
- - - ">"
109
+ - - ">="
103
110
  - !ruby/object:Gem::Version
104
- version: 1.3.1
111
+ version: '0'
105
112
  requirements: []
106
- rubygems_version: 3.0.3
107
- signing_key:
113
+ rubygems_version: 3.2.11
114
+ signing_key:
108
115
  specification_version: 4
109
116
  summary: Live recompilation support for Nanoc
110
117
  test_files: []