nanoc3 3.2.0a4 → 3.2.0b1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/NEWS.md +20 -2
- data/README.md +7 -3
- data/bin/nanoc3 +1 -3
- data/lib/nanoc3.rb +1 -13
- data/lib/nanoc3/base/compilation/filter.rb +21 -0
- data/lib/nanoc3/base/compilation/item_rep_recorder_proxy.rb +1 -3
- data/lib/nanoc3/base/compilation/outdatedness_checker.rb +1 -1
- data/lib/nanoc3/base/compilation/rule_memory_calculator.rb +0 -2
- data/lib/nanoc3/base/compilation/rules_collection.rb +37 -13
- data/lib/nanoc3/base/directed_graph.rb +3 -3
- data/lib/nanoc3/base/memoization.rb +6 -9
- data/lib/nanoc3/base/source_data/code_snippet.rb +2 -1
- data/lib/nanoc3/base/source_data/configuration.rb +7 -3
- data/lib/nanoc3/base/source_data/item.rb +52 -10
- data/lib/nanoc3/base/source_data/layout.rb +28 -1
- data/lib/nanoc3/base/source_data/site.rb +14 -3
- data/lib/nanoc3/cli.rb +98 -6
- data/lib/nanoc3/cli/{base.rb → command.rb} +117 -153
- data/lib/nanoc3/cli/commands/autocompile.rb +20 -48
- data/lib/nanoc3/cli/commands/compile.rb +32 -48
- data/lib/nanoc3/cli/commands/create_item.rb +21 -37
- data/lib/nanoc3/cli/commands/create_layout.rb +18 -36
- data/lib/nanoc3/cli/commands/create_site.rb +15 -34
- data/lib/nanoc3/cli/commands/debug.rb +17 -31
- data/lib/nanoc3/cli/commands/info.rb +14 -29
- data/lib/nanoc3/cli/commands/nanoc.rb +37 -0
- data/lib/nanoc3/cli/commands/update.rb +21 -44
- data/lib/nanoc3/cli/commands/view.rb +18 -44
- data/lib/nanoc3/cli/commands/watch.rb +16 -31
- data/lib/nanoc3/data_sources/filesystem.rb +25 -6
- data/lib/nanoc3/data_sources/filesystem_unified.rb +5 -5
- data/lib/nanoc3/extra/auto_compiler.rb +1 -0
- data/lib/nanoc3/extra/file_proxy.rb +0 -1
- data/lib/nanoc3/filters.rb +2 -0
- data/lib/nanoc3/filters/asciidoc.rb +16 -36
- data/lib/nanoc3/filters/bluecloth.rb +2 -2
- data/lib/nanoc3/filters/coderay.rb +2 -2
- data/lib/nanoc3/filters/colorize_syntax.rb +18 -5
- data/lib/nanoc3/filters/erb.rb +2 -2
- data/lib/nanoc3/filters/erubis.rb +2 -2
- data/lib/nanoc3/filters/haml.rb +2 -2
- data/lib/nanoc3/filters/kramdown.rb +2 -2
- data/lib/nanoc3/filters/less.rb +32 -1
- data/lib/nanoc3/filters/markaby.rb +2 -2
- data/lib/nanoc3/filters/maruku.rb +2 -2
- data/lib/nanoc3/filters/mustache.rb +2 -2
- data/lib/nanoc3/filters/rainpress.rb +2 -2
- data/lib/nanoc3/filters/rdiscount.rb +4 -3
- data/lib/nanoc3/filters/rdoc.rb +10 -6
- data/lib/nanoc3/filters/redcarpet.rb +2 -2
- data/lib/nanoc3/filters/redcloth.rb +2 -2
- data/lib/nanoc3/filters/rubypants.rb +2 -2
- data/lib/nanoc3/filters/sass.rb +44 -52
- data/lib/nanoc3/filters/slim.rb +2 -2
- data/lib/nanoc3/filters/typogruby.rb +2 -2
- data/lib/nanoc3/filters/uglify_js.rb +42 -0
- data/nanoc3.gemspec +1 -1
- data/tasks/test.rake +6 -0
- data/test/base/core_ext/array_spec.rb +0 -2
- data/test/base/core_ext/hash_spec.rb +0 -2
- data/test/base/core_ext/pathname_spec.rb +0 -2
- data/test/base/core_ext/string_spec.rb +0 -2
- data/test/base/test_checksum_store.rb +0 -2
- data/test/base/test_code_snippet.rb +0 -2
- data/test/base/test_compiler.rb +2 -4
- data/test/base/test_compiler_dsl.rb +1 -3
- data/test/base/test_context.rb +0 -2
- data/test/base/test_data_source.rb +0 -2
- data/test/base/test_dependency_tracker.rb +0 -2
- data/test/base/test_directed_graph.rb +0 -2
- data/test/base/test_filter.rb +0 -2
- data/test/base/test_item.rb +19 -4
- data/test/base/test_item_rep.rb +0 -2
- data/test/base/test_layout.rb +19 -4
- data/test/base/test_memoization.rb +39 -2
- data/test/base/test_notification_center.rb +0 -2
- data/test/base/test_outdatedness_checker.rb +31 -2
- data/test/base/test_plugin.rb +0 -2
- data/test/base/test_rule.rb +0 -2
- data/test/base/test_rule_context.rb +0 -2
- data/test/base/test_site.rb +30 -3
- data/test/cli/commands/test_compile.rb +24 -3
- data/test/cli/commands/test_create_item.rb +5 -3
- data/test/cli/commands/test_create_layout.rb +4 -4
- data/test/cli/commands/test_create_site.rb +5 -5
- data/test/cli/commands/test_help.rb +3 -3
- data/test/cli/commands/test_info.rb +2 -3
- data/test/cli/commands/test_update.rb +0 -2
- data/test/cli/test_cli.rb +40 -0
- data/test/cli/test_logger.rb +0 -2
- data/test/data_sources/test_filesystem.rb +0 -2
- data/test/data_sources/test_filesystem_unified.rb +32 -58
- data/test/data_sources/test_filesystem_verbose.rb +0 -2
- data/test/extra/core_ext/test_enumerable.rb +0 -2
- data/test/extra/core_ext/test_time.rb +0 -2
- data/test/extra/deployers/test_rsync.rb +0 -2
- data/test/extra/test_auto_compiler.rb +5 -7
- data/test/extra/test_file_proxy.rb +0 -2
- data/test/extra/test_vcs.rb +0 -2
- data/test/extra/validators/test_links.rb +0 -2
- data/test/extra/validators/test_w3c.rb +0 -2
- data/test/filters/test_asciidoc.rb +0 -2
- data/test/filters/test_bluecloth.rb +0 -2
- data/test/filters/test_coderay.rb +0 -2
- data/test/filters/test_colorize_syntax.rb +49 -2
- data/test/filters/test_erb.rb +0 -2
- data/test/filters/test_erubis.rb +0 -2
- data/test/filters/test_haml.rb +0 -2
- data/test/filters/test_kramdown.rb +0 -2
- data/test/filters/test_less.rb +59 -5
- data/test/filters/test_markaby.rb +0 -2
- data/test/filters/test_maruku.rb +0 -2
- data/test/filters/test_mustache.rb +0 -2
- data/test/filters/test_rainpress.rb +0 -2
- data/test/filters/test_rdiscount.rb +0 -2
- data/test/filters/test_rdoc.rb +0 -2
- data/test/filters/test_redcarpet.rb +0 -2
- data/test/filters/test_redcloth.rb +0 -2
- data/test/filters/test_relativize_paths.rb +77 -24
- data/test/filters/test_rubypants.rb +0 -2
- data/test/filters/test_sass.rb +136 -10
- data/test/filters/test_slim.rb +0 -2
- data/test/filters/test_typogruby.rb +0 -2
- data/test/filters/test_uglify_js.rb +30 -0
- data/test/gem_loader.rb +11 -0
- data/test/helper.rb +3 -0
- data/test/helpers/test_blogging.rb +0 -2
- data/test/helpers/test_breadcrumbs.rb +0 -2
- data/test/helpers/test_capturing.rb +0 -2
- data/test/helpers/test_filtering.rb +0 -2
- data/test/helpers/test_html_escape.rb +0 -2
- data/test/helpers/test_link_to.rb +0 -2
- data/test/helpers/test_rendering.rb +0 -2
- data/test/helpers/test_tagging.rb +0 -2
- data/test/helpers/test_text.rb +0 -2
- data/test/helpers/test_xml_sitemap.rb +0 -2
- data/test/tasks/test_clean.rb +0 -2
- metadata +11 -9
- data/lib/nanoc3/cli/commands.rb +0 -16
- data/lib/nanoc3/cli/commands/help.rb +0 -71
- data/tasks/clean.rake +0 -11
data/NEWS.md
CHANGED
|
@@ -10,18 +10,36 @@ Base:
|
|
|
10
10
|
* Added --color option to force color on
|
|
11
11
|
* Cleaned up internals, deprecating several parts and/or marking them as
|
|
12
12
|
private in the progress
|
|
13
|
+
* Allowed custom commands in commands/
|
|
13
14
|
|
|
14
15
|
Extensions:
|
|
15
16
|
|
|
16
17
|
* Added AsciiDoc filter
|
|
17
18
|
* Added Redcarpet filter [Peter Aronoff]
|
|
18
|
-
* Added Typogruby filter
|
|
19
19
|
* Added Slim filter [Zaiste de Grengolada]
|
|
20
|
-
* Added
|
|
20
|
+
* Added Typogruby filter
|
|
21
|
+
* Added UglifyJS filter [Justin Hileman]
|
|
22
|
+
* Added `:items` parameter for the XML site map [Justin Hileman]
|
|
21
23
|
* Added support for params to ERB
|
|
24
|
+
* Added `:default_colorizer` parameter to the `:colorize_syntax` filter
|
|
22
25
|
* Allowed for passing arbitrary options to pygmentize [Matthias Vallentin]
|
|
23
26
|
* Exposed RedCloth parameters in the filter [Vincent Driessen]
|
|
24
27
|
|
|
28
|
+
## 3.1.9 (2011-06-30)
|
|
29
|
+
|
|
30
|
+
* Really fixed dependency generation between Sass partials this time
|
|
31
|
+
* Updated Less filter to 2.0
|
|
32
|
+
* Made colorize_syntax filter throw an error if pygmentize is not available
|
|
33
|
+
|
|
34
|
+
## 3.1.8 (2011-06-25)
|
|
35
|
+
|
|
36
|
+
* Made link validator accept https: URLs
|
|
37
|
+
* Fixed erronous handling of layouts with names ending in index
|
|
38
|
+
* Fixed dependency generation between Sass partials
|
|
39
|
+
* Fixed errors related to thread requires
|
|
40
|
+
* Fixed crash while handling load errors
|
|
41
|
+
* Improved encoding handling while reading files
|
|
42
|
+
|
|
25
43
|
## 3.1.7 (2011-05-03)
|
|
26
44
|
|
|
27
45
|
* Restored compatibility with Sass 3.1
|
data/README.md
CHANGED
|
@@ -28,12 +28,14 @@ directories:
|
|
|
28
28
|
* `cli` contains the commandline interface
|
|
29
29
|
* `data_sources` contains the standard data sources ({Nanoc3::DataSource}
|
|
30
30
|
subclasses), such as the filesystem data source
|
|
31
|
-
* `helpers` contains helpers, which provide functionality some sites
|
|
32
|
-
may find useful, such as the blogging and tagging helpers
|
|
33
31
|
* `extra` contains stuff that is not needed by nanoc itself, but which may
|
|
34
32
|
be used by helpers, data sources, filters or VCSes.
|
|
35
33
|
* `filters` contains the standard filters ({Nanoc3::Filter} subclasses)
|
|
36
|
-
such as ERB, Markdown, Haml,
|
|
34
|
+
such as ERB, Markdown, Haml, …
|
|
35
|
+
* `helpers` contains helpers, which provide functionality some sites
|
|
36
|
+
may find useful, such as the blogging and tagging helpers
|
|
37
|
+
* `tasks` contains rake tasks that perform a variety of functions such as
|
|
38
|
+
validating HTML and CSS, uploading compiled files, …
|
|
37
39
|
|
|
38
40
|
The namespaces (modules) are organised like this:
|
|
39
41
|
|
|
@@ -90,10 +92,12 @@ may be interested in the development dependencies:
|
|
|
90
92
|
* Christian Plessl
|
|
91
93
|
* Šime Ramov
|
|
92
94
|
* Xavier Shay
|
|
95
|
+
* Arnau Siches
|
|
93
96
|
* “Soryu”
|
|
94
97
|
* Eric Sunshine
|
|
95
98
|
* Dennis Sutch
|
|
96
99
|
* Matthias Vallentin
|
|
100
|
+
* Toon Willems
|
|
97
101
|
|
|
98
102
|
## Contact
|
|
99
103
|
|
data/bin/nanoc3
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env ruby
|
|
2
2
|
# encoding: utf-8
|
|
3
3
|
|
|
4
|
-
puts "Starting..."
|
|
5
|
-
|
|
6
4
|
# Add lib to load path
|
|
7
5
|
$LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__) + '/../lib'))
|
|
8
6
|
|
|
@@ -11,4 +9,4 @@ require 'nanoc3'
|
|
|
11
9
|
require 'nanoc3/cli'
|
|
12
10
|
|
|
13
11
|
# Run base
|
|
14
|
-
Nanoc3::CLI
|
|
12
|
+
Nanoc3::CLI.run(ARGV)
|
data/lib/nanoc3.rb
CHANGED
|
@@ -3,22 +3,10 @@
|
|
|
3
3
|
module Nanoc3
|
|
4
4
|
|
|
5
5
|
# The current nanoc version.
|
|
6
|
-
VERSION = '3.2.
|
|
6
|
+
VERSION = '3.2.0b1'
|
|
7
7
|
|
|
8
8
|
end
|
|
9
9
|
|
|
10
|
-
# Switch #require for a faster variant
|
|
11
|
-
require 'set'
|
|
12
|
-
$_nanoc_requires ||= Set.new
|
|
13
|
-
module Kernel
|
|
14
|
-
alias_method :nanoc_original_require, :require
|
|
15
|
-
def require(r)
|
|
16
|
-
return if $_nanoc_requires.include?(r)
|
|
17
|
-
nanoc_original_require(r)
|
|
18
|
-
$_nanoc_requires << r
|
|
19
|
-
end
|
|
20
|
-
end
|
|
21
|
-
|
|
22
10
|
# Load general requirements
|
|
23
11
|
require 'digest'
|
|
24
12
|
require 'enumerator'
|
|
@@ -139,6 +139,27 @@ module Nanoc3
|
|
|
139
139
|
end
|
|
140
140
|
end
|
|
141
141
|
|
|
142
|
+
# Creates a dependency from the item that is currently being filtered onto
|
|
143
|
+
# the given collection of items. In other words, require the given items
|
|
144
|
+
# to be compiled first before this items is processed.
|
|
145
|
+
#
|
|
146
|
+
# @param [Array<Nanoc3::Item>] items The items that are depended on.
|
|
147
|
+
#
|
|
148
|
+
# @return [void]
|
|
149
|
+
def depend_on(items)
|
|
150
|
+
# Notify
|
|
151
|
+
items.each do |item|
|
|
152
|
+
Nanoc3::NotificationCenter.post(:visit_started, item)
|
|
153
|
+
Nanoc3::NotificationCenter.post(:visit_ended, item)
|
|
154
|
+
end
|
|
155
|
+
|
|
156
|
+
# Raise unmet dependency error if necessary
|
|
157
|
+
items.each do |item|
|
|
158
|
+
rep = item.reps.find { |r| !r.compiled? }
|
|
159
|
+
raise Nanoc3::Errors::UnmetDependency.new(rep) if rep
|
|
160
|
+
end
|
|
161
|
+
end
|
|
162
|
+
|
|
142
163
|
end
|
|
143
164
|
|
|
144
165
|
end
|
|
@@ -20,8 +20,6 @@ module Nanoc3
|
|
|
20
20
|
|
|
21
21
|
def_delegators :@item_rep, :item, :name, :binary, :binary?, :compiled_content, :has_snapshot?, :raw_path, :path, :assigns, :assigns=
|
|
22
22
|
|
|
23
|
-
# @return The list of recorded actions (“rule memory”)
|
|
24
|
-
#
|
|
25
23
|
# @example The compilation rule and the corresponding rule memory
|
|
26
24
|
#
|
|
27
25
|
# # rule
|
|
@@ -38,7 +36,7 @@ module Nanoc3
|
|
|
38
36
|
# [ :layout, 'meh' ]
|
|
39
37
|
# ]
|
|
40
38
|
#
|
|
41
|
-
# @return [Array] The rule memory
|
|
39
|
+
# @return [Array] The list of recorded actions (“rule memory”)
|
|
42
40
|
attr_reader :rule_memory
|
|
43
41
|
|
|
44
42
|
# @param [Nanoc3::ItemRep] item_rep The item representation that this
|
|
@@ -13,8 +13,6 @@ module Nanoc3
|
|
|
13
13
|
# @option params [Nanoc3::RulesCollection] rules_collection The rules
|
|
14
14
|
# collection
|
|
15
15
|
def initialize(params={})
|
|
16
|
-
super('tmp/rule_memory', 1)
|
|
17
|
-
|
|
18
16
|
@rules_collection = params[:rules_collection] or
|
|
19
17
|
raise ArgumentError, "Required :rules_collection option is missing"
|
|
20
18
|
end
|
|
@@ -34,7 +34,14 @@ module Nanoc3
|
|
|
34
34
|
@layout_filter_mapping = OrderedHash.new
|
|
35
35
|
end
|
|
36
36
|
|
|
37
|
-
#
|
|
37
|
+
# Add the given rule to the list of item compilation rules.
|
|
38
|
+
#
|
|
39
|
+
# @param [Nanoc3::Rule] rule The item compilation rule to add
|
|
40
|
+
#
|
|
41
|
+
# @param [:before, :after] position The place where the rule should be
|
|
42
|
+
# added (either at the beginning or the end of the list of rules)
|
|
43
|
+
#
|
|
44
|
+
# @return [void]
|
|
38
45
|
def add_item_compilation_rule(rule, position=:after)
|
|
39
46
|
case position
|
|
40
47
|
when :before
|
|
@@ -46,7 +53,14 @@ module Nanoc3
|
|
|
46
53
|
end
|
|
47
54
|
end
|
|
48
55
|
|
|
49
|
-
#
|
|
56
|
+
# Add the given rule to the list of item routing rules.
|
|
57
|
+
#
|
|
58
|
+
# @param [Nanoc3::Rule] rule The item routing rule to add
|
|
59
|
+
#
|
|
60
|
+
# @param [:before, :after] position The place where the rule should be
|
|
61
|
+
# added (either at the beginning or the end of the list of rules)
|
|
62
|
+
#
|
|
63
|
+
# @return [void]
|
|
50
64
|
def add_item_routing_rule(rule, position=:after)
|
|
51
65
|
case position
|
|
52
66
|
when :before
|
|
@@ -58,12 +72,17 @@ module Nanoc3
|
|
|
58
72
|
end
|
|
59
73
|
end
|
|
60
74
|
|
|
61
|
-
#
|
|
75
|
+
# @param [Nanoc3::Item] item The item for which the compilation rules
|
|
76
|
+
# should be retrieved
|
|
77
|
+
#
|
|
78
|
+
# @return [Array] The list of item compilation rules for the given item
|
|
62
79
|
def item_compilation_rules_for(item)
|
|
63
80
|
@item_compilation_rules.select { |r| r.applicable_to?(item) }
|
|
64
81
|
end
|
|
65
82
|
|
|
66
83
|
# Loads this site’s rules.
|
|
84
|
+
#
|
|
85
|
+
# @return [void]
|
|
67
86
|
def load
|
|
68
87
|
# Find rules file
|
|
69
88
|
rules_filenames = [ 'Rules', 'rules', 'Rules.rb', 'rules.rb' ]
|
|
@@ -78,6 +97,8 @@ module Nanoc3
|
|
|
78
97
|
end
|
|
79
98
|
|
|
80
99
|
# Unloads this site’s rules.
|
|
100
|
+
#
|
|
101
|
+
# @return [void]
|
|
81
102
|
def unload
|
|
82
103
|
@item_compilation_rules = []
|
|
83
104
|
@item_routing_rules = []
|
|
@@ -114,6 +135,8 @@ module Nanoc3
|
|
|
114
135
|
# returned. The result is a hash containing the corresponding rule for
|
|
115
136
|
# each snapshot.
|
|
116
137
|
#
|
|
138
|
+
# @param [Nanoc3::ItemRep] rep The item rep for which to fetch the rules
|
|
139
|
+
#
|
|
117
140
|
# @return [Hash<Symbol, Nanoc3::Rule>] The routing rules for the given rep
|
|
118
141
|
def routing_rules_for(rep)
|
|
119
142
|
rules = {}
|
|
@@ -146,17 +169,15 @@ module Nanoc3
|
|
|
146
169
|
end
|
|
147
170
|
memoize :dsl
|
|
148
171
|
|
|
149
|
-
#
|
|
172
|
+
# Returns an object that can be used for uniquely identifying objects.
|
|
173
|
+
#
|
|
174
|
+
# @return [Object] An unique reference to this object
|
|
150
175
|
def reference
|
|
151
176
|
:rules
|
|
152
177
|
end
|
|
153
178
|
|
|
154
|
-
#
|
|
155
|
-
|
|
156
|
-
@data
|
|
157
|
-
end
|
|
158
|
-
|
|
159
|
-
# TODO document
|
|
179
|
+
# @return [String] The checksum for this object. If its contents change,
|
|
180
|
+
# the checksum will change as well.
|
|
160
181
|
def checksum
|
|
161
182
|
@data.checksum
|
|
162
183
|
end
|
|
@@ -184,18 +205,21 @@ module Nanoc3
|
|
|
184
205
|
end
|
|
185
206
|
memoize :new_rule_memory_for_layout
|
|
186
207
|
|
|
187
|
-
#
|
|
208
|
+
# @param [Nanoc3::Item] obj The object for which to check the rule memory
|
|
209
|
+
#
|
|
210
|
+
# @return [Boolean] true if the rule memory for the given object has
|
|
211
|
+
# changed since the last compilation, false otherwise
|
|
188
212
|
def rule_memory_differs_for(obj)
|
|
189
213
|
!rule_memory_store[obj].eql?(rule_memory_calculator[obj])
|
|
190
214
|
end
|
|
191
215
|
memoize :rule_memory_differs_for
|
|
192
216
|
|
|
193
|
-
#
|
|
217
|
+
# @return [Nanoc3::RuleMemoryStore] The rule memory store
|
|
194
218
|
def rule_memory_store
|
|
195
219
|
@compiler.rule_memory_store
|
|
196
220
|
end
|
|
197
221
|
|
|
198
|
-
#
|
|
222
|
+
# @return [Nanoc3::RuleMemoryCalculator] The rule memory calculator
|
|
199
223
|
def rule_memory_calculator
|
|
200
224
|
@compiler.rule_memory_calculator
|
|
201
225
|
end
|
|
@@ -31,16 +31,16 @@ module Nanoc3
|
|
|
31
31
|
# # => %w( b c )
|
|
32
32
|
class DirectedGraph
|
|
33
33
|
|
|
34
|
-
# The
|
|
34
|
+
# The set of vertices in this graph.
|
|
35
35
|
#
|
|
36
|
-
# @return [
|
|
36
|
+
# @return [Set]
|
|
37
37
|
attr_reader :vertices
|
|
38
38
|
|
|
39
39
|
# @group Creating a graph
|
|
40
40
|
|
|
41
41
|
# Creates a new directed graph with the given vertices.
|
|
42
42
|
def initialize(vertices)
|
|
43
|
-
@vertices = vertices
|
|
43
|
+
@vertices = Set.new(vertices)
|
|
44
44
|
|
|
45
45
|
@from_graph = {}
|
|
46
46
|
@to_graph = {}
|
|
@@ -49,21 +49,18 @@ module Nanoc3
|
|
|
49
49
|
|
|
50
50
|
# Redefine
|
|
51
51
|
define_method(method_name) do |*args|
|
|
52
|
-
# Get
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
CACHE[key] = {}
|
|
56
|
-
end
|
|
57
|
-
method_cache = CACHE[key]
|
|
52
|
+
# Get cache
|
|
53
|
+
@cache ||= {}
|
|
54
|
+
@cache[method_name] ||= {}
|
|
58
55
|
|
|
59
56
|
# Recalculate if necessary
|
|
60
|
-
if
|
|
57
|
+
if !@cache[method_name].has_key?(args)
|
|
61
58
|
result = send(original_method_name, *args)
|
|
62
|
-
|
|
59
|
+
@cache[method_name][args] = result
|
|
63
60
|
end
|
|
64
61
|
|
|
65
62
|
# Done
|
|
66
|
-
|
|
63
|
+
@cache[method_name][args]
|
|
67
64
|
end
|
|
68
65
|
end
|
|
69
66
|
|
|
@@ -47,7 +47,8 @@ module Nanoc3
|
|
|
47
47
|
"<#{self.class}:0x#{self.object_id.to_s(16)} filename=#{self.filename}>"
|
|
48
48
|
end
|
|
49
49
|
|
|
50
|
-
#
|
|
50
|
+
# @return [String] The checksum for this object. If its contents change,
|
|
51
|
+
# the checksum will change as well.
|
|
51
52
|
def checksum
|
|
52
53
|
@data.checksum
|
|
53
54
|
end
|
|
@@ -2,15 +2,19 @@
|
|
|
2
2
|
|
|
3
3
|
module Nanoc3
|
|
4
4
|
|
|
5
|
-
#
|
|
5
|
+
# Represents the site configuration.
|
|
6
6
|
class Configuration < ::Hash
|
|
7
7
|
|
|
8
|
-
#
|
|
8
|
+
# Creates a new configuration with the given hash.
|
|
9
|
+
#
|
|
10
|
+
# @param [Hash] hash The actual configuration hash
|
|
9
11
|
def initialize(hash)
|
|
10
12
|
self.replace(hash)
|
|
11
13
|
end
|
|
12
14
|
|
|
13
|
-
#
|
|
15
|
+
# Returns an object that can be used for uniquely identifying objects.
|
|
16
|
+
#
|
|
17
|
+
# @return [Object] An unique reference to this object
|
|
14
18
|
def reference
|
|
15
19
|
:config
|
|
16
20
|
end
|
|
@@ -166,16 +166,19 @@ module Nanoc3
|
|
|
166
166
|
# Get captured content (hax)
|
|
167
167
|
# TODO [in nanoc 4.0] remove me
|
|
168
168
|
if key.to_s =~ /^content_for_(.*)$/
|
|
169
|
+
@@_content_for_warning_issued ||= false
|
|
170
|
+
@@_Nanoc3_Helpers_Capturing_included ||= false
|
|
171
|
+
|
|
169
172
|
# Warn
|
|
170
|
-
unless
|
|
173
|
+
unless @@_content_for_warning_issued
|
|
171
174
|
warn 'WARNING: Accessing captured content should happen using the #content_for method defined in the Capturing helper instead of using item[:content_for_something]. The latter way of accessing captured content will be removed in nanoc 4.0.'
|
|
172
|
-
|
|
175
|
+
@@_content_for_warning_issued = true
|
|
173
176
|
end
|
|
174
177
|
|
|
175
178
|
# Include capturing helper if necessary
|
|
176
|
-
unless
|
|
179
|
+
unless @@_Nanoc3_Helpers_Capturing_included
|
|
177
180
|
self.class.send(:include, ::Nanoc3::Helpers::Capturing)
|
|
178
|
-
|
|
181
|
+
@@_Nanoc3_Helpers_Capturing_included = true
|
|
179
182
|
end
|
|
180
183
|
|
|
181
184
|
# Get content
|
|
@@ -233,18 +236,57 @@ module Nanoc3
|
|
|
233
236
|
"<#{self.class}:0x#{self.object_id.to_s(16)} identifier=#{self.identifier} binary?=#{self.binary?}>"
|
|
234
237
|
end
|
|
235
238
|
|
|
236
|
-
#
|
|
239
|
+
# @return [String] The checksum for this object. If its contents change,
|
|
240
|
+
# the checksum will change as well.
|
|
237
241
|
def checksum
|
|
238
|
-
if binary?
|
|
239
|
-
|
|
242
|
+
content_checksum = if binary?
|
|
243
|
+
if File.exist?(raw_filename)
|
|
244
|
+
Pathname.new(raw_filename).checksum
|
|
245
|
+
else
|
|
246
|
+
''.checksum
|
|
247
|
+
end
|
|
240
248
|
else
|
|
241
|
-
|
|
242
|
-
attributes.delete(:file)
|
|
243
|
-
@raw_content.checksum + ',' + attributes.checksum
|
|
249
|
+
@raw_content.checksum
|
|
244
250
|
end
|
|
251
|
+
|
|
252
|
+
attributes = @attributes.dup
|
|
253
|
+
attributes.delete(:file)
|
|
254
|
+
attributes_checksum = attributes.checksum
|
|
255
|
+
|
|
256
|
+
content_checksum + ',' + attributes_checksum
|
|
245
257
|
end
|
|
246
258
|
memoize :checksum
|
|
247
259
|
|
|
260
|
+
def hash
|
|
261
|
+
self.class.hash ^ self.identifier.hash
|
|
262
|
+
end
|
|
263
|
+
|
|
264
|
+
def eql?(other)
|
|
265
|
+
self.class == other.class && self.identifier == other.identifier
|
|
266
|
+
end
|
|
267
|
+
|
|
268
|
+
def ==(other)
|
|
269
|
+
self.eql?(other)
|
|
270
|
+
end
|
|
271
|
+
|
|
272
|
+
def marshal_dump
|
|
273
|
+
[
|
|
274
|
+
@is_binary,
|
|
275
|
+
@raw_filename,
|
|
276
|
+
@raw_content,
|
|
277
|
+
@attributes,
|
|
278
|
+
@identifier
|
|
279
|
+
]
|
|
280
|
+
end
|
|
281
|
+
|
|
282
|
+
def marshal_load(source)
|
|
283
|
+
@is_binary,
|
|
284
|
+
@raw_filename,
|
|
285
|
+
@raw_content,
|
|
286
|
+
@attributes,
|
|
287
|
+
@identifier = *source
|
|
288
|
+
end
|
|
289
|
+
|
|
248
290
|
# @deprecated Access the modification time using `item[:mtime]` instead.
|
|
249
291
|
def mtime
|
|
250
292
|
self[:mtime]
|