nanoc 4.8.10 → 4.8.11
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/.rubocop.yml +6 -0
- data/NEWS.md +7 -0
- data/lib/nanoc.rb +11 -6
- data/lib/nanoc/base.rb +1 -0
- data/lib/nanoc/base/changes_stream.rb +53 -0
- data/lib/nanoc/base/contracts_support.rb +0 -2
- data/lib/nanoc/base/feature.rb +3 -0
- data/lib/nanoc/base/memoization.rb +0 -2
- data/lib/nanoc/base/repos/aggregate_data_source.rb +8 -0
- data/lib/nanoc/base/repos/data_source.rb +12 -0
- data/lib/nanoc/base/repos/in_mem_data_source.rb +10 -1
- data/lib/nanoc/base/repos/prefixed_data_source.rb +8 -0
- data/lib/nanoc/base/repos/site_loader.rb +11 -7
- data/lib/nanoc/base/services/compiler.rb +2 -3
- data/lib/nanoc/base/services/compiler/stages/postprocess.rb +2 -3
- data/lib/nanoc/base/services/compiler/stages/preprocess.rb +1 -1
- data/lib/nanoc/base/services/pruner.rb +0 -2
- data/lib/nanoc/base/services/temp_filename_factory.rb +0 -2
- data/lib/nanoc/checking/checks/external_links.rb +0 -5
- data/lib/nanoc/checking/checks/internal_links.rb +0 -2
- data/lib/nanoc/checking/checks/stale.rb +0 -2
- data/lib/nanoc/cli.rb +7 -1
- data/lib/nanoc/cli/commands/compile_listeners/diff_generator.rb +0 -3
- data/lib/nanoc/cli/commands/live.rb +30 -0
- data/lib/nanoc/cli/commands/view.rb +4 -5
- data/lib/nanoc/cli/error_handler.rb +52 -36
- data/lib/nanoc/cli/logger.rb +0 -2
- data/lib/nanoc/cli/stack_trace_writer.rb +50 -0
- data/lib/nanoc/data_sources/filesystem.rb +25 -0
- data/lib/nanoc/extra.rb +1 -0
- data/lib/nanoc/extra/jruby_nokogiri_warner.rb +0 -2
- data/lib/nanoc/extra/link_collector.rb +0 -2
- data/lib/nanoc/extra/live_recompiler.rb +131 -0
- data/lib/nanoc/extra/parallel_collection.rb +0 -2
- data/lib/nanoc/extra/piper.rb +0 -2
- data/lib/nanoc/filters/relativize_paths.rb +8 -7
- data/lib/nanoc/helpers/link_to.rb +0 -2
- data/lib/nanoc/rule_dsl/action_provider.rb +2 -2
- data/lib/nanoc/version.rb +1 -1
- data/nanoc.gemspec +15 -4
- data/nanoc.manifest +545 -0
- data/spec/manifest_spec.rb +22 -0
- data/spec/nanoc/base/changes_stream_spec.rb +45 -0
- data/spec/nanoc/base/checksummer_spec.rb +0 -2
- data/spec/nanoc/base/directed_graph_spec.rb +66 -0
- data/spec/nanoc/base/entities/code_snippet_spec.rb +9 -0
- data/spec/nanoc/base/entities/context_spec.rb +26 -0
- data/spec/nanoc/base/entities/identifiable_collection_spec.rb +53 -0
- data/spec/nanoc/base/repos/aggregate_data_source_spec.rb +87 -0
- data/spec/nanoc/base/repos/data_source_spec.rb +95 -0
- data/spec/nanoc/base/repos/in_mem_data_source_spec.rb +39 -0
- data/spec/nanoc/base/repos/prefixed_data_source_spec.rb +39 -0
- data/spec/nanoc/cli/error_handler_spec.rb +43 -0
- data/spec/nanoc/cli/stack_trace_writer_spec.rb +156 -0
- data/spec/nanoc/data_sources/filesystem_spec.rb +46 -0
- data/spec/nanoc/extra/live_recompiler_spec.rb +129 -0
- data/spec/nanoc/helpers/blogging_spec.rb +1 -1
- data/spec/spec_helper.rb +60 -0
- data/test/base/test_compiler.rb +11 -11
- data/test/cli/test_cli.rb +0 -1
- data/test/cli/test_error_handler.rb +4 -5
- data/test/filters/test_relativize_paths.rb +30 -0
- data/test/filters/test_sass.rb +3 -3
- data/test/rule_dsl/test_compiler_dsl.rb +2 -2
- metadata +39 -43
- data/.github/CONTRIBUTING.md +0 -17
- data/.github/ISSUE_TEMPLATE.md +0 -23
- data/.github/PULL_REQUEST_TEMPLATE.md +0 -18
- data/.gitignore +0 -10
- data/.travis.yml +0 -27
- data/Gemfile +0 -73
- data/Guardfile +0 -5
- data/scripts/release +0 -95
- data/test/base/test_code_snippet.rb +0 -17
- data/test/base/test_context.rb +0 -35
- data/test/base/test_data_source.rb +0 -60
- data/test/base/test_directed_graph.rb +0 -56
- data/test/base/test_item_array.rb +0 -37
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 686e6a239ceae1d59678f267f4aa4c5dfc46b45e
|
4
|
+
data.tar.gz: e80de3bfc0c9475292ad4f9f4fa886f87bd272a8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b476ce18ea4cdd880de849b64bc5c8bbe1287a1b3cbd67a7a54a0fa079812107d9448f839785b391ae192147f331facb47e89d828a65c896aae5dad8b40a5c08
|
7
|
+
data.tar.gz: 8ffcb7d57ea237b0fef6490828d960247fd618c814990e14f0f707a55831f8288b2666cc21693792452f3d9d1e475aa9c33cbebc6807405d7749cda3022fedc9
|
data/.rubocop.yml
CHANGED
@@ -45,6 +45,7 @@ Lint/NestedMethodDefinition:
|
|
45
45
|
Style/GlobalVars:
|
46
46
|
Exclude:
|
47
47
|
- 'test/**/*.rb'
|
48
|
+
- 'spec/**/*.rb'
|
48
49
|
|
49
50
|
|
50
51
|
|
@@ -165,3 +166,8 @@ Style/GuardClause:
|
|
165
166
|
# Used for “undo work, whatever error happens”
|
166
167
|
Lint/RescueWithoutErrorClass:
|
167
168
|
Enabled: false
|
169
|
+
|
170
|
+
# For the sake of consistency, it makes the most sense to retain $stderr.puts
|
171
|
+
# when used in situations where $stderr.flush, $stderr.print, … are also used.
|
172
|
+
Style/StderrPuts:
|
173
|
+
Enabled: false
|
data/NEWS.md
CHANGED
data/lib/nanoc.rb
CHANGED
@@ -19,28 +19,33 @@ module Nanoc
|
|
19
19
|
end
|
20
20
|
|
21
21
|
# Load external dependencies
|
22
|
+
require 'addressable'
|
23
|
+
require 'ddplugin'
|
22
24
|
require 'hamster'
|
23
25
|
require 'ref'
|
24
|
-
require '
|
25
|
-
require 'addressable'
|
26
|
+
require 'slow_enumerator_tools'
|
26
27
|
|
27
28
|
# Load general requirements
|
28
29
|
require 'cgi'
|
29
30
|
require 'digest'
|
30
|
-
require '
|
31
|
+
require 'English'
|
31
32
|
require 'fiber'
|
32
33
|
require 'fileutils'
|
34
|
+
require 'find'
|
33
35
|
require 'forwardable'
|
36
|
+
require 'net/http'
|
37
|
+
require 'net/https'
|
38
|
+
require 'open3'
|
34
39
|
require 'pathname'
|
35
40
|
require 'pstore'
|
36
41
|
require 'set'
|
37
42
|
require 'singleton'
|
38
43
|
require 'tempfile'
|
39
|
-
require 'thread'
|
40
44
|
require 'time'
|
41
|
-
require '
|
45
|
+
require 'timeout'
|
46
|
+
require 'tmpdir'
|
42
47
|
require 'uri'
|
43
|
-
require '
|
48
|
+
require 'yaml'
|
44
49
|
|
45
50
|
# Load Nanoc
|
46
51
|
require 'nanoc/version'
|
data/lib/nanoc/base.rb
CHANGED
@@ -0,0 +1,53 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Nanoc
|
4
|
+
class ChangesStream
|
5
|
+
class ChangesListener
|
6
|
+
def initialize(y)
|
7
|
+
@y = y
|
8
|
+
end
|
9
|
+
|
10
|
+
def unknown
|
11
|
+
@y << :unknown
|
12
|
+
end
|
13
|
+
|
14
|
+
def lib
|
15
|
+
@y << :lib
|
16
|
+
end
|
17
|
+
|
18
|
+
def to_stop(&block)
|
19
|
+
if block_given?
|
20
|
+
@to_stop = block
|
21
|
+
else
|
22
|
+
@to_stop
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def initialize(enum: nil)
|
28
|
+
@enum = enum
|
29
|
+
@enum ||=
|
30
|
+
Enumerator.new do |y|
|
31
|
+
@listener = ChangesListener.new(y)
|
32
|
+
yield(@listener)
|
33
|
+
end.lazy
|
34
|
+
end
|
35
|
+
|
36
|
+
def stop
|
37
|
+
@listener&.to_stop&.call
|
38
|
+
end
|
39
|
+
|
40
|
+
def map
|
41
|
+
self.class.new(enum: @enum.map { |e| yield(e) })
|
42
|
+
end
|
43
|
+
|
44
|
+
def to_enum
|
45
|
+
@enum
|
46
|
+
end
|
47
|
+
|
48
|
+
def each
|
49
|
+
@enum.each { |e| yield(e) }
|
50
|
+
nil
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
data/lib/nanoc/base/feature.rb
CHANGED
@@ -22,5 +22,13 @@ module Nanoc::Int
|
|
22
22
|
Nanoc::Int::LayoutCollection.new(@config, objs)
|
23
23
|
end
|
24
24
|
end
|
25
|
+
|
26
|
+
def item_changes
|
27
|
+
SlowEnumeratorTools.merge(@data_sources.map(&:item_changes))
|
28
|
+
end
|
29
|
+
|
30
|
+
def layout_changes
|
31
|
+
SlowEnumeratorTools.merge(@data_sources.map(&:layout_changes))
|
32
|
+
end
|
25
33
|
end
|
26
34
|
end
|
@@ -98,6 +98,18 @@ module Nanoc
|
|
98
98
|
[]
|
99
99
|
end
|
100
100
|
|
101
|
+
# @api private
|
102
|
+
def item_changes
|
103
|
+
warn "Caution: Data source #{self.class.identifier.inspect} does not implement #item_changes; live compilation will not pick up changes in this data source."
|
104
|
+
Enumerator.new { |_y| sleep }
|
105
|
+
end
|
106
|
+
|
107
|
+
# @api private
|
108
|
+
def layout_changes
|
109
|
+
warn "Caution: Data source #{self.class.identifier.inspect} does not implement #layout_changes; live compilation will not pick up changes in this data source."
|
110
|
+
Enumerator.new { |_y| sleep }
|
111
|
+
end
|
112
|
+
|
101
113
|
# Returns the collection of layouts (represented by {Nanoc::Int::Layout}) in
|
102
114
|
# this site. The default implementation simply returns an empty array.
|
103
115
|
#
|
@@ -5,11 +5,20 @@ module Nanoc::Int
|
|
5
5
|
attr_reader :items
|
6
6
|
attr_reader :layouts
|
7
7
|
|
8
|
-
def initialize(items, layouts)
|
8
|
+
def initialize(items, layouts, orig_data_source = nil)
|
9
9
|
super({}, '/', '/', {})
|
10
10
|
|
11
11
|
@items = items
|
12
12
|
@layouts = layouts
|
13
|
+
@orig_data_source = orig_data_source
|
14
|
+
end
|
15
|
+
|
16
|
+
def item_changes
|
17
|
+
@orig_data_source ? @orig_data_source.item_changes : super
|
18
|
+
end
|
19
|
+
|
20
|
+
def layout_changes
|
21
|
+
@orig_data_source ? @orig_data_source.layout_changes : super
|
13
22
|
end
|
14
23
|
end
|
15
24
|
end
|
@@ -17,5 +17,13 @@ module Nanoc::Int
|
|
17
17
|
def layouts
|
18
18
|
@data_source.layouts.map { |d| d.with_identifier_prefix(@layouts_prefix) }
|
19
19
|
end
|
20
|
+
|
21
|
+
def item_changes
|
22
|
+
@data_source.item_changes
|
23
|
+
end
|
24
|
+
|
25
|
+
def layout_changes
|
26
|
+
@data_source.layout_changes
|
27
|
+
end
|
20
28
|
end
|
21
29
|
end
|
@@ -19,12 +19,7 @@ module Nanoc::Int
|
|
19
19
|
Nanoc::Int::ConfigLoader.cwd_is_nanoc_site?
|
20
20
|
end
|
21
21
|
|
22
|
-
|
23
|
-
|
24
|
-
def site_from_config(config)
|
25
|
-
code_snippets = code_snippets_from_config(config)
|
26
|
-
code_snippets.each(&:load)
|
27
|
-
|
22
|
+
def gen_data_source_for_config(config)
|
28
23
|
data_sources_to_aggregate =
|
29
24
|
with_data_sources(config) do |data_sources|
|
30
25
|
data_sources.map do |ds|
|
@@ -32,7 +27,16 @@ module Nanoc::Int
|
|
32
27
|
end
|
33
28
|
end
|
34
29
|
|
35
|
-
|
30
|
+
Nanoc::Int::AggregateDataSource.new(data_sources_to_aggregate, config)
|
31
|
+
end
|
32
|
+
|
33
|
+
private
|
34
|
+
|
35
|
+
def site_from_config(config)
|
36
|
+
code_snippets = code_snippets_from_config(config)
|
37
|
+
code_snippets.each(&:load)
|
38
|
+
|
39
|
+
data_source = gen_data_source_for_config(config)
|
36
40
|
|
37
41
|
Nanoc::Int::Site.new(
|
38
42
|
config: config,
|
@@ -78,7 +78,7 @@ module Nanoc::Int
|
|
78
78
|
run_stage(prune_stage(reps))
|
79
79
|
run_stage(compile_reps_stage(action_sequences, reps))
|
80
80
|
run_stage(store_post_compilation_state_stage)
|
81
|
-
run_stage(postprocess_stage
|
81
|
+
run_stage(postprocess_stage, self)
|
82
82
|
ensure
|
83
83
|
run_stage(cleanup_stage)
|
84
84
|
end
|
@@ -191,11 +191,10 @@ module Nanoc::Int
|
|
191
191
|
)
|
192
192
|
end
|
193
193
|
|
194
|
-
def postprocess_stage
|
194
|
+
def postprocess_stage
|
195
195
|
@_postprocess_stage ||= Stages::Postprocess.new(
|
196
196
|
action_provider: @action_provider,
|
197
197
|
site: @site,
|
198
|
-
reps: reps,
|
199
198
|
)
|
200
199
|
end
|
201
200
|
|
@@ -4,15 +4,14 @@ module Nanoc::Int::Compiler::Stages
|
|
4
4
|
class Postprocess
|
5
5
|
include Nanoc::Int::ContractsSupport
|
6
6
|
|
7
|
-
def initialize(action_provider:, site
|
7
|
+
def initialize(action_provider:, site:)
|
8
8
|
@action_provider = action_provider
|
9
9
|
@site = site
|
10
|
-
@reps = reps
|
11
10
|
end
|
12
11
|
|
13
12
|
contract Nanoc::Int::Compiler => C::Any
|
14
13
|
def run(compiler)
|
15
|
-
@action_provider.postprocess(@site, compiler
|
14
|
+
@action_provider.postprocess(@site, compiler)
|
16
15
|
end
|
17
16
|
end
|
18
17
|
end
|
@@ -13,7 +13,7 @@ module Nanoc::Int::Compiler::Stages
|
|
13
13
|
return if @site.preprocessed?
|
14
14
|
|
15
15
|
if @action_provider.need_preprocessing?
|
16
|
-
@site.data_source = Nanoc::Int::InMemDataSource.new(@site.items, @site.layouts)
|
16
|
+
@site.data_source = Nanoc::Int::InMemDataSource.new(@site.items, @site.layouts, @site.data_source)
|
17
17
|
@action_provider.preprocess(@site)
|
18
18
|
|
19
19
|
@dependency_store.items = @site.items
|
data/lib/nanoc/cli.rb
CHANGED
@@ -20,6 +20,7 @@ require_relative 'cli/command_runner'
|
|
20
20
|
require_relative 'cli/cleaning_stream'
|
21
21
|
require_relative 'cli/stream_cleaners'
|
22
22
|
require_relative 'cli/error_handler'
|
23
|
+
require_relative 'cli/stack_trace_writer'
|
23
24
|
|
24
25
|
require_relative 'cli/commands/compile_listeners/abstract'
|
25
26
|
require_relative 'cli/commands/compile_listeners/debug_printer'
|
@@ -113,7 +114,12 @@ module Nanoc::CLI
|
|
113
114
|
# Add other commands
|
114
115
|
cmd_filenames = Dir[__dir__ + '/cli/commands/*.rb']
|
115
116
|
cmd_filenames.each do |cmd_filename|
|
116
|
-
|
117
|
+
basename = File.basename(cmd_filename, '.rb')
|
118
|
+
|
119
|
+
next if basename == 'nanoc'
|
120
|
+
|
121
|
+
next if basename == 'live' && !Nanoc::Feature.enabled?(Nanoc::Feature::LIVE_CMD)
|
122
|
+
|
117
123
|
cmd = load_command_at(cmd_filename)
|
118
124
|
add_command(cmd)
|
119
125
|
end
|
@@ -9,7 +9,6 @@ module Nanoc::CLI::Commands::CompileListeners
|
|
9
9
|
|
10
10
|
# @see Listener#start
|
11
11
|
def start
|
12
|
-
require 'tempfile'
|
13
12
|
setup_diffs
|
14
13
|
old_contents = {}
|
15
14
|
Nanoc::Int::NotificationCenter.on(:will_write_rep, self) do |rep, path|
|
@@ -65,8 +64,6 @@ module Nanoc::CLI::Commands::CompileListeners
|
|
65
64
|
end
|
66
65
|
|
67
66
|
def diff_strings(a, b)
|
68
|
-
require 'open3'
|
69
|
-
|
70
67
|
# Create files
|
71
68
|
Tempfile.open('old') do |old_file|
|
72
69
|
Tempfile.open('new') do |new_file|
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
usage 'live'
|
4
|
+
summary 'auto-recompile and serve'
|
5
|
+
description <<~EOS
|
6
|
+
Starts the live recompiler along with the static web server. Unless specified,
|
7
|
+
the web server will run on port 3000 and listen on all IP addresses. Running
|
8
|
+
this static web server requires `adsf` (not `asdf`!).
|
9
|
+
EOS
|
10
|
+
|
11
|
+
required :H, :handler, 'specify the handler to use (webrick/mongrel/...)'
|
12
|
+
required :o, :host, 'specify the host to listen on (default: 127.0.0.1)'
|
13
|
+
required :p, :port, 'specify the port to listen on (default: 3000)'
|
14
|
+
|
15
|
+
module Nanoc::CLI::Commands
|
16
|
+
class Live < ::Nanoc::CLI::CommandRunner
|
17
|
+
def run
|
18
|
+
self.class.enter_site_dir
|
19
|
+
|
20
|
+
Thread.new do
|
21
|
+
Thread.current.abort_on_exception = true
|
22
|
+
Nanoc::CLI::Commands::View.new(options, [], self).run
|
23
|
+
end
|
24
|
+
|
25
|
+
Nanoc::Extra::LiveRecompiler.new(command_runner: self).run
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
runner Nanoc::CLI::Commands::Live
|