nanoc 4.0.2 → 4.1.0a1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CONTRIBUTING.md +17 -0
- data/Gemfile +50 -46
- data/Gemfile.lock +365 -0
- data/Guardfile +3 -0
- data/NEWS.md +21 -0
- data/README.md +1 -1
- data/lib/nanoc/base.rb +3 -15
- data/lib/nanoc/base/checksummer.rb +3 -14
- data/lib/nanoc/base/compilation/compiler.rb +112 -283
- data/lib/nanoc/base/compilation/compiler_dsl.rb +29 -37
- data/lib/nanoc/base/compilation/dependency_tracker.rb +25 -170
- data/lib/nanoc/base/compilation/filter.rb +3 -4
- data/lib/nanoc/base/compilation/item_rep_repo.rb +33 -0
- data/lib/nanoc/base/compilation/outdatedness_checker.rb +39 -53
- data/lib/nanoc/base/compilation/rule.rb +13 -24
- data/lib/nanoc/base/compilation/rule_context.rb +29 -15
- data/lib/nanoc/base/entities.rb +10 -0
- data/lib/nanoc/base/{source_data → entities}/code_snippet.rb +1 -4
- data/lib/nanoc/base/{source_data → entities}/configuration.rb +1 -1
- data/lib/nanoc/base/entities/content.rb +8 -9
- data/lib/nanoc/base/{identifiable_collection.rb → entities/identifiable_collection.rb} +0 -0
- data/lib/nanoc/base/entities/identifier.rb +11 -2
- data/lib/nanoc/base/{source_data → entities}/item.rb +0 -18
- data/lib/nanoc/base/{result_data → entities}/item_rep.rb +15 -13
- data/lib/nanoc/base/entities/rule_memory.rb +54 -0
- data/lib/nanoc/base/entities/rule_memory_action.rb +19 -0
- data/lib/nanoc/base/entities/rule_memory_actions.rb +3 -0
- data/lib/nanoc/base/entities/rule_memory_actions/filter.rb +22 -0
- data/lib/nanoc/base/entities/rule_memory_actions/layout.rb +22 -0
- data/lib/nanoc/base/entities/rule_memory_actions/snapshot.rb +26 -0
- data/lib/nanoc/base/entities/rules_collection.rb +120 -0
- data/lib/nanoc/base/{source_data → entities}/site.rb +11 -10
- data/lib/nanoc/base/repos.rb +2 -0
- data/lib/nanoc/base/repos/checksum_store.rb +3 -9
- data/lib/nanoc/base/repos/compiled_content_cache.rb +0 -5
- data/lib/nanoc/base/{source_data → repos}/data_source.rb +3 -6
- data/lib/nanoc/base/repos/dependency_store.rb +118 -0
- data/lib/nanoc/base/repos/rule_memory_store.rb +1 -5
- data/lib/nanoc/base/repos/site_loader.rb +0 -28
- data/lib/nanoc/base/repos/store.rb +0 -12
- data/lib/nanoc/base/services.rb +8 -0
- data/lib/nanoc/base/services/compiler_loader.rb +49 -0
- data/lib/nanoc/base/services/executor.rb +4 -4
- data/lib/nanoc/base/services/item_rep_builder.rb +30 -0
- data/lib/nanoc/base/services/item_rep_router.rb +55 -0
- data/lib/nanoc/base/services/item_rep_selector.rb +39 -0
- data/lib/nanoc/base/services/item_rep_writer.rb +2 -0
- data/lib/nanoc/base/services/postprocessor.rb +26 -0
- data/lib/nanoc/base/services/preprocessor.rb +26 -0
- data/lib/nanoc/base/services/recording_executor.rb +36 -22
- data/lib/nanoc/base/services/rule_memory_calculator.rb +84 -0
- data/lib/nanoc/base/services/rules_loader.rb +29 -0
- data/lib/nanoc/base/views.rb +6 -0
- data/lib/nanoc/base/views/config_view.rb +8 -2
- data/lib/nanoc/base/views/identifiable_collection_view.rb +5 -4
- data/lib/nanoc/base/views/item_rep_collection_view.rb +7 -6
- data/lib/nanoc/base/views/item_rep_view.rb +13 -12
- data/lib/nanoc/base/views/item_view.rb +18 -12
- data/lib/nanoc/base/views/layout_view.rb +1 -1
- data/lib/nanoc/base/views/mixins/document_view_mixin.rb +2 -1
- data/lib/nanoc/base/views/mutable_identifiable_collection_view.rb +1 -1
- data/lib/nanoc/base/views/mutable_item_collection_view.rb +4 -7
- data/lib/nanoc/base/views/post_compile_item_collection_view.rb +8 -0
- data/lib/nanoc/base/views/post_compile_item_view.rb +7 -0
- data/lib/nanoc/base/views/site_view.rb +3 -2
- data/lib/nanoc/base/views/view.rb +12 -0
- data/lib/nanoc/base/views/view_context.rb +12 -0
- data/lib/nanoc/cli/commands/compile.rb +13 -15
- data/lib/nanoc/cli/commands/create-site.rb +15 -0
- data/lib/nanoc/cli/commands/prune.rb +1 -1
- data/lib/nanoc/cli/commands/shell.rb +3 -3
- data/lib/nanoc/cli/commands/show-data.rb +5 -5
- data/lib/nanoc/cli/commands/show-rules.rb +2 -1
- data/lib/nanoc/cli/error_handler.rb +28 -30
- data/lib/nanoc/cli/stream_cleaners/ansi_colors.rb +1 -1
- data/lib/nanoc/data_sources/filesystem.rb +1 -1
- data/lib/nanoc/extra/checking/check.rb +8 -7
- data/lib/nanoc/extra/checking/checks/external_links.rb +14 -1
- data/lib/nanoc/extra/checking/runner.rb +1 -1
- data/lib/nanoc/extra/deployer.rb +3 -3
- data/lib/nanoc/extra/piper.rb +5 -5
- data/lib/nanoc/extra/pruner.rb +8 -7
- data/lib/nanoc/filters/relativize_paths.rb +48 -32
- data/lib/nanoc/filters/sass/sass_filesystem_importer.rb +0 -1
- data/lib/nanoc/helpers/blogging.rb +15 -7
- data/lib/nanoc/helpers/capturing.rb +56 -13
- data/lib/nanoc/helpers/link_to.rb +2 -2
- data/lib/nanoc/helpers/tagging.rb +5 -10
- data/lib/nanoc/helpers/text.rb +9 -11
- data/lib/nanoc/version.rb +1 -1
- data/nanoc-4.0.2.gem +0 -0
- data/tags +1175 -0
- data/test/base/test_compiler.rb +48 -98
- data/test/base/test_compiler_dsl.rb +113 -39
- data/test/base/test_dependency_tracker.rb +80 -79
- data/test/base/test_outdatedness_checker.rb +39 -26
- data/test/base/test_site.rb +0 -97
- data/test/cli/commands/test_compile.rb +2 -3
- data/test/extra/checking/checks/test_external_links.rb +25 -0
- data/test/extra/deployers/test_fog.rb +12 -6
- data/test/filters/test_erb.rb +1 -1
- data/test/filters/test_erubis.rb +1 -1
- data/test/filters/test_haml.rb +1 -1
- data/test/filters/test_less.rb +4 -4
- data/test/filters/test_sass.rb +1 -0
- data/test/filters/test_xsl.rb +7 -8
- data/test/helper.rb +0 -2
- data/test/helpers/test_blogging.rb +26 -23
- data/test/helpers/test_capturing.rb +131 -12
- data/test/helpers/test_filtering.rb +6 -6
- data/test/helpers/test_link_to.rb +1 -1
- data/test/helpers/test_rendering.rb +16 -24
- data/test/helpers/test_tagging.rb +13 -10
- data/test/helpers/test_xml_sitemap.rb +25 -21
- metadata +36 -14
- data/lib/nanoc/base/compilation/rule_memory_calculator.rb +0 -35
- data/lib/nanoc/base/compilation/rules_collection.rb +0 -245
- data/test/base/test_rule_context.rb +0 -78
@@ -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::ItemView.new(Nanoc::Int::Item.new('content', {}, '/path/'))
|
6
|
+
item = Nanoc::ItemView.new(Nanoc::Int::Item.new('content', {}, '/path/'), nil)
|
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::ItemView.new(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/'), nil)
|
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::ItemView.new(Nanoc::Int::Item.new('content', { tags: [] }, '/path/'))
|
29
|
+
item = Nanoc::ItemView.new(Nanoc::Int::Item.new('content', { tags: [] }, '/path/'), nil)
|
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::ItemView.new(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/'), nil)
|
41
41
|
|
42
42
|
# Check
|
43
43
|
assert_equal(
|
@@ -49,7 +49,7 @@ class Nanoc::Helpers::TaggingTest < Nanoc::TestCase
|
|
49
49
|
|
50
50
|
def test_tags_for_without_base_url
|
51
51
|
# Create item
|
52
|
-
item = Nanoc::ItemView.new(Nanoc::Int::Item.new('content', { tags: %w(foo bar) }, '/path/'))
|
52
|
+
item = Nanoc::ItemView.new(Nanoc::Int::Item.new('content', { tags: %w(foo bar) }, '/path/'), nil)
|
53
53
|
|
54
54
|
# Check
|
55
55
|
assert_equal('foo, bar', tags_for(item))
|
@@ -57,11 +57,14 @@ class Nanoc::Helpers::TaggingTest < Nanoc::TestCase
|
|
57
57
|
|
58
58
|
def test_items_with_tag
|
59
59
|
# Create items
|
60
|
-
@items = Nanoc::ItemCollectionView.new(
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
60
|
+
@items = Nanoc::ItemCollectionView.new(
|
61
|
+
[
|
62
|
+
Nanoc::Int::Item.new('item 1', { tags: [:foo] }, '/item1/'),
|
63
|
+
Nanoc::Int::Item.new('item 2', { tags: [:bar] }, '/item2/'),
|
64
|
+
Nanoc::Int::Item.new('item 3', { tags: [:foo, :bar] }, '/item3/'),
|
65
|
+
],
|
66
|
+
nil,
|
67
|
+
)
|
65
68
|
|
66
69
|
# Find items
|
67
70
|
items_with_foo_tag = items_with_tag(:foo)
|
@@ -1,12 +1,16 @@
|
|
1
1
|
class Nanoc::Helpers::XMLSitemapTest < Nanoc::TestCase
|
2
2
|
include Nanoc::Helpers::XMLSitemap
|
3
3
|
|
4
|
-
def
|
4
|
+
def setup
|
5
5
|
super
|
6
|
+
|
7
|
+
@reps = Nanoc::Int::ItemRepRepo.new
|
8
|
+
@view_context = Nanoc::ViewContext.new(reps: @reps, items: nil)
|
9
|
+
|
6
10
|
@items = nil
|
7
|
-
@item
|
8
|
-
@site
|
9
|
-
|
11
|
+
@item = nil
|
12
|
+
@site = nil
|
13
|
+
@config = nil
|
10
14
|
end
|
11
15
|
|
12
16
|
def test_xml_sitemap
|
@@ -15,32 +19,32 @@ class Nanoc::Helpers::XMLSitemapTest < Nanoc::TestCase
|
|
15
19
|
@items = Nanoc::Int::IdentifiableCollection.new({})
|
16
20
|
|
17
21
|
# Create item 1
|
18
|
-
item = Nanoc::ItemView.new(Nanoc::Int::Item.new('some content 1', {}, '/item-one/'))
|
22
|
+
item = Nanoc::ItemView.new(Nanoc::Int::Item.new('some content 1', {}, '/item-one/'), @view_context)
|
19
23
|
@items << item
|
20
24
|
create_item_rep(item.unwrap, :one_a, '/item-one/a/')
|
21
25
|
create_item_rep(item.unwrap, :one_b, '/item-one/b/')
|
22
26
|
|
23
27
|
# Create item 2
|
24
|
-
item = Nanoc::ItemView.new(Nanoc::Int::Item.new('some content 2', { is_hidden: true }, '/item-two/'))
|
28
|
+
item = Nanoc::ItemView.new(Nanoc::Int::Item.new('some content 2', { is_hidden: true }, '/item-two/'), @view_context)
|
25
29
|
@items << item
|
26
30
|
|
27
31
|
# Create item 3
|
28
32
|
attrs = { mtime: Time.parse('2004-07-12'), changefreq: 'daily', priority: 0.5 }
|
29
|
-
item = Nanoc::ItemView.new(Nanoc::Int::Item.new('some content 3', attrs, '/item-three/'))
|
33
|
+
item = Nanoc::ItemView.new(Nanoc::Int::Item.new('some content 3', attrs, '/item-three/'), @view_context)
|
30
34
|
@items << item
|
31
35
|
create_item_rep(item.unwrap, :three_a, '/item-three/a/')
|
32
36
|
create_item_rep(item.unwrap, :three_b, '/item-three/b/')
|
33
37
|
|
34
38
|
# Create item 4
|
35
|
-
item = Nanoc::ItemView.new(Nanoc::Int::Item.new('some content 4', {}, '/item-four/'))
|
39
|
+
item = Nanoc::ItemView.new(Nanoc::Int::Item.new('some content 4', {}, '/item-four/'), @view_context)
|
36
40
|
@items << item
|
37
41
|
create_item_rep(item.unwrap, :four_a, nil)
|
38
42
|
|
39
43
|
# Create sitemap item
|
40
|
-
@item = Nanoc::ItemView.new(Nanoc::Int::Item.new('sitemap content', {}, '/sitemap/'))
|
44
|
+
@item = Nanoc::ItemView.new(Nanoc::Int::Item.new('sitemap content', {}, '/sitemap/'), @view_context)
|
41
45
|
|
42
46
|
# Create site
|
43
|
-
@config = Nanoc::ConfigView.new({ base_url: 'http://example.com' })
|
47
|
+
@config = Nanoc::ConfigView.new({ base_url: 'http://example.com' }, nil)
|
44
48
|
|
45
49
|
# Build sitemap
|
46
50
|
res = xml_sitemap
|
@@ -75,7 +79,7 @@ class Nanoc::Helpers::XMLSitemapTest < Nanoc::TestCase
|
|
75
79
|
# Create items
|
76
80
|
@items = Nanoc::Int::IdentifiableCollection.new({})
|
77
81
|
@items << nil
|
78
|
-
item = Nanoc::ItemView.new(Nanoc::Int::Item.new('some content 1', {}, '/item-one/'))
|
82
|
+
item = Nanoc::ItemView.new(Nanoc::Int::Item.new('some content 1', {}, '/item-one/'), @view_context)
|
79
83
|
@items << item
|
80
84
|
create_item_rep(item.unwrap, :one_a, '/item-one/a/')
|
81
85
|
create_item_rep(item.unwrap, :one_b, '/item-one/b/')
|
@@ -85,7 +89,7 @@ class Nanoc::Helpers::XMLSitemapTest < Nanoc::TestCase
|
|
85
89
|
@item = Nanoc::Int::Item.new('sitemap content', {}, '/sitemap/')
|
86
90
|
|
87
91
|
# Create site
|
88
|
-
@config = Nanoc::ConfigView.new({ base_url: 'http://example.com' })
|
92
|
+
@config = Nanoc::ConfigView.new({ base_url: 'http://example.com' }, nil)
|
89
93
|
|
90
94
|
# Build sitemap
|
91
95
|
res = xml_sitemap(items: [item])
|
@@ -111,16 +115,16 @@ class Nanoc::Helpers::XMLSitemapTest < Nanoc::TestCase
|
|
111
115
|
if_have 'builder', 'nokogiri' do
|
112
116
|
# Create items
|
113
117
|
@items = Nanoc::Int::IdentifiableCollection.new({})
|
114
|
-
item = Nanoc::ItemView.new(Nanoc::Int::Item.new('some content 1', {}, '/item-one/'))
|
118
|
+
item = Nanoc::ItemView.new(Nanoc::Int::Item.new('some content 1', {}, '/item-one/'), @view_context)
|
115
119
|
@items << item
|
116
120
|
create_item_rep(item.unwrap, :one_a, '/item-one/a/')
|
117
121
|
create_item_rep(item.unwrap, :one_b, '/item-one/b/')
|
118
122
|
|
119
123
|
# Create sitemap item
|
120
|
-
@item = Nanoc::ItemView.new(Nanoc::Int::Item.new('sitemap content', {}, '/sitemap/'))
|
124
|
+
@item = Nanoc::ItemView.new(Nanoc::Int::Item.new('sitemap content', {}, '/sitemap/'), @view_context)
|
121
125
|
|
122
126
|
# Create site
|
123
|
-
@config = Nanoc::ConfigView.new({ base_url: 'http://example.com' })
|
127
|
+
@config = Nanoc::ConfigView.new({ base_url: 'http://example.com' }, nil)
|
124
128
|
|
125
129
|
# Build sitemap
|
126
130
|
res = xml_sitemap(rep_select: ->(rep) { rep.name == :one_a })
|
@@ -142,24 +146,24 @@ class Nanoc::Helpers::XMLSitemapTest < Nanoc::TestCase
|
|
142
146
|
if_have 'builder', 'nokogiri' do
|
143
147
|
# Create items
|
144
148
|
@items = Nanoc::Int::IdentifiableCollection.new({})
|
145
|
-
item = Nanoc::ItemView.new(Nanoc::Int::Item.new('some content 1', {}, '/george/'))
|
149
|
+
item = Nanoc::ItemView.new(Nanoc::Int::Item.new('some content 1', {}, '/george/'), @view_context)
|
146
150
|
@items << item
|
147
151
|
create_item_rep(item.unwrap, :a_alice, '/george/alice/')
|
148
152
|
create_item_rep(item.unwrap, :b_zoey, '/george/zoey/')
|
149
|
-
item = Nanoc::ItemView.new(Nanoc::Int::Item.new('some content 1', {}, '/walton/'))
|
153
|
+
item = Nanoc::ItemView.new(Nanoc::Int::Item.new('some content 1', {}, '/walton/'), @view_context)
|
150
154
|
@items << item
|
151
155
|
create_item_rep(item.unwrap, :a_eve, '/walton/eve/')
|
152
156
|
create_item_rep(item.unwrap, :b_bob, '/walton/bob/')
|
153
|
-
item = Nanoc::ItemView.new(Nanoc::Int::Item.new('some content 1', {}, '/lucas/'))
|
157
|
+
item = Nanoc::ItemView.new(Nanoc::Int::Item.new('some content 1', {}, '/lucas/'), @view_context)
|
154
158
|
@items << item
|
155
159
|
create_item_rep(item.unwrap, :a_trudy, '/lucas/trudy/')
|
156
160
|
create_item_rep(item.unwrap, :b_mallory, '/lucas/mallory/')
|
157
161
|
|
158
162
|
# Create sitemap item
|
159
|
-
@item = Nanoc::ItemView.new(Nanoc::Int::Item.new('sitemap content', {}, '/sitemap/'))
|
163
|
+
@item = Nanoc::ItemView.new(Nanoc::Int::Item.new('sitemap content', {}, '/sitemap/'), @view_context)
|
160
164
|
|
161
165
|
# Create site
|
162
|
-
@config = Nanoc::ConfigView.new({ base_url: 'http://example.com' })
|
166
|
+
@config = Nanoc::ConfigView.new({ base_url: 'http://example.com' }, nil)
|
163
167
|
|
164
168
|
# Build sitemap
|
165
169
|
res = xml_sitemap(items: @items)
|
@@ -185,7 +189,7 @@ class Nanoc::Helpers::XMLSitemapTest < Nanoc::TestCase
|
|
185
189
|
rep = Nanoc::Int::ItemRep.new(item, name)
|
186
190
|
rep.paths = { last: path }
|
187
191
|
rep.raw_paths = { last: path }
|
188
|
-
|
192
|
+
@reps << rep
|
189
193
|
rep
|
190
194
|
end
|
191
195
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nanoc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.
|
4
|
+
version: 4.1.0a1
|
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-
|
11
|
+
date: 2015-12-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: cri
|
@@ -61,6 +61,8 @@ files:
|
|
61
61
|
- CONTRIBUTING.md
|
62
62
|
- ChangeLog
|
63
63
|
- Gemfile
|
64
|
+
- Gemfile.lock
|
65
|
+
- Guardfile
|
64
66
|
- LICENSE
|
65
67
|
- NEWS.md
|
66
68
|
- README.md
|
@@ -75,12 +77,11 @@ files:
|
|
75
77
|
- lib/nanoc/base/compilation/compiler_dsl.rb
|
76
78
|
- lib/nanoc/base/compilation/dependency_tracker.rb
|
77
79
|
- lib/nanoc/base/compilation/filter.rb
|
80
|
+
- lib/nanoc/base/compilation/item_rep_repo.rb
|
78
81
|
- lib/nanoc/base/compilation/outdatedness_checker.rb
|
79
82
|
- lib/nanoc/base/compilation/outdatedness_reasons.rb
|
80
83
|
- lib/nanoc/base/compilation/rule.rb
|
81
84
|
- lib/nanoc/base/compilation/rule_context.rb
|
82
|
-
- lib/nanoc/base/compilation/rule_memory_calculator.rb
|
83
|
-
- lib/nanoc/base/compilation/rules_collection.rb
|
84
85
|
- lib/nanoc/base/context.rb
|
85
86
|
- lib/nanoc/base/core_ext.rb
|
86
87
|
- lib/nanoc/base/core_ext/array.rb
|
@@ -89,36 +90,52 @@ files:
|
|
89
90
|
- lib/nanoc/base/core_ext/string.rb
|
90
91
|
- lib/nanoc/base/directed_graph.rb
|
91
92
|
- lib/nanoc/base/entities.rb
|
93
|
+
- lib/nanoc/base/entities/code_snippet.rb
|
94
|
+
- lib/nanoc/base/entities/configuration.rb
|
92
95
|
- lib/nanoc/base/entities/content.rb
|
93
96
|
- lib/nanoc/base/entities/document.rb
|
97
|
+
- lib/nanoc/base/entities/identifiable_collection.rb
|
94
98
|
- lib/nanoc/base/entities/identifier.rb
|
99
|
+
- lib/nanoc/base/entities/item.rb
|
100
|
+
- lib/nanoc/base/entities/item_rep.rb
|
95
101
|
- lib/nanoc/base/entities/layout.rb
|
96
102
|
- lib/nanoc/base/entities/pattern.rb
|
103
|
+
- lib/nanoc/base/entities/rule_memory.rb
|
104
|
+
- lib/nanoc/base/entities/rule_memory_action.rb
|
105
|
+
- lib/nanoc/base/entities/rule_memory_actions.rb
|
106
|
+
- lib/nanoc/base/entities/rule_memory_actions/filter.rb
|
107
|
+
- lib/nanoc/base/entities/rule_memory_actions/layout.rb
|
108
|
+
- lib/nanoc/base/entities/rule_memory_actions/snapshot.rb
|
109
|
+
- lib/nanoc/base/entities/rules_collection.rb
|
110
|
+
- lib/nanoc/base/entities/site.rb
|
97
111
|
- lib/nanoc/base/entities/snapshot_def.rb
|
98
112
|
- lib/nanoc/base/error.rb
|
99
113
|
- lib/nanoc/base/errors.rb
|
100
|
-
- lib/nanoc/base/identifiable_collection.rb
|
101
114
|
- lib/nanoc/base/memoization.rb
|
102
115
|
- lib/nanoc/base/plugin_registry.rb
|
103
116
|
- lib/nanoc/base/repos.rb
|
104
117
|
- lib/nanoc/base/repos/checksum_store.rb
|
105
118
|
- lib/nanoc/base/repos/compiled_content_cache.rb
|
106
119
|
- lib/nanoc/base/repos/config_loader.rb
|
120
|
+
- lib/nanoc/base/repos/data_source.rb
|
121
|
+
- lib/nanoc/base/repos/dependency_store.rb
|
107
122
|
- lib/nanoc/base/repos/rule_memory_store.rb
|
108
123
|
- lib/nanoc/base/repos/site_loader.rb
|
109
124
|
- lib/nanoc/base/repos/store.rb
|
110
|
-
- lib/nanoc/base/result_data/item_rep.rb
|
111
125
|
- lib/nanoc/base/services.rb
|
126
|
+
- lib/nanoc/base/services/compiler_loader.rb
|
112
127
|
- lib/nanoc/base/services/executor.rb
|
128
|
+
- lib/nanoc/base/services/item_rep_builder.rb
|
129
|
+
- lib/nanoc/base/services/item_rep_router.rb
|
130
|
+
- lib/nanoc/base/services/item_rep_selector.rb
|
113
131
|
- lib/nanoc/base/services/item_rep_writer.rb
|
114
132
|
- lib/nanoc/base/services/notification_center.rb
|
133
|
+
- lib/nanoc/base/services/postprocessor.rb
|
134
|
+
- lib/nanoc/base/services/preprocessor.rb
|
115
135
|
- lib/nanoc/base/services/recording_executor.rb
|
136
|
+
- lib/nanoc/base/services/rule_memory_calculator.rb
|
137
|
+
- lib/nanoc/base/services/rules_loader.rb
|
116
138
|
- lib/nanoc/base/services/temp_filename_factory.rb
|
117
|
-
- lib/nanoc/base/source_data/code_snippet.rb
|
118
|
-
- lib/nanoc/base/source_data/configuration.rb
|
119
|
-
- lib/nanoc/base/source_data/data_source.rb
|
120
|
-
- lib/nanoc/base/source_data/item.rb
|
121
|
-
- lib/nanoc/base/source_data/site.rb
|
122
139
|
- lib/nanoc/base/views.rb
|
123
140
|
- lib/nanoc/base/views/config_view.rb
|
124
141
|
- lib/nanoc/base/views/identifiable_collection_view.rb
|
@@ -136,7 +153,11 @@ files:
|
|
136
153
|
- lib/nanoc/base/views/mutable_item_view.rb
|
137
154
|
- lib/nanoc/base/views/mutable_layout_collection_view.rb
|
138
155
|
- lib/nanoc/base/views/mutable_layout_view.rb
|
156
|
+
- lib/nanoc/base/views/post_compile_item_collection_view.rb
|
157
|
+
- lib/nanoc/base/views/post_compile_item_view.rb
|
139
158
|
- lib/nanoc/base/views/site_view.rb
|
159
|
+
- lib/nanoc/base/views/view.rb
|
160
|
+
- lib/nanoc/base/views/view_context.rb
|
140
161
|
- lib/nanoc/cli.rb
|
141
162
|
- lib/nanoc/cli/ansi_string_colorizer.rb
|
142
163
|
- lib/nanoc/cli/cleaning_stream.rb
|
@@ -227,7 +248,9 @@ files:
|
|
227
248
|
- lib/nanoc/helpers/text.rb
|
228
249
|
- lib/nanoc/helpers/xml_sitemap.rb
|
229
250
|
- lib/nanoc/version.rb
|
251
|
+
- nanoc-4.0.2.gem
|
230
252
|
- nanoc.gemspec
|
253
|
+
- tags
|
231
254
|
- tasks/doc.rake
|
232
255
|
- tasks/rubocop.rake
|
233
256
|
- tasks/test.rake
|
@@ -254,7 +277,6 @@ files:
|
|
254
277
|
- test/base/test_outdatedness_checker.rb
|
255
278
|
- test/base/test_plugin.rb
|
256
279
|
- test/base/test_rule.rb
|
257
|
-
- test/base/test_rule_context.rb
|
258
280
|
- test/base/test_site.rb
|
259
281
|
- test/base/test_store.rb
|
260
282
|
- test/cli/commands/test_check.rb
|
@@ -347,9 +369,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
347
369
|
version: 2.1.0
|
348
370
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
349
371
|
requirements:
|
350
|
-
- - "
|
372
|
+
- - ">"
|
351
373
|
- !ruby/object:Gem::Version
|
352
|
-
version:
|
374
|
+
version: 1.3.1
|
353
375
|
requirements: []
|
354
376
|
rubyforge_project:
|
355
377
|
rubygems_version: 2.4.5.1
|
@@ -1,35 +0,0 @@
|
|
1
|
-
module Nanoc::Int
|
2
|
-
# Calculates rule memories for objects that can be run through a rule (item
|
3
|
-
# representations and layouts).
|
4
|
-
#
|
5
|
-
# @api private
|
6
|
-
class RuleMemoryCalculator
|
7
|
-
extend Nanoc::Int::Memoization
|
8
|
-
|
9
|
-
# @option params [Nanoc::Int::RulesCollection] rules_collection The rules
|
10
|
-
# collection
|
11
|
-
def initialize(params = {})
|
12
|
-
@rules_collection = params.fetch(:rules_collection) do
|
13
|
-
raise ArgumentError, 'Required :rules_collection option is missing'
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
# @param [#reference] obj The object to calculate the rule memory for
|
18
|
-
#
|
19
|
-
# @return [Array] The caluclated rule memory for the given object
|
20
|
-
def [](obj)
|
21
|
-
result =
|
22
|
-
case obj
|
23
|
-
when Nanoc::Int::ItemRep
|
24
|
-
@rules_collection.new_rule_memory_for_rep(obj)
|
25
|
-
when Nanoc::Int::Layout
|
26
|
-
@rules_collection.new_rule_memory_for_layout(obj)
|
27
|
-
else
|
28
|
-
raise "Do not know how to calculate the rule memory for #{obj.inspect}"
|
29
|
-
end
|
30
|
-
|
31
|
-
result
|
32
|
-
end
|
33
|
-
memoize :[]
|
34
|
-
end
|
35
|
-
end
|
@@ -1,245 +0,0 @@
|
|
1
|
-
module Nanoc::Int
|
2
|
-
# Keeps track of the rules in a site.
|
3
|
-
#
|
4
|
-
# @api private
|
5
|
-
class RulesCollection
|
6
|
-
# @return [String] the contents of the Rules file
|
7
|
-
attr_accessor :data
|
8
|
-
|
9
|
-
extend Nanoc::Int::Memoization
|
10
|
-
|
11
|
-
# @return [Array<Nanoc::Int::Rule>] The list of item compilation rules that
|
12
|
-
# will be used to compile items.
|
13
|
-
attr_reader :item_compilation_rules
|
14
|
-
|
15
|
-
# @return [Array<Nanoc::Int::Rule>] The list of routing rules that will be
|
16
|
-
# used to give all items a path.
|
17
|
-
attr_reader :item_routing_rules
|
18
|
-
|
19
|
-
# The hash containing layout-to-filter mapping rules. This hash is
|
20
|
-
# ordered: iterating over the hash will happen in insertion order.
|
21
|
-
#
|
22
|
-
# @return [Hash] The layout-to-filter mapping rules
|
23
|
-
attr_reader :layout_filter_mapping
|
24
|
-
|
25
|
-
# The hash containing preprocessor code blocks that will be executed after
|
26
|
-
# all data is loaded but before the site is compiled.
|
27
|
-
#
|
28
|
-
# @return [Hash] The hash containing the preprocessor code blocks that will
|
29
|
-
# be executed after all data is loaded but before the site is compiled
|
30
|
-
attr_accessor :preprocessors
|
31
|
-
|
32
|
-
# @param [Nanoc::Int::Compiler] compiler The site’s compiler
|
33
|
-
def initialize(compiler)
|
34
|
-
@compiler = compiler
|
35
|
-
|
36
|
-
@item_compilation_rules = []
|
37
|
-
@item_routing_rules = []
|
38
|
-
@layout_filter_mapping = {}
|
39
|
-
@preprocessors = {}
|
40
|
-
end
|
41
|
-
|
42
|
-
# Add the given rule to the list of item compilation rules.
|
43
|
-
#
|
44
|
-
# @param [Nanoc::Int::Rule] rule The item compilation rule to add
|
45
|
-
#
|
46
|
-
# @return [void]
|
47
|
-
def add_item_compilation_rule(rule)
|
48
|
-
@item_compilation_rules << rule
|
49
|
-
end
|
50
|
-
|
51
|
-
# Add the given rule to the list of item routing rules.
|
52
|
-
#
|
53
|
-
# @param [Nanoc::Int::Rule] rule The item routing rule to add
|
54
|
-
#
|
55
|
-
# @return [void]
|
56
|
-
def add_item_routing_rule(rule)
|
57
|
-
@item_routing_rules << rule
|
58
|
-
end
|
59
|
-
|
60
|
-
# @param [Nanoc::Int::Item] item The item for which the compilation rules
|
61
|
-
# should be retrieved
|
62
|
-
#
|
63
|
-
# @return [Array] The list of item compilation rules for the given item
|
64
|
-
def item_compilation_rules_for(item)
|
65
|
-
@item_compilation_rules.select { |r| r.applicable_to?(item) }
|
66
|
-
end
|
67
|
-
|
68
|
-
# Loads this site’s rules.
|
69
|
-
#
|
70
|
-
# @return [void]
|
71
|
-
def load
|
72
|
-
# Find rules file
|
73
|
-
rules_filenames = ['Rules', 'rules', 'Rules.rb', 'rules.rb']
|
74
|
-
rules_filename = rules_filenames.find { |f| File.file?(f) }
|
75
|
-
raise Nanoc::Int::Errors::NoRulesFileFound.new if rules_filename.nil?
|
76
|
-
|
77
|
-
parse(rules_filename)
|
78
|
-
end
|
79
|
-
|
80
|
-
def parse(rules_filename)
|
81
|
-
rules_filename = File.absolute_path(rules_filename)
|
82
|
-
|
83
|
-
# Get rule data
|
84
|
-
@data = File.read(rules_filename)
|
85
|
-
|
86
|
-
old_rules_filename = dsl.rules_filename
|
87
|
-
dsl.rules_filename = rules_filename
|
88
|
-
dsl.instance_eval(@data, rules_filename)
|
89
|
-
dsl.rules_filename = old_rules_filename
|
90
|
-
end
|
91
|
-
|
92
|
-
# Unloads this site’s rules.
|
93
|
-
#
|
94
|
-
# @return [void]
|
95
|
-
def unload
|
96
|
-
@item_compilation_rules = []
|
97
|
-
@item_routing_rules = []
|
98
|
-
@layout_filter_mapping = {}
|
99
|
-
@preprocessors = {}
|
100
|
-
end
|
101
|
-
|
102
|
-
# Finds the first matching compilation rule for the given item
|
103
|
-
# representation.
|
104
|
-
#
|
105
|
-
# @param [Nanoc::Int::ItemRep] rep The item rep for which to fetch the rule
|
106
|
-
#
|
107
|
-
# @return [Nanoc::Int::Rule, nil] The compilation rule for the given item rep,
|
108
|
-
# or nil if no rules have been found
|
109
|
-
def compilation_rule_for(rep)
|
110
|
-
@item_compilation_rules.find do |rule|
|
111
|
-
rule.applicable_to?(rep.item) && rule.rep_name == rep.name
|
112
|
-
end
|
113
|
-
end
|
114
|
-
|
115
|
-
# Finds the first matching routing rule for the given item representation.
|
116
|
-
#
|
117
|
-
# @param [Nanoc::Int::ItemRep] rep The item rep for which to fetch the rule
|
118
|
-
#
|
119
|
-
# @return [Nanoc::Int::Rule, nil] The routing rule for the given item rep, or
|
120
|
-
# nil if no rules have been found
|
121
|
-
def routing_rule_for(rep)
|
122
|
-
@item_routing_rules.find do |rule|
|
123
|
-
rule.applicable_to?(rep.item) && rule.rep_name == rep.name
|
124
|
-
end
|
125
|
-
end
|
126
|
-
|
127
|
-
# Returns the list of routing rules that can be applied to the given item
|
128
|
-
# representation. For each snapshot, the first matching rule will be
|
129
|
-
# returned. The result is a hash containing the corresponding rule for
|
130
|
-
# each snapshot.
|
131
|
-
#
|
132
|
-
# @param [Nanoc::Int::ItemRep] rep The item rep for which to fetch the rules
|
133
|
-
#
|
134
|
-
# @return [Hash<Symbol, Nanoc::Int::Rule>] The routing rules for the given rep
|
135
|
-
def routing_rules_for(rep)
|
136
|
-
rules = {}
|
137
|
-
@item_routing_rules.each do |rule|
|
138
|
-
next unless rule.applicable_to?(rep.item)
|
139
|
-
next if rule.rep_name != rep.name
|
140
|
-
next if rules.key?(rule.snapshot_name)
|
141
|
-
|
142
|
-
rules[rule.snapshot_name] = rule
|
143
|
-
end
|
144
|
-
rules
|
145
|
-
end
|
146
|
-
|
147
|
-
# Finds the filter name and arguments to use for the given layout.
|
148
|
-
#
|
149
|
-
# @param [Nanoc::Int::Layout] layout The layout for which to fetch the filter.
|
150
|
-
#
|
151
|
-
# @return [Array, nil] A tuple containing the filter name and the filter
|
152
|
-
# arguments for the given layout.
|
153
|
-
def filter_for_layout(layout)
|
154
|
-
@layout_filter_mapping.each_pair do |pattern, filter_name_and_args|
|
155
|
-
return filter_name_and_args if pattern.match?(layout.identifier)
|
156
|
-
end
|
157
|
-
nil
|
158
|
-
end
|
159
|
-
|
160
|
-
# Returns the Nanoc::Int::CompilerDSL that should be used for this site.
|
161
|
-
def dsl
|
162
|
-
Nanoc::Int::CompilerDSL.new(self, @compiler.site.config)
|
163
|
-
end
|
164
|
-
memoize :dsl
|
165
|
-
|
166
|
-
# Returns an object that can be used for uniquely identifying objects.
|
167
|
-
#
|
168
|
-
# @return [Object] An unique reference to this object
|
169
|
-
def reference
|
170
|
-
:rules
|
171
|
-
end
|
172
|
-
|
173
|
-
def inspect
|
174
|
-
"<#{self.class}>"
|
175
|
-
end
|
176
|
-
|
177
|
-
# @param [Nanoc::Int::ItemRep] rep The item representation to get the rule
|
178
|
-
# memory for
|
179
|
-
#
|
180
|
-
# @return [Array] The rule memory for the given item representation
|
181
|
-
def new_rule_memory_for_rep(rep)
|
182
|
-
executor = Nanoc::Int::RecordingExecutor.new
|
183
|
-
compilation_rule_for(rep).apply_to(rep, executor: executor, compiler: @compiler)
|
184
|
-
executor.record_write(rep, rep.path)
|
185
|
-
make_rule_memory_serializable(executor.rule_memory)
|
186
|
-
end
|
187
|
-
memoize :new_rule_memory_for_rep
|
188
|
-
|
189
|
-
# Makes the given rule memory serializable by calling
|
190
|
-
# `Nanoc::Int::Checksummer#calc` on the filter arguments, so that objects such as
|
191
|
-
# classes and filenames can be serialized.
|
192
|
-
#
|
193
|
-
# @param [Array] rs The rule memory for a certain item rep
|
194
|
-
#
|
195
|
-
# @return [Array] The serializable rule memory
|
196
|
-
def make_rule_memory_serializable(rs)
|
197
|
-
rs.map do |r|
|
198
|
-
if r[0] == :filter
|
199
|
-
[r[0], r[1], r[2].to_a.map { |a| Nanoc::Int::Checksummer.calc(a) }]
|
200
|
-
else
|
201
|
-
r
|
202
|
-
end
|
203
|
-
end
|
204
|
-
end
|
205
|
-
|
206
|
-
# @param [Nanoc::Int::Layout] layout The layout to get the rule memory for
|
207
|
-
#
|
208
|
-
# @return [Array] The rule memory for the given layout
|
209
|
-
def new_rule_memory_for_layout(layout)
|
210
|
-
filter_for_layout(layout)
|
211
|
-
end
|
212
|
-
memoize :new_rule_memory_for_layout
|
213
|
-
|
214
|
-
# @param [Nanoc::Int::ItemRep] rep The item representation for which to fetch
|
215
|
-
# the list of snapshots
|
216
|
-
#
|
217
|
-
# @return [Array] A list of snapshots, represented as arrays where the
|
218
|
-
# first element is the snapshot name (a Symbol) and the last element is
|
219
|
-
# a Boolean indicating whether the snapshot is final or not
|
220
|
-
def snapshots_defs_for(rep)
|
221
|
-
new_rule_memory_for_rep(rep).select { |e| e[0] == :snapshot }.map do |e|
|
222
|
-
Nanoc::Int::SnapshotDef.new(e[1], e[2].fetch(:final, true))
|
223
|
-
end
|
224
|
-
end
|
225
|
-
|
226
|
-
# @param [Nanoc::Int::Item] obj The object for which to check the rule memory
|
227
|
-
#
|
228
|
-
# @return [Boolean] true if the rule memory for the given object has
|
229
|
-
# changed since the last compilation, false otherwise
|
230
|
-
def rule_memory_differs_for(obj)
|
231
|
-
!rule_memory_store[obj].eql?(rule_memory_calculator[obj])
|
232
|
-
end
|
233
|
-
memoize :rule_memory_differs_for
|
234
|
-
|
235
|
-
# @return [Nanoc::Int::RuleMemoryStore] The rule memory store
|
236
|
-
def rule_memory_store
|
237
|
-
@compiler.rule_memory_store
|
238
|
-
end
|
239
|
-
|
240
|
-
# @return [Nanoc::Int::RuleMemoryCalculator] The rule memory calculator
|
241
|
-
def rule_memory_calculator
|
242
|
-
@compiler.rule_memory_calculator
|
243
|
-
end
|
244
|
-
end
|
245
|
-
end
|