nanoc 4.0.0b4 → 4.0.0rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (104) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +2 -2
  3. data/Gemfile.lock +31 -32
  4. data/NEWS.md +7 -0
  5. data/README.md +1 -2
  6. data/Rakefile +2 -11
  7. data/TODO.md +0 -1
  8. data/bin/nanoc +4 -0
  9. data/lib/nanoc/base/checksummer.rb +1 -1
  10. data/lib/nanoc/base/compilation/compiler.rb +7 -13
  11. data/lib/nanoc/base/compilation/dependency_tracker.rb +1 -1
  12. data/lib/nanoc/base/compilation/rule.rb +2 -0
  13. data/lib/nanoc/base/compilation/rules_collection.rb +2 -2
  14. data/lib/nanoc/base/entities/identifier.rb +45 -15
  15. data/lib/nanoc/base/entities/pattern.rb +8 -0
  16. data/lib/nanoc/base/entities/snapshot_def.rb +16 -0
  17. data/lib/nanoc/base/entities.rb +1 -0
  18. data/lib/nanoc/base/plugin_registry.rb +1 -1
  19. data/lib/nanoc/base/{compilation → repos}/checksum_store.rb +0 -0
  20. data/lib/nanoc/base/{compilation → repos}/compiled_content_cache.rb +0 -0
  21. data/lib/nanoc/base/repos/config_loader.rb +67 -0
  22. data/lib/nanoc/base/{compilation → repos}/rule_memory_store.rb +0 -0
  23. data/lib/nanoc/base/repos/site_loader.rb +118 -0
  24. data/lib/nanoc/base/{store.rb → repos/store.rb} +0 -0
  25. data/lib/nanoc/base/repos.rb +7 -0
  26. data/lib/nanoc/base/result_data/item_rep.rb +37 -66
  27. data/lib/nanoc/base/services/executor.rb +15 -9
  28. data/lib/nanoc/base/services/item_rep_writer.rb +1 -1
  29. data/lib/nanoc/base/services/recording_executor.rb +4 -4
  30. data/lib/nanoc/base/source_data/configuration.rb +89 -3
  31. data/lib/nanoc/base/source_data/data_source.rb +2 -15
  32. data/lib/nanoc/base/source_data/site.rb +14 -378
  33. data/lib/nanoc/base/views/{config.rb → config_view.rb} +0 -0
  34. data/lib/nanoc/base/views/{identifiable_collection.rb → identifiable_collection_view.rb} +0 -0
  35. data/lib/nanoc/base/views/{item_collection.rb → item_collection_view.rb} +0 -0
  36. data/lib/nanoc/base/views/{item_rep_collection.rb → item_rep_collection_view.rb} +7 -1
  37. data/lib/nanoc/base/views/{item_rep.rb → item_rep_view.rb} +0 -0
  38. data/lib/nanoc/base/views/{item.rb → item_view.rb} +0 -0
  39. data/lib/nanoc/base/views/{layout_collection.rb → layout_collection_view.rb} +0 -0
  40. data/lib/nanoc/base/views/{layout.rb → layout_view.rb} +0 -0
  41. data/lib/nanoc/base/views/mixins/{document.rb → document_view_mixin.rb} +0 -0
  42. data/lib/nanoc/base/views/mixins/{mutable_document.rb → mutable_document_view_mixin.rb} +0 -0
  43. data/lib/nanoc/base/views/{mutable_config.rb → mutable_config_view.rb} +0 -0
  44. data/lib/nanoc/base/views/{mutable_identifiable_collection.rb → mutable_identifiable_collection_view.rb} +0 -0
  45. data/lib/nanoc/base/views/{mutable_item_collection.rb → mutable_item_collection_view.rb} +0 -0
  46. data/lib/nanoc/base/views/{mutable_item.rb → mutable_item_view.rb} +0 -0
  47. data/lib/nanoc/base/views/{mutable_layout_collection.rb → mutable_layout_collection_view.rb} +0 -0
  48. data/lib/nanoc/base/views/{mutable_layout.rb → mutable_layout_view.rb} +0 -0
  49. data/lib/nanoc/base/views/{site.rb → site_view.rb} +0 -0
  50. data/lib/nanoc/base/views.rb +17 -17
  51. data/lib/nanoc/base.rb +1 -4
  52. data/lib/nanoc/cli/ansi_string_colorizer.rb +1 -1
  53. data/lib/nanoc/cli/cleaning_stream.rb +5 -0
  54. data/lib/nanoc/cli/command_runner.rb +10 -4
  55. data/lib/nanoc/cli/commands/compile.rb +1 -1
  56. data/lib/nanoc/cli/commands/create-site.rb +12 -11
  57. data/lib/nanoc/cli/commands/prune.rb +1 -0
  58. data/lib/nanoc/cli/commands/show-plugins.rb +4 -4
  59. data/lib/nanoc/cli/commands/show-rules.rb +21 -30
  60. data/lib/nanoc/cli/commands/view.rb +1 -1
  61. data/lib/nanoc/cli/error_handler.rb +1 -1
  62. data/lib/nanoc/cli.rb +3 -3
  63. data/lib/nanoc/data_sources/filesystem.rb +4 -4
  64. data/lib/nanoc/extra/checking/runner.rb +3 -2
  65. data/lib/nanoc/extra/deployers/rsync.rb +1 -1
  66. data/lib/nanoc/extra/link_collector.rb +1 -1
  67. data/lib/nanoc/helpers/capturing.rb +1 -1
  68. data/lib/nanoc/helpers/rendering.rb +2 -2
  69. data/lib/nanoc/version.rb +1 -1
  70. data/nanoc.gemspec +3 -4
  71. data/tasks/doc.rake +1 -1
  72. data/tasks/rubocop.rake +4 -8
  73. data/tasks/test.rake +11 -27
  74. data/test/base/test_compiler.rb +21 -16
  75. data/test/base/test_compiler_dsl.rb +8 -8
  76. data/test/base/test_item.rb +1 -1
  77. data/test/base/test_item_rep.rb +16 -14
  78. data/test/base/test_memoization.rb +1 -38
  79. data/test/base/test_outdatedness_checker.rb +38 -6
  80. data/test/base/test_site.rb +19 -121
  81. data/test/cli/commands/test_compile.rb +1 -1
  82. data/test/cli/commands/test_create_site.rb +7 -8
  83. data/test/data_sources/test_filesystem.rb +7 -7
  84. data/test/data_sources/test_filesystem_unified.rb +17 -17
  85. data/test/extra/checking/checks/test_mixed_content.rb +8 -8
  86. data/test/extra/checking/checks/test_stale.rb +3 -4
  87. data/test/extra/deployers/test_fog.rb +1 -1
  88. data/test/extra/deployers/test_rsync.rb +2 -2
  89. data/test/extra/test_filesystem_tools.rb +1 -1
  90. data/test/filters/test_erb.rb +1 -1
  91. data/test/filters/test_handlebars.rb +2 -2
  92. data/test/filters/test_less.rb +2 -2
  93. data/test/filters/test_mustache.rb +2 -2
  94. data/test/filters/test_relativize_paths.rb +1 -1
  95. data/test/filters/test_sass.rb +6 -6
  96. data/test/filters/test_xsl.rb +3 -3
  97. data/test/helper.rb +10 -15
  98. data/test/helpers/test_blogging.rb +16 -16
  99. data/test/helpers/test_capturing.rb +6 -6
  100. data/test/helpers/test_link_to.rb +13 -13
  101. data/test/helpers/test_rendering.rb +33 -0
  102. data/test/helpers/test_tagging.rb +8 -8
  103. metadata +32 -30
  104. data/test/gem_loader.rb +0 -9
@@ -1,54 +1,17 @@
1
1
  module Nanoc::Int
2
- # The in-memory representation of a nanoc site. It holds references to the
3
- # following site data:
4
- #
5
- # * {#items} — the list of items ({Nanoc::Int::Item})
6
- # * {#layouts} — the list of layouts ({Nanoc::Int::Layout})
7
- # * {#code_snippets} — the list of code snippets ({Nanoc::Int::CodeSnippet})
8
- # * {#data_sources} — the list of data sources ({Nanoc::DataSource})
9
- #
10
- # In addition, each site has a {#config} hash which stores the site
11
- # configuration.
12
- #
13
- # The physical representation of a {Nanoc::Int::Site} is usually a directory
14
- # that contains a configuration file, site data, a rakefile, a rules file,
15
- # etc. The way site data is stored depends on the data source.
16
- #
17
2
  # @api private
18
3
  class Site
19
- # The default configuration for a data source. A data source's
20
- # configuration overrides these options.
21
- DEFAULT_DATA_SOURCE_CONFIG = {
22
- type: 'filesystem',
23
- items_root: '/',
24
- layouts_root: '/',
25
- config: {},
26
- identifier_type: 'full',
27
- }
28
-
29
- # The default configuration for a site. A site's configuration overrides
30
- # these options: when a {Nanoc::Int::Site} is created with a configuration
31
- # that lacks some options, the default value will be taken from
32
- # `DEFAULT_CONFIG`.
33
- DEFAULT_CONFIG = {
34
- text_extensions: %w( css erb haml htm html js less markdown md php rb sass scss txt xhtml xml coffee hb handlebars mustache ms slim rdoc ).sort,
35
- lib_dirs: %w( lib ),
36
- commands_dirs: %w( commands ),
37
- output_dir: 'output',
38
- data_sources: [{}],
39
- index_filenames: ['index.html'],
40
- enable_output_diff: false,
41
- prune: { auto_prune: false, exclude: ['.git', '.hg', '.svn', 'CVS'] },
42
- string_pattern_type: 'glob',
43
- }
44
-
45
- # Creates a site object for the site specified by the given
46
- # `dir_or_config_hash` argument.
4
+ # @option params [Nanoc::Int::Configuration] :config
47
5
  #
48
- # @param [Hash, String] dir_or_config_hash If a string, contains the path
49
- # to the site directory; if a hash, contains the site configuration.
50
- def initialize(dir_or_config_hash)
51
- build_config(dir_or_config_hash)
6
+ # @option params [Enumerable<Nanoc::Int::CodeSnippet>] :code_snippets
7
+ def initialize(params = {})
8
+ @config = params.fetch(:config)
9
+ @code_snippets = params.fetch(:code_snippets)
10
+ @items = params.fetch(:items)
11
+ @layouts = params.fetch(:layouts)
12
+
13
+ ensure_identifier_uniqueness(@items, 'item')
14
+ ensure_identifier_uniqueness(@layouts, 'layout')
52
15
  end
53
16
 
54
17
  # Compiles the site.
@@ -68,142 +31,10 @@ module Nanoc::Int
68
31
  @compiler ||= Nanoc::Int::Compiler.new(self)
69
32
  end
70
33
 
71
- # Returns the data sources for this site. Will create a new data source if
72
- # none exists yet.
73
- #
74
- # @return [Array<Nanoc::DataSource>] The list of data sources for this
75
- # site
76
- #
77
- # @raise [Nanoc::Int::Errors::UnknownDataSource] if the site configuration
78
- # specifies an unknown data source
79
- def data_sources
80
- load_code_snippets
81
-
82
- @data_sources ||= begin
83
- @config[:data_sources].map do |data_source_hash|
84
- # Get data source class
85
- data_source_class = Nanoc::DataSource.named(data_source_hash[:type])
86
- raise Nanoc::Int::Errors::UnknownDataSource.new(data_source_hash[:type]) if data_source_class.nil?
87
-
88
- # Create data source
89
- data_source_class.new(
90
- self,
91
- data_source_hash[:items_root],
92
- data_source_hash[:layouts_root],
93
- data_source_hash.merge(data_source_hash[:config] || {})
94
- )
95
- end
96
- end
97
- end
98
-
99
- # Returns this site’s code snippets.
100
- #
101
- # @return [Array<Nanoc::Int::CodeSnippet>] The list of code snippets in this
102
- # site
103
- def code_snippets
104
- load
105
- @code_snippets
106
- end
107
-
108
- # Returns this site’s items.
109
- #
110
- # @return [Array<Nanoc::Int::Item>] The list of items in this site
111
- def items
112
- load
113
- @items
114
- end
115
-
116
- # Returns this site’s layouts.
117
- #
118
- # @return [Array<Nanoc::Int::Layouts>] The list of layout in this site
119
- def layouts
120
- load
121
- @layouts
122
- end
123
-
124
- # Returns the site configuration. It has the following keys:
125
- #
126
- # * `text_extensions` (`Array<String>`) - A list of file extensions that
127
- # will cause nanoc to threat the file as textual instead of binary. When
128
- # the data source finds a content file with an extension that is
129
- # included in this list, it will be marked as textual.
130
- #
131
- # * `output_dir` (`String`) - The directory to which compiled items will
132
- # be written. This path is relative to the current working directory,
133
- # but can also be an absolute path.
134
- #
135
- # * `data_sources` (`Array<Hash>`) - A list of data sources for this site.
136
- # See below for documentation on the structure of this list. By default,
137
- # there is only one data source of the filesystem type mounted at `/`.
138
- #
139
- # * `index_filenames` (`Array<String>`) - A list of filenames that will be
140
- # stripped off full item paths to create cleaner URLs. For example,
141
- # `/about/` will be used instead of `/about/index.html`). The default
142
- # value should be okay in most cases.
143
- #
144
- # * `enable_output_diff` (`Boolean`) - True when diffs should be generated
145
- # for the compiled content of this site; false otherwise.
146
- #
147
- # The list of data sources consists of hashes with the following keys:
148
- #
149
- # * `:type` (`String`) - The type of data source, i.e. its identifier.
150
- #
151
- # * `:items_root` (`String`) - The prefix that should be given to all
152
- # items returned by the {#items} method (comparable to mount points
153
- # for filesystems in Unix-ish OSes).
154
- #
155
- # * `:layouts_root` (`String`) - The prefix that should be given to all
156
- # layouts returned by the {#layouts} method (comparable to mount
157
- # points for filesystems in Unix-ish OSes).
158
- #
159
- # * `:config` (`Hash`) - A hash containing the configuration for this data
160
- # source. nanoc itself does not use this hash. This is especially
161
- # useful for online data sources; for example, a Twitter data source
162
- # would need the username of the account from which to fetch tweets.
163
- #
164
- # @return [Hash] The site configuration
165
- def config
166
- @config
167
- end
168
-
169
- # Fills each item's parent reference and children array with the
170
- # appropriate items. It is probably not necessary to call this method
171
- # manually; it will be called when appropriate.
172
- #
173
- # @return [void]
174
- def setup_child_parent_links
175
- teardown_child_parent_links
176
-
177
- item_map = {}
178
- @items.each do |item|
179
- next if item.identifier !~ /\/\z/
180
- item_map[item.identifier.to_s] = item
181
- end
182
-
183
- @items.each do |item|
184
- parent_id_end = item.identifier.to_s.rindex('/', -2)
185
- next unless parent_id_end
186
-
187
- parent_id = item.identifier.to_s[0..parent_id_end]
188
- parent = item_map[parent_id]
189
- next unless parent
190
-
191
- item.parent = parent
192
- parent.children << item
193
- end
194
- end
195
-
196
- # Removes all child-parent links.
197
- #
198
- # @api private
199
- #
200
- # @return [void]
201
- def teardown_child_parent_links
202
- @items.each do |item|
203
- item.parent = nil
204
- item.children = []
205
- end
206
- end
34
+ attr_reader :code_snippets
35
+ attr_reader :config
36
+ attr_reader :items
37
+ attr_reader :layouts
207
38
 
208
39
  # Prevents all further modifications to itself, its items, its layouts etc.
209
40
  #
@@ -212,167 +43,6 @@ module Nanoc::Int
212
43
  config.__nanoc_freeze_recursively
213
44
  items.each(&:freeze)
214
45
  layouts.each(&:freeze)
215
- code_snippets.each(&:freeze)
216
- end
217
-
218
- # Loads the site data. It is not necessary to call this method explicitly;
219
- # it will be called when it is necessary.
220
- #
221
- # @api private
222
- #
223
- # @return [void]
224
- def load
225
- return if @loaded || @loading
226
- @loading = true
227
-
228
- # Load all data
229
- load_code_snippets
230
- with_datasources do
231
- load_items
232
- load_layouts
233
- end
234
- setup_child_parent_links
235
-
236
- # Ensure unique
237
- ensure_identifier_uniqueness(@items, 'item')
238
- ensure_identifier_uniqueness(@layouts, 'layout')
239
-
240
- # Load compiler too
241
- # FIXME: this should not be necessary
242
- compiler.load
243
-
244
- @loaded = true
245
- rescue => e
246
- unload
247
- raise e
248
- ensure
249
- @loading = false
250
- end
251
-
252
- # Undoes the effects of {#load}. Used when {#load} raises an exception.
253
- #
254
- # @api private
255
- def unload
256
- return if @unloading
257
- @unloading = true
258
-
259
- @items_loaded = false
260
- @items = []
261
- @layouts_loaded = false
262
- @layouts = []
263
- @code_snippets_loaded = false
264
- @code_snippets = []
265
-
266
- compiler.unload
267
-
268
- @loaded = false
269
- @unloading = false
270
- end
271
-
272
- # @return [Boolean] true if the current working directory is a nanoc site, false otherwise
273
- #
274
- # @api private
275
- def self.cwd_is_nanoc_site?
276
- !config_filename_for_cwd.nil?
277
- end
278
-
279
- # @return [String] filename of the nanoc config file in the current working directory, or nil if there is none
280
- #
281
- # @api private
282
- def self.config_filename_for_cwd
283
- filenames = %w( nanoc.yaml config.yaml )
284
- filenames.find { |f| File.file?(f) }
285
- end
286
-
287
- private
288
-
289
- # Executes the given block, making sure that the datasources are
290
- # available for the duration of the block
291
- def with_datasources(&_block)
292
- data_sources.each(&:use)
293
- yield
294
- ensure
295
- data_sources.each(&:unuse)
296
- end
297
-
298
- # Loads this site’s code and executes it.
299
- def load_code_snippets
300
- @code_snippets_loaded ||= false
301
- return if @code_snippets_loaded
302
- @code_snippets_loaded = true
303
-
304
- # Get code snippets
305
- @code_snippets = []
306
- config[:lib_dirs].each do |lib|
307
- code_snippets = Dir["#{lib}/**/*.rb"].sort.map do |filename|
308
- Nanoc::Int::CodeSnippet.new(
309
- File.read(filename),
310
- filename
311
- )
312
- end
313
- @code_snippets.concat(code_snippets)
314
- end
315
-
316
- # Execute code snippets
317
- @code_snippets.each(&:load)
318
- end
319
-
320
- # Loads this site’s items, sets up item child-parent relationships and
321
- # builds each item's list of item representations.
322
- def load_items
323
- @items_loaded ||= false
324
- return if @items_loaded
325
- @items_loaded = true
326
-
327
- # Get items
328
- @items = Nanoc::Int::IdentifiableCollection.new(@config)
329
- data_sources.each do |ds|
330
- items_in_ds = ds.items
331
- items_in_ds.each do |i|
332
- i.identifier = i.identifier.prefix(ds.items_root)
333
- end
334
- @items.concat(items_in_ds)
335
- end
336
- end
337
-
338
- # Loads this site’s layouts.
339
- def load_layouts
340
- @layouts_loaded ||= false
341
- return if @layouts_loaded
342
- @layouts_loaded = true
343
-
344
- # Get layouts
345
- @layouts = Nanoc::Int::IdentifiableCollection.new(@config)
346
- data_sources.each do |ds|
347
- layouts_in_ds = ds.layouts
348
- layouts_in_ds.each do |l|
349
- l.identifier = l.identifier.prefix(ds.layouts_root)
350
- end
351
- @layouts.concat(layouts_in_ds)
352
- end
353
- end
354
-
355
- # Loads a configuration file.
356
- def load_config(config_path)
357
- YAML.load_file(config_path).__nanoc_symbolize_keys_recursively
358
- end
359
-
360
- def apply_parent_config(config, config_paths = [])
361
- parent_config_file = config[:parent_config_file]
362
- if parent_config_file
363
- config.delete(:parent_config_file)
364
- config_path = File.absolute_path(parent_config_file, File.dirname(config_paths.last))
365
- unless File.file?(config_path)
366
- raise Nanoc::Int::Errors::GenericTrivial, "Could not find parent configuration file '#{parent_config_file}'"
367
- end
368
- if config_paths.include?(config_path)
369
- raise Nanoc::Int::Errors::GenericTrivial, "Cycle detected. Could not use parent configuration file '#{parent_config_file}'"
370
- end
371
- parent_config = load_config(config_path)
372
- apply_parent_config(parent_config, config_paths + [config_path]).merge(config)
373
- else
374
- config
375
- end
376
46
  end
377
47
 
378
48
  def ensure_identifier_uniqueness(objects, type)
@@ -384,39 +54,5 @@ module Nanoc::Int
384
54
  seen << obj.identifier
385
55
  end
386
56
  end
387
-
388
- # Builds the configuration hash based on the given argument. Also see
389
- # {#initialize} for details.
390
- def build_config(dir_or_config_hash)
391
- if dir_or_config_hash.is_a? String
392
- # Check whether it is supported
393
- if dir_or_config_hash != '.'
394
- warn 'WARNING: Calling Nanoc::Int::Site.new with a directory that is not the current working directory is not supported. It is recommended to change the directory before calling Nanoc::Int::Site.new. For example, instead of Nanoc::Int::Site.new(\'abc\'), use Dir.chdir(\'abc\') { Nanoc::Int::Site.new(\'.\') }.'
395
- end
396
-
397
- # Read config from nanoc.yaml/config.yaml in given dir
398
- config_path = Dir.chdir(dir_or_config_hash) do
399
- filename = self.class.config_filename_for_cwd
400
- if filename.nil?
401
- raise Nanoc::Int::Errors::GenericTrivial, 'Could not find nanoc.yaml or config.yaml in the current working directory'
402
- end
403
- File.absolute_path(filename, dir_or_config_hash)
404
- end
405
-
406
- @config = apply_parent_config(load_config(config_path), [config_path])
407
- else
408
- # Use passed config hash
409
- @config = apply_parent_config(dir_or_config_hash.__nanoc_symbolize_keys_recursively)
410
- end
411
-
412
- # Merge config with default config
413
- @config = DEFAULT_CONFIG.merge(@config)
414
-
415
- # Merge data sources with default data source config
416
- @config[:data_sources] = @config[:data_sources].map { |ds| DEFAULT_DATA_SOURCE_CONFIG.merge(ds) }
417
-
418
- # Convert to proper configuration
419
- @config = Nanoc::Int::Configuration.new(@config)
420
- end
421
57
  end
422
58
  end
File without changes
@@ -2,6 +2,12 @@ module Nanoc
2
2
  class ItemRepCollectionView
3
3
  include Enumerable
4
4
 
5
+ class NoSuchItemRepError < ::Nanoc::Error
6
+ def initialize(rep_name)
7
+ super("No rep named #{rep_name.inspect} was found.")
8
+ end
9
+ end
10
+
5
11
  # @api private
6
12
  def initialize(item_reps)
7
13
  @item_reps = item_reps
@@ -58,7 +64,7 @@ module Nanoc
58
64
  if res
59
65
  Nanoc::ItemRepView.new(res)
60
66
  else
61
- raise Nanoc::Int::Errors::Generic, "No rep named #{rep_name.inspect} was found."
67
+ raise NoSuchItemRepError.new(rep_name)
62
68
  end
63
69
  end
64
70
  end
File without changes
File without changes
File without changes
@@ -1,18 +1,18 @@
1
- require_relative 'views/mixins/document'
2
- require_relative 'views/mixins/mutable_document'
1
+ require_relative 'views/mixins/document_view_mixin'
2
+ require_relative 'views/mixins/mutable_document_view_mixin'
3
3
 
4
- require_relative 'views/config'
5
- require_relative 'views/identifiable_collection'
6
- require_relative 'views/item'
7
- require_relative 'views/item_collection'
8
- require_relative 'views/item_rep'
9
- require_relative 'views/item_rep_collection'
10
- require_relative 'views/layout'
11
- require_relative 'views/layout_collection'
12
- require_relative 'views/mutable_config'
13
- require_relative 'views/mutable_identifiable_collection'
14
- require_relative 'views/mutable_item'
15
- require_relative 'views/mutable_item_collection'
16
- require_relative 'views/mutable_layout'
17
- require_relative 'views/mutable_layout_collection'
18
- require_relative 'views/site'
4
+ require_relative 'views/config_view'
5
+ require_relative 'views/identifiable_collection_view'
6
+ require_relative 'views/item_view'
7
+ require_relative 'views/item_collection_view'
8
+ require_relative 'views/item_rep_view'
9
+ require_relative 'views/item_rep_collection_view'
10
+ require_relative 'views/layout_view'
11
+ require_relative 'views/layout_collection_view'
12
+ require_relative 'views/mutable_config_view'
13
+ require_relative 'views/mutable_identifiable_collection_view'
14
+ require_relative 'views/mutable_item_view'
15
+ require_relative 'views/mutable_item_collection_view'
16
+ require_relative 'views/mutable_layout_view'
17
+ require_relative 'views/mutable_layout_collection_view'
18
+ require_relative 'views/site_view'
data/lib/nanoc/base.rb CHANGED
@@ -15,7 +15,6 @@ module Nanoc::Int
15
15
  autoload 'Errors', 'nanoc/base/errors'
16
16
  autoload 'Memoization', 'nanoc/base/memoization'
17
17
  autoload 'PluginRegistry', 'nanoc/base/plugin_registry'
18
- autoload 'Store', 'nanoc/base/store'
19
18
  autoload 'IdentifiableCollection', 'nanoc/base/identifiable_collection'
20
19
 
21
20
  # Load source data classes
@@ -28,8 +27,6 @@ module Nanoc::Int
28
27
  autoload 'ItemRep', 'nanoc/base/result_data/item_rep'
29
28
 
30
29
  # Load compilation classes
31
- autoload 'ChecksumStore', 'nanoc/base/compilation/checksum_store'
32
- autoload 'CompiledContentCache', 'nanoc/base/compilation/compiled_content_cache'
33
30
  autoload 'Compiler', 'nanoc/base/compilation/compiler'
34
31
  autoload 'CompilerDSL', 'nanoc/base/compilation/compiler_dsl'
35
32
  autoload 'DependencyTracker', 'nanoc/base/compilation/dependency_tracker'
@@ -38,10 +35,10 @@ module Nanoc::Int
38
35
  autoload 'Rule', 'nanoc/base/compilation/rule'
39
36
  autoload 'RuleContext', 'nanoc/base/compilation/rule_context'
40
37
  autoload 'RuleMemoryCalculator', 'nanoc/base/compilation/rule_memory_calculator'
41
- autoload 'RuleMemoryStore', 'nanoc/base/compilation/rule_memory_store'
42
38
  autoload 'RulesCollection', 'nanoc/base/compilation/rules_collection'
43
39
  end
44
40
 
45
41
  require_relative 'base/entities'
42
+ require_relative 'base/repos'
46
43
  require_relative 'base/services'
47
44
  require_relative 'base/views'
@@ -10,7 +10,7 @@ module Nanoc::CLI
10
10
  red: "\e[31m",
11
11
  green: "\e[32m",
12
12
  yellow: "\e[33m",
13
- blue: "\e[34m"
13
+ blue: "\e[34m",
14
14
  }
15
15
 
16
16
  # @param [String] s The string to colorize
@@ -132,6 +132,11 @@ module Nanoc::CLI
132
132
  @stream.external_encoding
133
133
  end
134
134
 
135
+ # @see ARGF.set_encoding
136
+ def set_encoding(*args)
137
+ @stream.set_encoding(*args)
138
+ end
139
+
135
140
  protected
136
141
 
137
142
  def _nanoc_clean(s)
@@ -21,16 +21,23 @@ module Nanoc::CLI
21
21
  # Load site if possible
22
22
  @site ||= nil
23
23
  if self.is_in_site_dir? && @site.nil?
24
- @site = Nanoc::Int::Site.new('.')
24
+ @site = Nanoc::Int::SiteLoader.new.new_from_cwd
25
25
  end
26
26
 
27
27
  @site
28
28
  end
29
29
 
30
+ # For debugging purposes.
31
+ #
32
+ # @api private
33
+ def site=(new_site)
34
+ @site = new_site
35
+ end
36
+
30
37
  # @return [Boolean] true if the current working directory is a nanoc site
31
38
  # directory, false otherwise
32
39
  def in_site_dir?
33
- Nanoc::Int::Site.cwd_is_nanoc_site?
40
+ Nanoc::Int::SiteLoader.cwd_is_nanoc_site?
34
41
  end
35
42
  alias_method :is_in_site_dir?, :in_site_dir?
36
43
 
@@ -50,9 +57,8 @@ module Nanoc::CLI
50
57
  #
51
58
  # @return [void]
52
59
  def load_site
60
+ print 'Loading site… '
53
61
  require_site
54
- print 'Loading site data… '
55
- site.load
56
62
  puts 'done'
57
63
  end
58
64
 
@@ -396,7 +396,7 @@ module Nanoc::CLI::Commands
396
396
  Nanoc::CLI::Commands::Compile::DebugPrinter,
397
397
  Nanoc::CLI::Commands::Compile::TimingRecorder,
398
398
  Nanoc::CLI::Commands::Compile::GCController,
399
- Nanoc::CLI::Commands::Compile::FileActionPrinter
399
+ Nanoc::CLI::Commands::Compile::FileActionPrinter,
400
400
  ]
401
401
  end
402
402