nanoc-live 1.0.0b5 → 1.0.0b6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/NEWS.md +6 -0
- data/lib/nanoc/live.rb +6 -3
- data/lib/nanoc/live/command_runners/live.rb +37 -0
- data/lib/nanoc/live/commands/live.rb +1 -21
- data/lib/nanoc/live/live_recompiler.rb +109 -107
- data/lib/nanoc/live/version.rb +1 -1
- metadata +19 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dc4fb7c9249c44322e8f50d6ef2cded2d659a8be4856f229c1824f86f76505ba
|
4
|
+
data.tar.gz: 0b15b54e3543b0b22f7b3b27ab2d9374d41fde0525f8b0ca22fe0ae0e61c70f7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 91412105e6511340a5baf4cefbf44b72f5e213733a62d33b9d6f394c0829a23e2bec96bd4725582984d3f713b66b237b259e018b65ae1927b439b749d0b318f4
|
7
|
+
data.tar.gz: 26ff48778052bcdc691c33b5556047e91cda9832ada694aedacfdd06295bdf3e8d2b93393367cb42e4b6e912314c93c22f955531214a961d4910d6b9489cd017
|
data/NEWS.md
CHANGED
data/lib/nanoc/live.rb
CHANGED
@@ -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
|
-
|
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
|
-
|
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,137 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
module Nanoc
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
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
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
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
|
-
|
28
|
-
pipe_write.close
|
16
|
+
private
|
29
17
|
|
30
|
-
site
|
31
|
-
|
32
|
-
|
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
|
-
|
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
|
-
|
41
|
-
|
42
|
-
break if quit.equal?(e)
|
43
|
-
|
44
|
-
$stderr.print 'Reloading site… '
|
45
|
-
$stderr.flush
|
46
|
-
site_loader = Nanoc::Core::SiteLoader.new
|
47
|
-
site = Nanoc::Core::Site.new(
|
48
|
-
config: Nanoc::Core::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
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
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
|
-
|
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
|
-
|
85
|
-
|
86
|
-
|
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
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
compiler = Nanoc::Core::Compiler.new_for(site)
|
95
|
-
listener = Nanoc::CLI::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
|
-
|
105
|
-
|
106
|
-
puts
|
107
|
-
end
|
91
|
+
def unsafe_handle_changes(site, command_runner)
|
92
|
+
time_before = Time.now
|
108
93
|
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
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
|
-
|
117
|
-
|
118
|
-
|
105
|
+
time_after = Time.now
|
106
|
+
puts "Site compiled in #{format('%.2f', time_after - time_before)}s."
|
107
|
+
puts
|
108
|
+
end
|
109
|
+
|
110
|
+
def gen_lib_changes
|
111
|
+
Nanoc::Core::ChangesStream.new do |cl|
|
112
|
+
opts = {
|
113
|
+
latency: 0.1,
|
114
|
+
wait_for_delay: 0.0,
|
115
|
+
}
|
116
|
+
|
117
|
+
listener = Listen.to('lib', opts) { |*| cl.lib }
|
118
|
+
listener.start
|
119
|
+
sleep
|
120
|
+
end
|
119
121
|
end
|
120
|
-
end
|
121
122
|
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
123
|
+
def gen_config_and_rules_changes
|
124
|
+
Nanoc::Core::ChangesStream.new do |cl|
|
125
|
+
opts = {
|
126
|
+
only: /(\/|\A)(nanoc\.yaml|config\.yaml|rules|Rules|rules\.rb|Rules\.rb)\z/,
|
127
|
+
latency: 0.1,
|
128
|
+
wait_for_delay: 0.0,
|
129
|
+
}
|
130
|
+
|
131
|
+
listener = Listen.to('.', opts) { |*| cl.unknown }
|
132
|
+
listener.start
|
133
|
+
sleep
|
134
|
+
end
|
133
135
|
end
|
134
136
|
end
|
135
137
|
end
|
data/lib/nanoc/live/version.rb
CHANGED
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.
|
4
|
+
version: 1.0.0b6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Denis Defreyne
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-03-07 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:
|
28
|
+
name: listen
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
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: '
|
40
|
+
version: '3.0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
42
|
+
name: nanoc-cli
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
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: '
|
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.
|
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.
|
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
|
@@ -103,7 +110,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
103
110
|
- !ruby/object:Gem::Version
|
104
111
|
version: 1.3.1
|
105
112
|
requirements: []
|
106
|
-
rubygems_version: 3.
|
113
|
+
rubygems_version: 3.1.2
|
107
114
|
signing_key:
|
108
115
|
specification_version: 4
|
109
116
|
summary: Live recompilation support for Nanoc
|