nanoc 4.8.3 → 4.8.4
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/cli/command_runner.rb +4 -21
- data/lib/nanoc/cli/commands/check.rb +2 -2
- data/lib/nanoc/cli/commands/compile.rb +4 -4
- data/lib/nanoc/cli/commands/compile_listeners/abstract.rb +1 -1
- data/lib/nanoc/cli/commands/compile_listeners/debug_printer.rb +1 -1
- data/lib/nanoc/cli/commands/compile_listeners/diff_generator.rb +2 -2
- data/lib/nanoc/cli/commands/compile_listeners/timing_recorder.rb +1 -1
- data/lib/nanoc/cli/commands/deploy.rb +4 -4
- data/lib/nanoc/cli/commands/prune.rb +5 -5
- data/lib/nanoc/cli/commands/shell.rb +2 -2
- data/lib/nanoc/cli/commands/show-data.rb +5 -5
- data/lib/nanoc/cli/commands/show-plugins.rb +1 -0
- data/lib/nanoc/cli/commands/show-rules.rb +5 -5
- data/lib/nanoc/cli/commands/view.rb +2 -2
- data/lib/nanoc/version.rb +1 -1
- data/spec/nanoc/cli/command_runner_spec.rb +17 -0
- data/spec/nanoc/cli/commands/compile/diff_generator_spec.rb +2 -4
- data/spec/nanoc/cli/commands/show_data_spec.rb +4 -0
- data/spec/nanoc/cli/commands/show_rules_spec.rb +5 -10
- metadata +2 -3
- data/test/cli/commands/test_info.rb +0 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f693f075f9d417738964c959fde56d79d89d1733
|
4
|
+
data.tar.gz: 7e9eaf4cbbc4fd08ce8bc1e034d3599338d523d0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d3adbb7324f0c594e3b59639c3bbbfce493e04d9e3253948596a01b237cc766ed960b3840a8365fe5e1ffa1f7d703e2e9072eae4576695def77d4d0ff6e7f16f
|
7
|
+
data.tar.gz: 75cd883a140e83374f766995511502a0c09b3ccdaf2705e012eff20b49e6a98469d14cee92ff64a2627deb9a004c49792a449b1068bba66d5cf1198507e23688
|
data/NEWS.md
CHANGED
@@ -15,27 +15,6 @@ module Nanoc::CLI
|
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
18
|
-
# Gets the site ({Nanoc::Int::Site} instance) in the current directory and
|
19
|
-
# loads its data.
|
20
|
-
#
|
21
|
-
# @return [Nanoc::Int::Site] The site in the current working directory
|
22
|
-
def site
|
23
|
-
# Load site if possible
|
24
|
-
@site ||= nil
|
25
|
-
if is_in_site_dir? && @site.nil?
|
26
|
-
@site = Nanoc::Int::SiteLoader.new.new_from_cwd
|
27
|
-
end
|
28
|
-
|
29
|
-
@site
|
30
|
-
end
|
31
|
-
|
32
|
-
# For debugging purposes.
|
33
|
-
#
|
34
|
-
# @api private
|
35
|
-
def site=(new_site)
|
36
|
-
@site = new_site
|
37
|
-
end
|
38
|
-
|
39
18
|
# @return [Boolean] true if the current working directory is a Nanoc site
|
40
19
|
# directory, false otherwise
|
41
20
|
def in_site_dir?
|
@@ -77,11 +56,15 @@ module Nanoc::CLI
|
|
77
56
|
$stderr.print 'Loading site… '
|
78
57
|
$stderr.flush
|
79
58
|
|
59
|
+
site = Nanoc::Int::SiteLoader.new.new_from_cwd
|
60
|
+
|
80
61
|
if preprocess
|
81
62
|
site.compiler.action_provider.preprocess(site)
|
82
63
|
end
|
83
64
|
|
84
65
|
$stderr.puts 'done'
|
66
|
+
|
67
|
+
site
|
85
68
|
end
|
86
69
|
|
87
70
|
# @return [Boolean] true if debug output is enabled, false if not
|
@@ -14,9 +14,9 @@ module Nanoc::CLI::Commands
|
|
14
14
|
class Check < ::Nanoc::CLI::CommandRunner
|
15
15
|
def run
|
16
16
|
validate_options_and_arguments
|
17
|
-
load_site(preprocess: true)
|
17
|
+
@site = load_site(preprocess: true)
|
18
18
|
|
19
|
-
runner = Nanoc::Checking::Runner.new(site)
|
19
|
+
runner = Nanoc::Checking::Runner.new(@site)
|
20
20
|
|
21
21
|
if options[:list]
|
22
22
|
runner.list_checks
|
@@ -19,11 +19,11 @@ module Nanoc::CLI::Commands
|
|
19
19
|
def run
|
20
20
|
time_before = Time.now
|
21
21
|
|
22
|
-
load_site
|
22
|
+
@site = load_site
|
23
23
|
|
24
24
|
puts 'Compiling site…'
|
25
25
|
run_listeners_while do
|
26
|
-
site.compile
|
26
|
+
@site.compile
|
27
27
|
end
|
28
28
|
|
29
29
|
time_after = Time.now
|
@@ -45,7 +45,7 @@ module Nanoc::CLI::Commands
|
|
45
45
|
def setup_listeners
|
46
46
|
@listeners =
|
47
47
|
@listener_classes
|
48
|
-
.select { |klass| klass.enable_for?(self) }
|
48
|
+
.select { |klass| klass.enable_for?(self, @site) }
|
49
49
|
.map { |klass| klass.new(reps: reps) }
|
50
50
|
|
51
51
|
@listeners.each(&:start_safely)
|
@@ -68,7 +68,7 @@ module Nanoc::CLI::Commands
|
|
68
68
|
end
|
69
69
|
|
70
70
|
def reps
|
71
|
-
site.compiler.reps
|
71
|
+
@site.compiler.reps
|
72
72
|
end
|
73
73
|
end
|
74
74
|
end
|
@@ -4,7 +4,7 @@ module Nanoc::CLI::Commands::CompileListeners
|
|
4
4
|
class Abstract
|
5
5
|
def initialize(*); end
|
6
6
|
|
7
|
-
def self.enable_for?(command_runner) # rubocop:disable Lint/UnusedMethodArgument
|
7
|
+
def self.enable_for?(command_runner, site) # rubocop:disable Lint/UnusedMethodArgument
|
8
8
|
true
|
9
9
|
end
|
10
10
|
|
@@ -3,8 +3,8 @@
|
|
3
3
|
module Nanoc::CLI::Commands::CompileListeners
|
4
4
|
class DiffGenerator < Abstract
|
5
5
|
# @see Listener#enable_for?
|
6
|
-
def self.enable_for?(command_runner)
|
7
|
-
|
6
|
+
def self.enable_for?(command_runner, site)
|
7
|
+
site.config[:enable_output_diff] || command_runner.options[:diff]
|
8
8
|
end
|
9
9
|
|
10
10
|
# @see Listener#start
|
@@ -15,7 +15,7 @@ option :n, :'dry-run', 'show what would be deployed'
|
|
15
15
|
module Nanoc::CLI::Commands
|
16
16
|
class Deploy < ::Nanoc::CLI::CommandRunner
|
17
17
|
def run
|
18
|
-
load_site(preprocess: true)
|
18
|
+
@site = load_site(preprocess: true)
|
19
19
|
|
20
20
|
if options[:'list-deployers']
|
21
21
|
list_deployers
|
@@ -80,14 +80,14 @@ module Nanoc::CLI::Commands
|
|
80
80
|
|
81
81
|
def deployer_for(config)
|
82
82
|
deployer_class_for_config(config).new(
|
83
|
-
site.config[:output_dir],
|
83
|
+
@site.config[:output_dir],
|
84
84
|
config,
|
85
85
|
dry_run: options[:'dry-run'],
|
86
86
|
)
|
87
87
|
end
|
88
88
|
|
89
89
|
def check
|
90
|
-
runner = Nanoc::Checking::Runner.new(site)
|
90
|
+
runner = Nanoc::Checking::Runner.new(@site)
|
91
91
|
if runner.dsl_present?
|
92
92
|
puts 'Running issue checks…'
|
93
93
|
is_success = runner.run_for_deploy
|
@@ -103,7 +103,7 @@ module Nanoc::CLI::Commands
|
|
103
103
|
end
|
104
104
|
|
105
105
|
def deploy_configs
|
106
|
-
site.config.fetch(:deploy, {})
|
106
|
+
@site.config.fetch(:deploy, {})
|
107
107
|
end
|
108
108
|
|
109
109
|
def deployer_class_for_config(config)
|
@@ -17,13 +17,13 @@ flag :n, :'dry-run', 'print files to be deleted instead of actually deleting the
|
|
17
17
|
module Nanoc::CLI::Commands
|
18
18
|
class Prune < ::Nanoc::CLI::CommandRunner
|
19
19
|
def run
|
20
|
-
load_site(preprocess: true)
|
21
|
-
site.compiler.build_reps
|
20
|
+
@site = load_site(preprocess: true)
|
21
|
+
@site.compiler.build_reps
|
22
22
|
|
23
23
|
if options.key?(:yes)
|
24
|
-
Nanoc::Pruner.new(site.config, site.compiler.reps, exclude: prune_config_exclude).run
|
24
|
+
Nanoc::Pruner.new(@site.config, @site.compiler.reps, exclude: prune_config_exclude).run
|
25
25
|
elsif options.key?(:'dry-run')
|
26
|
-
Nanoc::Pruner.new(site.config, site.compiler.reps, exclude: prune_config_exclude, dry_run: true).run
|
26
|
+
Nanoc::Pruner.new(@site.config, @site.compiler.reps, exclude: prune_config_exclude, dry_run: true).run
|
27
27
|
else
|
28
28
|
$stderr.puts 'WARNING: Since the prune command is a destructive command, it requires an additional --yes flag in order to work.'
|
29
29
|
$stderr.puts
|
@@ -35,7 +35,7 @@ module Nanoc::CLI::Commands
|
|
35
35
|
protected
|
36
36
|
|
37
37
|
def prune_config
|
38
|
-
site.config[:prune] || {}
|
38
|
+
@site.config[:prune] || {}
|
39
39
|
end
|
40
40
|
|
41
41
|
def prune_config_exclude
|
@@ -13,13 +13,13 @@ module Nanoc::CLI::Commands
|
|
13
13
|
def run
|
14
14
|
require 'pry'
|
15
15
|
|
16
|
-
load_site(preprocess: options[:preprocess])
|
16
|
+
@site = load_site(preprocess: options[:preprocess])
|
17
17
|
|
18
18
|
Nanoc::Int::Context.new(env).pry
|
19
19
|
end
|
20
20
|
|
21
21
|
def env
|
22
|
-
self.class.env_for_site(site)
|
22
|
+
self.class.env_for_site(@site)
|
23
23
|
end
|
24
24
|
|
25
25
|
def self.reps_for(site)
|
@@ -11,14 +11,14 @@ EOS
|
|
11
11
|
module Nanoc::CLI::Commands
|
12
12
|
class ShowData < ::Nanoc::CLI::CommandRunner
|
13
13
|
def run
|
14
|
-
load_site(preprocess: true)
|
14
|
+
@site = load_site(preprocess: true)
|
15
15
|
|
16
16
|
# Get data
|
17
|
-
items = site.items
|
18
|
-
layouts = site.layouts
|
17
|
+
items = @site.items
|
18
|
+
layouts = @site.layouts
|
19
19
|
|
20
20
|
# Get dependency tracker
|
21
|
-
compiler = site.compiler
|
21
|
+
compiler = @site.compiler
|
22
22
|
compiler.load_stores
|
23
23
|
dependency_store = compiler.dependency_store
|
24
24
|
|
@@ -45,7 +45,7 @@ module Nanoc::CLI::Commands
|
|
45
45
|
def sorted_reps_with_prev(items)
|
46
46
|
prev = nil
|
47
47
|
items.sort_by(&:identifier).each do |item|
|
48
|
-
site.compiler.reps[item].sort_by { |r| r.name.to_s }.each do |rep|
|
48
|
+
@site.compiler.reps[item].sort_by { |r| r.name.to_s }.each do |rep|
|
49
49
|
yield(rep, prev)
|
50
50
|
prev = rep
|
51
51
|
end
|
@@ -18,6 +18,7 @@ module Nanoc::CLI::Commands
|
|
18
18
|
|
19
19
|
# Get list of plugins (before and after)
|
20
20
|
plugins_before = PLUGIN_CLASSES.keys.each_with_object({}) { |c, acc| acc[c] = c.all }
|
21
|
+
site = load_site
|
21
22
|
site&.code_snippets
|
22
23
|
plugins_after = PLUGIN_CLASSES.keys.each_with_object({}) { |c, acc| acc[c] = c.all }
|
23
24
|
|
@@ -10,15 +10,15 @@ Prints the rules used for all items and layouts in the current site.
|
|
10
10
|
module Nanoc::CLI::Commands
|
11
11
|
class ShowRules < ::Nanoc::CLI::CommandRunner
|
12
12
|
def run
|
13
|
-
load_site
|
13
|
+
@site = load_site
|
14
14
|
|
15
15
|
@c = Nanoc::CLI::ANSIStringColorizer
|
16
16
|
|
17
|
-
compiler = site.compiler
|
17
|
+
compiler = @site.compiler
|
18
18
|
compiler.build_reps
|
19
19
|
@reps = compiler.reps
|
20
20
|
|
21
|
-
action_provider = site.compiler.action_provider
|
21
|
+
action_provider = @site.compiler.action_provider
|
22
22
|
unless action_provider.respond_to?(:rules_collection)
|
23
23
|
raise(
|
24
24
|
::Nanoc::Int::Errors::GenericTrivial,
|
@@ -27,8 +27,8 @@ module Nanoc::CLI::Commands
|
|
27
27
|
end
|
28
28
|
@rules = action_provider.rules_collection
|
29
29
|
|
30
|
-
site.items.sort_by(&:identifier).each { |e| explain_item(e) }
|
31
|
-
site.layouts.sort_by(&:identifier).each { |e| explain_layout(e) }
|
30
|
+
@site.items.sort_by(&:identifier).each { |e| explain_item(e) }
|
31
|
+
@site.layouts.sort_by(&:identifier).each { |e| explain_layout(e) }
|
32
32
|
end
|
33
33
|
|
34
34
|
def explain_item(item)
|
@@ -20,7 +20,7 @@ module Nanoc::CLI::Commands
|
|
20
20
|
load_adsf
|
21
21
|
require 'rack'
|
22
22
|
|
23
|
-
load_site
|
23
|
+
@site = load_site
|
24
24
|
|
25
25
|
# Set options
|
26
26
|
options_for_rack = {
|
@@ -40,7 +40,7 @@ module Nanoc::CLI::Commands
|
|
40
40
|
end
|
41
41
|
|
42
42
|
# Build app
|
43
|
-
site =
|
43
|
+
site = @site
|
44
44
|
app = Rack::Builder.new do
|
45
45
|
use Rack::CommonLogger
|
46
46
|
use Rack::ShowExceptions
|
data/lib/nanoc/version.rb
CHANGED
@@ -87,4 +87,21 @@ describe Nanoc::CLI::CommandRunner, stdio: true do
|
|
87
87
|
end
|
88
88
|
end
|
89
89
|
end
|
90
|
+
|
91
|
+
describe '#load_site' do
|
92
|
+
let(:command_runner) { described_class.new(nil, nil, nil) }
|
93
|
+
|
94
|
+
subject { command_runner.load_site }
|
95
|
+
|
96
|
+
before { File.write('nanoc.yaml', '{}') }
|
97
|
+
|
98
|
+
it 'does not set @site' do
|
99
|
+
expect(command_runner.instance_variable_get(:@site)).to be_nil
|
100
|
+
expect { subject }.not_to change { command_runner.instance_variable_get(:@site) }
|
101
|
+
end
|
102
|
+
|
103
|
+
it 'returns site' do
|
104
|
+
expect(subject).to be_a(Nanoc::Int::Site)
|
105
|
+
end
|
106
|
+
end
|
90
107
|
end
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
describe Nanoc::CLI::Commands::CompileListeners::DiffGenerator do
|
4
4
|
describe '.enable_for?' do
|
5
|
-
subject { described_class.enable_for?(command_runner) }
|
5
|
+
subject { described_class.enable_for?(command_runner, site) }
|
6
6
|
|
7
7
|
let(:options) { {} }
|
8
8
|
let(:config_hash) { {} }
|
@@ -24,9 +24,7 @@ describe Nanoc::CLI::Commands::CompileListeners::DiffGenerator do
|
|
24
24
|
let(:code_snippets) { [] }
|
25
25
|
|
26
26
|
let(:command_runner) do
|
27
|
-
Nanoc::CLI::Commands::Compile.new(options, arguments, command)
|
28
|
-
cr.site = site
|
29
|
-
end
|
27
|
+
Nanoc::CLI::Commands::Compile.new(options, arguments, command)
|
30
28
|
end
|
31
29
|
|
32
30
|
context 'default' do
|
@@ -155,6 +155,10 @@ describe Nanoc::CLI::Commands::ShowData, stdio: true do
|
|
155
155
|
describe '#print_item_rep_outdatedness' do
|
156
156
|
subject { runner.send(:print_item_rep_outdatedness, items, compiler) }
|
157
157
|
|
158
|
+
before do
|
159
|
+
runner.instance_variable_set(:@site, site)
|
160
|
+
end
|
161
|
+
|
158
162
|
let(:runner) do
|
159
163
|
described_class.new(options, arguments, command)
|
160
164
|
end
|
@@ -1,13 +1,11 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
describe Nanoc::CLI::Commands::ShowRules, stdio: true do
|
3
|
+
describe Nanoc::CLI::Commands::ShowRules, stdio: true, site: true do
|
4
4
|
describe '#run' do
|
5
5
|
subject { runner.run }
|
6
6
|
|
7
7
|
let(:runner) do
|
8
|
-
described_class.new(options, arguments, command)
|
9
|
-
runner.site = site
|
10
|
-
end
|
8
|
+
described_class.new(options, arguments, command)
|
11
9
|
end
|
12
10
|
|
13
11
|
let(:options) { {} }
|
@@ -105,16 +103,13 @@ describe Nanoc::CLI::Commands::ShowRules, stdio: true do
|
|
105
103
|
.gsub(/^ {8}/, '')
|
106
104
|
end
|
107
105
|
|
108
|
-
before do
|
109
|
-
expect(compiler).to receive(:build_reps).once
|
110
|
-
expect(Nanoc::CLI::CommandRunner).to receive(:find_site_dir).and_return(Dir.getwd)
|
111
|
-
end
|
112
|
-
|
113
106
|
it 'writes item and layout rules to stdout' do
|
107
|
+
expect(runner).to receive(:load_site).and_return(site)
|
108
|
+
expect(compiler).to receive(:build_reps).once
|
114
109
|
expect { subject }.to output(expected_out).to_stdout
|
115
110
|
end
|
116
111
|
|
117
|
-
it 'writes status
|
112
|
+
it 'writes status information to stderr' do
|
118
113
|
expect { subject }.to output("Loading site… done\n").to_stderr
|
119
114
|
end
|
120
115
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nanoc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.8.
|
4
|
+
version: 4.8.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Denis Defreyne
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-09-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: cri
|
@@ -581,7 +581,6 @@ files:
|
|
581
581
|
- test/cli/commands/test_compile.rb
|
582
582
|
- test/cli/commands/test_create_site.rb
|
583
583
|
- test/cli/commands/test_help.rb
|
584
|
-
- test/cli/commands/test_info.rb
|
585
584
|
- test/cli/commands/test_prune.rb
|
586
585
|
- test/cli/test_cleaning_stream.rb
|
587
586
|
- test/cli/test_cli.rb
|