nanoc 4.8.12 → 4.8.13

Sign up to get free protection for your applications and to get access to all the features.
Files changed (295) hide show
  1. checksums.yaml +4 -4
  2. data/NEWS.md +6 -0
  3. data/lib/nanoc/base/entities/document.rb +16 -1
  4. data/lib/nanoc/base/feature.rb +1 -1
  5. data/lib/nanoc/base/repos/action_sequence_store.rb +3 -3
  6. data/lib/nanoc/base/repos/checksum_store.rb +3 -3
  7. data/lib/nanoc/base/repos/compiled_content_cache.rb +3 -3
  8. data/lib/nanoc/base/repos/dependency_store.rb +3 -3
  9. data/lib/nanoc/base/repos/outdatedness_store.rb +3 -3
  10. data/lib/nanoc/base/repos/store.rb +3 -5
  11. data/lib/nanoc/base/services/compiler_loader.rb +5 -5
  12. data/lib/nanoc/base/views/mixins/mutable_document_view_mixin.rb +2 -14
  13. data/lib/nanoc/cli/commands/compile.rb +18 -0
  14. data/lib/nanoc/cli/commands/live.rb +1 -0
  15. data/lib/nanoc/cli/commands/view.rb +12 -35
  16. data/lib/nanoc/filters/redcarpet.rb +26 -65
  17. data/lib/nanoc/version.rb +1 -1
  18. metadata +2 -293
  19. data/.rspec +0 -3
  20. data/.rubocop.yml +0 -173
  21. data/Rakefile +0 -25
  22. data/nanoc.gemspec +0 -44
  23. data/nanoc.manifest +0 -543
  24. data/spec/contributors_spec.rb +0 -20
  25. data/spec/gem_spec.rb +0 -21
  26. data/spec/manifest_spec.rb +0 -22
  27. data/spec/nanoc/base/changes_stream_spec.rb +0 -45
  28. data/spec/nanoc/base/checksummer_spec.rb +0 -419
  29. data/spec/nanoc/base/compiler_spec.rb +0 -149
  30. data/spec/nanoc/base/core_ext/array_spec.rb +0 -35
  31. data/spec/nanoc/base/core_ext/hash_spec.rb +0 -41
  32. data/spec/nanoc/base/core_ext/string_spec.rb +0 -23
  33. data/spec/nanoc/base/directed_graph_spec.rb +0 -258
  34. data/spec/nanoc/base/entities/action_sequence_spec.rb +0 -297
  35. data/spec/nanoc/base/entities/code_snippet_spec.rb +0 -60
  36. data/spec/nanoc/base/entities/configuration_spec.rb +0 -132
  37. data/spec/nanoc/base/entities/content_spec.rb +0 -195
  38. data/spec/nanoc/base/entities/context_spec.rb +0 -26
  39. data/spec/nanoc/base/entities/document_spec.rb +0 -258
  40. data/spec/nanoc/base/entities/identifiable_collection_spec.rb +0 -209
  41. data/spec/nanoc/base/entities/identifier_spec.rb +0 -472
  42. data/spec/nanoc/base/entities/item_rep_spec.rb +0 -26
  43. data/spec/nanoc/base/entities/item_spec.rb +0 -13
  44. data/spec/nanoc/base/entities/layout_spec.rb +0 -13
  45. data/spec/nanoc/base/entities/lazy_value_spec.rb +0 -108
  46. data/spec/nanoc/base/entities/outdatedness_status_spec.rb +0 -115
  47. data/spec/nanoc/base/entities/pattern_spec.rb +0 -133
  48. data/spec/nanoc/base/entities/processing_action_spec.rb +0 -11
  49. data/spec/nanoc/base/entities/processing_actions/filter_spec.rb +0 -20
  50. data/spec/nanoc/base/entities/processing_actions/layout_spec.rb +0 -20
  51. data/spec/nanoc/base/entities/processing_actions/snapshot_spec.rb +0 -40
  52. data/spec/nanoc/base/entities/props_spec.rb +0 -413
  53. data/spec/nanoc/base/entities/site_spec.rb +0 -80
  54. data/spec/nanoc/base/errors/dependency_cycle_spec.rb +0 -35
  55. data/spec/nanoc/base/feature_spec.rb +0 -109
  56. data/spec/nanoc/base/filter_spec.rb +0 -166
  57. data/spec/nanoc/base/item_rep_writer_spec.rb +0 -140
  58. data/spec/nanoc/base/memoization_spec.rb +0 -108
  59. data/spec/nanoc/base/repos/aggregate_data_source_spec.rb +0 -87
  60. data/spec/nanoc/base/repos/checksum_store_spec.rb +0 -155
  61. data/spec/nanoc/base/repos/compiled_content_cache_spec.rb +0 -65
  62. data/spec/nanoc/base/repos/config_loader_spec.rb +0 -245
  63. data/spec/nanoc/base/repos/data_source_spec.rb +0 -95
  64. data/spec/nanoc/base/repos/dependency_store_spec.rb +0 -515
  65. data/spec/nanoc/base/repos/in_mem_data_source_spec.rb +0 -39
  66. data/spec/nanoc/base/repos/outdatedness_store_spec.rb +0 -72
  67. data/spec/nanoc/base/repos/prefixed_data_source_spec.rb +0 -39
  68. data/spec/nanoc/base/repos/site_loader_spec.rb +0 -264
  69. data/spec/nanoc/base/repos/snapshot_repo_spec.rb +0 -316
  70. data/spec/nanoc/base/repos/store_spec.rb +0 -93
  71. data/spec/nanoc/base/services/compiler/phases/abstract_spec.rb +0 -63
  72. data/spec/nanoc/base/services/compiler/phases/cache_spec.rb +0 -156
  73. data/spec/nanoc/base/services/compiler/stages/calculate_checksums_spec.rb +0 -74
  74. data/spec/nanoc/base/services/compiler/stages/cleanup_spec.rb +0 -88
  75. data/spec/nanoc/base/services/compiler/stages/compile_reps_spec.rb +0 -142
  76. data/spec/nanoc/base/services/compiler/stages/determine_outdatedness_spec.rb +0 -148
  77. data/spec/nanoc/base/services/compiler/stages/preprocess_spec.rb +0 -110
  78. data/spec/nanoc/base/services/dependency_tracker_spec.rb +0 -245
  79. data/spec/nanoc/base/services/executor_spec.rb +0 -686
  80. data/spec/nanoc/base/services/item_rep_router_spec.rb +0 -198
  81. data/spec/nanoc/base/services/item_rep_selector_spec.rb +0 -227
  82. data/spec/nanoc/base/services/notification_center_spec.rb +0 -25
  83. data/spec/nanoc/base/services/outdatedness_checker_spec.rb +0 -778
  84. data/spec/nanoc/base/services/outdatedness_rules_spec.rb +0 -495
  85. data/spec/nanoc/base/services/pruner_spec.rb +0 -116
  86. data/spec/nanoc/base/services/temp_filename_factory_spec.rb +0 -89
  87. data/spec/nanoc/base/views/basic_item_rep_collection_view_spec.rb +0 -8
  88. data/spec/nanoc/base/views/basic_item_rep_view_spec.rb +0 -9
  89. data/spec/nanoc/base/views/compilation_item_rep_collection_view_spec.rb +0 -8
  90. data/spec/nanoc/base/views/compilation_item_rep_view_spec.rb +0 -136
  91. data/spec/nanoc/base/views/config_view_spec.rb +0 -144
  92. data/spec/nanoc/base/views/item_collection_with_reps_view_spec.rb +0 -23
  93. data/spec/nanoc/base/views/item_collection_without_reps_view_spec.rb +0 -23
  94. data/spec/nanoc/base/views/item_view_spec.rb +0 -376
  95. data/spec/nanoc/base/views/layout_collection_view_spec.rb +0 -23
  96. data/spec/nanoc/base/views/layout_view_spec.rb +0 -18
  97. data/spec/nanoc/base/views/mutable_config_view_spec.rb +0 -18
  98. data/spec/nanoc/base/views/mutable_item_collection_view_spec.rb +0 -60
  99. data/spec/nanoc/base/views/mutable_item_view_spec.rb +0 -26
  100. data/spec/nanoc/base/views/mutable_layout_collection_view_spec.rb +0 -60
  101. data/spec/nanoc/base/views/mutable_layout_view_spec.rb +0 -17
  102. data/spec/nanoc/base/views/post_compile_item_rep_collection_view_spec.rb +0 -8
  103. data/spec/nanoc/base/views/post_compile_item_rep_view_spec.rb +0 -216
  104. data/spec/nanoc/base/views/post_compile_item_view_spec.rb +0 -58
  105. data/spec/nanoc/base/views/support/document_view_examples.rb +0 -340
  106. data/spec/nanoc/base/views/support/identifiable_collection_view_examples.rb +0 -277
  107. data/spec/nanoc/base/views/support/item_rep_collection_view_examples.rb +0 -140
  108. data/spec/nanoc/base/views/support/item_rep_view_examples.rb +0 -308
  109. data/spec/nanoc/base/views/support/mutable_document_view_examples.rb +0 -188
  110. data/spec/nanoc/base/views/support/mutable_identifiable_collection_view_examples.rb +0 -44
  111. data/spec/nanoc/checking/runner_spec.rb +0 -26
  112. data/spec/nanoc/cli/command_runner_spec.rb +0 -107
  113. data/spec/nanoc/cli/commands/compile/abstract_spec.rb +0 -80
  114. data/spec/nanoc/cli/commands/compile/diff_generator_spec.rb +0 -44
  115. data/spec/nanoc/cli/commands/compile/file_action_printer_spec.rb +0 -112
  116. data/spec/nanoc/cli/commands/compile/timing_recorder_spec.rb +0 -287
  117. data/spec/nanoc/cli/commands/compile_spec.rb +0 -45
  118. data/spec/nanoc/cli/commands/deploy_spec.rb +0 -329
  119. data/spec/nanoc/cli/commands/shell_spec.rb +0 -77
  120. data/spec/nanoc/cli/commands/show_data_spec.rb +0 -286
  121. data/spec/nanoc/cli/commands/show_plugins_spec.rb +0 -20
  122. data/spec/nanoc/cli/commands/show_rules_spec.rb +0 -118
  123. data/spec/nanoc/cli/commands/view_spec.rb +0 -75
  124. data/spec/nanoc/cli/error_handler_spec.rb +0 -43
  125. data/spec/nanoc/cli/stack_trace_writer_spec.rb +0 -156
  126. data/spec/nanoc/cli/stream_cleaners/utf8_spec.rb +0 -9
  127. data/spec/nanoc/cli_spec.rb +0 -44
  128. data/spec/nanoc/data_sources/filesystem_spec.rb +0 -128
  129. data/spec/nanoc/deploying/fog_spec.rb +0 -199
  130. data/spec/nanoc/deploying/git_spec.rb +0 -305
  131. data/spec/nanoc/extra/live_recompiler_spec.rb +0 -129
  132. data/spec/nanoc/extra/parallel_collection_spec.rb +0 -110
  133. data/spec/nanoc/filters/asciidoctor_spec.rb +0 -12
  134. data/spec/nanoc/filters/colorize_syntax/rouge_spec.rb +0 -155
  135. data/spec/nanoc/filters/less_spec.rb +0 -122
  136. data/spec/nanoc/helpers/blogging_spec.rb +0 -219
  137. data/spec/nanoc/helpers/breadcrumbs_spec.rb +0 -135
  138. data/spec/nanoc/helpers/capturing_spec.rb +0 -256
  139. data/spec/nanoc/helpers/child_parent_spec.rb +0 -76
  140. data/spec/nanoc/helpers/filtering_spec.rb +0 -77
  141. data/spec/nanoc/helpers/html_escape_spec.rb +0 -37
  142. data/spec/nanoc/helpers/link_to_spec.rb +0 -320
  143. data/spec/nanoc/helpers/rendering_spec.rb +0 -144
  144. data/spec/nanoc/helpers/tagging_spec.rb +0 -106
  145. data/spec/nanoc/helpers/text_spec.rb +0 -60
  146. data/spec/nanoc/integration/compile_command_spec.rb +0 -33
  147. data/spec/nanoc/integration/outdatedness_integration_spec.rb +0 -269
  148. data/spec/nanoc/integration/partial_recompilation_spec.rb +0 -50
  149. data/spec/nanoc/regressions/gh_1015_spec.rb +0 -19
  150. data/spec/nanoc/regressions/gh_1022_spec.rb +0 -26
  151. data/spec/nanoc/regressions/gh_1031_spec.rb +0 -56
  152. data/spec/nanoc/regressions/gh_1035_spec.rb +0 -35
  153. data/spec/nanoc/regressions/gh_1037a_spec.rb +0 -31
  154. data/spec/nanoc/regressions/gh_1037b_spec.rb +0 -20
  155. data/spec/nanoc/regressions/gh_1040_spec.rb +0 -24
  156. data/spec/nanoc/regressions/gh_1045_spec.rb +0 -50
  157. data/spec/nanoc/regressions/gh_1047_spec.rb +0 -30
  158. data/spec/nanoc/regressions/gh_1064_spec.rb +0 -20
  159. data/spec/nanoc/regressions/gh_1067_spec.rb +0 -36
  160. data/spec/nanoc/regressions/gh_1082a_spec.rb +0 -20
  161. data/spec/nanoc/regressions/gh_1082b_spec.rb +0 -22
  162. data/spec/nanoc/regressions/gh_1082c_spec.rb +0 -21
  163. data/spec/nanoc/regressions/gh_1082d_spec.rb +0 -19
  164. data/spec/nanoc/regressions/gh_1093_spec.rb +0 -51
  165. data/spec/nanoc/regressions/gh_1094_spec.rb +0 -24
  166. data/spec/nanoc/regressions/gh_1097_spec.rb +0 -23
  167. data/spec/nanoc/regressions/gh_1100_spec.rb +0 -22
  168. data/spec/nanoc/regressions/gh_1102_spec.rb +0 -28
  169. data/spec/nanoc/regressions/gh_1107_spec.rb +0 -15
  170. data/spec/nanoc/regressions/gh_1130_spec.rb +0 -21
  171. data/spec/nanoc/regressions/gh_1134_spec.rb +0 -29
  172. data/spec/nanoc/regressions/gh_1145_spec.rb +0 -18
  173. data/spec/nanoc/regressions/gh_1171_spec.rb +0 -57
  174. data/spec/nanoc/regressions/gh_1185_spec.rb +0 -22
  175. data/spec/nanoc/regressions/gh_1216_spec.rb +0 -91
  176. data/spec/nanoc/regressions/gh_1248_spec.rb +0 -24
  177. data/spec/nanoc/regressions/gh_761_spec.rb +0 -25
  178. data/spec/nanoc/regressions/gh_767_spec.rb +0 -21
  179. data/spec/nanoc/regressions/gh_769_spec.rb +0 -32
  180. data/spec/nanoc/regressions/gh_776_spec.rb +0 -42
  181. data/spec/nanoc/regressions/gh_787_spec.rb +0 -21
  182. data/spec/nanoc/regressions/gh_795_spec.rb +0 -21
  183. data/spec/nanoc/regressions/gh_804_spec.rb +0 -28
  184. data/spec/nanoc/regressions/gh_807_spec.rb +0 -19
  185. data/spec/nanoc/regressions/gh_809_spec.rb +0 -19
  186. data/spec/nanoc/regressions/gh_813_spec.rb +0 -24
  187. data/spec/nanoc/regressions/gh_815_spec.rb +0 -20
  188. data/spec/nanoc/regressions/gh_828_spec.rb +0 -25
  189. data/spec/nanoc/regressions/gh_833_spec.rb +0 -16
  190. data/spec/nanoc/regressions/gh_841_spec.rb +0 -17
  191. data/spec/nanoc/regressions/gh_867_spec.rb +0 -17
  192. data/spec/nanoc/regressions/gh_882_spec.rb +0 -31
  193. data/spec/nanoc/regressions/gh_885_spec.rb +0 -32
  194. data/spec/nanoc/regressions/gh_891_spec.rb +0 -28
  195. data/spec/nanoc/regressions/gh_913_spec.rb +0 -26
  196. data/spec/nanoc/regressions/gh_924_spec.rb +0 -91
  197. data/spec/nanoc/regressions/gh_928_spec.rb +0 -7
  198. data/spec/nanoc/regressions/gh_937_spec.rb +0 -27
  199. data/spec/nanoc/regressions/gh_942_spec.rb +0 -23
  200. data/spec/nanoc/regressions/gh_947_spec.rb +0 -23
  201. data/spec/nanoc/regressions/gh_948_spec.rb +0 -18
  202. data/spec/nanoc/regressions/gh_951_spec.rb +0 -21
  203. data/spec/nanoc/regressions/gh_954_spec.rb +0 -35
  204. data/spec/nanoc/regressions/gh_970a_spec.rb +0 -19
  205. data/spec/nanoc/regressions/gh_970b_spec.rb +0 -52
  206. data/spec/nanoc/regressions/gh_974_spec.rb +0 -19
  207. data/spec/nanoc/regressions/gh_981_spec.rb +0 -23
  208. data/spec/nanoc/rule_dsl/action_sequence_calculator_spec.rb +0 -230
  209. data/spec/nanoc/rule_dsl/recording_executor_spec.rb +0 -145
  210. data/spec/nanoc/rule_dsl/rule_context_spec.rb +0 -251
  211. data/spec/nanoc/rule_dsl/rule_spec.rb +0 -111
  212. data/spec/nanoc/rule_dsl/rules_collection_spec.rb +0 -301
  213. data/spec/nanoc/spec_spec.rb +0 -70
  214. data/spec/nanoc/telemetry/counter_spec.rb +0 -20
  215. data/spec/nanoc/telemetry/labelled_counter_spec.rb +0 -94
  216. data/spec/nanoc/telemetry/labelled_summary_spec.rb +0 -78
  217. data/spec/nanoc/telemetry/stopwatch_spec.rb +0 -63
  218. data/spec/nanoc/telemetry/summary_spec.rb +0 -68
  219. data/spec/nanoc/telemetry/table_spec.rb +0 -22
  220. data/spec/nanoc/telemetry_spec.rb +0 -28
  221. data/spec/regression_filenames_spec.rb +0 -18
  222. data/spec/spec_helper.rb +0 -371
  223. data/test/base/test_compiler.rb +0 -389
  224. data/test/base/test_filter.rb +0 -73
  225. data/test/base/test_site.rb +0 -146
  226. data/test/checking/checks/test_css.rb +0 -66
  227. data/test/checking/checks/test_external_links.rb +0 -88
  228. data/test/checking/checks/test_html.rb +0 -47
  229. data/test/checking/checks/test_internal_links.rb +0 -118
  230. data/test/checking/checks/test_mixed_content.rb +0 -190
  231. data/test/checking/checks/test_stale.rb +0 -69
  232. data/test/checking/test_check.rb +0 -22
  233. data/test/checking/test_dsl.rb +0 -35
  234. data/test/checking/test_runner.rb +0 -45
  235. data/test/cli/commands/test_check.rb +0 -20
  236. data/test/cli/commands/test_compile.rb +0 -199
  237. data/test/cli/commands/test_create_site.rb +0 -126
  238. data/test/cli/commands/test_help.rb +0 -10
  239. data/test/cli/commands/test_prune.rb +0 -157
  240. data/test/cli/test_cleaning_stream.rb +0 -97
  241. data/test/cli/test_cli.rb +0 -195
  242. data/test/cli/test_error_handler.rb +0 -102
  243. data/test/cli/test_logger.rb +0 -7
  244. data/test/data_sources/test_filesystem.rb +0 -1033
  245. data/test/data_sources/test_filesystem_tools.rb +0 -146
  246. data/test/deploying/test_fog.rb +0 -117
  247. data/test/deploying/test_git.rb +0 -263
  248. data/test/deploying/test_rsync.rb +0 -94
  249. data/test/extra/core_ext/test_time.rb +0 -17
  250. data/test/extra/test_link_collector.rb +0 -110
  251. data/test/extra/test_piper.rb +0 -48
  252. data/test/filters/colorize_syntax/test_coderay.rb +0 -247
  253. data/test/filters/colorize_syntax/test_common.rb +0 -109
  254. data/test/filters/colorize_syntax/test_pygmentize.rb +0 -39
  255. data/test/filters/colorize_syntax/test_pygments.rb +0 -21
  256. data/test/filters/colorize_syntax/test_simon.rb +0 -24
  257. data/test/filters/test_asciidoc.rb +0 -16
  258. data/test/filters/test_bluecloth.rb +0 -16
  259. data/test/filters/test_coffeescript.rb +0 -16
  260. data/test/filters/test_erb.rb +0 -107
  261. data/test/filters/test_erubi.rb +0 -75
  262. data/test/filters/test_erubis.rb +0 -76
  263. data/test/filters/test_haml.rb +0 -94
  264. data/test/filters/test_handlebars.rb +0 -61
  265. data/test/filters/test_kramdown.rb +0 -56
  266. data/test/filters/test_markaby.rb +0 -16
  267. data/test/filters/test_maruku.rb +0 -16
  268. data/test/filters/test_mustache.rb +0 -43
  269. data/test/filters/test_pandoc.rb +0 -47
  270. data/test/filters/test_rainpress.rb +0 -27
  271. data/test/filters/test_rdiscount.rb +0 -30
  272. data/test/filters/test_rdoc.rb +0 -14
  273. data/test/filters/test_redcarpet.rb +0 -111
  274. data/test/filters/test_redcloth.rb +0 -31
  275. data/test/filters/test_relativize_paths.rb +0 -887
  276. data/test/filters/test_rubypants.rb +0 -16
  277. data/test/filters/test_sass.rb +0 -315
  278. data/test/filters/test_slim.rb +0 -59
  279. data/test/filters/test_typogruby.rb +0 -18
  280. data/test/filters/test_uglify_js.rb +0 -30
  281. data/test/filters/test_xsl.rb +0 -192
  282. data/test/filters/test_yui_compressor.rb +0 -42
  283. data/test/fixtures/vcr_cassettes/css_run_error.yml +0 -70
  284. data/test/fixtures/vcr_cassettes/css_run_ok.yml +0 -60
  285. data/test/fixtures/vcr_cassettes/css_run_parse_error.yml +0 -70
  286. data/test/fixtures/vcr_cassettes/html_run_error.yml +0 -56
  287. data/test/fixtures/vcr_cassettes/html_run_ok.yml +0 -58
  288. data/test/helper.rb +0 -255
  289. data/test/helpers/test_blogging.rb +0 -684
  290. data/test/helpers/test_capturing.rb +0 -184
  291. data/test/helpers/test_link_to.rb +0 -57
  292. data/test/helpers/test_xml_sitemap.rb +0 -246
  293. data/test/rule_dsl/test_action_provider.rb +0 -80
  294. data/test/rule_dsl/test_compiler_dsl.rb +0 -448
  295. data/test/rule_dsl/test_rules_collection.rb +0 -93
@@ -1,126 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'helper'
4
-
5
- class Nanoc::CLI::Commands::CreateSiteTest < Nanoc::TestCase
6
- def test_create_site_with_existing_name
7
- Nanoc::CLI.run %w[create_site foo]
8
- assert_raises(::Nanoc::Int::Errors::GenericTrivial) do
9
- Nanoc::CLI.run %w[create_site foo]
10
- end
11
- end
12
-
13
- def test_can_compile_new_site
14
- Nanoc::CLI.run %w[create_site foo]
15
-
16
- FileUtils.cd('foo') do
17
- site = Nanoc::Int::SiteLoader.new.new_from_cwd
18
- site.compile
19
- end
20
- end
21
-
22
- def test_can_compile_new_site_in_current_directory
23
- FileUtils.mkdir('foo')
24
-
25
- FileUtils.cd('foo') do
26
- Nanoc::CLI.run %w[create_site ./]
27
- site = Nanoc::Int::SiteLoader.new.new_from_cwd
28
- site.compile
29
- end
30
- end
31
-
32
- def test_can_compile_new_site_with_binary_items
33
- Nanoc::CLI.run %w[create_site foo]
34
-
35
- FileUtils.cd('foo') do
36
- File.open('content/blah', 'w') { |io| io << 'asdf' }
37
- site = Nanoc::Int::SiteLoader.new.new_from_cwd
38
- site.compile
39
-
40
- assert File.file?('output/blah')
41
- end
42
- end
43
-
44
- def test_can_compile_site_in_nonempty_directory
45
- FileUtils.mkdir('foo')
46
- FileUtils.touch(File.join('foo', 'SomeFile.txt'))
47
- Nanoc::CLI.run %w[create_site foo --force]
48
-
49
- FileUtils.cd('foo') do
50
- site = Nanoc::Int::SiteLoader.new.new_from_cwd
51
- site.compile
52
- end
53
- end
54
-
55
- def test_compiled_site_output
56
- FileUtils.mkdir('foo')
57
- FileUtils.touch(File.join('foo', 'SomeFile.txt'))
58
- Nanoc::CLI.run %w[create_site foo --force]
59
-
60
- FileUtils.cd('foo') do
61
- site = Nanoc::Int::SiteLoader.new.new_from_cwd
62
- site.compile
63
-
64
- assert File.file?('output/index.html')
65
- end
66
- end
67
-
68
- def test_default_encoding
69
- unless defined?(Encoding)
70
- skip 'No Encoding class'
71
- return
72
- end
73
-
74
- original_encoding = Encoding.default_external
75
- Encoding.default_external = 'ISO-8859-1' # ew!
76
-
77
- Nanoc::CLI.run %w[create_site foo]
78
-
79
- FileUtils.cd('foo') do
80
- # Try with encoding = default encoding = utf-8
81
- File.open('content/index.html', 'w') { |io| io.write('Hello ' + 0xD6.chr + "!\n") }
82
- exception = assert_raises(Nanoc::DataSources::Filesystem::Errors::InvalidEncoding) do
83
- Nanoc::Int::SiteLoader.new.new_from_cwd
84
- end
85
- assert_equal 'Could not read content/index.html because the file is not valid UTF-8.', exception.message
86
-
87
- # Try with encoding = specific
88
- File.open('nanoc.yaml', 'w') do |io|
89
- io.write("string_pattern_type: glob\n")
90
- io.write("data_sources:\n")
91
- io.write(" -\n")
92
- io.write(" type: filesystem\n")
93
- io.write(" identifier_type: full\n")
94
- end
95
- site = Nanoc::Int::SiteLoader.new.new_from_cwd
96
- site.compile
97
- end
98
- FileUtils
99
- ensure
100
- Encoding.default_external = original_encoding
101
- end
102
-
103
- def test_new_site_has_correct_stylesheets
104
- Nanoc::CLI.run %w[create_site foo]
105
- FileUtils.cd('foo') do
106
- Nanoc::CLI.run %w[compile]
107
-
108
- assert File.file?('content/stylesheet.css')
109
- assert_match(/\/stylesheet.css/, File.read('output/index.html'))
110
- end
111
- end
112
-
113
- def test_new_site_prunes_by_default
114
- FileUtils.mkdir('foo')
115
- FileUtils.touch(File.join('foo', 'SomeFile.txt'))
116
- Nanoc::CLI.run %w[create_site foo --force]
117
-
118
- FileUtils.cd('foo') do
119
- File.write('output/blah.txt', 'stuff')
120
-
121
- Nanoc::CLI.run %w[compile]
122
-
123
- refute File.file?('output/blah.txt')
124
- end
125
- end
126
- end
@@ -1,10 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'helper'
4
-
5
- class Nanoc::CLI::Commands::HelpTest < Nanoc::TestCase
6
- def test_run
7
- Nanoc::CLI.run %w[help]
8
- Nanoc::CLI.run %w[help co]
9
- end
10
- end
@@ -1,157 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'helper'
4
-
5
- class Nanoc::CLI::Commands::PruneTest < Nanoc::TestCase
6
- def test_run_without_yes
7
- with_site do |_site|
8
- # Set output dir
9
- File.open('nanoc.yaml', 'w') { |io| io.write "output_dir: output2\nstring_pattern_type: legacy\n" }
10
- FileUtils.mkdir_p('output2')
11
-
12
- # Create source files
13
- File.open('content/index.html', 'w') { |io| io.write 'stuff' }
14
-
15
- # Create output files
16
- File.open('output2/foo.html', 'w') { |io| io.write 'this is a foo.' }
17
- File.open('output2/index.html', 'w') { |io| io.write 'this is a index.' }
18
-
19
- assert_raises SystemExit do
20
- Nanoc::CLI.run %w[prune]
21
- end
22
-
23
- assert File.file?('output2/index.html')
24
- assert File.file?('output2/foo.html')
25
- end
26
- end
27
-
28
- def test_run_with_yes
29
- with_site do |_site|
30
- # Set output dir
31
- File.open('nanoc.yaml', 'w') do |io|
32
- io << 'output_dir: output2' << "\n"
33
- io << 'string_pattern_type: legacy' << "\n"
34
- io << 'data_sources:' << "\n"
35
- io << ' -' << "\n"
36
- io << ' type: filesystem' << "\n"
37
- io << ' identifier_type: legacy' << "\n"
38
- end
39
- FileUtils.mkdir_p('output2')
40
-
41
- # Create source files
42
- File.open('content/index.html', 'w') { |io| io.write 'stuff' }
43
-
44
- # Create output files
45
- File.open('output2/foo.html', 'w') { |io| io.write 'this is a foo.' }
46
- File.open('output2/index.html', 'w') { |io| io.write 'this is a index.' }
47
-
48
- Nanoc::CLI.run %w[prune --yes]
49
-
50
- assert File.file?('output2/index.html')
51
- assert !File.file?('output2/foo.html')
52
- end
53
- end
54
-
55
- def test_run_with_dry_run
56
- with_site do |_site|
57
- # Set output dir
58
- File.open('nanoc.yaml', 'w') { |io| io.write "string_pattern_type: legacy\noutput_dir: output2" }
59
- FileUtils.mkdir_p('output2')
60
-
61
- # Create source files
62
- File.open('content/index.html', 'w') { |io| io.write 'stuff' }
63
-
64
- # Create output files
65
- File.open('output2/foo.html', 'w') { |io| io.write 'this is a foo.' }
66
- File.open('output2/index.html', 'w') { |io| io.write 'this is a index.' }
67
-
68
- Nanoc::CLI.run %w[prune --dry-run]
69
-
70
- assert File.file?('output2/index.html')
71
- assert File.file?('output2/foo.html')
72
- end
73
- end
74
-
75
- def test_run_with_exclude
76
- with_site do |_site|
77
- # Set output dir
78
- File.open('nanoc.yaml', 'w') do |io|
79
- io << 'prune:' << "\n"
80
- io << ' exclude: [ "good-dir", "good-file.html" ]' << "\n"
81
- io << 'string_pattern_type: legacy' << "\n"
82
- io << 'data_sources:' << "\n"
83
- io << ' -' << "\n"
84
- io << ' type: filesystem' << "\n"
85
- io << ' identifier_type: legacy' << "\n"
86
- end
87
- FileUtils.mkdir_p('output')
88
-
89
- # Create source files
90
- File.open('content/index.html', 'w') { |io| io.write 'stuff' }
91
-
92
- # Create output files
93
- FileUtils.mkdir_p('output/good-dir')
94
- FileUtils.mkdir_p('output/bad-dir')
95
- File.open('output/good-file.html', 'w') { |io| io.write 'stuff' }
96
- File.open('output/good-dir/blah', 'w') { |io| io.write 'stuff' }
97
- File.open('output/bad-file.html', 'w') { |io| io.write 'stuff' }
98
- File.open('output/bad-dir/blah', 'w') { |io| io.write 'stuff' }
99
- File.open('output/index.html', 'w') { |io| io.write 'stuff' }
100
-
101
- Nanoc::CLI.run %w[prune --yes]
102
-
103
- assert File.file?('output/index.html')
104
- assert File.file?('output/good-dir/blah')
105
- assert File.file?('output/good-file.html')
106
- assert !File.file?('output/bad-dir/blah')
107
- assert !File.file?('output/bad-file.html')
108
- end
109
- end
110
-
111
- def test_run_with_symlink_to_output_dir
112
- skip_unless_symlinks_supported
113
- if defined?(JRUBY_VERSION)
114
- skip 'JRuby has buggy File.find behavior (see https://github.com/jruby/jruby/issues/1647)'
115
- end
116
-
117
- with_site do |_site|
118
- # Set output dir
119
- FileUtils.rm_rf('output')
120
- FileUtils.mkdir_p('output-real')
121
- File.symlink('output-real', 'output')
122
-
123
- # Create source files
124
- File.open('content/index.html', 'w') { |io| io.write 'stuff' }
125
-
126
- # Create output files
127
- FileUtils.mkdir_p('output-real/some-dir')
128
- File.open('output-real/some-file.html', 'w') { |io| io.write 'stuff' }
129
- File.open('output-real/index.html', 'w') { |io| io.write 'stuff' }
130
-
131
- Nanoc::CLI.run %w[prune --yes]
132
-
133
- assert File.file?('output-real/index.html')
134
- assert !File.directory?('output-real/some-dir')
135
- assert !File.file?('output-real/some-file.html')
136
- end
137
- end
138
-
139
- def test_run_with_nested_empty_dirs
140
- with_site do |_site|
141
- # Set output dir
142
- File.open('nanoc.yaml', 'w') { |io| io.write 'output_dir: output' }
143
- FileUtils.mkdir_p('output')
144
-
145
- # Create output files
146
- FileUtils.mkdir_p('output/a/b/c')
147
- File.open('output/a/b/c/index.html', 'w') { |io| io.write 'stuff' }
148
-
149
- Nanoc::CLI.run %w[prune --yes]
150
-
151
- assert !File.file?('output/a/b/c/index.html')
152
- assert !File.directory?('output/a/b/c')
153
- assert !File.directory?('output/a/b')
154
- assert !File.directory?('output/a')
155
- end
156
- end
157
- end
@@ -1,97 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'helper'
4
-
5
- class Nanoc::CLI::CleaningStreamTest < Nanoc::TestCase
6
- class Stream
7
- attr_accessor :called_methods
8
-
9
- def initialize
10
- @called_methods = []
11
- end
12
-
13
- # rubocop:disable Style/MethodMissing
14
- def method_missing(symbol, *_args)
15
- @called_methods << symbol
16
- end
17
- # rubocop:enable Style/MethodMissing
18
-
19
- def respond_to_missing?(*_args)
20
- true
21
- end
22
- end
23
-
24
- def test_forward
25
- methods = %i[write << tty? tty? flush tell print puts string reopen exist? exists? close]
26
-
27
- s = Stream.new
28
- cs = Nanoc::CLI::CleaningStream.new(s)
29
-
30
- cs.write('aaa')
31
- cs << 'bb'
32
- cs.tty?
33
- cs.isatty
34
- cs.flush
35
- cs.tell
36
- cs.print('cc')
37
- cs.puts('dd')
38
- cs.string
39
- cs.reopen('/dev/null', 'r')
40
- cs.exist?
41
- cs.exists?
42
- cs.close
43
-
44
- methods.each do |m|
45
- assert s.called_methods.include?(m), "expected #{m} to be called"
46
- end
47
- end
48
-
49
- def test_forward_tty_cached
50
- s = Stream.new
51
- cs = Nanoc::CLI::CleaningStream.new(s)
52
-
53
- cs.tty?
54
- cs.isatty
55
-
56
- assert_equal [:tty?], s.called_methods
57
- end
58
-
59
- def test_works_with_logger
60
- require 'logger'
61
- stream = StringIO.new
62
- cleaning_stream = Nanoc::CLI::CleaningStream.new(stream)
63
- logger = Logger.new(cleaning_stream)
64
- logger.info('Some info')
65
- logger.warn('Something could start going wrong!')
66
- end
67
-
68
- def test_broken_pipe
69
- stream = StringIO.new
70
- def stream.write(_s)
71
- raise Errno::EPIPE.new
72
- end
73
-
74
- cleaning_stream = Nanoc::CLI::CleaningStream.new(stream)
75
- cleaning_stream.write('lol')
76
- end
77
-
78
- def test_non_string
79
- obj = Object.new
80
- def obj.to_s
81
- 'Hello… world!'
82
- end
83
-
84
- stream = StringIO.new
85
- cleaning_stream = Nanoc::CLI::CleaningStream.new(stream)
86
- cleaning_stream << obj
87
- assert_equal 'Hello… world!', stream.string
88
- end
89
-
90
- def test_invalid_string
91
- s = [128].pack('C').force_encoding('UTF-8')
92
- stream = StringIO.new
93
- cleaning_stream = Nanoc::CLI::CleaningStream.new(stream)
94
- cleaning_stream << s
95
- assert_equal "\xef\xbf\xbd", stream.string
96
- end
97
- end
data/test/cli/test_cli.rb DELETED
@@ -1,195 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'helper'
4
-
5
- class Nanoc::CLITest < Nanoc::TestCase
6
- COMMAND_CODE = <<~EOS
7
- usage '_test [options]'
8
- summary 'meh'
9
- description 'longer meh'
10
-
11
- run do |opts, args, cmd|
12
- File.open('_test.out', 'w') { |io| io.write('It works!') }
13
- end
14
- EOS
15
-
16
- SUBCOMMAND_CODE = <<~EOS
17
- usage '_sub [options]'
18
- summary 'meh sub'
19
- description 'longer meh sub'
20
-
21
- run do |opts, args, cmd|
22
- File.open('_test_sub.out', 'w') { |io| io.write('It works sub!') }
23
- end
24
- EOS
25
-
26
- def test_load_custom_commands
27
- Nanoc::CLI.run %w[create_site foo]
28
-
29
- FileUtils.cd('foo') do
30
- # Create command
31
- FileUtils.mkdir_p('commands')
32
- File.open('commands/_test.rb', 'w') { |io| io.write(COMMAND_CODE) }
33
-
34
- # Run command
35
- begin
36
- Nanoc::CLI.run %w[_test]
37
- rescue SystemExit
38
- assert false, 'Running _test should not cause system exit'
39
- end
40
-
41
- # Check
42
- assert File.file?('_test.out')
43
- assert_equal 'It works!', File.read('_test.out')
44
- end
45
- end
46
-
47
- def test_load_custom_commands_nested
48
- Nanoc::CLI.run %w[create_site foo]
49
- FileUtils.cd('foo') do
50
- # Create command
51
- FileUtils.mkdir_p('commands')
52
- File.open('commands/_test.rb', 'w') do |io|
53
- io.write(COMMAND_CODE)
54
- end
55
-
56
- # Create subcommand
57
- FileUtils.mkdir_p('commands/_test')
58
- File.open('commands/_test/_sub.rb', 'w') do |io|
59
- io.write(SUBCOMMAND_CODE)
60
- end
61
-
62
- # Run command
63
- begin
64
- Nanoc::CLI.run %w[_test _sub]
65
- rescue SystemExit
66
- assert false, 'Running _test sub should not cause system exit'
67
- end
68
-
69
- # Check
70
- assert File.file?('_test_sub.out')
71
- assert_equal 'It works sub!', File.read('_test_sub.out')
72
- end
73
- end
74
-
75
- def test_load_custom_commands_non_default_commands_dirs
76
- Nanoc::CLI.run %w[create_site foo]
77
- FileUtils.cd('foo') do
78
- File.open('nanoc.yaml', 'w') { |io| io.write('commands_dirs: [commands, commands_alt]') }
79
-
80
- # Create command
81
- FileUtils.mkdir_p('commands_alt')
82
- File.open('commands_alt/_test.rb', 'w') do |io|
83
- io.write(COMMAND_CODE)
84
- end
85
-
86
- # Create subcommand
87
- FileUtils.mkdir_p('commands_alt/_test')
88
- File.open('commands_alt/_test/_sub.rb', 'w') do |io|
89
- io.write(SUBCOMMAND_CODE)
90
- end
91
-
92
- # Run command
93
- begin
94
- Nanoc::CLI.run %w[_test _sub]
95
- rescue SystemExit
96
- assert false, 'Running _test sub should not cause system exit'
97
- end
98
-
99
- # Check
100
- assert File.file?('_test_sub.out')
101
- assert_equal 'It works sub!', File.read('_test_sub.out')
102
- end
103
- end
104
-
105
- def test_load_custom_commands_broken
106
- Nanoc::CLI.run %w[create_site foo]
107
-
108
- FileUtils.cd('foo') do
109
- # Create command
110
- FileUtils.mkdir_p('commands')
111
- File.open('commands/_test.rb', 'w') { |io| io.write('raise "meh"') }
112
-
113
- # Run command
114
- position_before = $stderr.tell
115
- Nanoc::CLI::ErrorHandler.disable
116
- assert_raises RuntimeError do
117
- Nanoc::CLI.run %w[_test]
118
- end
119
- Nanoc::CLI::ErrorHandler.enable
120
- assert_raises SystemExit do
121
- Nanoc::CLI.run %w[_test]
122
- end
123
- position_after = $stderr.tell
124
-
125
- # Check error output
126
- stderr_addition = $stderr.string[position_before, position_after]
127
- assert_match(/commands\/_test.rb/, stderr_addition)
128
- end
129
- end
130
-
131
- def test_load_command_at_with_non_utf8_encoding
132
- Encoding.default_external = Encoding::US_ASCII
133
- Nanoc::CLI.load_command_at(root_dir + '/lib/nanoc/cli/commands/create-site.rb')
134
- ensure
135
- Encoding.default_external = Encoding::UTF_8
136
- end
137
-
138
- def test_after_setup
139
- $after_setup_success = false
140
- Nanoc::CLI.after_setup do
141
- $after_setup_success = true
142
- end
143
- Nanoc::CLI.setup
144
- assert $after_setup_success
145
- end
146
-
147
- def test_enable_utf8_only_on_tty
148
- new_env_diff = {
149
- 'LC_ALL' => 'en_US.ISO-8859-1',
150
- 'LC_CTYPE' => 'en_US.ISO-8859-1',
151
- 'LANG' => 'en_US.ISO-8859-1',
152
- }
153
- with_env_vars(new_env_diff) do
154
- io = StringIO.new
155
- def io.tty?
156
- true
157
- end
158
- refute Nanoc::CLI.enable_utf8?(io)
159
-
160
- io = StringIO.new
161
- def io.tty?
162
- false
163
- end
164
- assert Nanoc::CLI.enable_utf8?(io)
165
- end
166
- end
167
-
168
- def test_enable_utf8
169
- io = StringIO.new
170
- def io.tty?
171
- true
172
- end
173
-
174
- new_env_diff = {
175
- 'LC_ALL' => 'en_US.ISO-8859-1',
176
- 'LC_CTYPE' => 'en_US.ISO-8859-1',
177
- 'LANG' => 'en_US.ISO-8859-1',
178
- }
179
- with_env_vars(new_env_diff) do
180
- refute Nanoc::CLI.enable_utf8?(io)
181
-
182
- with_env_vars('LC_ALL' => 'en_US.UTF-8') { assert Nanoc::CLI.enable_utf8?(io) }
183
- with_env_vars('LC_CTYPE' => 'en_US.UTF-8') { assert Nanoc::CLI.enable_utf8?(io) }
184
- with_env_vars('LANG' => 'en_US.UTF-8') { assert Nanoc::CLI.enable_utf8?(io) }
185
-
186
- with_env_vars('LC_ALL' => 'en_US.utf-8') { assert Nanoc::CLI.enable_utf8?(io) }
187
- with_env_vars('LC_CTYPE' => 'en_US.utf-8') { assert Nanoc::CLI.enable_utf8?(io) }
188
- with_env_vars('LANG' => 'en_US.utf-8') { assert Nanoc::CLI.enable_utf8?(io) }
189
-
190
- with_env_vars('LC_ALL' => 'en_US.utf8') { assert Nanoc::CLI.enable_utf8?(io) }
191
- with_env_vars('LC_CTYPE' => 'en_US.utf8') { assert Nanoc::CLI.enable_utf8?(io) }
192
- with_env_vars('LANG' => 'en_US.utf8') { assert Nanoc::CLI.enable_utf8?(io) }
193
- end
194
- end
195
- end