nanoc 4.0.0b2 → 4.0.0b3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (255) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +11 -22
  3. data/NEWS.md +20 -0
  4. data/Rakefile +0 -2
  5. data/bin/nanoc +0 -2
  6. data/lib/nanoc.rb +0 -2
  7. data/lib/nanoc/base.rb +1 -2
  8. data/lib/nanoc/base/checksummer.rb +0 -2
  9. data/lib/nanoc/base/compilation/checksum_store.rb +0 -2
  10. data/lib/nanoc/base/compilation/compiled_content_cache.rb +0 -2
  11. data/lib/nanoc/base/compilation/compiler.rb +0 -2
  12. data/lib/nanoc/base/compilation/compiler_dsl.rb +0 -2
  13. data/lib/nanoc/base/compilation/dependency_tracker.rb +0 -2
  14. data/lib/nanoc/base/compilation/filter.rb +0 -2
  15. data/lib/nanoc/base/compilation/item_rep_proxy.rb +0 -2
  16. data/lib/nanoc/base/compilation/item_rep_recorder_proxy.rb +0 -2
  17. data/lib/nanoc/base/compilation/outdatedness_checker.rb +0 -2
  18. data/lib/nanoc/base/compilation/outdatedness_reasons.rb +0 -2
  19. data/lib/nanoc/base/compilation/rule.rb +0 -2
  20. data/lib/nanoc/base/compilation/rule_context.rb +0 -2
  21. data/lib/nanoc/base/compilation/rule_memory_calculator.rb +0 -2
  22. data/lib/nanoc/base/compilation/rule_memory_store.rb +0 -2
  23. data/lib/nanoc/base/compilation/rules_collection.rb +0 -2
  24. data/lib/nanoc/base/context.rb +0 -2
  25. data/lib/nanoc/base/core_ext.rb +0 -2
  26. data/lib/nanoc/base/core_ext/array.rb +0 -2
  27. data/lib/nanoc/base/core_ext/hash.rb +0 -2
  28. data/lib/nanoc/base/core_ext/pathname.rb +0 -2
  29. data/lib/nanoc/base/core_ext/string.rb +0 -2
  30. data/lib/nanoc/base/directed_graph.rb +0 -2
  31. data/lib/nanoc/base/error.rb +0 -2
  32. data/lib/nanoc/base/errors.rb +0 -2
  33. data/lib/nanoc/base/identifiable_collection.rb +0 -2
  34. data/lib/nanoc/base/memoization.rb +0 -2
  35. data/lib/nanoc/base/notification_center.rb +0 -2
  36. data/lib/nanoc/base/pattern.rb +0 -2
  37. data/lib/nanoc/base/plugin_registry.rb +0 -2
  38. data/lib/nanoc/base/result_data/item_rep.rb +0 -2
  39. data/lib/nanoc/base/source_data/code_snippet.rb +0 -2
  40. data/lib/nanoc/base/source_data/configuration.rb +0 -2
  41. data/lib/nanoc/base/source_data/data_source.rb +0 -2
  42. data/lib/nanoc/base/source_data/identifier.rb +0 -2
  43. data/lib/nanoc/base/source_data/item.rb +0 -2
  44. data/lib/nanoc/base/source_data/layout.rb +0 -2
  45. data/lib/nanoc/base/source_data/site.rb +1 -3
  46. data/lib/nanoc/base/store.rb +0 -2
  47. data/lib/nanoc/base/temp_filename_factory.rb +0 -2
  48. data/lib/nanoc/base/views/config.rb +0 -2
  49. data/lib/nanoc/base/views/identifiable_collection.rb +0 -2
  50. data/lib/nanoc/base/views/item.rb +3 -5
  51. data/lib/nanoc/base/views/item_collection.rb +0 -2
  52. data/lib/nanoc/base/views/item_rep.rb +0 -2
  53. data/lib/nanoc/base/views/item_rep_collection.rb +48 -0
  54. data/lib/nanoc/base/views/layout.rb +0 -2
  55. data/lib/nanoc/base/views/layout_collection.rb +0 -2
  56. data/lib/nanoc/base/views/mutable_config.rb +0 -2
  57. data/lib/nanoc/base/views/mutable_identifiable_collection.rb +0 -2
  58. data/lib/nanoc/base/views/mutable_item.rb +0 -2
  59. data/lib/nanoc/base/views/mutable_item_collection.rb +0 -2
  60. data/lib/nanoc/base/views/mutable_layout.rb +0 -2
  61. data/lib/nanoc/base/views/mutable_layout_collection.rb +0 -2
  62. data/lib/nanoc/base/views/site.rb +0 -2
  63. data/lib/nanoc/cli.rb +0 -2
  64. data/lib/nanoc/cli/ansi_string_colorizer.rb +0 -2
  65. data/lib/nanoc/cli/cleaning_stream.rb +0 -2
  66. data/lib/nanoc/cli/command_runner.rb +0 -2
  67. data/lib/nanoc/cli/commands/check.rb +0 -2
  68. data/lib/nanoc/cli/commands/compile.rb +0 -2
  69. data/lib/nanoc/cli/commands/create-site.rb +7 -25
  70. data/lib/nanoc/cli/commands/deploy.rb +0 -2
  71. data/lib/nanoc/cli/commands/nanoc.rb +0 -2
  72. data/lib/nanoc/cli/commands/prune.rb +0 -2
  73. data/lib/nanoc/cli/commands/shell.rb +0 -2
  74. data/lib/nanoc/cli/commands/show-data.rb +0 -2
  75. data/lib/nanoc/cli/commands/show-plugins.rb +0 -2
  76. data/lib/nanoc/cli/commands/show-rules.rb +0 -2
  77. data/lib/nanoc/cli/commands/view.rb +0 -2
  78. data/lib/nanoc/cli/error_handler.rb +0 -2
  79. data/lib/nanoc/cli/logger.rb +0 -2
  80. data/lib/nanoc/cli/stream_cleaners.rb +0 -2
  81. data/lib/nanoc/cli/stream_cleaners/abstract.rb +0 -2
  82. data/lib/nanoc/cli/stream_cleaners/ansi_colors.rb +0 -2
  83. data/lib/nanoc/cli/stream_cleaners/utf8.rb +0 -2
  84. data/lib/nanoc/data_sources.rb +1 -5
  85. data/lib/nanoc/data_sources/filesystem.rb +2 -2
  86. data/lib/nanoc/data_sources/filesystem_unified.rb +0 -2
  87. data/lib/nanoc/extra.rb +0 -2
  88. data/lib/nanoc/extra/checking.rb +0 -2
  89. data/lib/nanoc/extra/checking/check.rb +23 -15
  90. data/lib/nanoc/extra/checking/checks.rb +0 -2
  91. data/lib/nanoc/extra/checking/checks/css.rb +1 -3
  92. data/lib/nanoc/extra/checking/checks/external_links.rb +0 -2
  93. data/lib/nanoc/extra/checking/checks/html.rb +1 -3
  94. data/lib/nanoc/extra/checking/checks/internal_links.rb +3 -5
  95. data/lib/nanoc/extra/checking/checks/mixed_content.rb +0 -2
  96. data/lib/nanoc/extra/checking/checks/stale.rb +2 -4
  97. data/lib/nanoc/extra/checking/dsl.rb +0 -2
  98. data/lib/nanoc/extra/checking/issue.rb +0 -2
  99. data/lib/nanoc/extra/checking/runner.rb +1 -3
  100. data/lib/nanoc/extra/core_ext.rb +0 -2
  101. data/lib/nanoc/extra/core_ext/pathname.rb +0 -2
  102. data/lib/nanoc/extra/core_ext/time.rb +0 -2
  103. data/lib/nanoc/extra/deployer.rb +0 -2
  104. data/lib/nanoc/extra/deployers.rb +0 -2
  105. data/lib/nanoc/extra/deployers/fog.rb +40 -8
  106. data/lib/nanoc/extra/deployers/rsync.rb +0 -2
  107. data/lib/nanoc/extra/filesystem_tools.rb +0 -2
  108. data/lib/nanoc/extra/jruby_nokogiri_warner.rb +0 -2
  109. data/lib/nanoc/extra/link_collector.rb +0 -2
  110. data/lib/nanoc/extra/piper.rb +0 -2
  111. data/lib/nanoc/extra/pruner.rb +0 -2
  112. data/lib/nanoc/filters.rb +0 -2
  113. data/lib/nanoc/filters/asciidoc.rb +0 -2
  114. data/lib/nanoc/filters/bluecloth.rb +0 -2
  115. data/lib/nanoc/filters/coffeescript.rb +0 -2
  116. data/lib/nanoc/filters/colorize_syntax.rb +0 -2
  117. data/lib/nanoc/filters/erb.rb +0 -2
  118. data/lib/nanoc/filters/erubis.rb +0 -2
  119. data/lib/nanoc/filters/haml.rb +0 -2
  120. data/lib/nanoc/filters/handlebars.rb +0 -2
  121. data/lib/nanoc/filters/kramdown.rb +0 -2
  122. data/lib/nanoc/filters/less.rb +0 -2
  123. data/lib/nanoc/filters/markaby.rb +0 -2
  124. data/lib/nanoc/filters/maruku.rb +0 -2
  125. data/lib/nanoc/filters/mustache.rb +0 -2
  126. data/lib/nanoc/filters/pandoc.rb +0 -2
  127. data/lib/nanoc/filters/rainpress.rb +0 -2
  128. data/lib/nanoc/filters/rdiscount.rb +0 -2
  129. data/lib/nanoc/filters/rdoc.rb +0 -2
  130. data/lib/nanoc/filters/redcarpet.rb +0 -2
  131. data/lib/nanoc/filters/redcloth.rb +0 -2
  132. data/lib/nanoc/filters/relativize_paths.rb +0 -2
  133. data/lib/nanoc/filters/rubypants.rb +0 -2
  134. data/lib/nanoc/filters/sass.rb +0 -2
  135. data/lib/nanoc/filters/sass/sass_filesystem_importer.rb +0 -2
  136. data/lib/nanoc/filters/slim.rb +0 -2
  137. data/lib/nanoc/filters/typogruby.rb +0 -2
  138. data/lib/nanoc/filters/uglify_js.rb +0 -2
  139. data/lib/nanoc/filters/xsl.rb +0 -2
  140. data/lib/nanoc/filters/yui_compressor.rb +0 -2
  141. data/lib/nanoc/helpers.rb +0 -2
  142. data/lib/nanoc/helpers/blogging.rb +0 -2
  143. data/lib/nanoc/helpers/breadcrumbs.rb +0 -2
  144. data/lib/nanoc/helpers/capturing.rb +0 -2
  145. data/lib/nanoc/helpers/filtering.rb +0 -2
  146. data/lib/nanoc/helpers/html_escape.rb +0 -2
  147. data/lib/nanoc/helpers/link_to.rb +0 -2
  148. data/lib/nanoc/helpers/rendering.rb +0 -2
  149. data/lib/nanoc/helpers/tagging.rb +0 -2
  150. data/lib/nanoc/helpers/text.rb +0 -2
  151. data/lib/nanoc/helpers/xml_sitemap.rb +0 -2
  152. data/lib/nanoc/version.rb +1 -3
  153. data/nanoc.gemspec +1 -3
  154. data/tasks/doc.rake +0 -2
  155. data/tasks/test.rake +0 -2
  156. data/test/base/checksummer_spec.rb +0 -2
  157. data/test/base/core_ext/array_spec.rb +0 -2
  158. data/test/base/core_ext/hash_spec.rb +0 -2
  159. data/test/base/core_ext/pathname_spec.rb +0 -2
  160. data/test/base/core_ext/string_spec.rb +0 -2
  161. data/test/base/temp_filename_factory_spec.rb +0 -2
  162. data/test/base/test_checksum_store.rb +0 -2
  163. data/test/base/test_code_snippet.rb +0 -2
  164. data/test/base/test_compiler.rb +0 -2
  165. data/test/base/test_compiler_dsl.rb +1 -3
  166. data/test/base/test_context.rb +0 -2
  167. data/test/base/test_data_source.rb +0 -2
  168. data/test/base/test_dependency_tracker.rb +0 -2
  169. data/test/base/test_directed_graph.rb +0 -2
  170. data/test/base/test_filter.rb +0 -2
  171. data/test/base/test_item.rb +0 -2
  172. data/test/base/test_item_array.rb +0 -2
  173. data/test/base/test_item_rep.rb +0 -2
  174. data/test/base/test_item_rep_recorder_proxy.rb +0 -2
  175. data/test/base/test_layout.rb +0 -2
  176. data/test/base/test_memoization.rb +0 -2
  177. data/test/base/test_notification_center.rb +0 -2
  178. data/test/base/test_outdatedness_checker.rb +1 -3
  179. data/test/base/test_plugin.rb +0 -2
  180. data/test/base/test_rule.rb +0 -2
  181. data/test/base/test_rule_context.rb +0 -2
  182. data/test/base/test_site.rb +1 -3
  183. data/test/base/test_store.rb +0 -2
  184. data/test/cli/commands/test_check.rb +0 -2
  185. data/test/cli/commands/test_compile.rb +0 -2
  186. data/test/cli/commands/test_create_site.rb +1 -3
  187. data/test/cli/commands/test_deploy.rb +0 -2
  188. data/test/cli/commands/test_help.rb +0 -2
  189. data/test/cli/commands/test_info.rb +0 -2
  190. data/test/cli/commands/test_prune.rb +2 -4
  191. data/test/cli/test_cleaning_stream.rb +0 -2
  192. data/test/cli/test_cli.rb +0 -6
  193. data/test/cli/test_error_handler.rb +0 -2
  194. data/test/cli/test_logger.rb +0 -2
  195. data/test/data_sources/test_filesystem.rb +0 -2
  196. data/test/data_sources/test_filesystem_unified.rb +15 -2
  197. data/test/extra/checking/checks/test_css.rb +3 -5
  198. data/test/extra/checking/checks/test_external_links.rb +5 -7
  199. data/test/extra/checking/checks/test_html.rb +2 -4
  200. data/test/extra/checking/checks/test_internal_links.rb +5 -7
  201. data/test/extra/checking/checks/test_mixed_content.rb +8 -10
  202. data/test/extra/checking/checks/test_stale.rb +1 -3
  203. data/test/extra/checking/test_check.rb +2 -6
  204. data/test/extra/checking/test_dsl.rb +0 -2
  205. data/test/extra/checking/test_runner.rb +0 -2
  206. data/test/extra/core_ext/test_pathname.rb +0 -2
  207. data/test/extra/core_ext/test_time.rb +0 -2
  208. data/test/extra/deployers/test_fog.rb +147 -2
  209. data/test/extra/deployers/test_rsync.rb +0 -2
  210. data/test/extra/test_filesystem_tools.rb +0 -2
  211. data/test/extra/test_link_collector.rb +0 -2
  212. data/test/extra/test_piper.rb +0 -2
  213. data/test/filters/test_asciidoc.rb +0 -2
  214. data/test/filters/test_bluecloth.rb +0 -2
  215. data/test/filters/test_coffeescript.rb +0 -2
  216. data/test/filters/test_colorize_syntax.rb +0 -2
  217. data/test/filters/test_erb.rb +0 -2
  218. data/test/filters/test_erubis.rb +0 -2
  219. data/test/filters/test_haml.rb +0 -2
  220. data/test/filters/test_handlebars.rb +0 -2
  221. data/test/filters/test_kramdown.rb +0 -2
  222. data/test/filters/test_less.rb +0 -2
  223. data/test/filters/test_markaby.rb +0 -2
  224. data/test/filters/test_maruku.rb +0 -2
  225. data/test/filters/test_mustache.rb +0 -2
  226. data/test/filters/test_pandoc.rb +0 -2
  227. data/test/filters/test_rainpress.rb +0 -2
  228. data/test/filters/test_rdiscount.rb +0 -2
  229. data/test/filters/test_rdoc.rb +0 -2
  230. data/test/filters/test_redcarpet.rb +0 -2
  231. data/test/filters/test_redcloth.rb +0 -2
  232. data/test/filters/test_relativize_paths.rb +0 -2
  233. data/test/filters/test_rubypants.rb +0 -2
  234. data/test/filters/test_sass.rb +0 -2
  235. data/test/filters/test_slim.rb +0 -2
  236. data/test/filters/test_typogruby.rb +0 -2
  237. data/test/filters/test_uglify_js.rb +0 -2
  238. data/test/filters/test_xsl.rb +0 -2
  239. data/test/filters/test_yui_compressor.rb +0 -2
  240. data/test/gem_loader.rb +0 -2
  241. data/test/helper.rb +1 -3
  242. data/test/helpers/test_blogging.rb +0 -2
  243. data/test/helpers/test_breadcrumbs.rb +0 -2
  244. data/test/helpers/test_capturing.rb +0 -2
  245. data/test/helpers/test_filtering.rb +0 -2
  246. data/test/helpers/test_html_escape.rb +0 -2
  247. data/test/helpers/test_link_to.rb +0 -2
  248. data/test/helpers/test_rendering.rb +0 -2
  249. data/test/helpers/test_tagging.rb +0 -2
  250. data/test/helpers/test_text.rb +0 -2
  251. data/test/helpers/test_xml_sitemap.rb +0 -2
  252. data/test/test_gem.rb +0 -5
  253. metadata +5 -6
  254. data/lib/nanoc/data_sources/filesystem_verbose.rb +0 -71
  255. data/test/data_sources/test_filesystem_verbose.rb +0 -308
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  class Nanoc::Helpers::TextTest < Nanoc::TestCase
4
2
  include Nanoc::Helpers::Text
5
3
 
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  class Nanoc::Helpers::XMLSitemapTest < Nanoc::TestCase
4
2
  include Nanoc::Helpers::XMLSitemap
5
3
 
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  class Nanoc::GemTest < Nanoc::TestCase
4
2
  def setup
5
3
  super
@@ -22,9 +20,6 @@ class Nanoc::GemTest < Nanoc::TestCase
22
20
  diff = files_after - files_before
23
21
  assert_equal 1, diff.size
24
22
  assert_match(/^nanoc-.*\.gem$/, diff.to_a[0])
25
-
26
- # Check output
27
- assert_match(/Successfully built RubyGem\s+Name: nanoc\s+Version: .*\s+File: nanoc-.*\.gem\s+/, stdout.string)
28
23
  ensure
29
24
  Dir['nanoc-*.gem'].each { |f| FileUtils.rm(f) }
30
25
  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.0.0b2
4
+ version: 4.0.0b3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Denis Defreyne
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-05-23 00:00:00.000000000 Z
11
+ date: 2015-05-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cri
@@ -116,6 +116,7 @@ files:
116
116
  - lib/nanoc/base/views/item.rb
117
117
  - lib/nanoc/base/views/item_collection.rb
118
118
  - lib/nanoc/base/views/item_rep.rb
119
+ - lib/nanoc/base/views/item_rep_collection.rb
119
120
  - lib/nanoc/base/views/layout.rb
120
121
  - lib/nanoc/base/views/layout_collection.rb
121
122
  - lib/nanoc/base/views/mutable_config.rb
@@ -149,7 +150,6 @@ files:
149
150
  - lib/nanoc/data_sources.rb
150
151
  - lib/nanoc/data_sources/filesystem.rb
151
152
  - lib/nanoc/data_sources/filesystem_unified.rb
152
- - lib/nanoc/data_sources/filesystem_verbose.rb
153
153
  - lib/nanoc/extra.rb
154
154
  - lib/nanoc/extra/checking.rb
155
155
  - lib/nanoc/extra/checking/check.rb
@@ -261,7 +261,6 @@ files:
261
261
  - test/cli/test_logger.rb
262
262
  - test/data_sources/test_filesystem.rb
263
263
  - test/data_sources/test_filesystem_unified.rb
264
- - test/data_sources/test_filesystem_verbose.rb
265
264
  - test/extra/checking/checks/test_css.rb
266
265
  - test/extra/checking/checks/test_external_links.rb
267
266
  - test/extra/checking/checks/test_html.rb
@@ -337,7 +336,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
337
336
  requirements:
338
337
  - - ">="
339
338
  - !ruby/object:Gem::Version
340
- version: 2.0.0
339
+ version: 2.2.0
341
340
  required_rubygems_version: !ruby/object:Gem::Requirement
342
341
  requirements:
343
342
  - - ">"
@@ -345,7 +344,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
345
344
  version: 1.3.1
346
345
  requirements: []
347
346
  rubyforge_project:
348
- rubygems_version: 2.4.6
347
+ rubygems_version: 2.4.7
349
348
  signing_key:
350
349
  specification_version: 4
351
350
  summary: a web publishing system written in Ruby for building small to medium-sized
@@ -1,71 +0,0 @@
1
- # encoding: utf-8
2
-
3
- module Nanoc::DataSources
4
- # The filesystem_verbose data source is the old data source for a new nanoc
5
- # site. It stores all data as files on the hard disk.
6
- #
7
- # None of the methods are documented in this file. See {Nanoc::DataSource}
8
- # for documentation on the overridden methods instead.
9
- #
10
- # The filesystem_verbose data source stores its items and layouts in nested
11
- # directories. Each directory represents a single item or layout. The root
12
- # directory for items is the `content` directory; for layouts it is the
13
- # `layouts` directory.
14
- #
15
- # Every directory has a content file and a meta file. The content file
16
- # contains the actual item content, while the meta file contains the item’s
17
- # or the layout’s metadata, formatted as YAML.
18
- #
19
- # Both content files and meta files are named after its parent directory
20
- # (i.e. item). For example, an item/layout named `foo` will have a directory
21
- # named `foo`, with e.g. a `foo.markdown` content file and a `foo.yaml` meta
22
- # file.
23
- #
24
- # Content file extensions are not used for determining the filter that
25
- # should be run; the meta file defines the list of filters. The meta file
26
- # extension must always be `.yaml`, though.
27
- #
28
- # For backwards compatibility, content files can also have the `index`
29
- # basename. Similarly, meta files can have the `meta` basename. For example,
30
- # a parent directory named `foo` can have an `index.txt` content file and a
31
- # `meta.yaml` meta file.
32
- #
33
- # The identifier is calculated by stripping the extension; if there is more
34
- # than one extension, only the last extension is stripped and the previous
35
- # extensions will be part of the identifier.
36
- #
37
- # It is possible to set an explicit encoding that should be used when reading
38
- # files. In the data source configuration, set `encoding` to an encoding
39
- # understood by Ruby’s `Encoding`. If no encoding is set in the configuration,
40
- # one will be inferred from the environment.
41
- #
42
- # @api private
43
- class FilesystemVerbose < Nanoc::DataSource
44
- include Nanoc::DataSources::Filesystem
45
-
46
- private
47
-
48
- # See {Nanoc::DataSources::Filesystem#filename_for}.
49
- def filename_for(base_filename, ext)
50
- return nil if ext.nil?
51
-
52
- last_component = base_filename[%r{[^/]+$}]
53
- possibilities = [
54
- base_filename + (ext.empty? ? '' : '.' + ext), # foo/bar.html
55
- base_filename + '/' + last_component + (ext.empty? ? '' : '.' + ext), # foo/bar/bar.html
56
- base_filename + '/' + 'index' + (ext.empty? ? '' : '.' + ext) # foo/bar/index.html
57
- ]
58
-
59
- possibilities.find { |p| File.file?(p) }
60
- end
61
-
62
- # See {Nanoc::DataSources::Filesystem#identifier_for_filename}.
63
- def identifier_for_filename(filename)
64
- if config[:identifier_type] == 'full'
65
- return Nanoc::Identifier.new(filename)
66
- end
67
-
68
- Nanoc::Identifier.new(filename.sub(/[^\/]+\.yaml$/, ''), type: :legacy)
69
- end
70
- end
71
- end
@@ -1,308 +0,0 @@
1
- # encoding: utf-8
2
-
3
- class Nanoc::DataSources::FilesystemVerboseTest < Nanoc::TestCase
4
- def new_data_source(params = nil)
5
- # Mock site
6
- site = Nanoc::Int::Site.new({})
7
-
8
- # Create data source
9
- data_source = Nanoc::DataSources::FilesystemVerbose.new(site, nil, nil, params)
10
-
11
- # Done
12
- data_source
13
- end
14
-
15
- def test_items
16
- # Create data source
17
- data_source = new_data_source
18
-
19
- # Create foo item
20
- FileUtils.mkdir_p('content/foo')
21
- File.open('content/foo/foo.yaml', 'w') do |io|
22
- io.write("---\n")
23
- io.write("title: Foo\n")
24
- end
25
- File.open('content/foo/foo.html', 'w') do |io|
26
- io.write('Lorem ipsum dolor sit amet...')
27
- end
28
-
29
- # Create bar item
30
- FileUtils.mkdir_p('content/bar')
31
- File.open('content/bar/bar.yaml', 'w') do |io|
32
- io.write("---\n")
33
- io.write("title: Bar\n")
34
- end
35
- File.open('content/bar/bar.xml', 'w') do |io|
36
- io.write('Lorem ipsum dolor sit amet...')
37
- end
38
-
39
- # Load items
40
- items = data_source.items
41
-
42
- # Check items
43
- assert_equal(2, items.size)
44
- assert(items.any? do |a|
45
- a[:title] == 'Foo' &&
46
- a[:extension] == 'html' &&
47
- a[:content_filename] == 'content/foo/foo.html' &&
48
- a[:meta_filename] == 'content/foo/foo.yaml'
49
- end)
50
- assert(items.any? do |a|
51
- a[:title] == 'Bar' &&
52
- a[:extension] == 'xml' &&
53
- a[:content_filename] == 'content/bar/bar.xml' &&
54
- a[:meta_filename] == 'content/bar/bar.yaml'
55
- end)
56
- end
57
-
58
- def test_items_with_period_in_name
59
- data_source = new_data_source(allow_periods_in_identifiers: true)
60
-
61
- # Create foo.css
62
- FileUtils.mkdir_p('content/foo')
63
- File.open('content/foo/foo.yaml', 'w') do |io|
64
- io.write(YAML.dump({ 'title' => 'Foo' }))
65
- end
66
- File.open('content/foo/foo.css', 'w') do |io|
67
- io.write('body.foo {}')
68
- end
69
-
70
- # Create foo.bar.css
71
- FileUtils.mkdir_p('content/foo.bar')
72
- File.open('content/foo.bar/foo.bar.yaml', 'w') do |io|
73
- io.write(YAML.dump({ 'title' => 'Foo Bar' }))
74
- end
75
- File.open('content/foo.bar/foo.bar.css', 'w') do |io|
76
- io.write('body.foobar {}')
77
- end
78
-
79
- # Load
80
- items = data_source.items.sort_by { |i| i[:title] }
81
-
82
- # Check
83
- assert_equal 2, items.size
84
- assert_equal '/foo/', items[0].identifier.to_s
85
- assert_equal 'Foo', items[0][:title]
86
- assert_equal 'content/foo/foo.css', items[0][:content_filename]
87
- assert_equal 'content/foo/foo.yaml', items[0][:meta_filename]
88
- assert_equal '/foo.bar/', items[1].identifier.to_s
89
- assert_equal 'Foo Bar', items[1][:title]
90
- assert_equal 'content/foo.bar/foo.bar.css', items[1][:content_filename]
91
- assert_equal 'content/foo.bar/foo.bar.yaml', items[1][:meta_filename]
92
- end
93
-
94
- def test_items_with_optional_meta_file
95
- # Create data source
96
- data_source = new_data_source
97
-
98
- # Create foo item
99
- FileUtils.mkdir_p('content/foo')
100
- File.open('content/foo/foo.html', 'w') do |io|
101
- io.write('Lorem ipsum dolor sit amet...')
102
- end
103
-
104
- # Create bar item
105
- FileUtils.mkdir_p('content/bar')
106
- File.open('content/bar/bar.yaml', 'w') do |io|
107
- io.write("---\n")
108
- io.write("title: Bar\n")
109
- end
110
-
111
- # Load items
112
- items = data_source.items
113
-
114
- # Check items
115
- assert_equal(2, items.size)
116
- assert(items.any? do |a|
117
- a[:title].nil? &&
118
- a[:extension] == 'html' &&
119
- a[:content_filename] == 'content/foo/foo.html' &&
120
- a[:meta_filename].nil?
121
- end)
122
- assert(items.any? do |a|
123
- a[:title] == 'Bar' &&
124
- a[:extension].nil? &&
125
- a[:content_filename].nil? &&
126
- a[:meta_filename] == 'content/bar/bar.yaml'
127
- end)
128
- end
129
-
130
- def test_layouts
131
- # Create data source
132
- data_source = new_data_source
133
-
134
- # Create layout
135
- FileUtils.mkdir_p('layouts/foo')
136
- File.open('layouts/foo/foo.yaml', 'w') do |io|
137
- io.write("---\n")
138
- io.write("filter: erb\n")
139
- end
140
- File.open('layouts/foo/foo.html', 'w') do |io|
141
- io.write('Lorem ipsum dolor sit amet...')
142
- end
143
-
144
- # Load layouts
145
- layouts = data_source.layouts
146
-
147
- # Check layouts
148
- assert_equal(1, layouts.size)
149
- assert_equal('erb', layouts[0][:filter])
150
- assert_equal('html', layouts[0][:extension])
151
- assert_equal('layouts/foo/foo.html', layouts[0][:content_filename])
152
- assert_equal('layouts/foo/foo.yaml', layouts[0][:meta_filename])
153
- end
154
-
155
- def test_layouts_with_period_in_name_disallowing_periods_in_identifiers
156
- data_source = new_data_source
157
-
158
- # Create foo.html
159
- FileUtils.mkdir_p('layouts/foo')
160
- File.open('layouts/foo/foo.yaml', 'w') do |io|
161
- io.write(YAML.dump({ 'dog' => 'woof' }))
162
- end
163
- File.open('layouts/foo/foo.html', 'w') do |io|
164
- io.write('body.foo {}')
165
- end
166
-
167
- # Create bar.html.erb
168
- FileUtils.mkdir_p('layouts/bar')
169
- File.open('layouts/bar/bar.yaml', 'w') do |io|
170
- io.write(YAML.dump({ 'cat' => 'meow' }))
171
- end
172
- File.open('layouts/bar/bar.html.erb', 'w') do |io|
173
- io.write('body.foobar {}')
174
- end
175
-
176
- # Load
177
- layouts = data_source.layouts.sort_by(&:identifier)
178
-
179
- # Check
180
- assert_equal 2, layouts.size
181
- assert_equal '/bar/', layouts[0].identifier.to_s
182
- assert_equal 'meow', layouts[0][:cat]
183
- assert_equal '/foo/', layouts[1].identifier.to_s
184
- assert_equal 'woof', layouts[1][:dog]
185
- end
186
-
187
- def test_layouts_with_period_in_name_allowing_periods_in_identifiers
188
- data_source = new_data_source(allow_periods_in_identifiers: true)
189
-
190
- # Create foo.html
191
- FileUtils.mkdir_p('layouts/foo')
192
- File.open('layouts/foo/foo.yaml', 'w') do |io|
193
- io.write(YAML.dump({ 'dog' => 'woof' }))
194
- end
195
- File.open('layouts/foo/foo.html', 'w') do |io|
196
- io.write('body.foo {}')
197
- end
198
-
199
- # Create bar.html.erb
200
- FileUtils.mkdir_p('layouts/bar.xyz')
201
- File.open('layouts/bar.xyz/bar.xyz.yaml', 'w') do |io|
202
- io.write(YAML.dump({ 'cat' => 'meow' }))
203
- end
204
- File.open('layouts/bar.xyz/bar.xyz.html', 'w') do |io|
205
- io.write('body.foobar {}')
206
- end
207
-
208
- # Load
209
- layouts = data_source.layouts.sort_by(&:identifier)
210
-
211
- # Check
212
- assert_equal 2, layouts.size
213
- assert_equal '/bar.xyz/', layouts[0].identifier.to_s
214
- assert_equal 'meow', layouts[0][:cat]
215
- assert_equal '/foo/', layouts[1].identifier.to_s
216
- assert_equal 'woof', layouts[1][:dog]
217
- end
218
-
219
- def test_load_binary_objects
220
- # Create data source
221
- data_source = new_data_source
222
-
223
- # Create sample files
224
- FileUtils.mkdir_p('foo')
225
- File.open('foo/stuff.dat', 'w') { |io| io.write('random binary data') }
226
-
227
- # Load
228
- items = data_source.send(:load_objects, 'foo', 'item', Nanoc::Int::Item)
229
-
230
- # Check
231
- assert_equal 1, items.size
232
- assert items[0].binary?
233
- assert_equal 'foo/stuff.dat', items[0].raw_filename
234
- assert_nil items[0].raw_content
235
- end
236
-
237
- def test_filename_for_with_single
238
- data_source = new_data_source
239
-
240
- FileUtils.mkdir_p('foo/bar')
241
- File.open('foo/bar.ext', 'w') { |io| io.write('o hai') }
242
- assert_equal 'foo/bar.ext', data_source.send(:filename_for, 'foo/bar', 'ext')
243
- end
244
-
245
- def test_filename_for_with_double
246
- data_source = new_data_source
247
-
248
- FileUtils.mkdir_p('foo/bar')
249
- File.open('foo/bar/bar.ext', 'w') { |io| io.write('o hai') }
250
- assert_equal 'foo/bar/bar.ext', data_source.send(:filename_for, 'foo/bar', 'ext')
251
- end
252
-
253
- def test_filename_for_with_index
254
- data_source = new_data_source
255
-
256
- FileUtils.mkdir_p('foo/bar')
257
- File.open('foo/bar/index.ext', 'w') { |io| io.write('o hai') }
258
- assert_equal 'foo/bar/index.ext', data_source.send(:filename_for, 'foo/bar', 'ext')
259
- end
260
-
261
- def test_filename_for_with_nil
262
- data_source = new_data_source
263
-
264
- assert_equal nil, data_source.send(:filename_for, 'foo/bar', nil)
265
- end
266
-
267
- def test_filename_for_with_single_and_empty_ext
268
- data_source = new_data_source
269
-
270
- FileUtils.mkdir_p('foo')
271
- File.open('foo/bar', 'w') { |io| io.write('o hai') }
272
- assert_equal 'foo/bar', data_source.send(:filename_for, 'foo/bar', '')
273
- end
274
-
275
- def test_filename_for_with_double_and_empty_ext
276
- data_source = new_data_source
277
-
278
- FileUtils.mkdir_p('foo/bar')
279
- File.open('foo/bar/bar', 'w') { |io| io.write('o hai') }
280
- assert_equal 'foo/bar/bar', data_source.send(:filename_for, 'foo/bar', '')
281
- end
282
-
283
- def test_filename_for_with_index_and_empty_ext
284
- data_source = new_data_source
285
-
286
- FileUtils.mkdir_p('foo/bar')
287
- File.open('foo/bar/index', 'w') { |io| io.write('o hai') }
288
- assert_equal 'foo/bar/index', data_source.send(:filename_for, 'foo/bar', '')
289
- end
290
-
291
- def test_compile_huge_site
292
- if_implemented do
293
- # Create data source
294
- data_source = new_data_source
295
-
296
- # Create a lot of items
297
- count = Process.getrlimit(Process::RLIMIT_NOFILE)[0] + 5
298
- count.times do |i|
299
- FileUtils.mkdir_p("content/#{i}")
300
- File.open("content/#{i}/#{i}.html", 'w') { |io| io << "This is item #{i}." }
301
- File.open("content/#{i}/#{i}.yaml", 'w') { |io| io << "title: Item #{i}" }
302
- end
303
-
304
- # Read all items
305
- data_source.items
306
- end
307
- end
308
- end