nanoc3 3.1.9 → 3.2.0a1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (136) hide show
  1. data/LICENSE +1 -1
  2. data/NEWS.md +0 -50
  3. data/README.md +3 -15
  4. data/bin/nanoc3 +2 -0
  5. data/lib/nanoc3/base/checksummer.rb +40 -0
  6. data/lib/nanoc3/base/code_snippet.rb +30 -12
  7. data/lib/nanoc3/base/compiled_content_cache.rb +86 -0
  8. data/lib/nanoc3/base/compiler.rb +134 -95
  9. data/lib/nanoc3/base/compiler_dsl.rb +12 -11
  10. data/lib/nanoc3/base/core_ext/string.rb +2 -2
  11. data/lib/nanoc3/base/data_source.rb +17 -16
  12. data/lib/nanoc3/base/dependency_tracker.rb +102 -121
  13. data/lib/nanoc3/base/directed_graph.rb +65 -3
  14. data/lib/nanoc3/base/errors.rb +20 -16
  15. data/lib/nanoc3/base/item.rb +58 -50
  16. data/lib/nanoc3/base/item_rep.rb +177 -150
  17. data/lib/nanoc3/base/layout.rb +51 -18
  18. data/lib/nanoc3/base/notification_center.rb +8 -8
  19. data/lib/nanoc3/base/plugin_registry.rb +9 -9
  20. data/lib/nanoc3/base/rule.rb +18 -9
  21. data/lib/nanoc3/base/rule_context.rb +5 -5
  22. data/lib/nanoc3/base/site.rb +135 -47
  23. data/lib/nanoc3/base.rb +21 -19
  24. data/lib/nanoc3/cli/base.rb +51 -74
  25. data/lib/nanoc3/cli/commands/autocompile.rb +3 -0
  26. data/lib/nanoc3/cli/commands/compile.rb +35 -74
  27. data/lib/nanoc3/cli/commands/create_site.rb +17 -5
  28. data/lib/nanoc3/cli/commands/debug.rb +11 -4
  29. data/lib/nanoc3/cli/commands/view.rb +0 -1
  30. data/lib/nanoc3/cli/commands/watch.rb +148 -0
  31. data/lib/nanoc3/cli/commands.rb +1 -0
  32. data/lib/nanoc3/cli/logger.rb +15 -21
  33. data/lib/nanoc3/data_sources/deprecated/twitter.rb +0 -1
  34. data/lib/nanoc3/data_sources/filesystem.rb +11 -40
  35. data/lib/nanoc3/data_sources/filesystem_unified.rb +22 -22
  36. data/lib/nanoc3/extra/auto_compiler.rb +1 -1
  37. data/lib/nanoc3/extra/chick.rb +8 -8
  38. data/lib/nanoc3/extra/deployers/rsync.rb +2 -3
  39. data/lib/nanoc3/extra/validators/links.rb +32 -51
  40. data/lib/nanoc3/extra/validators/w3c.rb +2 -2
  41. data/lib/nanoc3/extra/vcs.rb +1 -1
  42. data/lib/nanoc3/filters/colorize_syntax.rb +15 -19
  43. data/lib/nanoc3/filters/erb.rb +1 -5
  44. data/lib/nanoc3/filters/erubis.rb +1 -5
  45. data/lib/nanoc3/filters/haml.rb +1 -2
  46. data/lib/nanoc3/filters/less.rb +2 -51
  47. data/lib/nanoc3/filters/mustache.rb +21 -0
  48. data/lib/nanoc3/filters/rdiscount.rb +1 -2
  49. data/lib/nanoc3/filters/relativize_paths.rb +3 -2
  50. data/lib/nanoc3/filters/sass.rb +50 -56
  51. data/lib/nanoc3/filters.rb +2 -0
  52. data/lib/nanoc3/helpers/blogging.rb +22 -29
  53. data/lib/nanoc3/helpers/breadcrumbs.rb +1 -1
  54. data/lib/nanoc3/helpers/capturing.rb +1 -1
  55. data/lib/nanoc3/helpers/filtering.rb +1 -1
  56. data/lib/nanoc3/helpers/link_to.rb +10 -21
  57. data/lib/nanoc3/helpers/rendering.rb +5 -24
  58. data/lib/nanoc3/helpers/tagging.rb +6 -6
  59. data/lib/nanoc3/helpers/text.rb +2 -2
  60. data/lib/nanoc3.rb +1 -1
  61. metadata +35 -93
  62. data/.gemtest +0 -0
  63. data/doc/yardoc_templates/default/layout/html/footer.erb +0 -10
  64. data/nanoc3.gemspec +0 -41
  65. data/tasks/clean.rake +0 -11
  66. data/tasks/doc.rake +0 -14
  67. data/tasks/gem.rake +0 -13
  68. data/tasks/test.rake +0 -38
  69. data/test/base/core_ext/array_spec.rb +0 -23
  70. data/test/base/core_ext/hash_spec.rb +0 -41
  71. data/test/base/core_ext/string_spec.rb +0 -27
  72. data/test/base/test_code_snippet.rb +0 -33
  73. data/test/base/test_compiler.rb +0 -410
  74. data/test/base/test_compiler_dsl.rb +0 -121
  75. data/test/base/test_context.rb +0 -33
  76. data/test/base/test_data_source.rb +0 -48
  77. data/test/base/test_dependency_tracker.rb +0 -510
  78. data/test/base/test_directed_graph.rb +0 -91
  79. data/test/base/test_filter.rb +0 -85
  80. data/test/base/test_item.rb +0 -141
  81. data/test/base/test_item_rep.rb +0 -953
  82. data/test/base/test_layout.rb +0 -44
  83. data/test/base/test_notification_center.rb +0 -36
  84. data/test/base/test_plugin.rb +0 -32
  85. data/test/base/test_rule.rb +0 -21
  86. data/test/base/test_rule_context.rb +0 -63
  87. data/test/base/test_site.rb +0 -366
  88. data/test/cli/commands/test_compile.rb +0 -12
  89. data/test/cli/commands/test_create_item.rb +0 -12
  90. data/test/cli/commands/test_create_layout.rb +0 -28
  91. data/test/cli/commands/test_create_site.rb +0 -24
  92. data/test/cli/commands/test_help.rb +0 -12
  93. data/test/cli/commands/test_info.rb +0 -12
  94. data/test/cli/commands/test_update.rb +0 -12
  95. data/test/cli/test_logger.rb +0 -12
  96. data/test/data_sources/test_filesystem.rb +0 -420
  97. data/test/data_sources/test_filesystem_unified.rb +0 -538
  98. data/test/data_sources/test_filesystem_verbose.rb +0 -359
  99. data/test/extra/core_ext/test_enumerable.rb +0 -32
  100. data/test/extra/core_ext/test_time.rb +0 -17
  101. data/test/extra/deployers/test_rsync.rb +0 -234
  102. data/test/extra/test_auto_compiler.rb +0 -482
  103. data/test/extra/test_file_proxy.rb +0 -21
  104. data/test/extra/test_vcs.rb +0 -24
  105. data/test/extra/validators/test_links.rb +0 -53
  106. data/test/extra/validators/test_w3c.rb +0 -49
  107. data/test/filters/test_bluecloth.rb +0 -20
  108. data/test/filters/test_coderay.rb +0 -46
  109. data/test/filters/test_colorize_syntax.rb +0 -84
  110. data/test/filters/test_erb.rb +0 -72
  111. data/test/filters/test_erubis.rb +0 -72
  112. data/test/filters/test_haml.rb +0 -98
  113. data/test/filters/test_kramdown.rb +0 -20
  114. data/test/filters/test_less.rb +0 -118
  115. data/test/filters/test_markaby.rb +0 -26
  116. data/test/filters/test_maruku.rb +0 -20
  117. data/test/filters/test_rainpress.rb +0 -31
  118. data/test/filters/test_rdiscount.rb +0 -33
  119. data/test/filters/test_rdoc.rb +0 -18
  120. data/test/filters/test_redcloth.rb +0 -20
  121. data/test/filters/test_relativize_paths.rb +0 -231
  122. data/test/filters/test_rubypants.rb +0 -20
  123. data/test/filters/test_sass.rb +0 -235
  124. data/test/gem_loader.rb +0 -11
  125. data/test/helper.rb +0 -99
  126. data/test/helpers/test_blogging.rb +0 -808
  127. data/test/helpers/test_breadcrumbs.rb +0 -83
  128. data/test/helpers/test_capturing.rb +0 -42
  129. data/test/helpers/test_filtering.rb +0 -108
  130. data/test/helpers/test_html_escape.rb +0 -18
  131. data/test/helpers/test_link_to.rb +0 -251
  132. data/test/helpers/test_rendering.rb +0 -109
  133. data/test/helpers/test_tagging.rb +0 -89
  134. data/test/helpers/test_text.rb +0 -26
  135. data/test/helpers/test_xml_sitemap.rb +0 -69
  136. data/test/tasks/test_clean.rb +0 -71
@@ -1,141 +0,0 @@
1
- # encoding: utf-8
2
-
3
- require 'test/helper'
4
-
5
- class Nanoc3::ItemTest < MiniTest::Unit::TestCase
6
-
7
- include Nanoc3::TestHelpers
8
-
9
- def test_initialize_with_attributes_with_string_keys
10
- item = Nanoc3::Item.new("foo", { 'abc' => 'xyz' }, '/foo/')
11
-
12
- assert_equal nil, item.attributes['abc']
13
- assert_equal 'xyz', item.attributes[:abc]
14
- end
15
-
16
- def test_initialize_with_unclean_identifier
17
- item = Nanoc3::Item.new("foo", {}, '/foo')
18
-
19
- assert_equal '/foo/', item.identifier
20
- end
21
-
22
- def test_frozen_identifier
23
- item = Nanoc3::Item.new("foo", {}, '/foo')
24
-
25
- error = assert_raises(RuntimeError) do
26
- item.identifier.chop!
27
- end
28
- assert_equal "can't modify frozen string", error.message
29
- end
30
-
31
- def test_lookup
32
- # Create item
33
- item = Nanoc3::Item.new(
34
- "content",
35
- { :one => 'one in item' },
36
- '/path/'
37
- )
38
-
39
- # Test finding one
40
- assert_equal('one in item', item[:one])
41
-
42
- # Test finding two
43
- assert_equal(nil, item[:two])
44
- end
45
-
46
- def test_set_attribute
47
- item = Nanoc3::Item.new("foo", {}, '/foo')
48
- assert_equal nil, item[:motto]
49
-
50
- item[:motto] = 'More human than human'
51
- assert_equal 'More human than human', item[:motto]
52
- end
53
-
54
- def test_compiled_content_with_default_rep_and_default_snapshot
55
- # Mock rep
56
- rep = Object.new
57
- def rep.name ; :default ; end
58
- def rep.compiled_content(params)
59
- "content at #{params[:snapshot].inspect}"
60
- end
61
-
62
- # Mock item
63
- item = Nanoc3::Item.new("foo", {}, '/foo')
64
- item.expects(:reps).returns([ rep ])
65
-
66
- # Check
67
- assert_equal 'content at nil', item.compiled_content
68
- end
69
-
70
- def test_compiled_content_with_custom_rep_and_default_snapshot
71
- # Mock reps
72
- rep = Object.new
73
- def rep.name ; :foo ; end
74
- def rep.compiled_content(params)
75
- "content at #{params[:snapshot].inspect}"
76
- end
77
-
78
- # Mock item
79
- item = Nanoc3::Item.new("foo", {}, '/foo')
80
- item.expects(:reps).returns([ rep ])
81
-
82
- # Check
83
- assert_equal 'content at nil', item.compiled_content(:rep => :foo)
84
- end
85
-
86
- def test_compiled_content_with_default_rep_and_custom_snapshot
87
- # Mock reps
88
- rep = Object.new
89
- def rep.name ; :default ; end
90
- def rep.compiled_content(params)
91
- "content at #{params[:snapshot].inspect}"
92
- end
93
-
94
- # Mock item
95
- item = Nanoc3::Item.new("foo", {}, '/foo')
96
- item.expects(:reps).returns([ rep ])
97
-
98
- # Check
99
- assert_equal 'content at :blah', item.compiled_content(:snapshot => :blah)
100
- end
101
-
102
- def test_compiled_content_with_custom_nonexistant_rep
103
- # Mock item
104
- item = Nanoc3::Item.new("foo", {}, '/foo')
105
- item.expects(:reps).returns([])
106
-
107
- # Check
108
- assert_raises(Nanoc3::Errors::Generic) do
109
- item.compiled_content(:rep => :lkasdhflahgwfe)
110
- end
111
- end
112
-
113
- def test_path_with_default_rep
114
- # Mock reps
115
- rep = mock
116
- rep.expects(:name).returns(:default)
117
- rep.expects(:path).returns('the correct path')
118
-
119
- # Mock item
120
- item = Nanoc3::Item.new("foo", {}, '/foo')
121
- item.expects(:reps).returns([ rep ])
122
-
123
- # Check
124
- assert_equal 'the correct path', item.path
125
- end
126
-
127
- def test_path_with_custom_rep
128
- # Mock reps
129
- rep = mock
130
- rep.expects(:name).returns(:moo)
131
- rep.expects(:path).returns('the correct path')
132
-
133
- # Mock item
134
- item = Nanoc3::Item.new("foo", {}, '/foo')
135
- item.expects(:reps).returns([ rep ])
136
-
137
- # Check
138
- assert_equal 'the correct path', item.path(:rep => :moo)
139
- end
140
-
141
- end