nanoc 4.7.4 → 4.7.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (36) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +2 -2
  3. data/Gemfile.lock +19 -29
  4. data/NEWS.md +11 -0
  5. data/lib/nanoc/base/entities/identifiable_collection.rb +21 -0
  6. data/lib/nanoc/base/services/compilation_context.rb +54 -0
  7. data/lib/nanoc/base/services/compiler/stages/build_reps.rb +27 -0
  8. data/lib/nanoc/base/services/compiler/stages/determine_outdatedness.rb +4 -6
  9. data/lib/nanoc/base/services/compiler/stages/forget_outdated_dependencies.rb +14 -0
  10. data/lib/nanoc/base/services/compiler/stages/load_stores.rb +22 -0
  11. data/lib/nanoc/base/services/compiler/stages/postprocess.rb +16 -0
  12. data/lib/nanoc/base/services/compiler/stages/store_post_compilation_state.rb +14 -0
  13. data/lib/nanoc/base/services/compiler/stages/store_pre_compilation_state.rb +33 -0
  14. data/lib/nanoc/base/services/compiler/stages.rb +6 -0
  15. data/lib/nanoc/base/services/compiler.rb +85 -142
  16. data/lib/nanoc/base/services/compiler_loader.rb +0 -11
  17. data/lib/nanoc/base/services/outdatedness_checker.rb +19 -40
  18. data/lib/nanoc/base/services.rb +1 -0
  19. data/lib/nanoc/base/views/identifiable_collection_view.rb +1 -2
  20. data/lib/nanoc/cli/commands/compile_listeners/timing_recorder.rb +2 -2
  21. data/lib/nanoc/cli/commands/show-data.rb +14 -12
  22. data/lib/nanoc/version.rb +1 -1
  23. data/spec/nanoc/base/compiler_spec.rb +0 -5
  24. data/spec/nanoc/base/entities/identifiable_collection_spec.rb +34 -0
  25. data/spec/nanoc/base/services/compiler/stages/compile_reps_spec.rb +1 -1
  26. data/spec/nanoc/base/services/executor_spec.rb +1 -1
  27. data/spec/nanoc/base/services/outdatedness_checker_spec.rb +21 -8
  28. data/spec/nanoc/base/services/outdatedness_rules_spec.rb +6 -9
  29. data/spec/nanoc/cli/commands/show_data_spec.rb +147 -0
  30. data/spec/nanoc/integration/outdatedness_integration_spec.rb +14 -14
  31. data/spec/nanoc/integration/partial_recompilation_spec.rb +4 -4
  32. data/spec/nanoc/regressions/gh_1145_spec.rb +16 -0
  33. data/spec/nanoc/regressions/gh_970b_spec.rb +3 -3
  34. data/spec/spec_helper.rb +1 -1
  35. metadata +10 -3
  36. data/test/base/test_outdatedness_checker.rb +0 -491
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a7edb702d8929a927c1451d25bfa2371a4464914
4
- data.tar.gz: 1120a8323748658b9d26bb5ca10b500dfc162a31
3
+ metadata.gz: ab8752a7ee706e88d3de7f0161673dd839a2edd2
4
+ data.tar.gz: 418c19a9d06ab842d45f5ece1b51d98eba42f9b6
5
5
  SHA512:
6
- metadata.gz: a62949639c9c7ebb38ecaf5c1c4c60c1b03e73cdcc4791c300a811517e8fbf826b71079eee6dc5966ae4c25c7aea4e1eefe0ff589c3ec477e0a41f3b70717d16
7
- data.tar.gz: 962038a9d13bb4d58395999e77f73a48fc6b3be78fc862e83135aa8fa82f894f01ffb8b696d2354dcaabc7b1b4983245a339bdc96d3cb98ac9bede5153cc0536
6
+ metadata.gz: 051aa20802e5b97c886dc8b33051af32dac210a78efbae3a1f4595e6c181f49d2f7eda56e502f4d15323963ccf420f7e81a94040e3dac9e9e07ef83f37d56aa1
7
+ data.tar.gz: ef1423214832df499234d8320496f67a65f709f1d6eee68fa320b33c458598f921dfc38872e7cf1989e027d7269d7d82679a547c9375b1a0641ed6e88777a3ea
data/Gemfile CHANGED
@@ -49,7 +49,7 @@ group :plugins do
49
49
  gem 'mustache', '~> 1.0'
50
50
  gem 'nokogiri', '~> 1.6'
51
51
  gem 'pandoc-ruby'
52
- gem 'pygments.rb', github: 'tmm1/pygments.rb', platforms: %i(ruby mswin)
52
+ gem 'pygments.rb', '~> 1.1', '>= 1.1.1', platforms: %i(ruby mswin)
53
53
  gem 'rack'
54
54
  gem 'rainpress'
55
55
  gem 'rdiscount', '~> 2.2', platforms: %i(ruby mswin)
@@ -59,7 +59,7 @@ group :plugins do
59
59
  gem 'rubypants'
60
60
  gem 'sass'
61
61
  gem 'slim'
62
- gem 'therubyracer', github: 'cowboyd/therubyracer'
62
+ gem 'therubyracer', '~> 0.12'
63
63
  gem 'typogruby'
64
64
  gem 'uglifier'
65
65
  gem 'w3c_validators'
data/Gemfile.lock CHANGED
@@ -1,6 +1,6 @@
1
1
  GIT
2
2
  remote: https://github.com/bbatsov/rubocop.git
3
- revision: d602d0a763da9f4f16b441f6205c6913eb99fbe4
3
+ revision: f0990436f0c766747bbd37b164f43b00fb2d9785
4
4
  specs:
5
5
  rubocop (0.48.0)
6
6
  parser (>= 2.3.3.1, < 3.0)
@@ -9,25 +9,10 @@ GIT
9
9
  ruby-progressbar (~> 1.7)
10
10
  unicode-display_width (~> 1.0, >= 1.0.1)
11
11
 
12
- GIT
13
- remote: https://github.com/cowboyd/therubyracer.git
14
- revision: 466a1f0d4f696acfe971899272359623ec0a7a97
15
- specs:
16
- therubyracer (0.12.3)
17
- libv8 (~> 3.16.14.15)
18
- ref
19
-
20
- GIT
21
- remote: https://github.com/tmm1/pygments.rb.git
22
- revision: cf50cbeda48e8a242ef9cba9467e092935730f66
23
- specs:
24
- pygments.rb (1.1.1)
25
- multi_json (>= 1.0.0)
26
-
27
12
  PATH
28
13
  remote: .
29
14
  specs:
30
- nanoc (4.7.4)
15
+ nanoc (4.7.5)
31
16
  cri (~> 2.3)
32
17
  ddplugin (~> 1.0)
33
18
  hamster (~> 3.0)
@@ -38,7 +23,7 @@ GEM
38
23
  specs:
39
24
  CFPropertyList (2.3.5)
40
25
  RedCloth (4.3.2)
41
- addressable (2.5.0)
26
+ addressable (2.5.1)
42
27
  public_suffix (~> 2.0, >= 2.0.2)
43
28
  adsf (1.2.1)
44
29
  rack (>= 1.0.0)
@@ -75,11 +60,11 @@ GEM
75
60
  sass (>= 3.2, < 3.5)
76
61
  concurrent-ruby (1.0.5)
77
62
  contracts (0.15.0)
78
- coveralls (0.8.19)
63
+ coveralls (0.8.20)
79
64
  json (>= 1.8, < 3)
80
- simplecov (~> 0.12.0)
65
+ simplecov (~> 0.14.1)
81
66
  term-ansicolor (~> 1.3)
82
- thor (~> 0.19.1)
67
+ thor (~> 0.19.4)
83
68
  tins (~> 1.6)
84
69
  crack (0.4.3)
85
70
  safe_yaml (~> 1.0.0)
@@ -132,7 +117,7 @@ GEM
132
117
  fog-atmos (0.1.0)
133
118
  fog-core
134
119
  fog-xml
135
- fog-aws (1.2.1)
120
+ fog-aws (1.3.0)
136
121
  fog-core (~> 1.38)
137
122
  fog-json (~> 1.0)
138
123
  fog-xml (~> 0.1)
@@ -211,15 +196,15 @@ GEM
211
196
  fog-voxel (0.1.0)
212
197
  fog-core
213
198
  fog-xml
214
- fog-vsphere (1.8.0)
199
+ fog-vsphere (1.9.0)
215
200
  fog-core
216
201
  rbvmomi (~> 1.9)
217
202
  fog-xenserver (0.3.0)
218
203
  fog-core
219
204
  fog-xml
220
- fog-xml (0.1.2)
205
+ fog-xml (0.1.3)
221
206
  fog-core
222
- nokogiri (~> 1.5, >= 1.5.11)
207
+ nokogiri (>= 1.5.11, < 2.0.0)
223
208
  formatador (0.2.5)
224
209
  fuubar (2.2.0)
225
210
  rspec-core (~> 3.0)
@@ -289,6 +274,8 @@ GEM
289
274
  method_source (~> 0.8.1)
290
275
  slop (~> 3.4)
291
276
  public_suffix (2.0.5)
277
+ pygments.rb (1.1.1)
278
+ multi_json (>= 1.0.0)
292
279
  rack (2.0.1)
293
280
  rainbow (2.2.1)
294
281
  rainpress (1.0.1)
@@ -328,7 +315,7 @@ GEM
328
315
  safe_yaml (1.0.4)
329
316
  sass (3.4.23)
330
317
  shellany (0.0.1)
331
- simplecov (0.12.0)
318
+ simplecov (0.14.1)
332
319
  docile (~> 1.1.0)
333
320
  json (>= 1.8, < 3)
334
321
  simplecov-html (~> 0.10.0)
@@ -340,6 +327,9 @@ GEM
340
327
  temple (0.7.7)
341
328
  term-ansicolor (1.5.0)
342
329
  tins (~> 1.0)
330
+ therubyracer (0.12.3)
331
+ libv8 (~> 3.16.14.15)
332
+ ref
343
333
  thor (0.19.4)
344
334
  tilt (2.0.7)
345
335
  timecop (0.8.1)
@@ -347,7 +337,7 @@ GEM
347
337
  trollop (2.1.2)
348
338
  typogruby (1.0.18)
349
339
  rubypants
350
- uglifier (3.1.11)
340
+ uglifier (3.1.12)
351
341
  execjs (>= 0.3.0, < 3)
352
342
  unicode-display_width (1.1.3)
353
343
  url (0.3.2)
@@ -404,7 +394,7 @@ DEPENDENCIES
404
394
  nokogiri (~> 1.6)
405
395
  pandoc-ruby
406
396
  pry
407
- pygments.rb!
397
+ pygments.rb (~> 1.1, >= 1.1.1)
408
398
  rack
409
399
  rainbow (~> 2.1)
410
400
  rainpress
@@ -421,7 +411,7 @@ DEPENDENCIES
421
411
  sass
422
412
  simplecov
423
413
  slim
424
- therubyracer!
414
+ therubyracer (~> 0.12)
425
415
  timecop
426
416
  typogruby
427
417
  uglifier
data/NEWS.md CHANGED
@@ -1,5 +1,16 @@
1
1
  # Nanoc news
2
2
 
3
+ ## 4.7.5 (2017-04-01)
4
+
5
+ Fixes:
6
+
7
+ * Recognize `--verbose` when calling `nanoc` without subcommand (#1145, #1146)
8
+
9
+ Enhancements:
10
+
11
+ * Made `show-data` print all outdatedness reasons, not just the first (#1142)
12
+ * Sped up `@items.find_all` (#1147)
13
+
3
14
  ## 4.7.4 (2017-03-29)
4
15
 
5
16
  Enhancements:
@@ -37,6 +37,15 @@ module Nanoc::Int
37
37
  end
38
38
  end
39
39
 
40
+ contract C::Any => C::IterOf[C::RespondTo[:identifier]]
41
+ def find_all(arg)
42
+ if frozen?
43
+ find_all_memoized(arg)
44
+ else
45
+ find_all_unmemoized(arg)
46
+ end
47
+ end
48
+
40
49
  contract C::None => C::ArrayOf[C::RespondTo[:identifier]]
41
50
  def to_a
42
51
  @objects.to_a
@@ -77,6 +86,18 @@ module Nanoc::Int
77
86
  end
78
87
  memoize :get_memoized
79
88
 
89
+ contract C::Any => C::IterOf[C::RespondTo[:identifier]]
90
+ def find_all_unmemoized(arg)
91
+ pat = Nanoc::Int::Pattern.from(arg)
92
+ select { |i| pat.match?(i.identifier) }
93
+ end
94
+
95
+ contract C::Any => C::IterOf[C::RespondTo[:identifier]]
96
+ def find_all_memoized(arg)
97
+ find_all_unmemoized(arg)
98
+ end
99
+ memoize :find_all_memoized
100
+
80
101
  def object_with_identifier(identifier)
81
102
  if frozen?
82
103
  @mapping[identifier.to_s]
@@ -0,0 +1,54 @@
1
+ module Nanoc::Int
2
+ class CompilationContext
3
+ attr_reader :site
4
+ attr_reader :compiled_content_cache
5
+ attr_reader :snapshot_repo
6
+
7
+ def initialize(action_provider:, reps:, site:, compiled_content_cache:, snapshot_repo:)
8
+ @action_provider = action_provider
9
+ @reps = reps
10
+ @site = site
11
+ @compiled_content_cache = compiled_content_cache
12
+ @snapshot_repo = snapshot_repo
13
+ end
14
+
15
+ def filter_name_and_args_for_layout(layout)
16
+ mem = @action_provider.action_sequence_for(layout)
17
+ if mem.nil? || mem.size != 1 || !mem[0].is_a?(Nanoc::Int::ProcessingActions::Filter)
18
+ raise Nanoc::Int::Errors::UndefinedFilterForLayout.new(layout)
19
+ end
20
+ [mem[0].filter_name, mem[0].params]
21
+ end
22
+
23
+ def create_view_context(dependency_tracker)
24
+ Nanoc::ViewContext.new(
25
+ reps: @reps,
26
+ items: @site.items,
27
+ dependency_tracker: dependency_tracker,
28
+ compilation_context: self,
29
+ snapshot_repo: @snapshot_repo,
30
+ )
31
+ end
32
+
33
+ def assigns_for(rep, dependency_tracker)
34
+ last_content = @snapshot_repo.get(rep, :last)
35
+ content_or_filename_assigns =
36
+ if last_content.binary?
37
+ { filename: last_content.filename }
38
+ else
39
+ { content: last_content.string }
40
+ end
41
+
42
+ view_context = create_view_context(dependency_tracker)
43
+
44
+ content_or_filename_assigns.merge(
45
+ item: Nanoc::ItemWithRepsView.new(rep.item, view_context),
46
+ rep: Nanoc::ItemRepView.new(rep, view_context),
47
+ item_rep: Nanoc::ItemRepView.new(rep, view_context),
48
+ items: Nanoc::ItemCollectionWithRepsView.new(@site.items, view_context),
49
+ layouts: Nanoc::LayoutCollectionView.new(@site.layouts, view_context),
50
+ config: Nanoc::ConfigView.new(@site.config, view_context),
51
+ )
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,27 @@
1
+ module Nanoc::Int::Compiler::Stages
2
+ class BuildReps
3
+ def initialize(site:, action_provider:, reps:)
4
+ @site = site
5
+ @action_provider = action_provider
6
+ @reps = reps
7
+ end
8
+
9
+ def run
10
+ # FIXME: This also, as a side effect, generates the action sequences. :(
11
+ # Better: let this stage return a mapping of reps onto (raw) paths *and* a mapping of objects
12
+ # onto action sequences.
13
+
14
+ builder = Nanoc::Int::ItemRepBuilder.new(
15
+ @site, @action_provider, @reps
16
+ )
17
+
18
+ action_sequences = builder.run
19
+
20
+ @site.layouts.each do |layout|
21
+ action_sequences[layout] = @action_provider.action_sequence_for(layout)
22
+ end
23
+
24
+ action_sequences
25
+ end
26
+ end
27
+ end
@@ -8,12 +8,10 @@ module Nanoc::Int::Compiler::Stages
8
8
  @outdatedness_store = outdatedness_store
9
9
  end
10
10
 
11
- C_OBJ = C::Or[Nanoc::Int::Item, Nanoc::Int::ItemRep, Nanoc::Int::Layout]
12
-
13
- contract C::HashOf[C_OBJ => Nanoc::Int::ActionSequence], C::Func[C::IterOf[Nanoc::Int::Item] => C::Any] => C::Any
14
- def run(action_sequences)
11
+ contract C::None => C::Any
12
+ def run
15
13
  outdated_reps_tmp = @reps.select do |r|
16
- @outdatedness_store.include?(r) || @outdatedness_checker.outdated?(r, action_sequences)
14
+ @outdatedness_store.include?(r) || @outdatedness_checker.outdated?(r)
17
15
  end
18
16
 
19
17
  outdated_items = outdated_reps_tmp.map(&:item).uniq
@@ -21,7 +19,7 @@ module Nanoc::Int::Compiler::Stages
21
19
 
22
20
  outdated_reps.each { |r| @outdatedness_store.add(r) }
23
21
 
24
- yield(outdated_items)
22
+ outdated_items
25
23
  end
26
24
  end
27
25
  end
@@ -0,0 +1,14 @@
1
+ module Nanoc::Int::Compiler::Stages
2
+ class ForgetOutdatedDependencies
3
+ include Nanoc::Int::ContractsSupport
4
+
5
+ def initialize(dependency_store:)
6
+ @dependency_store = dependency_store
7
+ end
8
+
9
+ contract C::IterOf[Nanoc::Int::Item] => C::Any
10
+ def run(outdated_items)
11
+ outdated_items.each { |i| @dependency_store.forget_dependencies_for(i) }
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,22 @@
1
+ module Nanoc::Int::Compiler::Stages
2
+ class LoadStores
3
+ include Nanoc::Int::ContractsSupport
4
+
5
+ def initialize(checksum_store:, compiled_content_cache:, dependency_store:, action_sequence_store:, outdatedness_store:)
6
+ @checksum_store = checksum_store
7
+ @compiled_content_cache = compiled_content_cache
8
+ @dependency_store = dependency_store
9
+ @action_sequence_store = action_sequence_store
10
+ @outdatedness_store = outdatedness_store
11
+ end
12
+
13
+ contract C::None => C::Any
14
+ def run
15
+ @checksum_store.load
16
+ @compiled_content_cache.load
17
+ @dependency_store.load
18
+ @action_sequence_store.load
19
+ @outdatedness_store.load
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,16 @@
1
+ module Nanoc::Int::Compiler::Stages
2
+ class Postprocess
3
+ include Nanoc::Int::ContractsSupport
4
+
5
+ def initialize(action_provider:, site:, reps:)
6
+ @action_provider = action_provider
7
+ @site = site
8
+ @reps = reps
9
+ end
10
+
11
+ contract C::None => C::Any
12
+ def run
13
+ @action_provider.postprocess(@site, @reps)
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,14 @@
1
+ module Nanoc::Int::Compiler::Stages
2
+ class StorePostCompilationState
3
+ include Nanoc::Int::ContractsSupport
4
+
5
+ def initialize(dependency_store:)
6
+ @dependency_store = dependency_store
7
+ end
8
+
9
+ contract C::None => C::Any
10
+ def run
11
+ @dependency_store.store
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,33 @@
1
+ module Nanoc::Int::Compiler::Stages
2
+ class StorePreCompilationState
3
+ include Nanoc::Int::ContractsSupport
4
+
5
+ def initialize(reps:, layouts:, items:, code_snippets:, config:, checksum_store:, action_sequence_store:, action_sequences:)
6
+ @reps = reps
7
+ @layouts = layouts
8
+ @items = items
9
+ @code_snippets = code_snippets
10
+ @config = config
11
+ @checksum_store = checksum_store
12
+ @action_sequence_store = action_sequence_store
13
+ @action_sequences = action_sequences
14
+ end
15
+
16
+ contract C::None => C::Any
17
+ def run
18
+ # Calculate action sequence
19
+ (@reps.to_a + @layouts.to_a).each do |obj|
20
+ @action_sequence_store[obj] = @action_sequences[obj].serialize
21
+ end
22
+
23
+ # Calculate checksums
24
+ objects_to_checksum =
25
+ @items.to_a + @layouts.to_a + @code_snippets + [@config]
26
+ objects_to_checksum.each { |obj| @checksum_store.add(obj) }
27
+
28
+ # Store
29
+ @checksum_store.store
30
+ @action_sequence_store.store
31
+ end
32
+ end
33
+ end
@@ -6,3 +6,9 @@ require_relative 'stages/compile_reps'
6
6
  require_relative 'stages/determine_outdatedness'
7
7
  require_relative 'stages/prune'
8
8
  require_relative 'stages/preprocess'
9
+ require_relative 'stages/load_stores'
10
+ require_relative 'stages/forget_outdated_dependencies'
11
+ require_relative 'stages/store_pre_compilation_state'
12
+ require_relative 'stages/store_post_compilation_state'
13
+ require_relative 'stages/postprocess'
14
+ require_relative 'stages/build_reps'