nanoc3 3.2.0a1 → 3.2.0a2
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog +2 -2
- data/NEWS.md +14 -0
- data/README.md +20 -12
- data/doc/yardoc_templates/default/layout/html/footer.erb +10 -0
- data/lib/nanoc3/base/compilation/checksum_store.rb +130 -0
- data/lib/nanoc3/base/compilation/checksummer.rb +68 -0
- data/lib/nanoc3/base/compilation/compiled_content_cache.rb +57 -0
- data/lib/nanoc3/base/{compiler.rb → compilation/compiler.rb} +255 -55
- data/lib/nanoc3/base/{compiler_dsl.rb → compilation/compiler_dsl.rb} +11 -6
- data/lib/nanoc3/base/{dependency_tracker.rb → compilation/dependency_tracker.rb} +62 -92
- data/lib/nanoc3/base/{filter.rb → compilation/filter.rb} +0 -0
- data/lib/nanoc3/base/compilation/item_rep_proxy.rb +87 -0
- data/lib/nanoc3/base/compilation/outdatedness_checker.rb +86 -0
- data/lib/nanoc3/base/compilation/outdatedness_reasons.rb +43 -0
- data/lib/nanoc3/base/{rule.rb → compilation/rule.rb} +8 -2
- data/lib/nanoc3/base/{rule_context.rb → compilation/rule_context.rb} +17 -14
- data/lib/nanoc3/base/directed_graph.rb +8 -0
- data/lib/nanoc3/base/errors.rb +9 -17
- data/lib/nanoc3/base/plugin_registry.rb +1 -1
- data/lib/nanoc3/base/result_data/item_rep.rb +447 -0
- data/lib/nanoc3/base/{code_snippet.rb → source_data/code_snippet.rb} +7 -22
- data/lib/nanoc3/base/{data_source.rb → source_data/data_source.rb} +0 -0
- data/lib/nanoc3/base/{item.rb → source_data/item.rb} +20 -30
- data/lib/nanoc3/base/{layout.rb → source_data/layout.rb} +7 -26
- data/lib/nanoc3/base/source_data/site.rb +314 -0
- data/lib/nanoc3/base/store.rb +126 -0
- data/lib/nanoc3/base.rb +26 -15
- data/lib/nanoc3/cli/base.rb +2 -1
- data/lib/nanoc3/cli/commands/compile.rb +116 -48
- data/lib/nanoc3/cli/commands/create_item.rb +0 -1
- data/lib/nanoc3/cli/commands/create_layout.rb +0 -1
- data/lib/nanoc3/cli/commands/create_site.rb +11 -1
- data/lib/nanoc3/cli/commands/debug.rb +11 -6
- data/lib/nanoc3/cli/commands/info.rb +1 -2
- data/lib/nanoc3/cli/commands/update.rb +0 -1
- data/lib/nanoc3/cli/commands/watch.rb +27 -32
- data/lib/nanoc3/cli/logger.rb +2 -2
- data/lib/nanoc3/data_sources/filesystem.rb +1 -6
- data/lib/nanoc3/extra/auto_compiler.rb +2 -3
- data/lib/nanoc3/extra/deployers/rsync.rb +1 -0
- data/lib/nanoc3/extra/validators/links.rb +45 -26
- data/lib/nanoc3/filters/asciidoc.rb +58 -0
- data/lib/nanoc3/filters/colorize_syntax.rb +47 -9
- data/lib/nanoc3/filters/less.rb +6 -0
- data/lib/nanoc3/filters/sass.rb +8 -5
- data/lib/nanoc3/filters.rb +2 -0
- data/lib/nanoc3/helpers/blogging.rb +8 -0
- data/lib/nanoc3/helpers/html_escape.rb +37 -7
- data/lib/nanoc3/helpers/link_to.rb +15 -4
- data/lib/nanoc3/helpers/rendering.rb +6 -2
- data/lib/nanoc3/tasks/clean.rb +0 -4
- data/lib/nanoc3.rb +1 -1
- data/nanoc3.gemspec +42 -0
- metadata +35 -19
- data/lib/nanoc3/base/checksummer.rb +0 -40
- data/lib/nanoc3/base/compiled_content_cache.rb +0 -86
- data/lib/nanoc3/base/item_rep.rb +0 -537
- data/lib/nanoc3/base/site.rb +0 -490
data/ChangeLog
CHANGED
@@ -1,3 +1,3 @@
|
|
1
1
|
For a list of all changes, please see the changelog on the project repository
|
2
|
-
instead (http://projects.stoneship.org/hg/nanoc
|
3
|
-
|
2
|
+
instead (http://projects.stoneship.org/hg/nanoc). For release notes, please
|
3
|
+
see the NEWS file.
|
data/NEWS.md
CHANGED
@@ -1,5 +1,19 @@
|
|
1
1
|
# nanoc news
|
2
2
|
|
3
|
+
## 3.2 (???)
|
4
|
+
|
5
|
+
* Sped up nanoc quite a bit
|
6
|
+
* Added AsciiDoc filter
|
7
|
+
* Added progress indicator for long-running filters
|
8
|
+
|
9
|
+
## 3.1.3 (2010-04-25)
|
10
|
+
|
11
|
+
* Removed annoying win32console warning [Eric Sunshine]
|
12
|
+
* Removed color codes when not writing to a terminal, or when writing to
|
13
|
+
Windows’ console when win32console is not installed [Eric Sunshine]
|
14
|
+
* Added .xhtml and .xml to list of text extensions
|
15
|
+
* Improved support for relative Sass @imports [Chris Eppstein]
|
16
|
+
|
3
17
|
## 3.1.2 (2010-04-07)
|
4
18
|
|
5
19
|
* Fixed bug which could cause incorrect output when compilation of an item is
|
data/README.md
CHANGED
@@ -10,13 +10,8 @@ Note: This documentation looks best with Yardoc, not RDoc.
|
|
10
10
|
## Resources
|
11
11
|
|
12
12
|
The [nanoc web site](http://nanoc.stoneship.org) contains a few useful
|
13
|
-
resources to help you get started with nanoc
|
14
|
-
|
15
|
-
* The [tutorial](http://nanoc.stoneship.org/tutorial)
|
16
|
-
* The [manual](http://nanoc.stoneship.org/manual)
|
17
|
-
* The [migration guide](http://nanoc.stoneship.org/migrating)
|
18
|
-
|
19
|
-
If you need assistance, the following places will help you out:
|
13
|
+
resources to help you get started with nanoc. If you need further assistance,
|
14
|
+
the following places will help you out:
|
20
15
|
|
21
16
|
* The [discussion group](http://groups.google.com/group/nanoc)
|
22
17
|
* The [IRC channel](irc://chat.freenode.net/#nanoc)
|
@@ -27,6 +22,9 @@ The source code is located in `lib/nanoc3` and is structured in a few
|
|
27
22
|
directories:
|
28
23
|
|
29
24
|
* `base` contains the bare essentials necessary for nanoc to function
|
25
|
+
* `source_data` contains raw, uncompiled content that will be compiled
|
26
|
+
* `result_data` contains the compiled content
|
27
|
+
* `compilation` contains the compilation functionality
|
30
28
|
* `cli` contains the commandline interface
|
31
29
|
* `data_sources` contains the standard data sources ({Nanoc3::DataSource}
|
32
30
|
subclasses), such as the filesystem data source
|
@@ -52,32 +50,42 @@ you want to explore nanoc from a technical perspective.
|
|
52
50
|
|
53
51
|
## Dependencies
|
54
52
|
|
55
|
-
nanoc
|
56
|
-
|
53
|
+
nanoc has few dependencies. It is possible to use nanoc programmatically
|
54
|
+
without any dependencies at all, but if you want to use nanoc in a proper way,
|
55
|
+
you’ll likely need some dependencies:
|
57
56
|
|
57
|
+
* The **commandline frontend** depends on `cli`.
|
58
58
|
* The **autocompiler** depends on `mime-types` and `rack`.
|
59
|
+
* Filters and helpers likely have dependencies on their own too.
|
60
|
+
|
61
|
+
If you’re developing for nanoc, such as writing custom filters or helpers, you
|
62
|
+
may be interested in the development dependencies:
|
63
|
+
|
59
64
|
* For **documentation generation** you’ll need `yard`.
|
60
65
|
* For **packaging** you’ll need `rubygems` (1.3 or newer).
|
61
|
-
* For **testing** you’ll need `mocha`.
|
66
|
+
* For **testing** you’ll need `mocha` and `minitest`.
|
62
67
|
|
63
68
|
## Contributors
|
64
69
|
|
65
70
|
(In alphabetical order)
|
66
71
|
|
72
|
+
* Ben Armston
|
67
73
|
* Colin Barrett
|
68
74
|
* Dmitry Bilunov
|
75
|
+
* Devon Luke Buchanan
|
69
76
|
* Brian Candler
|
70
77
|
* Chris Eppstein
|
78
|
+
* Felix Hanley
|
71
79
|
* Starr Horne
|
80
|
+
* Ale Muñoz
|
72
81
|
* Nicky Peeters
|
73
82
|
* Christian Plessl
|
74
83
|
* Šime Ramov
|
84
|
+
* Xavier Shay
|
75
85
|
* “Soryu”
|
76
86
|
* Eric Sunshine
|
77
87
|
* Dennis Sutch
|
78
88
|
|
79
|
-
Special thanks to Ale Muñoz.
|
80
|
-
|
81
89
|
## Contact
|
82
90
|
|
83
91
|
You can reach me at <denis.defreyne@stoneship.org>.
|
@@ -0,0 +1,10 @@
|
|
1
|
+
<%= superb %>
|
2
|
+
<script type="text/javascript">
|
3
|
+
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
|
4
|
+
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
|
5
|
+
</script>
|
6
|
+
<script type="text/javascript">
|
7
|
+
try {
|
8
|
+
var pageTracker = _gat._getTracker("UA-15639968-1");
|
9
|
+
pageTracker._trackPageview();
|
10
|
+
} catch(err) {}</script>
|
@@ -0,0 +1,130 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
module Nanoc3
|
4
|
+
|
5
|
+
# Stores checksums for objects in order to be able to detect whether a file
|
6
|
+
# has changed since the last site compilation.
|
7
|
+
#
|
8
|
+
# Old checksums are checksums that were in effect during the previous site
|
9
|
+
# compilation. New checksums are checksums that are in effect right now. If
|
10
|
+
# an old checksum differs from a new checksum, the corresponding object was
|
11
|
+
# modified and will need to be recompiled (along with the objects that
|
12
|
+
# depend on that object).
|
13
|
+
#
|
14
|
+
# @api private
|
15
|
+
class ChecksumStore < ::Nanoc3::Store
|
16
|
+
|
17
|
+
# @option params [Nanoc3::Site] site The site where this checksum store
|
18
|
+
# belongs to
|
19
|
+
def initialize(params={})
|
20
|
+
super('tmp/checksums', 1)
|
21
|
+
|
22
|
+
@site = params[:site] if params.has_key?(:site)
|
23
|
+
|
24
|
+
@new_checksums = {}
|
25
|
+
@old_checksums = {}
|
26
|
+
end
|
27
|
+
|
28
|
+
# Returns the old checksum for the given object. The object must respond
|
29
|
+
# to `#reference` (for example, {Nanoc3::Item#reference},
|
30
|
+
# {Nanoc3::Layout#reference}, {Nanoc3::CodeSnippet#reference}, …).
|
31
|
+
#
|
32
|
+
# @param [#reference] obj The object for which to fetch the old checksum
|
33
|
+
#
|
34
|
+
# @return [String] The old checksum for the given object
|
35
|
+
def old_checksum_for(obj)
|
36
|
+
@old_checksums[obj.reference]
|
37
|
+
end
|
38
|
+
|
39
|
+
# Returns the new checksum for the given object. The object must respond
|
40
|
+
# to `#reference` (for example, {Nanoc3::Item#reference},
|
41
|
+
# {Nanoc3::Layout#reference}, {Nanoc3::CodeSnippet#reference}, …).
|
42
|
+
#
|
43
|
+
# @param [#reference] obj The object for which to calculate the new
|
44
|
+
# checksum
|
45
|
+
#
|
46
|
+
# @return [String] The new checksum for the given object
|
47
|
+
def new_checksum_for(obj)
|
48
|
+
@new_checksums[obj.reference] ||= begin
|
49
|
+
checksum_parts = []
|
50
|
+
|
51
|
+
# Calculate content checksum
|
52
|
+
checksum_parts << if obj.respond_to?(:binary?) && obj.binary?
|
53
|
+
Nanoc3::Checksummer.checksum_for_file(obj.raw_filename)
|
54
|
+
elsif obj.respond_to?(:raw_content)
|
55
|
+
Nanoc3::Checksummer.checksum_for_string(obj.raw_content)
|
56
|
+
elsif obj.respond_to?(:data)
|
57
|
+
Nanoc3::Checksummer.checksum_for_string(obj.data)
|
58
|
+
else
|
59
|
+
raise RuntimeError, "Couldn’t figure out how to calculate the " \
|
60
|
+
"content checksum for #{obj.inspect} (tried #raw_filename, " \
|
61
|
+
"#raw_content and #data but none of these worked)"
|
62
|
+
end
|
63
|
+
|
64
|
+
# Calculate attributes checksum
|
65
|
+
if obj.respond_to?(:attributes)
|
66
|
+
attributes = obj.attributes.dup
|
67
|
+
attributes.delete(:file)
|
68
|
+
checksum_parts << Nanoc3::Checksummer.checksum_for_hash(attributes)
|
69
|
+
end
|
70
|
+
|
71
|
+
# Done
|
72
|
+
checksum_parts.join('-')
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
# Calculates the checksums for all objects in the site. This method should
|
77
|
+
# be used to make the checksum store remember the new checksums for all
|
78
|
+
# given objects; it is probably necessary to call this method before
|
79
|
+
# calling {#store}, to make sure that all new checksums are calculated. It
|
80
|
+
# is not necessary to call this method in order to use
|
81
|
+
# {#new_checksum_for}.
|
82
|
+
#
|
83
|
+
# @return [void]
|
84
|
+
def calculate_all_checksums
|
85
|
+
@site.objects.each { |obj| new_checksum_for(obj) }
|
86
|
+
end
|
87
|
+
|
88
|
+
# @param [#reference] obj
|
89
|
+
#
|
90
|
+
# @return [Boolean] false if either the new or the old checksum for the
|
91
|
+
# given object is not available, true if both checksums are available
|
92
|
+
def checksums_available?(obj)
|
93
|
+
!!old_checksum_for(obj) && !!new_checksum_for(obj)
|
94
|
+
end
|
95
|
+
|
96
|
+
# @param [#reference] obj
|
97
|
+
#
|
98
|
+
# @return [Boolean] false if the old and new checksums for the given
|
99
|
+
# object differ, true if they are identical
|
100
|
+
def checksums_identical?(obj)
|
101
|
+
old_checksum_for(obj) == new_checksum_for(obj)
|
102
|
+
end
|
103
|
+
|
104
|
+
# @param [#reference] obj
|
105
|
+
#
|
106
|
+
# @return [Boolean] true if the old and new checksums for the given object
|
107
|
+
# are available and identical, false otherwise
|
108
|
+
def object_modified?(obj)
|
109
|
+
!checksums_available?(obj) || !checksums_identical?(obj)
|
110
|
+
end
|
111
|
+
|
112
|
+
# @see Nanoc3::Store#store
|
113
|
+
def store
|
114
|
+
calculate_all_checksums
|
115
|
+
super
|
116
|
+
end
|
117
|
+
|
118
|
+
protected
|
119
|
+
|
120
|
+
def data
|
121
|
+
@new_checksums
|
122
|
+
end
|
123
|
+
|
124
|
+
def data=(new_data)
|
125
|
+
@old_checksums = new_data
|
126
|
+
end
|
127
|
+
|
128
|
+
end
|
129
|
+
|
130
|
+
end
|
@@ -0,0 +1,68 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
module Nanoc3
|
4
|
+
|
5
|
+
# Responsible for creating checksums of files. Such checksums are used to
|
6
|
+
# determine whether files have changed between compilations.
|
7
|
+
#
|
8
|
+
# Identical content will always result in the same checksum. Multiple
|
9
|
+
# invocations of the checksum creation methods with the same content or
|
10
|
+
# filename will yield the same result.
|
11
|
+
#
|
12
|
+
# The returned checksum has the property that for two given files with
|
13
|
+
# different content, the returned checksum will be different with a very
|
14
|
+
# high probability. In practice, this boils down to using a secure
|
15
|
+
# cryptographic hash function, such as SHA-1.
|
16
|
+
#
|
17
|
+
# The format of the resulting checksum should not be relied upon. In future
|
18
|
+
# versions of nanoc, this function may use a different method for generating
|
19
|
+
# checksums.
|
20
|
+
#
|
21
|
+
# @api private
|
22
|
+
class Checksummer
|
23
|
+
|
24
|
+
# Returns a checksum for the specified file.
|
25
|
+
#
|
26
|
+
# @param [String] filename The name of the file for which the checksum
|
27
|
+
# should be calculated
|
28
|
+
#
|
29
|
+
# @return [String] The checksum for the given file
|
30
|
+
def self.checksum_for_file(filename)
|
31
|
+
require 'digest'
|
32
|
+
|
33
|
+
digest = Digest::SHA1.new
|
34
|
+
File.open(filename, 'r') do |io|
|
35
|
+
until io.eof
|
36
|
+
data = io.readpartial(2**10)
|
37
|
+
digest.update(data)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
digest.hexdigest
|
41
|
+
end
|
42
|
+
|
43
|
+
# Returns a checksum for the specified string.
|
44
|
+
#
|
45
|
+
# @param [String] string The string for which the checksum should be
|
46
|
+
# calculated
|
47
|
+
#
|
48
|
+
# @return [String] The checksum for the given string
|
49
|
+
def self.checksum_for_string(string)
|
50
|
+
require 'digest'
|
51
|
+
|
52
|
+
digest = Digest::SHA1.new
|
53
|
+
digest.update(string)
|
54
|
+
digest.hexdigest
|
55
|
+
end
|
56
|
+
|
57
|
+
# Returns a checksum for the specified hash.
|
58
|
+
#
|
59
|
+
# @param [Hash] hash The hash for which the checksum should be calculated.
|
60
|
+
#
|
61
|
+
# @return [String] The checksum for the given hash
|
62
|
+
def self.checksum_for_hash(hash)
|
63
|
+
self.checksum_for_string(YAML.dump(hash))
|
64
|
+
end
|
65
|
+
|
66
|
+
end
|
67
|
+
|
68
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
module Nanoc3
|
4
|
+
|
5
|
+
# Represents a cache than can be used to store already compiled content,
|
6
|
+
# to prevent it from being needlessly recompiled.
|
7
|
+
#
|
8
|
+
# @api private
|
9
|
+
class CompiledContentCache < ::Nanoc3::Store
|
10
|
+
|
11
|
+
def initialize
|
12
|
+
super('tmp/compiled_content', 1)
|
13
|
+
|
14
|
+
@cache = {}
|
15
|
+
end
|
16
|
+
|
17
|
+
# Returns the cached compiled content for the given item
|
18
|
+
# representation. This cached compiled content is a hash where the keys
|
19
|
+
# are the snapshot names and the values the compiled content at the
|
20
|
+
# given snapshot.
|
21
|
+
#
|
22
|
+
# @param [Nanoc3::ItemRep] rep The item rep to fetch the content for
|
23
|
+
#
|
24
|
+
# @return [Hash<Symbol,String>] A hash containing the cached compiled
|
25
|
+
# content for the given item representation
|
26
|
+
def [](rep)
|
27
|
+
item_cache = @cache[rep.item.identifier] || {}
|
28
|
+
item_cache[rep.name]
|
29
|
+
end
|
30
|
+
|
31
|
+
# Sets the compiled content for the given representation.
|
32
|
+
#
|
33
|
+
# @param [Nanoc3::ItemRep] rep The item representation for which to set
|
34
|
+
# the compiled content
|
35
|
+
#
|
36
|
+
# @param [Hash<Symbol,String>] content A hash containing the compiled
|
37
|
+
# content of the given representation
|
38
|
+
#
|
39
|
+
# @return [void]
|
40
|
+
def []=(rep, content)
|
41
|
+
@cache[rep.item.identifier] ||= {}
|
42
|
+
@cache[rep.item.identifier][rep.name] = content
|
43
|
+
end
|
44
|
+
|
45
|
+
protected
|
46
|
+
|
47
|
+
def data
|
48
|
+
@cache
|
49
|
+
end
|
50
|
+
|
51
|
+
def data=(new_data)
|
52
|
+
@cache = new_data
|
53
|
+
end
|
54
|
+
|
55
|
+
end
|
56
|
+
|
57
|
+
end
|