nanoc3 3.2.4 → 3.3.0

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 (211) hide show
  1. metadata +14 -313
  2. data/.gemtest +0 -0
  3. data/ChangeLog +0 -3
  4. data/Gemfile +0 -29
  5. data/LICENSE +0 -19
  6. data/NEWS.md +0 -449
  7. data/README.md +0 -108
  8. data/Rakefile +0 -14
  9. data/bin/nanoc3 +0 -12
  10. data/doc/yardoc_templates/default/layout/html/footer.erb +0 -10
  11. data/lib/nanoc3.rb +0 -28
  12. data/lib/nanoc3/base.rb +0 -49
  13. data/lib/nanoc3/base/compilation/checksum_store.rb +0 -57
  14. data/lib/nanoc3/base/compilation/compiled_content_cache.rb +0 -62
  15. data/lib/nanoc3/base/compilation/compiler.rb +0 -455
  16. data/lib/nanoc3/base/compilation/compiler_dsl.rb +0 -214
  17. data/lib/nanoc3/base/compilation/dependency_tracker.rb +0 -196
  18. data/lib/nanoc3/base/compilation/filter.rb +0 -165
  19. data/lib/nanoc3/base/compilation/item_rep_proxy.rb +0 -102
  20. data/lib/nanoc3/base/compilation/item_rep_recorder_proxy.rb +0 -88
  21. data/lib/nanoc3/base/compilation/outdatedness_checker.rb +0 -223
  22. data/lib/nanoc3/base/compilation/outdatedness_reasons.rb +0 -46
  23. data/lib/nanoc3/base/compilation/rule.rb +0 -73
  24. data/lib/nanoc3/base/compilation/rule_context.rb +0 -84
  25. data/lib/nanoc3/base/compilation/rule_memory_calculator.rb +0 -40
  26. data/lib/nanoc3/base/compilation/rule_memory_store.rb +0 -53
  27. data/lib/nanoc3/base/compilation/rules_collection.rb +0 -231
  28. data/lib/nanoc3/base/context.rb +0 -47
  29. data/lib/nanoc3/base/core_ext.rb +0 -6
  30. data/lib/nanoc3/base/core_ext/array.rb +0 -62
  31. data/lib/nanoc3/base/core_ext/hash.rb +0 -63
  32. data/lib/nanoc3/base/core_ext/pathname.rb +0 -26
  33. data/lib/nanoc3/base/core_ext/string.rb +0 -46
  34. data/lib/nanoc3/base/directed_graph.rb +0 -275
  35. data/lib/nanoc3/base/errors.rb +0 -174
  36. data/lib/nanoc3/base/memoization.rb +0 -67
  37. data/lib/nanoc3/base/notification_center.rb +0 -84
  38. data/lib/nanoc3/base/ordered_hash.rb +0 -200
  39. data/lib/nanoc3/base/plugin_registry.rb +0 -165
  40. data/lib/nanoc3/base/result_data/item_rep.rb +0 -488
  41. data/lib/nanoc3/base/source_data/code_snippet.rb +0 -58
  42. data/lib/nanoc3/base/source_data/configuration.rb +0 -24
  43. data/lib/nanoc3/base/source_data/data_source.rb +0 -234
  44. data/lib/nanoc3/base/source_data/item.rb +0 -301
  45. data/lib/nanoc3/base/source_data/layout.rb +0 -130
  46. data/lib/nanoc3/base/source_data/site.rb +0 -361
  47. data/lib/nanoc3/base/store.rb +0 -135
  48. data/lib/nanoc3/cli.rb +0 -133
  49. data/lib/nanoc3/cli/command.rb +0 -139
  50. data/lib/nanoc3/cli/commands/autocompile.rb +0 -60
  51. data/lib/nanoc3/cli/commands/compile.rb +0 -280
  52. data/lib/nanoc3/cli/commands/create_item.rb +0 -62
  53. data/lib/nanoc3/cli/commands/create_layout.rb +0 -75
  54. data/lib/nanoc3/cli/commands/create_site.rb +0 -410
  55. data/lib/nanoc3/cli/commands/debug.rb +0 -119
  56. data/lib/nanoc3/cli/commands/info.rb +0 -98
  57. data/lib/nanoc3/cli/commands/nanoc.rb +0 -37
  58. data/lib/nanoc3/cli/commands/update.rb +0 -72
  59. data/lib/nanoc3/cli/commands/view.rb +0 -84
  60. data/lib/nanoc3/cli/commands/watch.rb +0 -125
  61. data/lib/nanoc3/cli/error_handler.rb +0 -193
  62. data/lib/nanoc3/cli/logger.rb +0 -91
  63. data/lib/nanoc3/data_sources.rb +0 -29
  64. data/lib/nanoc3/data_sources/deprecated/delicious.rb +0 -42
  65. data/lib/nanoc3/data_sources/deprecated/last_fm.rb +0 -87
  66. data/lib/nanoc3/data_sources/deprecated/twitter.rb +0 -38
  67. data/lib/nanoc3/data_sources/filesystem.rb +0 -299
  68. data/lib/nanoc3/data_sources/filesystem_unified.rb +0 -116
  69. data/lib/nanoc3/data_sources/filesystem_verbose.rb +0 -86
  70. data/lib/nanoc3/extra.rb +0 -22
  71. data/lib/nanoc3/extra/auto_compiler.rb +0 -103
  72. data/lib/nanoc3/extra/chick.rb +0 -125
  73. data/lib/nanoc3/extra/core_ext.rb +0 -4
  74. data/lib/nanoc3/extra/core_ext/enumerable.rb +0 -33
  75. data/lib/nanoc3/extra/core_ext/time.rb +0 -19
  76. data/lib/nanoc3/extra/deployers.rb +0 -11
  77. data/lib/nanoc3/extra/deployers/rsync.rb +0 -114
  78. data/lib/nanoc3/extra/file_proxy.rb +0 -40
  79. data/lib/nanoc3/extra/validators.rb +0 -12
  80. data/lib/nanoc3/extra/validators/links.rb +0 -264
  81. data/lib/nanoc3/extra/validators/w3c.rb +0 -95
  82. data/lib/nanoc3/extra/vcs.rb +0 -66
  83. data/lib/nanoc3/extra/vcses.rb +0 -17
  84. data/lib/nanoc3/extra/vcses/bazaar.rb +0 -25
  85. data/lib/nanoc3/extra/vcses/dummy.rb +0 -24
  86. data/lib/nanoc3/extra/vcses/git.rb +0 -25
  87. data/lib/nanoc3/extra/vcses/mercurial.rb +0 -25
  88. data/lib/nanoc3/extra/vcses/subversion.rb +0 -25
  89. data/lib/nanoc3/filters.rb +0 -53
  90. data/lib/nanoc3/filters/asciidoc.rb +0 -38
  91. data/lib/nanoc3/filters/bluecloth.rb +0 -19
  92. data/lib/nanoc3/filters/coderay.rb +0 -21
  93. data/lib/nanoc3/filters/colorize_syntax.rb +0 -261
  94. data/lib/nanoc3/filters/erb.rb +0 -35
  95. data/lib/nanoc3/filters/erubis.rb +0 -27
  96. data/lib/nanoc3/filters/haml.rb +0 -27
  97. data/lib/nanoc3/filters/kramdown.rb +0 -20
  98. data/lib/nanoc3/filters/less.rb +0 -53
  99. data/lib/nanoc3/filters/markaby.rb +0 -20
  100. data/lib/nanoc3/filters/maruku.rb +0 -20
  101. data/lib/nanoc3/filters/mustache.rb +0 -24
  102. data/lib/nanoc3/filters/rainpress.rb +0 -19
  103. data/lib/nanoc3/filters/rdiscount.rb +0 -22
  104. data/lib/nanoc3/filters/rdoc.rb +0 -33
  105. data/lib/nanoc3/filters/redcarpet.rb +0 -27
  106. data/lib/nanoc3/filters/redcloth.rb +0 -47
  107. data/lib/nanoc3/filters/relativize_paths.rb +0 -45
  108. data/lib/nanoc3/filters/rubypants.rb +0 -20
  109. data/lib/nanoc3/filters/sass.rb +0 -66
  110. data/lib/nanoc3/filters/slim.rb +0 -25
  111. data/lib/nanoc3/filters/typogruby.rb +0 -23
  112. data/lib/nanoc3/filters/uglify_js.rb +0 -42
  113. data/lib/nanoc3/helpers.rb +0 -16
  114. data/lib/nanoc3/helpers/blogging.rb +0 -319
  115. data/lib/nanoc3/helpers/breadcrumbs.rb +0 -40
  116. data/lib/nanoc3/helpers/capturing.rb +0 -138
  117. data/lib/nanoc3/helpers/filtering.rb +0 -50
  118. data/lib/nanoc3/helpers/html_escape.rb +0 -55
  119. data/lib/nanoc3/helpers/link_to.rb +0 -151
  120. data/lib/nanoc3/helpers/rendering.rb +0 -140
  121. data/lib/nanoc3/helpers/tagging.rb +0 -71
  122. data/lib/nanoc3/helpers/text.rb +0 -44
  123. data/lib/nanoc3/helpers/xml_sitemap.rb +0 -76
  124. data/lib/nanoc3/tasks.rb +0 -10
  125. data/lib/nanoc3/tasks/clean.rake +0 -16
  126. data/lib/nanoc3/tasks/clean.rb +0 -29
  127. data/lib/nanoc3/tasks/deploy/rsync.rake +0 -14
  128. data/lib/nanoc3/tasks/validate.rake +0 -92
  129. data/nanoc3.gemspec +0 -49
  130. data/tasks/doc.rake +0 -16
  131. data/tasks/test.rake +0 -44
  132. data/test/base/core_ext/array_spec.rb +0 -73
  133. data/test/base/core_ext/hash_spec.rb +0 -98
  134. data/test/base/core_ext/pathname_spec.rb +0 -27
  135. data/test/base/core_ext/string_spec.rb +0 -37
  136. data/test/base/test_checksum_store.rb +0 -35
  137. data/test/base/test_code_snippet.rb +0 -31
  138. data/test/base/test_compiler.rb +0 -316
  139. data/test/base/test_compiler_dsl.rb +0 -161
  140. data/test/base/test_context.rb +0 -31
  141. data/test/base/test_data_source.rb +0 -46
  142. data/test/base/test_dependency_tracker.rb +0 -262
  143. data/test/base/test_directed_graph.rb +0 -283
  144. data/test/base/test_filter.rb +0 -83
  145. data/test/base/test_item.rb +0 -179
  146. data/test/base/test_item_rep.rb +0 -553
  147. data/test/base/test_layout.rb +0 -59
  148. data/test/base/test_memoization.rb +0 -90
  149. data/test/base/test_notification_center.rb +0 -34
  150. data/test/base/test_outdatedness_checker.rb +0 -394
  151. data/test/base/test_plugin.rb +0 -30
  152. data/test/base/test_rule.rb +0 -19
  153. data/test/base/test_rule_context.rb +0 -65
  154. data/test/base/test_site.rb +0 -190
  155. data/test/cli/commands/test_compile.rb +0 -33
  156. data/test/cli/commands/test_create_item.rb +0 -14
  157. data/test/cli/commands/test_create_layout.rb +0 -28
  158. data/test/cli/commands/test_create_site.rb +0 -24
  159. data/test/cli/commands/test_help.rb +0 -12
  160. data/test/cli/commands/test_info.rb +0 -11
  161. data/test/cli/commands/test_update.rb +0 -10
  162. data/test/cli/test_cli.rb +0 -102
  163. data/test/cli/test_error_handler.rb +0 -29
  164. data/test/cli/test_logger.rb +0 -10
  165. data/test/data_sources/test_filesystem.rb +0 -433
  166. data/test/data_sources/test_filesystem_unified.rb +0 -536
  167. data/test/data_sources/test_filesystem_verbose.rb +0 -357
  168. data/test/extra/core_ext/test_enumerable.rb +0 -30
  169. data/test/extra/core_ext/test_time.rb +0 -15
  170. data/test/extra/deployers/test_rsync.rb +0 -232
  171. data/test/extra/test_auto_compiler.rb +0 -417
  172. data/test/extra/test_file_proxy.rb +0 -19
  173. data/test/extra/test_vcs.rb +0 -22
  174. data/test/extra/validators/test_links.rb +0 -51
  175. data/test/extra/validators/test_w3c.rb +0 -47
  176. data/test/filters/test_asciidoc.rb +0 -22
  177. data/test/filters/test_bluecloth.rb +0 -18
  178. data/test/filters/test_coderay.rb +0 -44
  179. data/test/filters/test_colorize_syntax.rb +0 -283
  180. data/test/filters/test_erb.rb +0 -99
  181. data/test/filters/test_erubis.rb +0 -70
  182. data/test/filters/test_haml.rb +0 -96
  183. data/test/filters/test_kramdown.rb +0 -18
  184. data/test/filters/test_less.rb +0 -113
  185. data/test/filters/test_markaby.rb +0 -24
  186. data/test/filters/test_maruku.rb +0 -18
  187. data/test/filters/test_mustache.rb +0 -25
  188. data/test/filters/test_rainpress.rb +0 -29
  189. data/test/filters/test_rdiscount.rb +0 -31
  190. data/test/filters/test_rdoc.rb +0 -18
  191. data/test/filters/test_redcarpet.rb +0 -63
  192. data/test/filters/test_redcloth.rb +0 -33
  193. data/test/filters/test_relativize_paths.rb +0 -332
  194. data/test/filters/test_rubypants.rb +0 -18
  195. data/test/filters/test_sass.rb +0 -229
  196. data/test/filters/test_slim.rb +0 -35
  197. data/test/filters/test_typogruby.rb +0 -21
  198. data/test/filters/test_uglify_js.rb +0 -30
  199. data/test/gem_loader.rb +0 -11
  200. data/test/helper.rb +0 -179
  201. data/test/helpers/test_blogging.rb +0 -754
  202. data/test/helpers/test_breadcrumbs.rb +0 -81
  203. data/test/helpers/test_capturing.rb +0 -41
  204. data/test/helpers/test_filtering.rb +0 -106
  205. data/test/helpers/test_html_escape.rb +0 -32
  206. data/test/helpers/test_link_to.rb +0 -249
  207. data/test/helpers/test_rendering.rb +0 -89
  208. data/test/helpers/test_tagging.rb +0 -87
  209. data/test/helpers/test_text.rb +0 -24
  210. data/test/helpers/test_xml_sitemap.rb +0 -103
  211. data/test/tasks/test_clean.rb +0 -67
@@ -1,102 +0,0 @@
1
- # encoding: utf-8
2
-
3
- class Nanoc3::CLITest < MiniTest::Unit::TestCase
4
-
5
- include Nanoc3::TestHelpers
6
-
7
- COMMAND_CODE = <<EOS
8
- # encoding: utf-8
9
-
10
- usage '_test [options]'
11
- summary 'meh'
12
- description 'longer meh'
13
-
14
- run do |opts, args, cmd|
15
- File.open('_test.out', 'w') { |io| io.write('It works!') }
16
- end
17
- EOS
18
-
19
- SUBCOMMAND_CODE = <<EOS
20
- # encoding: utf-8
21
-
22
- usage '_sub [options]'
23
- summary 'meh sub'
24
- description 'longer meh sub'
25
-
26
- run do |opts, args, cmd|
27
- File.open('_test_sub.out', 'w') { |io| io.write('It works sub!') }
28
- end
29
- EOS
30
-
31
- def test_load_custom_commands
32
- Nanoc3::CLI.run %w( create_site foo )
33
-
34
- FileUtils.cd('foo') do
35
- # Create command
36
- FileUtils.mkdir_p('commands')
37
- File.open('commands/_test.rb', 'w') { |io| io.write(COMMAND_CODE) }
38
-
39
- # Run command
40
- begin
41
- Nanoc3::CLI.run %w( _test )
42
- rescue SystemExit
43
- assert false, 'Running _test should not cause system exit'
44
- end
45
-
46
- # Check
47
- assert File.file?('_test.out')
48
- assert_equal 'It works!', File.read('_test.out')
49
- end
50
- end
51
-
52
- def test_load_custom_commands_nested
53
- Nanoc3::CLI.run %w( create_site foo )
54
- FileUtils.cd('foo') do
55
- # Create command
56
- FileUtils.mkdir_p('commands')
57
- File.open('commands/_test.rb', 'w') do |io|
58
- io.write(COMMAND_CODE)
59
- end
60
-
61
- # Create subcommand
62
- FileUtils.mkdir_p('commands/_test')
63
- File.open('commands/_test/_sub.rb', 'w') do |io|
64
- io.write(SUBCOMMAND_CODE)
65
- end
66
-
67
- # Run command
68
- begin
69
- Nanoc3::CLI.run %w( _test _sub )
70
- rescue SystemExit
71
- assert false, 'Running _test sub should not cause system exit'
72
- end
73
-
74
- # Check
75
- assert File.file?('_test_sub.out')
76
- assert_equal 'It works sub!', File.read('_test_sub.out')
77
- end
78
- end
79
-
80
- def test_load_custom_commands_broken
81
- Nanoc3::CLI.run %w( create_site foo )
82
-
83
- FileUtils.cd('foo') do
84
- # Create command
85
- FileUtils.mkdir_p('commands')
86
- File.open('commands/_test.rb', 'w') { |io| io.write('raise "meh"') }
87
-
88
- # Run command
89
- position_before = $stderr.tell
90
- assert_raises SystemExit do
91
- Nanoc3::CLI.run %w( _test )
92
- end
93
- position_after = $stderr.tell
94
-
95
- # Check error output
96
- stderr_addition = $stderr.string[position_before, position_after]
97
- assert_match(/=== BACKTRACE:/, stderr_addition)
98
- assert_match(/commands\/_test.rb/, stderr_addition)
99
- end
100
- end
101
-
102
- end
@@ -1,29 +0,0 @@
1
- # encoding: utf-8
2
-
3
- class Nanoc3::CLI::ErrorHandlerTest < MiniTest::Unit::TestCase
4
-
5
- include Nanoc3::TestHelpers
6
-
7
- def test_resolution_for_with_unknown_gem
8
- error = LoadError.new('no such file to load -- afjlrestjlsgrshter')
9
- assert_nil handler.send(:resolution_for, error)
10
- end
11
-
12
- def test_resolution_for_with_known_gem
13
- $loud = true
14
- error = LoadError.new('no such file to load -- kramdown')
15
- assert_match /^Try installing /, handler.send(:resolution_for, error)
16
- ensure
17
- $loud = false
18
- end
19
-
20
- def test_resolution_for_with_not_load_error
21
- error = RuntimeError.new('nuclear meltdown detected')
22
- assert_nil handler.send(:resolution_for, error)
23
- end
24
-
25
- def handler
26
- Nanoc3::CLI::ErrorHandler.new
27
- end
28
-
29
- end
@@ -1,10 +0,0 @@
1
- # encoding: utf-8
2
-
3
- class Nanoc3::CLI::LoggerTest < MiniTest::Unit::TestCase
4
-
5
- include Nanoc3::TestHelpers
6
-
7
- def test_stub
8
- end
9
-
10
- end
@@ -1,433 +0,0 @@
1
- # encoding: utf-8
2
-
3
- class Nanoc3::DataSources::FilesystemTest < MiniTest::Unit::TestCase
4
-
5
- include Nanoc3::TestHelpers
6
-
7
- class SampleFilesystemDataSource < Nanoc3::DataSource
8
- include Nanoc3::DataSources::Filesystem
9
- end
10
-
11
- def test_setup
12
- # Create data source
13
- data_source = SampleFilesystemDataSource.new(nil, nil, nil, nil)
14
-
15
- # Remove files to make sure they are recreated
16
- FileUtils.rm_rf('content')
17
- FileUtils.rm_rf('layouts/default')
18
- FileUtils.rm_rf('lib')
19
-
20
- # Mock VCS
21
- vcs = mock
22
- vcs.expects(:add).times(2) # One time for each directory
23
- data_source.vcs = vcs
24
-
25
- # Recreate files
26
- data_source.setup
27
-
28
- # Ensure essential files have been recreated
29
- assert(File.directory?('content/'))
30
- assert(File.directory?('layouts/'))
31
-
32
- # Ensure no non-essential files have been recreated
33
- assert(!File.file?('content/index.html'))
34
- assert(!File.file?('layouts/default.html'))
35
- refute(File.directory?('lib/'))
36
- end
37
-
38
- def test_items
39
- # Create data source
40
- data_source = SampleFilesystemDataSource.new(nil, nil, nil, nil)
41
-
42
- # Check
43
- data_source.expects(:load_objects).with('content', 'item', Nanoc3::Item)
44
- data_source.items
45
- end
46
-
47
- def test_layouts
48
- # Create data source
49
- data_source = SampleFilesystemDataSource.new(nil, nil, nil, nil)
50
-
51
- # Check
52
- data_source.expects(:load_objects).with('layouts', 'layout', Nanoc3::Layout)
53
- data_source.layouts
54
- end
55
-
56
- def test_create_item
57
- # Create data source
58
- data_source = SampleFilesystemDataSource.new(nil, nil, nil, nil)
59
-
60
- # Check
61
- data_source.expects(:create_object).with('content', 'the content', 'the attributes', 'the identifier', {})
62
- data_source.create_item('the content', 'the attributes', 'the identifier')
63
- end
64
-
65
- def test_create_layout
66
- # Create data source
67
- data_source = SampleFilesystemDataSource.new(nil, nil, nil, nil)
68
-
69
- # Check
70
- data_source.expects(:create_object).with('layouts', 'the content', 'the attributes', 'the identifier', {})
71
- data_source.create_layout('the content', 'the attributes', 'the identifier')
72
- end
73
-
74
- def test_all_split_files_in_allowing_periods_in_identifiers
75
- # Create data source
76
- data_source = Nanoc3::DataSources::FilesystemCompact.new(nil, nil, nil, { :allow_periods_in_identifiers => true })
77
-
78
- # Write sample files
79
- FileUtils.mkdir_p('foo')
80
- %w( foo.html foo.yaml bar.entry.html foo/qux.yaml ).each do |filename|
81
- File.open(filename, 'w') { |io| io.write('test') }
82
- end
83
-
84
- # Write stray files
85
- %w( foo.html~ foo.yaml.orig bar.entry.html.bak ).each do |filename|
86
- File.open(filename, 'w') { |io| io.write('test') }
87
- end
88
-
89
- # Get all files
90
- output_expected = {
91
- './foo' => [ 'yaml', 'html' ],
92
- './bar.entry' => [ nil, 'html' ],
93
- './foo/qux' => [ 'yaml', nil ]
94
- }
95
- output_actual = data_source.send :all_split_files_in, '.'
96
-
97
- # Check
98
- assert_equal output_expected, output_actual
99
- end
100
-
101
- def test_all_split_files_in_disallowing_periods_in_identifiers
102
- # Create data source
103
- data_source = Nanoc3::DataSources::FilesystemCompact.new(nil, nil, nil, nil)
104
-
105
- # Write sample files
106
- FileUtils.mkdir_p('foo')
107
- %w( foo.html foo.yaml bar.html.erb foo/qux.yaml ).each do |filename|
108
- File.open(filename, 'w') { |io| io.write('test') }
109
- end
110
-
111
- # Write stray files
112
- %w( foo.html~ foo.yaml.orig bar.entry.html.bak ).each do |filename|
113
- File.open(filename, 'w') { |io| io.write('test') }
114
- end
115
-
116
- # Get all files
117
- output_expected = {
118
- './foo' => [ 'yaml', 'html' ],
119
- './bar' => [ nil, 'html.erb' ],
120
- './foo/qux' => [ 'yaml', nil ]
121
- }
122
- output_actual = data_source.send :all_split_files_in, '.'
123
-
124
- # Check
125
- assert_equal output_expected, output_actual
126
- end
127
-
128
- def test_all_split_files_in_with_multiple_dirs
129
- # Create data source
130
- data_source = Nanoc3::DataSources::FilesystemCompact.new(nil, nil, nil, nil)
131
-
132
- # Write sample files
133
- %w( aaa/foo.html bbb/foo.html ccc/foo.html ).each do |filename|
134
- FileUtils.mkdir_p(File.dirname(filename))
135
- File.open(filename, 'w') { |io| io.write('test') }
136
- end
137
-
138
- # Check
139
- expected = {
140
- './aaa/foo' => [ nil, 'html' ],
141
- './bbb/foo' => [ nil, 'html' ],
142
- './ccc/foo' => [ nil, 'html' ]
143
- }
144
- assert_equal expected, data_source.send(:all_split_files_in, '.')
145
- end
146
-
147
- def test_all_split_files_in_with_multiple_content_files
148
- # Create data source
149
- data_source = Nanoc3::DataSources::FilesystemCompact.new(nil, nil, nil, nil)
150
-
151
- # Write sample files
152
- %w( foo.html foo.xhtml foo.txt foo.yaml bar.html qux.yaml ).each do |filename|
153
- File.open(filename, 'w') { |io| io.write('test') }
154
- end
155
-
156
- # Check
157
- assert_raises RuntimeError do
158
- data_source.send(:all_split_files_in, '.')
159
- end
160
- end
161
-
162
- def test_basename_of_allowing_periods_in_identifiers
163
- # Create data source
164
- data_source = Nanoc3::DataSources::FilesystemCompact.new(nil, nil, nil, { :allow_periods_in_identifiers => true })
165
-
166
- # Get input and expected output
167
- expected = {
168
- '/' => '/',
169
- '/foo' => '/foo',
170
- '/foo.html' => '/foo',
171
- '/foo.xyz.html' => '/foo.xyz',
172
- '/foo/' => '/foo/',
173
- '/foo.xyz/' => '/foo.xyz/',
174
- '/foo/bar' => '/foo/bar',
175
- '/foo/bar.html' => '/foo/bar',
176
- '/foo/bar.xyz.html' => '/foo/bar.xyz',
177
- '/foo/bar/' => '/foo/bar/',
178
- '/foo/bar.xyz/' => '/foo/bar.xyz/',
179
- '/foo.xyz/bar.xyz/' => '/foo.xyz/bar.xyz/'
180
- }
181
-
182
- # Check
183
- expected.each_pair do |input, expected_output|
184
- actual_output = data_source.send(:basename_of, input)
185
- assert_equal(
186
- expected_output, actual_output,
187
- "basename_of(#{input.inspect}) should equal #{expected_output.inspect}, not #{actual_output.inspect}"
188
- )
189
- end
190
- end
191
-
192
- def test_basename_of_disallowing_periods_in_identifiers
193
- # Create data source
194
- data_source = Nanoc3::DataSources::FilesystemCompact.new(nil, nil, nil, nil)
195
-
196
- # Get input and expected output
197
- expected = {
198
- '/' => '/',
199
- '/foo' => '/foo',
200
- '/foo.html' => '/foo',
201
- '/foo.xyz.html' => '/foo',
202
- '/foo/' => '/foo/',
203
- '/foo.xyz/' => '/foo.xyz/',
204
- '/foo/bar' => '/foo/bar',
205
- '/foo/bar.html' => '/foo/bar',
206
- '/foo/bar.xyz.html' => '/foo/bar',
207
- '/foo/bar/' => '/foo/bar/',
208
- '/foo/bar.xyz/' => '/foo/bar.xyz/',
209
- '/foo.xyz/bar.xyz/' => '/foo.xyz/bar.xyz/'
210
- }
211
-
212
- # Check
213
- expected.each_pair do |input, expected_output|
214
- actual_output = data_source.send(:basename_of, input)
215
- assert_equal(
216
- expected_output, actual_output,
217
- "basename_of(#{input.inspect}) should equal #{expected_output.inspect}, not #{actual_output.inspect}"
218
- )
219
- end
220
- end
221
-
222
- def test_ext_of_allowing_periods_in_identifiers
223
- # Create data source
224
- data_source = Nanoc3::DataSources::FilesystemCompact.new(nil, nil, nil, { :allow_periods_in_identifiers => true })
225
-
226
- # Get input and expected output
227
- expected = {
228
- '/' => '',
229
- '/foo' => '',
230
- '/foo.html' => '.html',
231
- '/foo.xyz.html' => '.html',
232
- '/foo/' => '',
233
- '/foo.xyz/' => '',
234
- '/foo/bar' => '',
235
- '/foo/bar.html' => '.html',
236
- '/foo/bar.xyz.html' => '.html',
237
- '/foo/bar/' => '',
238
- '/foo/bar.xyz/' => '',
239
- '/foo.xyz/bar.xyz/' => ''
240
- }
241
-
242
- # Check
243
- expected.each_pair do |input, expected_output|
244
- actual_output = data_source.send(:ext_of, input)
245
- assert_equal(
246
- expected_output, actual_output,
247
- "basename_of(#{input.inspect}) should equal #{expected_output.inspect}, not #{actual_output.inspect}"
248
- )
249
- end
250
- end
251
-
252
- def test_ext_of_disallowing_periods_in_identifiers
253
- # Create data source
254
- data_source = Nanoc3::DataSources::FilesystemCompact.new(nil, nil, nil, nil)
255
-
256
- # Get input and expected output
257
- expected = {
258
- '/' => '',
259
- '/foo' => '',
260
- '/foo.html' => '.html',
261
- '/foo.xyz.html' => '.xyz.html',
262
- '/foo/' => '',
263
- '/foo.xyz/' => '',
264
- '/foo/bar' => '',
265
- '/foo/bar.html' => '.html',
266
- '/foo/bar.xyz.html' => '.xyz.html',
267
- '/foo/bar/' => '',
268
- '/foo/bar.xyz/' => '',
269
- '/foo.xyz/bar.xyz/' => ''
270
- }
271
-
272
- # Check
273
- expected.each_pair do |input, expected_output|
274
- actual_output = data_source.send(:ext_of, input)
275
- assert_equal(
276
- expected_output, actual_output,
277
- "basename_of(#{input.inspect}) should equal #{expected_output.inspect}, not #{actual_output.inspect}"
278
- )
279
- end
280
- end
281
-
282
- def test_parse_embedded_invalid_2
283
- # Create a file
284
- File.open('test.html', 'w') do |io|
285
- io.write "-----\n"
286
- io.write "blah blah\n"
287
- end
288
-
289
- # Create data source
290
- data_source = Nanoc3::DataSources::FilesystemCombined.new(nil, nil, nil, nil)
291
-
292
- # Parse it
293
- assert_raises(RuntimeError) do
294
- data_source.instance_eval { parse('test.html', nil, 'foobar') }
295
- end
296
- end
297
-
298
- def test_parse_embedded_separators_but_not_metadata
299
- # Create a file
300
- File.open('test.html', 'w') do |io|
301
- io.write "blah blah\n"
302
- io.write "-----\n"
303
- io.write "blah blah\n"
304
- end
305
-
306
- # Create data source
307
- data_source = Nanoc3::DataSources::FilesystemCombined.new(nil, nil, nil, nil)
308
-
309
- # Parse it
310
- result = data_source.instance_eval { parse('test.html', nil, 'foobar') }
311
- assert_equal(File.read('test.html'), result[1])
312
- assert_equal({}, result[0])
313
- end
314
-
315
- def test_parse_embedded_full_meta
316
- # Create a file
317
- File.open('test.html', 'w') do |io|
318
- io.write "-----\n"
319
- io.write "foo: bar\n"
320
- io.write "-----\n"
321
- io.write "blah blah\n"
322
- end
323
-
324
- # Create data source
325
- data_source = Nanoc3::DataSources::FilesystemCombined.new(nil, nil, nil, nil)
326
-
327
- # Parse it
328
- result = data_source.instance_eval { parse('test.html', nil, 'foobar') }
329
- assert_equal({ 'foo' => 'bar' }, result[0])
330
- assert_equal('blah blah', result[1])
331
- end
332
-
333
- def test_parse_embedded_with_extra_spaces
334
- # Create a file
335
- File.open('test.html', 'w') do |io|
336
- io.write "----- \n"
337
- io.write "foo: bar\n"
338
- io.write "-----\t\t\t\t\t\n"
339
- io.write "blah blah\n"
340
- end
341
-
342
- # Create data source
343
- data_source = Nanoc3::DataSources::FilesystemCombined.new(nil, nil, nil, nil)
344
-
345
- # Parse it
346
- result = data_source.instance_eval { parse('test.html', nil, 'foobar') }
347
- assert_equal({ 'foo' => 'bar' }, result[0])
348
- assert_equal('blah blah', result[1])
349
- end
350
-
351
- def test_parse_embedded_empty_meta
352
- # Create a file
353
- File.open('test.html', 'w') do |io|
354
- io.write "-----\n"
355
- io.write "-----\n"
356
- io.write "blah blah\n"
357
- end
358
-
359
- # Create data source
360
- data_source = Nanoc3::DataSources::FilesystemCombined.new(nil, nil, nil, nil)
361
-
362
- # Parse it
363
- result = data_source.instance_eval { parse('test.html', nil, 'foobar') }
364
- assert_equal({}, result[0])
365
- assert_equal('blah blah', result[1])
366
- end
367
-
368
- def test_parse_utf8_bom
369
- File.open('test.html', 'w') do |io|
370
- io.write [ 0xEF, 0xBB, 0xBF ].map { |i| i.chr }.join
371
- io.write "-----\n"
372
- io.write "utf8bomawareness: high\n"
373
- io.write "-----\n"
374
- io.write "content goes here\n"
375
- end
376
-
377
- data_source = Nanoc3::DataSources::FilesystemCombined.new(nil, nil, nil, nil)
378
-
379
- result = data_source.instance_eval { parse('test.html', nil, 'foobar') }
380
- assert_equal({ 'utf8bomawareness' => 'high' }, result[0])
381
- assert_equal('content goes here', result[1])
382
- end
383
-
384
- def test_parse_embedded_no_meta
385
- content = "blah\n" \
386
- "blah blah blah\n" \
387
- "blah blah\n"
388
-
389
- # Create a file
390
- File.open('test.html', 'w') { |io| io.write(content) }
391
-
392
- # Create data source
393
- data_source = Nanoc3::DataSources::FilesystemCombined.new(nil, nil, nil, nil)
394
-
395
- # Parse it
396
- result = data_source.instance_eval { parse('test.html', nil, 'foobar') }
397
- assert_equal({}, result[0])
398
- assert_equal(content, result[1])
399
- end
400
-
401
- def test_parse_embedded_diff
402
- content = \
403
- "--- a/foo\n" \
404
- "+++ b/foo\n" \
405
- "blah blah\n"
406
-
407
- # Create a file
408
- File.open('test.html', 'w') { |io| io.write(content) }
409
-
410
- # Create data source
411
- data_source = Nanoc3::DataSources::FilesystemCombined.new(nil, nil, nil, nil)
412
-
413
- # Parse it
414
- result = data_source.instance_eval { parse('test.html', nil, 'foobar') }
415
- assert_equal({}, result[0])
416
- assert_equal(content, result[1])
417
- end
418
-
419
- def test_parse_external
420
- # Create a file
421
- File.open('test.html', 'w') { |io| io.write("blah blah") }
422
- File.open('test.yaml', 'w') { |io| io.write("foo: bar") }
423
-
424
- # Create data source
425
- data_source = Nanoc3::DataSources::FilesystemCombined.new(nil, nil, nil, nil)
426
-
427
- # Parse it
428
- result = data_source.instance_eval { parse('test.html', 'test.yaml', 'foobar') }
429
- assert_equal({ "foo" => "bar"}, result[0])
430
- assert_equal("blah blah", result[1])
431
- end
432
-
433
- end