nanoc 4.7.10 → 4.7.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.
Files changed (52) hide show
  1. checksums.yaml +4 -4
  2. data/.github/CONTRIBUTING.md +17 -0
  3. data/.github/ISSUE_TEMPLATE.md +23 -0
  4. data/.github/PULL_REQUEST_TEMPLATE.md +18 -0
  5. data/.gitignore +8 -0
  6. data/.rspec +3 -0
  7. data/.rubocop.yml +174 -0
  8. data/.travis.yml +27 -0
  9. data/Gemfile +4 -3
  10. data/NEWS.md +11 -0
  11. data/Rakefile +5 -2
  12. data/lib/nanoc/base/entities/dependency.rb +5 -3
  13. data/lib/nanoc/base/entities/layout.rb +1 -1
  14. data/lib/nanoc/base/repos/dependency_store.rb +64 -28
  15. data/lib/nanoc/base/services/dependency_tracker.rb +1 -1
  16. data/lib/nanoc/base/views/config_view.rb +4 -0
  17. data/lib/nanoc/checking/checks/external_links.rb +3 -6
  18. data/lib/nanoc/cli.rb +0 -2
  19. data/lib/nanoc/cli/commands/shell.rb +2 -3
  20. data/lib/nanoc/filters/colorize_syntax/colorizers.rb +4 -1
  21. data/lib/nanoc/telemetry/table.rb +1 -1
  22. data/lib/nanoc/version.rb +1 -1
  23. data/nanoc.gemspec +1 -5
  24. data/scripts/release +95 -0
  25. data/{test → spec/nanoc}/base/core_ext/array_spec.rb +5 -14
  26. data/{test → spec/nanoc}/base/core_ext/hash_spec.rb +6 -15
  27. data/{test → spec/nanoc}/base/core_ext/pathname_spec.rb +0 -0
  28. data/spec/nanoc/base/core_ext/string_spec.rb +23 -0
  29. data/spec/nanoc/base/directed_graph_spec.rb +291 -0
  30. data/spec/nanoc/base/entities/identifiable_collection_spec.rb +56 -0
  31. data/spec/nanoc/base/entities/item_spec.rb +8 -0
  32. data/spec/nanoc/base/entities/layout_spec.rb +8 -0
  33. data/spec/nanoc/base/repos/dependency_store_spec.rb +166 -21
  34. data/spec/nanoc/base/views/config_view_spec.rb +29 -1
  35. data/spec/nanoc/cli/commands/shell_spec.rb +23 -8
  36. data/spec/nanoc/filters/less_spec.rb +1 -1
  37. data/spec/nanoc/regressions/gh_1185_spec.rb +22 -0
  38. data/spec/nanoc/telemetry/table_spec.rb +22 -0
  39. data/spec/spec_helper.rb +5 -6
  40. data/test/base/test_item_array.rb +0 -35
  41. data/test/checking/checks/test_external_links.rb +0 -14
  42. data/test/filters/test_coffeescript.rb +0 -2
  43. data/test/filters/test_handlebars.rb +0 -4
  44. data/test/filters/test_uglify_js.rb +0 -4
  45. data/test/helper.rb +0 -6
  46. data/test/helpers/test_blogging.rb +66 -26
  47. data/test/helpers/test_xml_sitemap.rb +23 -7
  48. metadata +16 -9
  49. data/Gemfile.lock +0 -433
  50. data/test/base/core_ext/string_spec.rb +0 -25
  51. data/test/base/test_item.rb +0 -40
  52. data/test/base/test_layout.rb +0 -16
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b056ea57fc16e94cee44d842ac7cc9d4f801b604
4
- data.tar.gz: 743593e44dee1341ff69b3f799d322dc9361b743
3
+ metadata.gz: 99eef92742ae4e7c6eec52f7efc9c456a44b72ca
4
+ data.tar.gz: 2d4f5da906f23c186cf965541a582175a91fe38f
5
5
  SHA512:
6
- metadata.gz: a6cd971e349f5d80baf44bcfe405788f6da72f9d7864ff4da44e708b72dcb0616ae26e740553037447b46390182e6d740b4e11735c8eb2dca369bba7e139ccbe
7
- data.tar.gz: 84f84414da253488dde8866209c827928da5502c79f1d80c2a0e0dfc8bca2dbe504ebae7adbbfb7430c7ff0bb1e008926fe4589a86f4d1b54ff227b8dc40481d
6
+ metadata.gz: 95a74693fa0cc09e0789bbaca9cc2c8f846f5936ae3e57f49ce8bba64721b970809438f200057aa3d7c8d3c520795015a19a7c220a462dfae6d0f7bbb048b8b8
7
+ data.tar.gz: d1bd24af79448f4e22250c95ce4ebc1a3fab8e9e827d24b130bc5c486154c8db099dace97e669903d9d7c8f8559d43134afcb1478875d177938fbecde08c46a6
@@ -0,0 +1,17 @@
1
+ Contributing
2
+ ============
3
+
4
+ Reporting bugs
5
+ --------------
6
+
7
+ If you find a bug in Nanoc, you should report it! Some information that you should include in your bug report is the Nanoc version (`nanoc --version`) and, if relevant, the crash log (`crash.log`). For details, check the [*bug reporting* section of the development guide](http://nanoc.ws/development/#reporting-bugs).
8
+
9
+ Contributing code
10
+ -----------------
11
+
12
+ Pull requests are appreciated! When submitting a PR, make sure that your changes have covering tests, that the documentation remains up-to-date and that you retain backwards compatibility. For details, check the [*contributing code* section of the development guide](http://nanoc.ws/development/#contributing-code).
13
+
14
+ Contributor code of conduct
15
+ ---------------------------
16
+
17
+ In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone. For details, see the contributor code of conduct at http://nanoc.ws/contributing/#contributor-code-of-conduct.
@@ -0,0 +1,23 @@
1
+ (Summarise the bug in a single line.)
2
+
3
+ ### Steps to reproduce
4
+
5
+ 1. [First step]
6
+ 2. [Second step]
7
+ 3. …
8
+
9
+ ### Expected behavior
10
+
11
+ (Describe what you expected to happen.)
12
+
13
+ ### Actual behavior
14
+
15
+ (Describe what actually happened instead.)
16
+
17
+ ### Details
18
+
19
+ (Describe other details, if any, that you believe might be relevant.)
20
+
21
+ ### Crash log
22
+
23
+ (When reporting a crash, create a [Gist](https://gist.github.com/) with the contents of the `crash.log` file, and link the Gist here.)
@@ -0,0 +1,18 @@
1
+ (Summarise the change in a single line.)
2
+
3
+ ### Detailed description
4
+
5
+ (Describe the change in detail.)
6
+
7
+ ### To do
8
+
9
+ (Include the to-do list for this PR to be finished here.)
10
+
11
+ * [ ] Tests
12
+ * [ ] Documentation
13
+ * [ ] Feature flags
14
+ * [ ] …
15
+
16
+ ### Related issues
17
+
18
+ (Add issue IDs for related issues here.)
data/.gitignore ADDED
@@ -0,0 +1,8 @@
1
+ doc/yardoc
2
+ .DS_Store
3
+ *.gem
4
+ /coverage/
5
+ /.yardoc
6
+ *~
7
+ /Gemfile.lock
8
+ *.gemfile.lock
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ -r ./spec/spec_helper.rb
2
+ --format Fuubar
3
+ --color
data/.rubocop.yml ADDED
@@ -0,0 +1,174 @@
1
+ # ----- CONFIGURED -----
2
+
3
+ AllCops:
4
+ TargetRubyVersion: 2.3
5
+ DisplayCopNames: true
6
+
7
+ # We use filenames such as “create-site.rb” that translate to method names.
8
+ FileName:
9
+ Exclude:
10
+ - 'lib/nanoc/cli/commands/*.rb'
11
+ - 'Appraisals'
12
+
13
+ # A common pattern in tests is to define anonymous classes in which methods are defined, which trips
14
+ # up Rubocop’s nested method definition cop.
15
+ Lint/NestedMethodDefinition:
16
+ Exclude:
17
+ - 'test/**/*.rb'
18
+ - 'spec/**/*.rb'
19
+
20
+ # This is used in tests, to verify the effect of state-changing functions.
21
+ Style/GlobalVars:
22
+ Exclude:
23
+ - 'test/**/*.rb'
24
+
25
+ Style/TrailingCommaInArguments:
26
+ EnforcedStyleForMultiline: comma
27
+
28
+ Style/TrailingCommaInLiteral:
29
+ EnforcedStyleForMultiline: comma
30
+
31
+ # `rescue nil` is useful in specs where the exception is not important, but
32
+ # the size effects are.
33
+ Style/RescueModifier:
34
+ Exclude:
35
+ - 'spec/**/*.rb'
36
+
37
+ Layout/IndentArray:
38
+ EnforcedStyle: consistent
39
+
40
+ Lint/DuplicateMethods:
41
+ Exclude:
42
+ - 'test/data_sources/test_filesystem.rb'
43
+ - 'spec/spec_helper.rb'
44
+
45
+ # This needs to be fixed in Ruby 2.4.
46
+ Lint/UnifiedInteger:
47
+ Enabled: false
48
+
49
+ Layout/IndentHeredoc:
50
+ EnforcedStyle: squiggly
51
+
52
+ # This breaks RSpec on occasion, e.g. `expect { subject }.not_to change { foo }`,
53
+ # and generally does not provide useful warnings
54
+ Lint/AmbiguousBlockAssociation:
55
+ Enabled: false
56
+
57
+ # ----- TO ENABLE LATER -----
58
+
59
+ # Valid cops, but fixing the offenses they report is non-trivial.
60
+
61
+ RegexpLiteral:
62
+ Enabled: false
63
+
64
+ ClassAndModuleChildren:
65
+ Enabled: false
66
+
67
+ Style/EmptyElse:
68
+ Enabled: false
69
+
70
+ Style/Next:
71
+ Enabled: false
72
+
73
+
74
+
75
+ # ----- DISABLED (hard) -----
76
+
77
+ # Rubocop trips up on this.
78
+ Layout/LeadingCommentSpace:
79
+ Enabled: false
80
+
81
+
82
+
83
+ # ----- DISABLED (security) -----
84
+
85
+ # Nanoc runs offline in a trusted environment, and these security checks are false positives.
86
+
87
+ Security/YAMLLoad:
88
+ Enabled: false
89
+
90
+ Security/MarshalLoad:
91
+ Enabled: false
92
+
93
+ Security/Eval:
94
+ Exclude:
95
+ - 'test/**/*.rb'
96
+ - 'spec/**/*.rb'
97
+ - 'lib/nanoc/base/entities/code_snippet.rb'
98
+ - 'lib/nanoc/filters/erubi.rb'
99
+
100
+
101
+ # ----- DISABLED (metrics) -----
102
+
103
+ # Cops for metrics are disabled because they should not cause tests to fail.
104
+
105
+ Metrics/AbcSize:
106
+ Enabled: false
107
+
108
+ Metrics/BlockLength:
109
+ Enabled: false
110
+
111
+ Metrics/BlockNesting:
112
+ Enabled: false
113
+
114
+ Metrics/ClassLength:
115
+ Enabled: false
116
+
117
+ Metrics/CyclomaticComplexity:
118
+ Enabled: false
119
+
120
+ Metrics/LineLength:
121
+ Enabled: false
122
+
123
+ Metrics/MethodLength:
124
+ Enabled: false
125
+
126
+ Metrics/ModuleLength:
127
+ Enabled: false
128
+
129
+ Metrics/ParameterLists:
130
+ Enabled: false
131
+
132
+ Metrics/PerceivedComplexity:
133
+ Enabled: false
134
+
135
+
136
+
137
+ # ----- DISABLED (opinionated) -----
138
+
139
+ # We should embrace UTF-8, not avoid it. Since the Encoding cop is enabled,
140
+ # there’s no point in enforcing ASCII comments.
141
+ AsciiComments:
142
+ Enabled: false
143
+
144
+ # It does not make sense to enforce everything to have documentation.
145
+ Documentation:
146
+ Enabled: false
147
+
148
+ # Nanoc suppresses exceptions for valid reasons in a few cases.
149
+ HandleExceptions:
150
+ Enabled: false
151
+
152
+ # if/unless at the end of the line makes it too easy to oversee.
153
+ IfUnlessModifier:
154
+ Enabled: false
155
+
156
+ # Personal preference is to have decent constructors for exceptions rather than
157
+ # just a class and a message.
158
+ RaiseArgs:
159
+ Enabled: false
160
+
161
+ # Personal preference is to use `raise` to signal exceptions (normal control
162
+ # flow should not use exceptions anyway).
163
+ SignalException:
164
+ Enabled: false
165
+
166
+ # Some methods that appear to be accessors (return a single value or set a
167
+ # single value) should still not be considered to be accessors. This is a purely
168
+ # semantic difference.
169
+ TrivialAccessors:
170
+ Enabled: false
171
+
172
+ # This does not always semantically make sense.
173
+ GuardClause:
174
+ Enabled: false
data/.travis.yml ADDED
@@ -0,0 +1,27 @@
1
+ language: ruby
2
+ rvm:
3
+ - "2.3"
4
+ - "2.4"
5
+ branches:
6
+ only:
7
+ - "master"
8
+ env:
9
+ global:
10
+ -
11
+ LC_ALL=en_US.UTF_8
12
+ LANG=en_US.UTF_8
13
+ matrix:
14
+ fast_finish: true
15
+ include:
16
+ - rvm: jruby-9.1.9.0
17
+ env: DISABLE_NOKOGIRI=1
18
+ allow_failures:
19
+ - rvm: jruby-9.1.9.0
20
+ env: DISABLE_NOKOGIRI=1
21
+ script:
22
+ - bundle exec rake test_ci
23
+ - bundle exec appraisal install && FOCUS=rouge bundle exec appraisal rake spec
24
+ cache: bundler
25
+ sudo: false
26
+ git:
27
+ depth: 10
data/Gemfile CHANGED
@@ -21,7 +21,7 @@ group :devel do
21
21
  gem 'rspec'
22
22
  gem 'rspec-its', '~> 1.2'
23
23
  gem 'rspec-mocks'
24
- gem 'rubocop', github: 'bbatsov/rubocop'
24
+ gem 'rubocop', '~> 0.49'
25
25
  gem 'simplecov', require: false
26
26
  gem 'timecop'
27
27
  gem 'vcr'
@@ -44,13 +44,14 @@ group :plugins do
44
44
  gem 'handlebars', platforms: :ruby
45
45
  gem 'kramdown'
46
46
  gem 'less', '~> 2.0', platforms: :ruby
47
+ gem 'libv8', platforms: :ruby
47
48
  gem 'listen'
48
49
  gem 'markaby'
49
50
  gem 'maruku'
50
51
  gem 'mime-types'
51
52
  gem 'mustache', '~> 1.0'
52
53
  gem 'nokogiri', '~> 1.6'
53
- gem 'nokogumbo', '~> 1.4'
54
+ gem 'nokogumbo', '~> 1.4', platforms: :ruby
54
55
  gem 'pandoc-ruby'
55
56
  gem 'pygments.rb', '~> 1.1', '>= 1.1.1', platforms: %i[ruby mswin]
56
57
  gem 'rack'
@@ -62,7 +63,7 @@ group :plugins do
62
63
  gem 'rubypants'
63
64
  gem 'sass'
64
65
  gem 'slim', '~> 3.0'
65
- gem 'therubyracer', '~> 0.12'
66
+ gem 'therubyracer', '~> 0.12', platforms: :ruby
66
67
  gem 'typogruby'
67
68
  gem 'uglifier'
68
69
  gem 'w3c_validators'
data/NEWS.md CHANGED
@@ -1,5 +1,16 @@
1
1
  # Nanoc news
2
2
 
3
+ ## 4.7.11 (2017-06-17)
4
+
5
+ Fixes:
6
+
7
+ * Made the `external_links` check always use GET, not HEAD (#1178, #1179)
8
+ * Fixed an issue where changing identifiers during preprocessing could cause a crash (#1184, #1185)
9
+
10
+ Enhancements:
11
+
12
+ * Added `--preprocess` to `shell` command, to load preprocessed site data (#1180)
13
+
3
14
  ## 4.7.10 (2017-05-14)
4
15
 
5
16
  Fixes:
data/Rakefile CHANGED
@@ -10,11 +10,14 @@ RuboCop::RakeTask.new(:rubocop)
10
10
  Coveralls::RakeTask.new
11
11
 
12
12
  Rake::TestTask.new(:test_all) do |t|
13
- t.test_files = Dir['test/**/*_spec.rb'] + Dir['test/**/test_*.rb']
13
+ t.test_files = Dir['test/**/test_*.rb']
14
14
  t.libs << 'test'
15
+ t.verbose = false
15
16
  end
16
17
 
17
- RSpec::Core::RakeTask.new(:spec)
18
+ RSpec::Core::RakeTask.new(:spec) do |t|
19
+ t.verbose = false
20
+ end
18
21
 
19
22
  task test: %i[spec test_all rubocop]
20
23
  task test_ci: %i[test coveralls:push]
@@ -6,16 +6,18 @@ module Nanoc::Int
6
6
  class Dependency
7
7
  include Nanoc::Int::ContractsSupport
8
8
 
9
- contract C::None => C::Maybe[C::Or[Nanoc::Int::Item, Nanoc::Int::Layout]]
9
+ C_OBJ = C::Or[Nanoc::Int::Item, Nanoc::Int::Layout, Nanoc::Int::Configuration]
10
+
11
+ contract C::None => C::Maybe[C_OBJ]
10
12
  attr_reader :from
11
13
 
12
- contract C::None => C::Maybe[C::Or[Nanoc::Int::Item, Nanoc::Int::Layout]]
14
+ contract C::None => C::Maybe[C_OBJ]
13
15
  attr_reader :to
14
16
 
15
17
  contract C::None => Nanoc::Int::Props
16
18
  attr_reader :props
17
19
 
18
- contract C::Maybe[C::Or[Nanoc::Int::Item, Nanoc::Int::Layout]], C::Maybe[C::Or[Nanoc::Int::Item, Nanoc::Int::Layout]], Nanoc::Int::Props => C::Any
20
+ contract C::Maybe[C_OBJ], C::Maybe[C_OBJ], Nanoc::Int::Props => C::Any
19
21
  def initialize(from, to, props)
20
22
  @from = from
21
23
  @to = to
@@ -4,7 +4,7 @@ module Nanoc::Int
4
4
  # @api private
5
5
  class Layout < ::Nanoc::Int::Document
6
6
  def reference
7
- [:layout, identifier]
7
+ [:layout, identifier.to_s]
8
8
  end
9
9
  end
10
10
  end
@@ -14,11 +14,17 @@ module Nanoc::Int
14
14
  @items = items
15
15
  @layouts = layouts
16
16
 
17
+ @refs2objs = {}
18
+ items.each { |o| add_vertex_for(o) }
19
+ layouts.each { |o| add_vertex_for(o) }
20
+
17
21
  @new_objects = []
18
- @graph = Nanoc::Int::DirectedGraph.new([nil] + @items.to_a + @layouts.to_a)
22
+ @graph = Nanoc::Int::DirectedGraph.new([nil] + objs2refs(@items) + objs2refs(@layouts))
19
23
  end
20
24
 
21
- contract C::Or[Nanoc::Int::Item, Nanoc::Int::ItemRep, Nanoc::Int::Layout] => C::ArrayOf[Nanoc::Int::Dependency]
25
+ # FIXME: ItemRep?
26
+ C_OBJ = C::Or[Nanoc::Int::Item, Nanoc::Int::ItemRep, Nanoc::Int::Layout, Nanoc::Int::Configuration]
27
+ contract C_OBJ => C::ArrayOf[Nanoc::Int::Dependency]
22
28
  def dependencies_causing_outdatedness_of(object)
23
29
  objects_causing_outdatedness_of(object).map do |other_object|
24
30
  props = props_for(other_object, object)
@@ -36,6 +42,16 @@ module Nanoc::Int
36
42
  end
37
43
  end
38
44
 
45
+ def items=(items)
46
+ @items = items
47
+ items.each { |o| @refs2objs[obj2ref(o)] = o }
48
+ end
49
+
50
+ def layouts=(layouts)
51
+ @layouts = layouts
52
+ layouts.each { |o| @refs2objs[obj2ref(o)] = o }
53
+ end
54
+
39
55
  # Returns the direct dependencies for the given object.
40
56
  #
41
57
  # The direct dependencies of the given object include the items and
@@ -57,13 +73,12 @@ module Nanoc::Int
57
73
  if @new_objects.any?
58
74
  [@new_objects.first]
59
75
  else
60
- @graph.direct_predecessors_of(object)
76
+ refs2objs(@graph.direct_predecessors_of(obj2ref(object)))
61
77
  end
62
78
  end
63
79
 
64
- C_DOC = C::Or[Nanoc::Int::Item, Nanoc::Int::Layout]
65
80
  C_ATTR = C::Or[C::IterOf[Symbol], C::Bool]
66
- contract C::Maybe[C_DOC], C::Maybe[C_DOC], C::KeywordArgs[raw_content: C::Optional[C::Bool], attributes: C::Optional[C_ATTR], compiled_content: C::Optional[C::Bool], path: C::Optional[C::Bool]] => C::Any
81
+ contract C::Maybe[C_OBJ], C::Maybe[C_OBJ], C::KeywordArgs[raw_content: C::Optional[C::Bool], attributes: C::Optional[C_ATTR], compiled_content: C::Optional[C::Bool], path: C::Optional[C::Bool]] => C::Any
67
82
  # Records a dependency from `src` to `dst` in the dependency graph. When
68
83
  # `dst` is oudated, `src` will also become outdated.
69
84
  #
@@ -76,11 +91,23 @@ module Nanoc::Int
76
91
  #
77
92
  # @return [void]
78
93
  def record_dependency(src, dst, raw_content: false, attributes: false, compiled_content: false, path: false)
79
- existing_props = Nanoc::Int::Props.new(@graph.props_for(dst, src) || {})
94
+ # TODO: do src == dst check first (faster)
95
+
96
+ add_vertex_for(src)
97
+ add_vertex_for(dst)
98
+
99
+ src_ref = obj2ref(src)
100
+ dst_ref = obj2ref(dst)
101
+
102
+ existing_props = Nanoc::Int::Props.new(@graph.props_for(dst_ref, src_ref) || {})
80
103
  new_props = Nanoc::Int::Props.new(raw_content: raw_content, attributes: attributes, compiled_content: compiled_content, path: path)
81
104
  props = existing_props.merge(new_props)
82
105
 
83
- @graph.add_edge(dst, src, props: props.to_h) unless src == dst
106
+ @graph.add_edge(dst_ref, src_ref, props: props.to_h) unless src == dst
107
+ end
108
+
109
+ def add_vertex_for(o)
110
+ @refs2objs[obj2ref(o)] = o
84
111
  end
85
112
 
86
113
  # Empties the list of dependencies for the given object. This is necessary
@@ -93,13 +120,33 @@ module Nanoc::Int
93
120
  #
94
121
  # @return [void]
95
122
  def forget_dependencies_for(object)
96
- @graph.delete_edges_to(object)
123
+ @graph.delete_edges_to(obj2ref(object))
97
124
  end
98
125
 
99
126
  protected
100
127
 
128
+ def obj2ref(obj)
129
+ obj && obj.reference
130
+ end
131
+
132
+ def ref2obj(reference)
133
+ if reference
134
+ @refs2objs[reference]
135
+ else
136
+ nil
137
+ end
138
+ end
139
+
140
+ def objs2refs(objs)
141
+ objs.map { |o| obj2ref(o) }
142
+ end
143
+
144
+ def refs2objs(refs)
145
+ refs.map { |r| ref2obj(r) }
146
+ end
147
+
101
148
  def props_for(a, b)
102
- props = @graph.props_for(a, b) || {}
149
+ props = @graph.props_for(obj2ref(a), obj2ref(b)) || {}
103
150
 
104
151
  if props.values.any? { |v| v }
105
152
  props
@@ -111,37 +158,26 @@ module Nanoc::Int
111
158
  def data
112
159
  {
113
160
  edges: @graph.edges,
114
- vertices: @graph.vertices.map { |obj| obj && obj.reference },
161
+ vertices: @graph.vertices,
115
162
  }
116
163
  end
117
164
 
118
165
  def data=(new_data)
119
- objects = @items.to_a + @layouts.to_a
166
+ objects = Set.new(@items.to_a + @layouts.to_a)
167
+ refs = objs2refs(objects)
120
168
 
121
169
  # Create new graph
122
- @graph = Nanoc::Int::DirectedGraph.new([nil] + objects)
170
+ @graph = Nanoc::Int::DirectedGraph.new([nil] + refs)
123
171
 
124
172
  # Load vertices
125
- previous_objects = new_data[:vertices].map do |reference|
126
- if reference
127
- case reference[0]
128
- when :item
129
- @items.object_with_identifier(reference[1])
130
- when :layout
131
- @layouts.object_with_identifier(reference[1])
132
- else
133
- raise Nanoc::Int::Errors::InternalInconsistency, "unrecognised reference #{reference[0].inspect}"
134
- end
135
- else
136
- nil
137
- end
138
- end
173
+ previous_refs = new_data[:vertices]
174
+ previous_objects = Set.new(refs2objs(previous_refs))
139
175
 
140
176
  # Load edges
141
177
  new_data[:edges].each do |edge|
142
178
  from_index, to_index, props = *edge
143
- from = from_index && previous_objects[from_index]
144
- to = to_index && previous_objects[to_index]
179
+ from = from_index && previous_refs[from_index]
180
+ to = to_index && previous_refs[to_index]
145
181
  @graph.add_edge(from, to, props: props)
146
182
  end
147
183