nanoc 4.0.0b3 → 4.0.0b4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (86) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +1 -0
  3. data/Gemfile.lock +4 -2
  4. data/NEWS.md +10 -0
  5. data/TODO.md +15 -0
  6. data/lib/nanoc/base.rb +4 -27
  7. data/lib/nanoc/base/checksummer.rb +69 -19
  8. data/lib/nanoc/base/compilation/compiler.rb +14 -12
  9. data/lib/nanoc/base/compilation/compiler_dsl.rb +2 -0
  10. data/lib/nanoc/base/compilation/filter.rb +4 -2
  11. data/lib/nanoc/base/compilation/outdatedness_checker.rb +7 -7
  12. data/lib/nanoc/base/compilation/rule.rb +5 -6
  13. data/lib/nanoc/base/compilation/rule_context.rb +16 -34
  14. data/lib/nanoc/base/compilation/rule_memory_calculator.rb +3 -3
  15. data/lib/nanoc/base/compilation/rules_collection.rb +4 -10
  16. data/lib/nanoc/base/context.rb +2 -0
  17. data/lib/nanoc/base/core_ext/array.rb +0 -10
  18. data/lib/nanoc/base/core_ext/hash.rb +0 -10
  19. data/lib/nanoc/base/core_ext/pathname.rb +0 -9
  20. data/lib/nanoc/base/core_ext/string.rb +0 -10
  21. data/lib/nanoc/base/entities.rb +5 -0
  22. data/lib/nanoc/base/entities/content.rb +86 -0
  23. data/lib/nanoc/base/entities/document.rb +56 -0
  24. data/lib/nanoc/base/{source_data → entities}/identifier.rb +12 -1
  25. data/lib/nanoc/base/entities/layout.rb +8 -0
  26. data/lib/nanoc/base/{pattern.rb → entities/pattern.rb} +0 -0
  27. data/lib/nanoc/base/errors.rb +2 -1
  28. data/lib/nanoc/base/result_data/item_rep.rb +13 -278
  29. data/lib/nanoc/base/services.rb +5 -0
  30. data/lib/nanoc/base/services/executor.rb +141 -0
  31. data/lib/nanoc/base/services/item_rep_writer.rb +40 -0
  32. data/lib/nanoc/base/{notification_center.rb → services/notification_center.rb} +0 -0
  33. data/lib/nanoc/base/services/recording_executor.rb +41 -0
  34. data/lib/nanoc/base/{temp_filename_factory.rb → services/temp_filename_factory.rb} +0 -0
  35. data/lib/nanoc/base/source_data/code_snippet.rb +0 -6
  36. data/lib/nanoc/base/source_data/data_source.rb +4 -3
  37. data/lib/nanoc/base/source_data/item.rb +23 -213
  38. data/lib/nanoc/base/source_data/site.rb +0 -1
  39. data/lib/nanoc/base/views.rb +18 -0
  40. data/lib/nanoc/base/views/config.rb +1 -1
  41. data/lib/nanoc/base/views/item.rb +8 -73
  42. data/lib/nanoc/base/views/item_rep.rb +9 -0
  43. data/lib/nanoc/base/views/item_rep_collection.rb +17 -0
  44. data/lib/nanoc/base/views/layout.rb +1 -40
  45. data/lib/nanoc/base/views/mixins/document.rb +76 -0
  46. data/lib/nanoc/base/views/mixins/mutable_document.rb +22 -0
  47. data/lib/nanoc/base/views/mutable_identifiable_collection.rb +1 -1
  48. data/lib/nanoc/base/views/mutable_item.rb +1 -18
  49. data/lib/nanoc/base/views/mutable_item_collection.rb +6 -2
  50. data/lib/nanoc/base/views/mutable_layout.rb +1 -8
  51. data/lib/nanoc/cli/commands/compile.rb +1 -2
  52. data/lib/nanoc/cli/commands/create-site.rb +5 -5
  53. data/lib/nanoc/cli/commands/show-data.rb +11 -1
  54. data/lib/nanoc/data_sources/filesystem.rb +17 -10
  55. data/lib/nanoc/helpers/capturing.rb +1 -2
  56. data/lib/nanoc/helpers/filtering.rb +13 -1
  57. data/lib/nanoc/helpers/rendering.rb +4 -2
  58. data/lib/nanoc/version.rb +1 -1
  59. data/test/base/core_ext/array_spec.rb +0 -7
  60. data/test/base/core_ext/hash_spec.rb +0 -13
  61. data/test/base/core_ext/pathname_spec.rb +0 -33
  62. data/test/base/core_ext/string_spec.rb +0 -10
  63. data/test/base/test_compiler_dsl.rb +3 -3
  64. data/test/base/test_data_source.rb +2 -2
  65. data/test/base/test_item.rb +5 -129
  66. data/test/base/test_item_rep.rb +26 -558
  67. data/test/base/test_layout.rb +2 -26
  68. data/test/base/test_rule.rb +3 -3
  69. data/test/base/test_rule_context.rb +34 -15
  70. data/test/data_sources/test_filesystem.rb +2 -2
  71. data/test/data_sources/test_filesystem_unified.rb +39 -33
  72. data/test/extra/checking/checks/test_html.rb +0 -1
  73. data/test/extra/checking/checks/test_mixed_content.rb +3 -3
  74. data/test/extra/deployers/test_fog.rb +24 -24
  75. data/test/filters/test_less.rb +4 -4
  76. data/test/filters/test_sass.rb +10 -5
  77. data/test/filters/test_xsl.rb +6 -0
  78. data/test/helpers/test_capturing.rb +0 -1
  79. data/test/helpers/test_filtering.rb +5 -19
  80. data/test/helpers/test_tagging.rb +6 -6
  81. metadata +18 -11
  82. data/lib/nanoc/base/compilation/item_rep_proxy.rb +0 -109
  83. data/lib/nanoc/base/compilation/item_rep_recorder_proxy.rb +0 -97
  84. data/lib/nanoc/base/source_data/layout.rb +0 -111
  85. data/test/base/checksummer_spec.rb +0 -256
  86. data/test/base/test_item_rep_recorder_proxy.rb +0 -17
@@ -87,9 +87,11 @@ EOS
87
87
  item = Nanoc::Int::Item.new(SAMPLE_XML_IN,
88
88
  {},
89
89
  '/content/')
90
+ item = Nanoc::ItemView.new(item)
90
91
  layout = Nanoc::Int::Layout.new(SAMPLE_XSL,
91
92
  {},
92
93
  '/layout/')
94
+ layout = Nanoc::LayoutView.new(layout)
93
95
 
94
96
  # Create an instance of the filter
95
97
  assigns = {
@@ -111,9 +113,11 @@ EOS
111
113
  item = Nanoc::Int::Item.new(SAMPLE_XML_IN_WITH_PARAMS,
112
114
  {},
113
115
  '/content/')
116
+ item = Nanoc::ItemView.new(item)
114
117
  layout = Nanoc::Int::Layout.new(SAMPLE_XSL_WITH_PARAMS,
115
118
  {},
116
119
  '/layout/')
120
+ layout = Nanoc::LayoutView.new(layout)
117
121
 
118
122
  # Create an instance of the filter
119
123
  assigns = {
@@ -136,9 +140,11 @@ EOS
136
140
  item = Nanoc::Int::Item.new(SAMPLE_XML_IN_WITH_OMIT_XML_DECL,
137
141
  {},
138
142
  '/content/')
143
+ item = Nanoc::ItemView.new(item)
139
144
  layout = Nanoc::Int::Layout.new(SAMPLE_XSL_WITH_OMIT_XML_DECL,
140
145
  {},
141
146
  '/layout/')
147
+ layout = Nanoc::LayoutView.new(layout)
142
148
 
143
149
  # Create an instance of the filter
144
150
  assigns = {
@@ -17,7 +17,6 @@ class Nanoc::Helpers::CapturingTest < Nanoc::TestCase
17
17
  # Build site
18
18
  site = Nanoc::Int::Site.new({})
19
19
  item = Nanoc::Int::Item.new('moo', {}, '/blah/')
20
- item.site = site
21
20
  @site = Nanoc::SiteView.new(Nanoc::Int::Site.new({}))
22
21
  @item = Nanoc::ItemView.new(item)
23
22
 
@@ -11,7 +11,6 @@ class Nanoc::Helpers::FilteringTest < Nanoc::TestCase
11
11
 
12
12
  # Mock item and rep
13
13
  @item_rep = mock
14
- @item_rep.expects(:assigns).returns({})
15
14
  @item_rep = Nanoc::ItemRepView.new(@item_rep)
16
15
 
17
16
  # Evaluate content
@@ -25,29 +24,19 @@ class Nanoc::Helpers::FilteringTest < Nanoc::TestCase
25
24
 
26
25
  def test_filter_with_assigns
27
26
  if_have 'rubypants' do
28
- # Build content to be evaluated
29
27
  content = "<p>Foo...</p>\n" \
30
28
  "<% filter :erb do %>\n" \
31
29
  " <p><%%= @item[:title] %></p>\n" \
32
30
  "<% end %>\n"
33
31
 
34
- # Mock item and rep
35
- @item = mock
36
- @item.expects(:[]).with(:title).returns('Bar...')
37
- @item.expects(:identifier).returns('/blah/')
38
- @item = Nanoc::ItemView.new(@item)
39
- @item_rep = mock
40
- @item_rep.expects(:name).returns('default')
41
- @item_rep.expects(:assigns).returns({
42
- item: @item,
43
- item_rep: @item_rep
44
- })
45
- @item_rep = Nanoc::ItemRepView.new(@item_rep)
32
+ item = Nanoc::Int::Item.new('stuff', { title: 'Bar...' }, '/foo.md')
33
+ item_rep = Nanoc::Int::ItemRep.new(item, :default)
34
+
35
+ @item = Nanoc::ItemView.new(item)
36
+ @item_rep = Nanoc::ItemRepView.new(item_rep)
46
37
 
47
- # Evaluate content
48
38
  result = ::ERB.new(content).result(binding)
49
39
 
50
- # Check
51
40
  assert_match('<p>Foo...</p>', result)
52
41
  assert_match('<p>Bar...</p>', result)
53
42
  end
@@ -75,7 +64,6 @@ class Nanoc::Helpers::FilteringTest < Nanoc::TestCase
75
64
 
76
65
  # Mock item and rep
77
66
  @item_rep = mock
78
- @item_rep.expects(:assigns).returns({})
79
67
  @item_rep = Nanoc::ItemRepView.new(@item_rep)
80
68
 
81
69
  # Evaluate content
@@ -94,7 +82,6 @@ class Nanoc::Helpers::FilteringTest < Nanoc::TestCase
94
82
 
95
83
  # Mock item and rep
96
84
  @item_rep = mock
97
- @item_rep.expects(:assigns).returns({})
98
85
  @item_rep = Nanoc::ItemRepView.new(@item_rep)
99
86
 
100
87
  # Evaluate content
@@ -115,7 +102,6 @@ class Nanoc::Helpers::FilteringTest < Nanoc::TestCase
115
102
 
116
103
  # Mock item and rep
117
104
  @item_rep = mock
118
- @item_rep.expects(:assigns).returns({})
119
105
  @item_rep = Nanoc::ItemRepView.new(@item_rep)
120
106
 
121
107
  ::ERB.new(content).result(binding)
@@ -3,7 +3,7 @@ class Nanoc::Helpers::TaggingTest < Nanoc::TestCase
3
3
 
4
4
  def test_tags_for_without_tags
5
5
  # Create item
6
- item = Nanoc::Int::Item.new('content', {}, '/path/')
6
+ item = Nanoc::ItemView.new(Nanoc::Int::Item.new('content', {}, '/path/'))
7
7
 
8
8
  # Check
9
9
  assert_equal(
@@ -14,7 +14,7 @@ class Nanoc::Helpers::TaggingTest < Nanoc::TestCase
14
14
 
15
15
  def test_tags_for_with_custom_base_url
16
16
  # Create item
17
- item = Nanoc::Int::Item.new('content', { tags: %w(foo bar) }, '/path/')
17
+ item = Nanoc::ItemView.new(Nanoc::Int::Item.new('content', { tags: %w(foo bar) }, '/path/'))
18
18
 
19
19
  # Check
20
20
  assert_equal(
@@ -26,7 +26,7 @@ class Nanoc::Helpers::TaggingTest < Nanoc::TestCase
26
26
 
27
27
  def test_tags_for_with_custom_none_text
28
28
  # Create item
29
- item = Nanoc::Int::Item.new('content', { tags: [] }, '/path/')
29
+ item = Nanoc::ItemView.new(Nanoc::Int::Item.new('content', { tags: [] }, '/path/'))
30
30
 
31
31
  # Check
32
32
  assert_equal(
@@ -37,7 +37,7 @@ class Nanoc::Helpers::TaggingTest < Nanoc::TestCase
37
37
 
38
38
  def test_tags_for_with_custom_separator
39
39
  # Create item
40
- item = Nanoc::Int::Item.new('content', { tags: %w(foo bar) }, '/path/')
40
+ item = Nanoc::ItemView.new(Nanoc::Int::Item.new('content', { tags: %w(foo bar) }, '/path/'))
41
41
 
42
42
  # Check
43
43
  assert_equal(
@@ -49,11 +49,11 @@ class Nanoc::Helpers::TaggingTest < Nanoc::TestCase
49
49
 
50
50
  def test_items_with_tag
51
51
  # Create items
52
- @items = [
52
+ @items = Nanoc::ItemCollectionView.new([
53
53
  Nanoc::Int::Item.new('item 1', { tags: [:foo] }, '/item1/'),
54
54
  Nanoc::Int::Item.new('item 2', { tags: [:bar] }, '/item2/'),
55
55
  Nanoc::Int::Item.new('item 3', { tags: [:foo, :bar] }, '/item3/')
56
- ]
56
+ ])
57
57
 
58
58
  # Find items
59
59
  items_with_foo_tag = items_with_tag(:foo)
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.0b3
4
+ version: 4.0.0b4
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-31 00:00:00.000000000 Z
11
+ date: 2015-06-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cri
@@ -66,6 +66,7 @@ files:
66
66
  - NEWS.md
67
67
  - README.md
68
68
  - Rakefile
69
+ - TODO.md
69
70
  - bin/nanoc
70
71
  - doc/yardoc_handlers/identifier.rb
71
72
  - doc/yardoc_templates/default/layout/html/footer.erb
@@ -78,8 +79,6 @@ files:
78
79
  - lib/nanoc/base/compilation/compiler_dsl.rb
79
80
  - lib/nanoc/base/compilation/dependency_tracker.rb
80
81
  - lib/nanoc/base/compilation/filter.rb
81
- - lib/nanoc/base/compilation/item_rep_proxy.rb
82
- - lib/nanoc/base/compilation/item_rep_recorder_proxy.rb
83
82
  - lib/nanoc/base/compilation/outdatedness_checker.rb
84
83
  - lib/nanoc/base/compilation/outdatedness_reasons.rb
85
84
  - lib/nanoc/base/compilation/rule.rb
@@ -94,23 +93,31 @@ files:
94
93
  - lib/nanoc/base/core_ext/pathname.rb
95
94
  - lib/nanoc/base/core_ext/string.rb
96
95
  - lib/nanoc/base/directed_graph.rb
96
+ - lib/nanoc/base/entities.rb
97
+ - lib/nanoc/base/entities/content.rb
98
+ - lib/nanoc/base/entities/document.rb
99
+ - lib/nanoc/base/entities/identifier.rb
100
+ - lib/nanoc/base/entities/layout.rb
101
+ - lib/nanoc/base/entities/pattern.rb
97
102
  - lib/nanoc/base/error.rb
98
103
  - lib/nanoc/base/errors.rb
99
104
  - lib/nanoc/base/identifiable_collection.rb
100
105
  - lib/nanoc/base/memoization.rb
101
- - lib/nanoc/base/notification_center.rb
102
- - lib/nanoc/base/pattern.rb
103
106
  - lib/nanoc/base/plugin_registry.rb
104
107
  - lib/nanoc/base/result_data/item_rep.rb
108
+ - lib/nanoc/base/services.rb
109
+ - lib/nanoc/base/services/executor.rb
110
+ - lib/nanoc/base/services/item_rep_writer.rb
111
+ - lib/nanoc/base/services/notification_center.rb
112
+ - lib/nanoc/base/services/recording_executor.rb
113
+ - lib/nanoc/base/services/temp_filename_factory.rb
105
114
  - lib/nanoc/base/source_data/code_snippet.rb
106
115
  - lib/nanoc/base/source_data/configuration.rb
107
116
  - lib/nanoc/base/source_data/data_source.rb
108
- - lib/nanoc/base/source_data/identifier.rb
109
117
  - lib/nanoc/base/source_data/item.rb
110
- - lib/nanoc/base/source_data/layout.rb
111
118
  - lib/nanoc/base/source_data/site.rb
112
119
  - lib/nanoc/base/store.rb
113
- - lib/nanoc/base/temp_filename_factory.rb
120
+ - lib/nanoc/base/views.rb
114
121
  - lib/nanoc/base/views/config.rb
115
122
  - lib/nanoc/base/views/identifiable_collection.rb
116
123
  - lib/nanoc/base/views/item.rb
@@ -119,6 +126,8 @@ files:
119
126
  - lib/nanoc/base/views/item_rep_collection.rb
120
127
  - lib/nanoc/base/views/layout.rb
121
128
  - lib/nanoc/base/views/layout_collection.rb
129
+ - lib/nanoc/base/views/mixins/document.rb
130
+ - lib/nanoc/base/views/mixins/mutable_document.rb
122
131
  - lib/nanoc/base/views/mutable_config.rb
123
132
  - lib/nanoc/base/views/mutable_identifiable_collection.rb
124
133
  - lib/nanoc/base/views/mutable_item.rb
@@ -220,7 +229,6 @@ files:
220
229
  - tasks/doc.rake
221
230
  - tasks/rubocop.rake
222
231
  - tasks/test.rake
223
- - test/base/checksummer_spec.rb
224
232
  - test/base/core_ext/array_spec.rb
225
233
  - test/base/core_ext/hash_spec.rb
226
234
  - test/base/core_ext/pathname_spec.rb
@@ -238,7 +246,6 @@ files:
238
246
  - test/base/test_item.rb
239
247
  - test/base/test_item_array.rb
240
248
  - test/base/test_item_rep.rb
241
- - test/base/test_item_rep_recorder_proxy.rb
242
249
  - test/base/test_layout.rb
243
250
  - test/base/test_memoization.rb
244
251
  - test/base/test_notification_center.rb
@@ -1,109 +0,0 @@
1
- module Nanoc::Int
2
- # Represents an item representation, but provides an interface that is
3
- # easier to use when writing compilation and routing rules. It is also
4
- # responsible for fetching the necessary information from the compiler, such
5
- # as assigns.
6
- #
7
- # The API provided by item representation proxies allows layout identifiers
8
- # to be given as literals instead of as references to {Nanoc::Int::Layout}.
9
- #
10
- # @api private
11
- class ItemRepProxy
12
- extend Forwardable
13
-
14
- def_delegators :@item_rep, :item, :name, :binary, :binary?, :compiled_content, :has_snapshot?, :raw_path, :path
15
- def_delegator :@item_rep, :snapshot
16
-
17
- # @param [Nanoc::Int::ItemRep] item_rep The item representation that this
18
- # proxy should behave like
19
- #
20
- # @param [Nanoc::Int::Compiler] compiler The compiler that will provide the
21
- # necessary compilation-related functionality.
22
- def initialize(item_rep, compiler)
23
- @item_rep = item_rep
24
- @compiler = compiler
25
- end
26
-
27
- # Runs the item content through the given filter with the given arguments.
28
- # This method will replace the content of the `:last` snapshot with the
29
- # filtered content of the last snapshot.
30
- #
31
- # This method is supposed to be called only in a compilation rule block
32
- # (see {Nanoc::Int::CompilerDSL#compile}).
33
- #
34
- # @see Nanoc::Int::ItemRep#filter
35
- #
36
- # @param [Symbol] name The name of the filter to run the item
37
- # representations' content through
38
- #
39
- # @param [Hash] args The filter arguments that should be passed to the
40
- # filter's #run method
41
- #
42
- # @return [void]
43
- def filter(name, args = {})
44
- set_assigns
45
- @item_rep.filter(name, args)
46
- end
47
-
48
- # Lays out the item using the given layout. This method will replace the
49
- # content of the `:last` snapshot with the laid out content of the last
50
- # snapshot.
51
- #
52
- # This method is supposed to be called only in a compilation rule block
53
- # (see {Nanoc::Int::CompilerDSL#compile}).
54
- #
55
- # @see Nanoc::Int::ItemRep#layout
56
- #
57
- # @param [String] layout_identifier The identifier of the layout to use
58
- #
59
- # @return [void]
60
- def layout(layout_identifier, extra_filter_args = {})
61
- set_assigns
62
-
63
- layout = layout_with_identifier(layout_identifier)
64
- filter_name, filter_args = @compiler.rules_collection.filter_for_layout(layout)
65
- filter_args = filter_args.merge(extra_filter_args)
66
-
67
- @item_rep.layout(layout, filter_name, filter_args)
68
- end
69
-
70
- # Returns true because this item is already a proxy, and therefore doesn’t
71
- # need to be wrapped anymore.
72
- #
73
- # @api private
74
- #
75
- # @return [true]
76
- #
77
- # @see Nanoc::Int::ItemRep#proxy?
78
- # @see Nanoc::Int::ItemRepRecorderProxy#proxy?
79
- def proxy?
80
- true
81
- end
82
- alias_method :is_proxy?, :proxy?
83
-
84
- private
85
-
86
- def set_assigns
87
- @item_rep.assigns = @compiler.assigns_for(@item_rep)
88
- end
89
-
90
- def layouts
91
- @compiler.site.layouts
92
- end
93
-
94
- def layout_with_identifier(layout_identifier)
95
- req_id = layout_identifier.__nanoc_cleaned_identifier
96
- layout = layouts.find { |l| l.identifier == req_id }
97
- if layout.nil? && use_globs?
98
- pat = Nanoc::Int::Pattern.from(layout_identifier)
99
- layout = layouts.find { |l| pat.match?(l.identifier) }
100
- end
101
- raise Nanoc::Int::Errors::UnknownLayout.new(layout_identifier) if layout.nil?
102
- layout
103
- end
104
-
105
- def use_globs?
106
- @compiler.site.config[:string_pattern_type] == 'glob'
107
- end
108
- end
109
- end
@@ -1,97 +0,0 @@
1
- module Nanoc::Int
2
- # Represents a fake iem representation that does not actually perform any
3
- # actual filtering, layouting or snapshotting, but instead keeps track of
4
- # what would happen if a real item representation would have been used
5
- # instead. It therefore “records” the actions that happens upon it.
6
- #
7
- # The list of recorded actions is used during compilation to determine
8
- # whether an item representation needs to be recompiled: if the list of
9
- # actions is different from the list of actions from the previous
10
- # compilation run, the item needs to be recompiled; if it is the same, it
11
- # may not need to be recompiled.
12
- #
13
- # @api private
14
- class ItemRepRecorderProxy
15
- extend Forwardable
16
-
17
- def_delegators :@item_rep, :item, :name, :binary, :binary?, :compiled_content, :has_snapshot?, :raw_path, :path, :assigns, :assigns=
18
-
19
- # @example The compilation rule and the corresponding rule memory
20
- #
21
- # # rule
22
- # compile '/foo/' do
23
- # filter :erb
24
- # filter :myfilter, :arg1 => 'stuff'
25
- # layout 'meh'
26
- # end
27
- #
28
- # # memory
29
- # [
30
- # [ :filter, :erb, {} ],
31
- # [ :filter, :myfilter, { :arg1 => 'stuff' } ],
32
- # [ :layout, 'meh' ]
33
- # ]
34
- #
35
- # @return [Array] The list of recorded actions (“rule memory”)
36
- attr_reader :rule_memory
37
-
38
- # @param [Nanoc::Int::ItemRep] item_rep The item representation that this
39
- # proxy should behave like
40
- def initialize(item_rep)
41
- @item_rep = item_rep
42
- @rule_memory = []
43
- end
44
-
45
- # @return [void]
46
- #
47
- # @see Nanoc::Int::ItemRepProxy#filter, Nanoc::Int::ItemRep#filter
48
- def filter(name, args = {})
49
- @rule_memory << [:filter, name, args]
50
- end
51
-
52
- # @return [void]
53
- #
54
- # @see Nanoc::Int::ItemRepProxy#layout, Nanoc::Int::ItemRep#layout
55
- def layout(layout_identifier, extra_filter_args = nil)
56
- if extra_filter_args
57
- @rule_memory << [:layout, layout_identifier, extra_filter_args]
58
- else
59
- @rule_memory << [:layout, layout_identifier]
60
- end
61
- end
62
-
63
- # @return [void]
64
- #
65
- # @see Nanoc::Int::ItemRep#snapshot
66
- def snapshot(snapshot_name, params = {})
67
- @rule_memory << [:snapshot, snapshot_name, params]
68
-
69
- # Count
70
- existing = Set.new
71
- names = @rule_memory.select { |r| r[0] == :snapshot }.map { |r| r[1] }
72
- names.each do |n|
73
- if existing.include?(n)
74
- raise Nanoc::Int::Errors::CannotCreateMultipleSnapshotsWithSameName.new(@item_rep, snapshot_name)
75
- end
76
- existing << n
77
- end
78
- end
79
-
80
- # @return [{}]
81
- def content
82
- {}
83
- end
84
-
85
- # Returns true because this item is already a proxy, and therefore doesn’t
86
- # need to be wrapped anymore.
87
- #
88
- # @return [true]
89
- #
90
- # @see Nanoc::Int::ItemRep#proxy?
91
- # @see Nanoc::Int::ItemRepProxy#proxy?
92
- def proxy?
93
- true
94
- end
95
- alias_method :is_proxy?, :proxy?
96
- end
97
- end