nanoc 3.5.0 → 3.6.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +1 -0
- data/Gemfile.lock +20 -12
- data/NEWS.md +23 -0
- data/README.md +6 -3
- data/doc/yardoc_templates/default/layout/html/footer.erb +16 -7
- data/lib/nanoc.rb +1 -1
- data/lib/nanoc/base.rb +1 -0
- data/lib/nanoc/base/compilation/compiler_dsl.rb +31 -0
- data/lib/nanoc/base/compilation/filter.rb +34 -0
- data/lib/nanoc/base/result_data/item_rep.rb +3 -3
- data/lib/nanoc/base/source_data/code_snippet.rb +1 -1
- data/lib/nanoc/base/source_data/data_source.rb +12 -0
- data/lib/nanoc/base/source_data/item.rb +1 -1
- data/lib/nanoc/base/source_data/item_array.rb +62 -0
- data/lib/nanoc/base/source_data/layout.rb +1 -1
- data/lib/nanoc/base/source_data/site.rb +24 -3
- data/lib/nanoc/cli/cleaning_stream.rb +10 -0
- data/lib/nanoc/cli/command_runner.rb +25 -12
- data/lib/nanoc/cli/commands/autocompile.rb +5 -3
- data/lib/nanoc/cli/commands/check.rb +9 -1
- data/lib/nanoc/cli/commands/compile.rb +1 -1
- data/lib/nanoc/cli/commands/create-site.rb +5 -5
- data/lib/nanoc/cli/commands/prune.rb +1 -1
- data/lib/nanoc/cli/commands/shell.rb +37 -0
- data/lib/nanoc/cli/commands/show-data.rb +1 -1
- data/lib/nanoc/cli/commands/sync.rb +34 -0
- data/lib/nanoc/cli/error_handler.rb +11 -2
- data/lib/nanoc/extra/checking/checks/stale.rb +10 -2
- data/lib/nanoc/extra/pruner.rb +14 -11
- data/lib/nanoc/filters/asciidoc.rb +2 -2
- data/lib/nanoc/filters/bluecloth.rb +2 -2
- data/lib/nanoc/filters/coderay.rb +2 -2
- data/lib/nanoc/filters/coffeescript.rb +2 -2
- data/lib/nanoc/filters/colorize_syntax.rb +2 -4
- data/lib/nanoc/filters/erb.rb +2 -2
- data/lib/nanoc/filters/erubis.rb +2 -2
- data/lib/nanoc/filters/haml.rb +2 -2
- data/lib/nanoc/filters/handlebars.rb +2 -2
- data/lib/nanoc/filters/kramdown.rb +2 -2
- data/lib/nanoc/filters/less.rb +2 -2
- data/lib/nanoc/filters/markaby.rb +2 -2
- data/lib/nanoc/filters/maruku.rb +2 -2
- data/lib/nanoc/filters/mustache.rb +2 -2
- data/lib/nanoc/filters/pandoc.rb +2 -2
- data/lib/nanoc/filters/rainpress.rb +2 -2
- data/lib/nanoc/filters/rdiscount.rb +2 -2
- data/lib/nanoc/filters/rdoc.rb +3 -17
- data/lib/nanoc/filters/redcarpet.rb +7 -3
- data/lib/nanoc/filters/redcloth.rb +2 -2
- data/lib/nanoc/filters/rubypants.rb +2 -2
- data/lib/nanoc/filters/sass.rb +2 -3
- data/lib/nanoc/filters/slim.rb +2 -2
- data/lib/nanoc/filters/typogruby.rb +2 -2
- data/lib/nanoc/filters/uglify_js.rb +2 -2
- data/lib/nanoc/filters/xsl.rb +2 -1
- data/lib/nanoc/filters/yui_compressor.rb +2 -2
- data/lib/nanoc/helpers/blogging.rb +1 -1
- data/lib/nanoc/helpers/filtering.rb +1 -1
- data/lib/nanoc/helpers/rendering.rb +1 -1
- data/nanoc.gemspec +2 -2
- data/test/base/core_ext/array_spec.rb +4 -12
- data/test/base/core_ext/hash_spec.rb +4 -12
- data/test/base/test_compiler_dsl.rb +63 -0
- data/test/base/test_item.rb +3 -18
- data/test/base/test_item_array.rb +336 -0
- data/test/base/test_item_rep.rb +2 -12
- data/test/base/test_layout.rb +1 -6
- data/test/base/test_outdatedness_checker.rb +1 -1
- data/test/base/test_site.rb +9 -3
- data/test/cli/commands/test_check.rb +22 -0
- data/test/cli/commands/test_compile.rb +2 -2
- data/test/cli/commands/test_deploy.rb +6 -6
- data/test/cli/commands/test_prune.rb +23 -4
- data/test/cli/commands/test_sync.rb +31 -0
- data/test/cli/test_error_handler.rb +16 -11
- data/test/extra/checking/checks/test_stale.rb +24 -1
- data/test/extra/test_auto_compiler.rb +4 -4
- data/test/filters/test_asciidoc.rb +1 -1
- data/test/filters/test_bluecloth.rb +1 -1
- data/test/filters/test_coderay.rb +3 -3
- data/test/filters/test_coffeescript.rb +1 -1
- data/test/filters/test_colorize_syntax.rb +20 -20
- data/test/filters/test_erb.rb +10 -10
- data/test/filters/test_erubis.rb +6 -6
- data/test/filters/test_haml.rb +10 -10
- data/test/filters/test_handlebars.rb +3 -3
- data/test/filters/test_kramdown.rb +1 -1
- data/test/filters/test_less.rb +4 -4
- data/test/filters/test_markaby.rb +1 -1
- data/test/filters/test_maruku.rb +1 -1
- data/test/filters/test_mustache.rb +2 -2
- data/test/filters/test_pandoc.rb +1 -1
- data/test/filters/test_rainpress.rb +2 -2
- data/test/filters/test_rdiscount.rb +2 -2
- data/test/filters/test_rdoc.rb +1 -1
- data/test/filters/test_redcarpet.rb +21 -6
- data/test/filters/test_redcloth.rb +3 -3
- data/test/filters/test_relativize_paths.rb +27 -27
- data/test/filters/test_rubypants.rb +1 -1
- data/test/filters/test_sass.rb +8 -8
- data/test/filters/test_slim.rb +4 -4
- data/test/filters/test_typogruby.rb +1 -1
- data/test/filters/test_uglify_js.rb +2 -2
- data/test/filters/test_xsl.rb +2 -2
- data/test/filters/test_yui_compressor.rb +3 -3
- data/test/helper.rb +6 -1
- metadata +12 -6
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
nanoc (3.
|
5
|
-
cri (~> 2.
|
4
|
+
nanoc (3.6.0)
|
5
|
+
cri (~> 2.3)
|
6
6
|
|
7
7
|
GEM
|
8
8
|
remote: http://rubygems.org/
|
@@ -36,11 +36,12 @@ GEM
|
|
36
36
|
nokogiri (~> 1.5.0)
|
37
37
|
ruby-hmac
|
38
38
|
formatador (0.2.4)
|
39
|
-
haml (
|
39
|
+
haml (4.0.0)
|
40
|
+
tilt
|
40
41
|
handlebars (0.3.2)
|
41
42
|
commonjs (~> 0.2.3)
|
42
43
|
therubyracer (~> 0.11.1)
|
43
|
-
json (1.7.
|
44
|
+
json (1.7.7)
|
44
45
|
kramdown (0.14.2)
|
45
46
|
less (2.2.2)
|
46
47
|
commonjs (~> 0.2.6)
|
@@ -51,26 +52,31 @@ GEM
|
|
51
52
|
maruku (0.6.1)
|
52
53
|
syntax (>= 1.0.0)
|
53
54
|
metaclass (0.0.1)
|
54
|
-
|
55
|
-
|
55
|
+
method_source (0.8.1)
|
56
|
+
mime-types (1.21)
|
57
|
+
minitest (4.6.1)
|
56
58
|
mocha (0.13.2)
|
57
59
|
metaclass (~> 0.0.1)
|
58
|
-
multi_json (1.
|
60
|
+
multi_json (1.6.1)
|
59
61
|
mustache (0.99.4)
|
60
62
|
net-scp (1.0.4)
|
61
63
|
net-ssh (>= 1.99.1)
|
62
|
-
net-ssh (2.6.
|
64
|
+
net-ssh (2.6.5)
|
63
65
|
nokogiri (1.5.6)
|
64
66
|
pandoc-ruby (0.6.0)
|
65
67
|
posix-spawn (0.3.6)
|
68
|
+
pry (0.9.12)
|
69
|
+
coderay (~> 1.0.5)
|
70
|
+
method_source (~> 0.8)
|
71
|
+
slop (~> 3.4)
|
66
72
|
pygments.rb (0.3.7)
|
67
73
|
posix-spawn (~> 0.3.6)
|
68
74
|
yajl-ruby (~> 1.1.0)
|
69
|
-
rack (1.5.
|
75
|
+
rack (1.5.2)
|
70
76
|
rainpress (1.0)
|
71
77
|
rake (10.0.3)
|
72
|
-
rdiscount (
|
73
|
-
rdoc (3.12)
|
78
|
+
rdiscount (2.0.7)
|
79
|
+
rdoc (3.12.1)
|
74
80
|
json (~> 1.4)
|
75
81
|
redcarpet (2.2.2)
|
76
82
|
ref (1.0.2)
|
@@ -80,6 +86,7 @@ GEM
|
|
80
86
|
slim (1.3.6)
|
81
87
|
temple (~> 0.5.5)
|
82
88
|
tilt (~> 1.3.3)
|
89
|
+
slop (3.4.3)
|
83
90
|
syntax (1.0.0)
|
84
91
|
systemu (2.5.2)
|
85
92
|
temple (0.5.5)
|
@@ -96,7 +103,7 @@ GEM
|
|
96
103
|
json
|
97
104
|
nokogiri
|
98
105
|
yajl-ruby (1.1.0)
|
99
|
-
yard (0.8.
|
106
|
+
yard (0.8.4.1)
|
100
107
|
yuicompressor (1.2.0)
|
101
108
|
|
102
109
|
PLATFORMS
|
@@ -125,6 +132,7 @@ DEPENDENCIES
|
|
125
132
|
nanoc!
|
126
133
|
nokogiri (~> 1.5.5)
|
127
134
|
pandoc-ruby
|
135
|
+
pry
|
128
136
|
pygments.rb
|
129
137
|
rack
|
130
138
|
rainpress
|
data/NEWS.md
CHANGED
@@ -1,5 +1,28 @@
|
|
1
1
|
# nanoc news
|
2
2
|
|
3
|
+
## 3.6 (2013-02-24)
|
4
|
+
|
5
|
+
Features:
|
6
|
+
|
7
|
+
* Added `sync` command, allowing data sources to update local caches of
|
8
|
+
external data [Justin Hileman]
|
9
|
+
* Added `#ignore` compiler DSL method
|
10
|
+
* Allowed accessing items by identifier using e.g. `@items['/about/']`
|
11
|
+
* Added `shell` command
|
12
|
+
|
13
|
+
Enhancements:
|
14
|
+
|
15
|
+
* Renamed the nanoc configuration file from `config.yaml` to `nanoc.yaml`
|
16
|
+
|
17
|
+
Fixes:
|
18
|
+
|
19
|
+
* Updated references to old web site and old repository
|
20
|
+
* Made `require` errors mention Bundler if appropriate
|
21
|
+
* Fixed bug which caused pruner not to delete directories in some cases [@reima]
|
22
|
+
* Made `check` command exit with the proper exit status
|
23
|
+
* Added support for the `HTML_TOC` Redcarpet renderer
|
24
|
+
* Made `stale` check honor files excluded by the pruner
|
25
|
+
|
3
26
|
## 3.5 (2013-01-27)
|
4
27
|
|
5
28
|
Major changes:
|
data/README.md
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
[![Build Status](https://travis-ci.org/nanoc/nanoc.png)](https://travis-ci.org/nanoc/nanoc)
|
2
|
+
[![Code Climate](https://codeclimate.com/badge.png)](https://codeclimate.com/github/nanoc/nanoc)
|
3
|
+
|
4
|
+
**Please take a moment and [donate](http://pledgie.com/campaigns/9282) to nanoc. A lot of time has gone into developing nanoc, and I would like to keep the current pace. Your support will ensure that nanoc will continue to improve.**
|
5
|
+
|
1
6
|
# nanoc 3
|
2
7
|
|
3
8
|
nanoc is a simple but very flexible static site generator written in Ruby.
|
@@ -9,9 +14,7 @@ Note: This documentation looks best with Yardoc, not RDoc.
|
|
9
14
|
|
10
15
|
## Resources
|
11
16
|
|
12
|
-
The [nanoc web site](http://nanoc.
|
13
|
-
resources to help you get started with nanoc. If you need further assistance,
|
14
|
-
the following places will help you out:
|
17
|
+
The [nanoc web site](http://nanoc.ws) contains a few useful resources to help you get started with nanoc. If you need further assistance, the following places will help you out:
|
15
18
|
|
16
19
|
* The [discussion group](http://groups.google.com/group/nanoc)
|
17
20
|
* The [IRC channel](irc://chat.freenode.net/#nanoc)
|
@@ -1,10 +1,19 @@
|
|
1
1
|
<%= superb %>
|
2
2
|
<script type="text/javascript">
|
3
|
-
var
|
4
|
-
|
3
|
+
var _gaq = _gaq || [];
|
4
|
+
var pluginUrl = '//www.google-analytics.com/plugins/ga/inpage_linkid.js';
|
5
|
+
_gaq.push(['_require', 'inpage_linkid', pluginUrl]);
|
6
|
+
_gaq.push(['_setAccount', 'UA-15639968-1']);
|
7
|
+
_gaq.push(['_setDomainName', 'nanoc.ws']);
|
8
|
+
_gaq.push(['_setAllowLinker', true]);
|
9
|
+
_gaq.push(['_trackPageview']);
|
10
|
+
|
11
|
+
(function() {
|
12
|
+
var ga = document.createElement('script');
|
13
|
+
ga.type = 'text/javascript';
|
14
|
+
ga.async = true;
|
15
|
+
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
|
16
|
+
var s = document.getElementsByTagName('script')[0];
|
17
|
+
s.parentNode.insertBefore(ga, s);
|
18
|
+
})();
|
5
19
|
</script>
|
6
|
-
<script type="text/javascript">
|
7
|
-
try {
|
8
|
-
var pageTracker = _gat._getTracker("UA-15639968-1");
|
9
|
-
pageTracker._trackPageview();
|
10
|
-
} catch(err) {}</script>
|
data/lib/nanoc.rb
CHANGED
data/lib/nanoc/base.rb
CHANGED
@@ -19,6 +19,7 @@ module Nanoc
|
|
19
19
|
autoload 'Configuration', 'nanoc/base/source_data/configuration'
|
20
20
|
autoload 'DataSource', 'nanoc/base/source_data/data_source'
|
21
21
|
autoload 'Item', 'nanoc/base/source_data/item'
|
22
|
+
autoload 'ItemArray', 'nanoc/base/source_data/item_array'
|
22
23
|
autoload 'Layout', 'nanoc/base/source_data/layout'
|
23
24
|
autoload 'Site', 'nanoc/base/source_data/site'
|
24
25
|
|
@@ -190,6 +190,37 @@ module Nanoc
|
|
190
190
|
@rules_collection.add_item_routing_rule(routing_rule)
|
191
191
|
end
|
192
192
|
|
193
|
+
# Creates a pair of compilation and routing rules that indicate that the
|
194
|
+
# specified item(s) should be ignored, e.g. compiled and routed with an
|
195
|
+
# empty rule. The items are selected using an identifier, which may either
|
196
|
+
# be a string containing the `*` wildcard, or a regular expression.
|
197
|
+
#
|
198
|
+
# This meta-rule will be applicable to reps with a name equal to
|
199
|
+
# `:default`; this can be changed by giving an explicit `:rep` parameter.
|
200
|
+
#
|
201
|
+
# @param [String] identifier A pattern matching identifiers of items that
|
202
|
+
# should be processed using this meta-rule
|
203
|
+
#
|
204
|
+
# @option params [Symbol] :rep (:default) The name of the representation
|
205
|
+
# that should be routed using this rule
|
206
|
+
#
|
207
|
+
# @return [void]
|
208
|
+
#
|
209
|
+
# @example Suppressing compilation and output for all all `/foo/*` items.
|
210
|
+
#
|
211
|
+
# ignore '/foo/*'
|
212
|
+
def ignore(identifier, params={})
|
213
|
+
raise ArgumentError.new("#ignore does not require a block") if block_given?
|
214
|
+
|
215
|
+
rep_name = params[:rep] || :default
|
216
|
+
|
217
|
+
compilation_rule = Rule.new(identifier_to_regex(identifier), rep_name, proc { })
|
218
|
+
@rules_collection.add_item_compilation_rule(compilation_rule)
|
219
|
+
|
220
|
+
routing_rule = Rule.new(identifier_to_regex(identifier), rep_name, proc { }, :snapshot_name => :last)
|
221
|
+
@rules_collection.add_item_routing_rule(routing_rule)
|
222
|
+
end
|
223
|
+
|
193
224
|
# Includes an additional rules file in the current rules collection.
|
194
225
|
#
|
195
226
|
# @param [String] name The name of the rules file — an ".rb" extension is
|
@@ -77,6 +77,31 @@ module Nanoc
|
|
77
77
|
(@to || :text) == :binary
|
78
78
|
end
|
79
79
|
|
80
|
+
# @overload requires(*requires)
|
81
|
+
# Sets the required libraries for this filter.
|
82
|
+
# @param [Array<String>] requires A list of library names that are required
|
83
|
+
# @return [void]
|
84
|
+
# @overload requires
|
85
|
+
# Returns the required libraries for this filter.
|
86
|
+
# @return [Enumerable<String>] This filter’s list of library names that are required
|
87
|
+
def requires(*requires)
|
88
|
+
if requires.size > 0
|
89
|
+
@requires = requires
|
90
|
+
else
|
91
|
+
@requires || []
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
# Requires the filter’s required library if necessary.
|
96
|
+
#
|
97
|
+
# @return [void]
|
98
|
+
def setup
|
99
|
+
@setup ||= begin
|
100
|
+
self.requires.each { |r| require r }
|
101
|
+
true
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
80
105
|
end
|
81
106
|
|
82
107
|
# Creates a new filter that has access to the given assigns.
|
@@ -88,6 +113,15 @@ module Nanoc
|
|
88
113
|
super
|
89
114
|
end
|
90
115
|
|
116
|
+
# Sets up the filter and runs the filter. This method passes its arguments
|
117
|
+
# to {#run} unchanged and returns the return value from {#run}.
|
118
|
+
#
|
119
|
+
# @see {#run}
|
120
|
+
def setup_and_run(*args)
|
121
|
+
self.class.setup
|
122
|
+
self.run(*args)
|
123
|
+
end
|
124
|
+
|
91
125
|
# Runs the filter on the given content or filename.
|
92
126
|
#
|
93
127
|
# @abstract
|
@@ -333,7 +333,7 @@ module Nanoc
|
|
333
333
|
|
334
334
|
# Run filter
|
335
335
|
source = self.binary? ? temporary_filenames[:last] : @content[:last]
|
336
|
-
result = filter.
|
336
|
+
result = filter.setup_and_run(source, filter_args)
|
337
337
|
if klass.to_binary?
|
338
338
|
temporary_filenames[:last] = filter.output_filename
|
339
339
|
else
|
@@ -398,7 +398,7 @@ module Nanoc
|
|
398
398
|
Nanoc::NotificationCenter.post(:filtering_started, self, filter_name)
|
399
399
|
|
400
400
|
# Layout
|
401
|
-
@content[:last] = filter.
|
401
|
+
@content[:last] = filter.setup_and_run(layout.raw_content, filter_args)
|
402
402
|
|
403
403
|
# Create "post" snapshot
|
404
404
|
snapshot(:post, :final => false)
|
@@ -458,7 +458,7 @@ module Nanoc
|
|
458
458
|
end
|
459
459
|
|
460
460
|
def inspect
|
461
|
-
"<#{self.class} name
|
461
|
+
"<#{self.class} name=\"#{self.name}\" binary=#{self.binary?} raw_path=\"#{self.raw_path}\" item.identifier=\"#{self.item.identifier}\">"
|
462
462
|
end
|
463
463
|
|
464
464
|
private
|
@@ -148,6 +148,18 @@ module Nanoc
|
|
148
148
|
def update
|
149
149
|
end
|
150
150
|
|
151
|
+
# Sync the content for this data source with an external source.
|
152
|
+
# This method is called by the `nanoc sync` command so that data sources may
|
153
|
+
# update local caches of external data, such as items fetched from
|
154
|
+
# third-party APIs.
|
155
|
+
#
|
156
|
+
# Subclasses may override this method, but are not required to do so; the
|
157
|
+
# default implementation simply does nothing.
|
158
|
+
#
|
159
|
+
# @return [void]
|
160
|
+
def sync
|
161
|
+
end
|
162
|
+
|
151
163
|
# Returns the list of items (represented by {Nanoc::Item}) in this site.
|
152
164
|
# The default implementation simply returns an empty array.
|
153
165
|
#
|
@@ -240,7 +240,7 @@ module Nanoc
|
|
240
240
|
end
|
241
241
|
|
242
242
|
def inspect
|
243
|
-
"<#{self.class} identifier
|
243
|
+
"<#{self.class} identifier=\"#{self.identifier}\" binary?=#{self.binary?}>"
|
244
244
|
end
|
245
245
|
|
246
246
|
# @return [String] The checksum for this object. If its contents change,
|
@@ -0,0 +1,62 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
module Nanoc
|
4
|
+
|
5
|
+
# Acts as an array, but allows fetching items using identifiers, e.g. `@items['/blah/']`.
|
6
|
+
class ItemArray
|
7
|
+
|
8
|
+
include Enumerable
|
9
|
+
|
10
|
+
extend Forwardable
|
11
|
+
|
12
|
+
DELEGATED_METHODS = Array.instance_methods + Enumerable.instance_methods - [ :[], :slice, :at, :initialize, :freeze ]
|
13
|
+
def_delegators :@items, *DELEGATED_METHODS
|
14
|
+
|
15
|
+
def initialize
|
16
|
+
@items = []
|
17
|
+
end
|
18
|
+
|
19
|
+
def freeze
|
20
|
+
@items.freeze
|
21
|
+
self.build_mapping
|
22
|
+
super
|
23
|
+
end
|
24
|
+
|
25
|
+
def [](*args)
|
26
|
+
if 1 == args.size && args.first.is_a?(String)
|
27
|
+
self.item_with_identifier(args.first)
|
28
|
+
else
|
29
|
+
@items[*args]
|
30
|
+
end
|
31
|
+
end
|
32
|
+
alias_method :slice, :[]
|
33
|
+
|
34
|
+
def at(arg)
|
35
|
+
if arg.is_a?(String)
|
36
|
+
self.item_with_identifier(arg)
|
37
|
+
else
|
38
|
+
@items[arg]
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
protected
|
43
|
+
|
44
|
+
def item_with_identifier(identifier)
|
45
|
+
if self.frozen?
|
46
|
+
@mapping[identifier]
|
47
|
+
else
|
48
|
+
@items.find { |i| i.identifier == identifier }
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
def build_mapping
|
53
|
+
@mapping = {}
|
54
|
+
@items.each do |item|
|
55
|
+
@mapping[item.identifier] = item
|
56
|
+
end
|
57
|
+
@mapping.freeze
|
58
|
+
end
|
59
|
+
|
60
|
+
end
|
61
|
+
|
62
|
+
end
|
@@ -277,6 +277,21 @@ module Nanoc
|
|
277
277
|
@unloading = false
|
278
278
|
end
|
279
279
|
|
280
|
+
# @return [Boolean] true if the current working directory is a nanoc site, false otherwise
|
281
|
+
#
|
282
|
+
# @api private
|
283
|
+
def self.cwd_is_nanoc_site?
|
284
|
+
!self.config_filename_for_cwd.nil?
|
285
|
+
end
|
286
|
+
|
287
|
+
# @return [String] filename of the nanoc config file in the current working directory, or nil if there is none
|
288
|
+
#
|
289
|
+
# @api private
|
290
|
+
def self.config_filename_for_cwd
|
291
|
+
filenames = %w( nanoc.yaml config.yaml )
|
292
|
+
filenames.find { |f| File.file?(f) }
|
293
|
+
end
|
294
|
+
|
280
295
|
private
|
281
296
|
|
282
297
|
# Loads this site’s code and executes it.
|
@@ -305,7 +320,7 @@ module Nanoc
|
|
305
320
|
@items_loaded = true
|
306
321
|
|
307
322
|
# Get items
|
308
|
-
@items =
|
323
|
+
@items = Nanoc::ItemArray.new
|
309
324
|
data_sources.each do |ds|
|
310
325
|
items_in_ds = ds.items
|
311
326
|
items_in_ds.each do |i|
|
@@ -340,8 +355,14 @@ module Nanoc
|
|
340
355
|
warn 'WARNING: Calling Nanoc::Site.new with a directory that is not the current working directory is not supported. It is recommended to change the directory before calling Nanoc::Site.new. For example, instead of Nanoc::Site.new(\'abc\'), use Dir.chdir(\'abc\') { Nanoc::Site.new(\'.\') }.'
|
341
356
|
end
|
342
357
|
|
343
|
-
# Read config from config.yaml in given dir
|
344
|
-
config_path =
|
358
|
+
# Read config from nanoc.yaml/config.yaml in given dir
|
359
|
+
config_path = Dir.chdir(dir_or_config_hash) do
|
360
|
+
filename = self.class.config_filename_for_cwd
|
361
|
+
if filename.nil?
|
362
|
+
raise Nanoc::Errors::GenericTrivial, 'Could not find nanoc.yaml or config.yaml in the current working directory'
|
363
|
+
end
|
364
|
+
File.join(dir_or_config_hash, filename)
|
365
|
+
end
|
345
366
|
@config = DEFAULT_CONFIG.merge(YAML.load_file(config_path).symbolize_keys_recursively)
|
346
367
|
@config[:data_sources].map! { |ds| ds.symbolize_keys_recursively }
|
347
368
|
else
|