nanoc3 3.1.0a2 → 3.1.0a3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (46) hide show
  1. data/LICENSE +1 -1
  2. data/NEWS.md +12 -2
  3. data/README.md +2 -0
  4. data/lib/nanoc3/base/code_snippet.rb +6 -2
  5. data/lib/nanoc3/base/compiler.rb +9 -6
  6. data/lib/nanoc3/base/compiler_dsl.rb +15 -9
  7. data/lib/nanoc3/base/data_source.rb +14 -14
  8. data/lib/nanoc3/base/dependency_tracker.rb +9 -9
  9. data/lib/nanoc3/base/directed_graph.rb +6 -7
  10. data/lib/nanoc3/base/errors.rb +48 -13
  11. data/lib/nanoc3/base/filter.rb +62 -16
  12. data/lib/nanoc3/base/item.rb +63 -20
  13. data/lib/nanoc3/base/item_rep.rb +117 -48
  14. data/lib/nanoc3/base/layout.rb +18 -5
  15. data/lib/nanoc3/base/notification_center.rb +8 -8
  16. data/lib/nanoc3/base/plugin_registry.rb +9 -9
  17. data/lib/nanoc3/base/rule.rb +8 -8
  18. data/lib/nanoc3/base/rule_context.rb +5 -5
  19. data/lib/nanoc3/base/site.rb +33 -29
  20. data/lib/nanoc3/cli/base.rb +1 -1
  21. data/lib/nanoc3/cli/commands/create_site.rb +12 -14
  22. data/lib/nanoc3/cli.rb +0 -1
  23. data/lib/nanoc3/data_sources/filesystem.rb +12 -2
  24. data/lib/nanoc3/data_sources/filesystem_unified.rb +22 -19
  25. data/lib/nanoc3/extra/auto_compiler.rb +12 -3
  26. data/lib/nanoc3/extra/chick.rb +12 -6
  27. data/lib/nanoc3/extra/deployers/rsync.rb +30 -27
  28. data/lib/nanoc3/extra/deployers.rb +0 -1
  29. data/lib/nanoc3/extra/file_proxy.rb +2 -15
  30. data/lib/nanoc3/extra/validators/links.rb +242 -0
  31. data/lib/nanoc3/extra/validators/w3c.rb +49 -25
  32. data/lib/nanoc3/extra/validators.rb +2 -2
  33. data/lib/nanoc3/extra/vcs.rb +1 -1
  34. data/lib/nanoc3/extra.rb +4 -1
  35. data/lib/nanoc3/helpers/blogging.rb +57 -29
  36. data/lib/nanoc3/helpers/breadcrumbs.rb +1 -1
  37. data/lib/nanoc3/helpers/capturing.rb +4 -2
  38. data/lib/nanoc3/helpers/filtering.rb +2 -1
  39. data/lib/nanoc3/helpers/link_to.rb +13 -6
  40. data/lib/nanoc3/helpers/rendering.rb +4 -3
  41. data/lib/nanoc3/helpers/tagging.rb +7 -6
  42. data/lib/nanoc3/helpers/text.rb +2 -2
  43. data/lib/nanoc3/tasks/validate.rake +62 -5
  44. data/lib/nanoc3.rb +2 -2
  45. metadata +23 -11
  46. data/lib/nanoc3/base/core_ext/enumerable.rb +0 -41
@@ -15,9 +15,10 @@ module Nanoc3
15
15
  # A site also has several helper classes:
16
16
  #
17
17
  # * {#data_sources} (array of {Nanoc3::DataSource}) - A list of data sources
18
- # that are used for loading site data
18
+ # that are used for loading site data
19
+ #
19
20
  # * {#compiler} ({Nanoc3::Compiler}) - The compiler that is used for
20
- # compiling items and their representations
21
+ # compiling items and their representations
21
22
  #
22
23
  # The physical representation of a {Nanoc3::Site} is usually a directory
23
24
  # that contains a configuration file, site data, a rakefile, a rules file,
@@ -38,6 +39,7 @@ module Nanoc3
38
39
  # that lacks some options, the default value will be taken from
39
40
  # `DEFAULT_CONFIG`.
40
41
  DEFAULT_CONFIG = {
42
+ :text_extensions => %w( css erb haml htm html less markdown md sass txt ),
41
43
  :output_dir => 'output',
42
44
  :data_sources => [ {} ],
43
45
  :index_filenames => [ 'index.html' ]
@@ -46,55 +48,54 @@ module Nanoc3
46
48
  # The site configuration. The configuration has the following keys:
47
49
  #
48
50
  # * `output_dir` ({String}) - The directory to which compiled items will
49
- # be written. This path is relative to the current working directory,
50
- # but can also be an absolute path.
51
+ # be written. This path is relative to the current working directory,
52
+ # but can also be an absolute path.
51
53
  #
52
54
  # * `data_sources` ({Array<Hash>}) - A list of data sources for this site.
53
- # See below for documentation on the structure of this list. By
54
- # default, there is only one data source of the filesystem type
55
- # mounted at `/`.
55
+ # See below for documentation on the structure of this list. By default,
56
+ # there is only one data source of the filesystem type mounted at `/`.
56
57
  #
57
58
  # * `index_filenames` ({Array<String>}) - A list of filenames that will be
58
- # stripped off full item paths to create cleaner URLs. For example,
59
- # `/about/` will be used instead of `/about/index.html`). The default
60
- # value should be okay in most cases.
59
+ # stripped off full item paths to create cleaner URLs. For example,
60
+ # `/about/` will be used instead of `/about/index.html`). The default
61
+ # value should be okay in most cases.
61
62
  #
62
63
  # The list of data sources consists of hashes with the following keys:
63
64
  #
64
65
  # * `:type` ({String}) - The type of data source, i.e. its identifier.
65
66
  #
66
67
  # * `:items_root` ({String}) - The prefix that should be given to all
67
- # items returned by the {#items} method (comparable to mount points
68
- # for filesystems in Unix-ish OSes).
68
+ # items returned by the {#items} method (comparable to mount points
69
+ # for filesystems in Unix-ish OSes).
69
70
  #
70
71
  # * `:layouts_root` ({String}) - The prefix that should be given to all
71
- # layouts returned by the {#layouts} method (comparable to mount
72
- # points for filesystems in Unix-ish OSes).
72
+ # layouts returned by the {#layouts} method (comparable to mount
73
+ # points for filesystems in Unix-ish OSes).
73
74
  #
74
75
  # * `:config` ({Hash}) - A hash containing the configuration for this data
75
- # source. nanoc itself does not use this hash. This is especially
76
- # useful for online data sources; for example, a Twitter data source
77
- # would need the username of the account from which to fetch tweets.
76
+ # source. nanoc itself does not use this hash. This is especially
77
+ # useful for online data sources; for example, a Twitter data source
78
+ # would need the username of the account from which to fetch tweets.
78
79
  #
79
80
  # @return [Hash] The site configuration
80
81
  attr_reader :config
81
82
 
82
83
  # @return [Time] The timestamp when the site configuration was last
83
- # modified
84
+ # modified
84
85
  attr_reader :config_mtime
85
86
 
86
87
  # @return [Time] The timestamp when the rules were last modified
87
88
  attr_reader :rules_mtime
88
89
 
89
90
  # @return [Proc] The code block that will be executed after all data is
90
- # loaded but before the site is compiled
91
+ # loaded but before the site is compiled
91
92
  attr_accessor :preprocessor
92
93
 
93
94
  # Creates a site object for the site specified by the given
94
95
  # `dir_or_config_hash` argument.
95
96
  #
96
97
  # @param [Hash, String] dir_or_config_hash If a string, contains the path
97
- # to the site directory; if a hash, contains the site configuration.
98
+ # to the site directory; if a hash, contains the site configuration.
98
99
  def initialize(dir_or_config_hash)
99
100
  build_config(dir_or_config_hash)
100
101
 
@@ -115,10 +116,10 @@ module Nanoc3
115
116
  # none exists yet.
116
117
  #
117
118
  # @return [Array<Nanoc3::DataSource>] The list of data sources for this
118
- # site
119
+ # site
119
120
  #
120
121
  # @raise [Nanoc3::Errors::UnknownDataSource] if the site configuration
121
- # specifies an unknown data source
122
+ # specifies an unknown data source
122
123
  def data_sources
123
124
  @data_sources ||= begin
124
125
  @config[:data_sources].map do |data_source_hash|
@@ -128,8 +129,11 @@ module Nanoc3
128
129
 
129
130
  # Warn about deprecated data sources
130
131
  # TODO [in nanoc 4.0] remove me
131
- if data_source_hash[:type] == 'filesystem'
132
- warn "Warning: the 'filesystem' data source has been renamed to 'filesystem_verbose'. Using 'filesystem' will work in nanoc 3.1.x, but it will likely not work anymore in a future release of nanoc. Please update your data source configuration and replace 'filesystem' with 'filesystem_verbose'."
132
+ case data_source_hash[:type]
133
+ when 'filesystem'
134
+ warn "Warning: the 'filesystem' data source has been renamed to 'filesystem_verbose'. Using 'filesystem' will work in nanoc 3.1.x, but it will likely not work anymore in a future release of nanoc. Please update your data source configuration and replace 'filesystem' with 'filesystem_verbose'."
135
+ when 'filesystem_combined', 'filesystem_compact'
136
+ warn "Warning: the 'filesystem_combined' and 'filesystem_compact' data source has been merged into the new 'filesystem_unified' data source. Using 'filesystem_combined' and 'filesystem_compact' will work in nanoc 3.1.x, but it will likely not work anymore in a future release of nanoc. Please update your data source configuration and replace 'filesystem_combined' and 'filesystem_compact with 'filesystem_unified'."
133
137
  end
134
138
 
135
139
  # Create data source
@@ -149,7 +153,7 @@ module Nanoc3
149
153
  # the `force` parameter is true.
150
154
  #
151
155
  # @param [Boolean] force If true, will force load the site data even if it
152
- # has been loaded before, to circumvent caching issues
156
+ # has been loaded before, to circumvent caching issues
153
157
  #
154
158
  # @return [void]
155
159
  def load_data(force=false)
@@ -179,10 +183,10 @@ module Nanoc3
179
183
  # Returns this site’s code snippets.
180
184
  #
181
185
  # @return [Array<Nanoc3::CodeSnippet>] The list of code snippets in this
182
- # site
186
+ # site
183
187
  #
184
188
  # @raise [Nanoc3::Errors::DataNotYetAvailable] if the site data hasn’t
185
- # been loaded yet (call {#load_data} to load the site data)
189
+ # been loaded yet (call {#load_data} to load the site data)
186
190
  def code_snippets
187
191
  raise Nanoc3::Errors::DataNotYetAvailable.new('Code snippets', false) unless @code_snippets_loaded
188
192
  @code_snippets
@@ -193,7 +197,7 @@ module Nanoc3
193
197
  # @return [Array<Nanoc3::Item>] The list of items in this site
194
198
  #
195
199
  # @raise [Nanoc3::Errors::DataNotYetAvailable] if the site data hasn’t
196
- # been loaded yet (call {#load_data} to load the site data)
200
+ # been loaded yet (call {#load_data} to load the site data)
197
201
  def items
198
202
  raise Nanoc3::Errors::DataNotYetAvailable.new('Items', true) unless @items_loaded
199
203
  @items
@@ -204,7 +208,7 @@ module Nanoc3
204
208
  # @return [Array<Nanoc3::Layouts>] The list of layout in this site
205
209
  #
206
210
  # @raise [Nanoc3::Errors::DataNotYetAvailable] if the site data hasn’t
207
- # been loaded yet (call {#load_data} to load the site data)
211
+ # been loaded yet (call {#load_data} to load the site data)
208
212
  def layouts
209
213
  raise Nanoc3::Errors::DataNotYetAvailable.new('Layouts', true) unless @layouts_loaded
210
214
  @layouts
@@ -203,7 +203,7 @@ module Nanoc3::CLI
203
203
  def handle_option(option)
204
204
  case option
205
205
  when :version
206
- puts "nanoc #{Nanoc3::VERSION} (c) 2007-2009 Denis Defreyne."
206
+ puts "nanoc #{Nanoc3::VERSION} (c) 2007-2010 Denis Defreyne."
207
207
  puts "Ruby #{RUBY_VERSION} (#{RUBY_RELEASE_DATE}) running on #{RUBY_PLATFORM}"
208
208
  exit 0
209
209
  when :verbose
@@ -40,13 +40,11 @@ EOS
40
40
  DEFAULT_ITEM = <<EOS
41
41
  <h1>A Brand New nanoc Site</h1>
42
42
 
43
- <p>You’ve just created a new nanoc site. The page you are looking at right now is the home page for your site (and it’s probably the only page).</p>
44
-
45
- <p>To get started, consider replacing this default homepage with your own customized homepage. Some pointers on how to do so:</p>
43
+ <p>You’ve just created a new nanoc site. The page you are looking at right now is the home page for your site. To get started, consider replacing this default homepage with your own customized homepage. Some pointers on how to do so:</p>
46
44
 
47
45
  <ul>
48
- <li><p><strong>Change this page’s content</strong> by editing “content.html” file in the “content” directory. This is the actual page content, and therefore doesn’t include the header, sidebar or style information (those are part of the layout).</p></li>
49
- <li><p><strong>Change the layout</strong>, which is the “default.txt” file in the “layouts/default” directory, and create something unique (and hopefully less bland).</p></li>
46
+ <li><p><strong>Change this page’s content</strong> by editing the index.html” file in the “content” directory. This is the actual page content, and therefore doesn’t include the header, sidebar or style information (those are part of the layout).</p></li>
47
+ <li><p><strong>Change the layout</strong>, which is the “default.html” file in the “layouts” directory, and create something unique (and hopefully less bland).</p></li>
50
48
  </ul>
51
49
 
52
50
  <p>If you need any help with customizing your nanoc web site, be sure to check out the documentation (see sidebar), and be sure to subscribe to the discussion group (also see sidebar). Enjoy!</p>
@@ -155,28 +153,28 @@ a:hover {
155
153
  EOS
156
154
 
157
155
  DEFAULT_LAYOUT = <<EOS
158
- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
159
- <html>
156
+ <!DOCTYPE HTML>
157
+ <html lang="en">
160
158
  <head>
159
+ <meta charset="utf-8">
161
160
  <title>A Brand New nanoc Site - <%= @item[:title] %></title>
162
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
163
161
  <link rel="stylesheet" type="text/css" href="/style.css" media="screen">
164
162
  <meta name="generator" content="nanoc #{Nanoc3::VERSION}">
165
163
  </head>
166
164
  <body>
167
165
  <div id="main">
168
- <%= yield %>
166
+ <%= yield %>
169
167
  </div>
170
168
  <div id="sidebar">
171
169
  <h2>Documentation</h2>
172
170
  <ul>
173
- <li><a href="http://nanoc.stoneship.org/tutorial/">Tutorial</a></li>
174
- <li><a href="http://nanoc.stoneship.org/manual/">Manual</a></li>
171
+ <li><a href="http://nanoc.stoneship.org/docs/">Documentation</a></li>
172
+ <li><a href="http://nanoc.stoneship.org/docs/3-getting-started/">Getting Started</a></li>
175
173
  </ul>
176
174
  <h2>Community</h2>
177
175
  <ul>
178
176
  <li><a href="http://groups.google.com/group/nanoc/">Discussion Group</a></li>
179
- <li><a href="http://groups.google.com/group/nanoc-es/">Spanish Discussion Group</a></li>
177
+ <li><a href="irc://chat.freenode.net/#nanoc">IRC Channel</a></li>
180
178
  <li><a href="http://projects.stoneship.org/trac/nanoc/">Wiki</a></li>
181
179
  </ul>
182
180
  </div>
@@ -198,7 +196,7 @@ EOS
198
196
 
199
197
  def long_desc
200
198
  'Create a new site at the given path. The site will use the ' +
201
- 'filesystem_compact data source by default, but this can be ' +
199
+ 'filesystem_unified data source by default, but this can be ' +
202
200
  'changed using the --datasource commandline option.'
203
201
  end
204
202
 
@@ -225,7 +223,7 @@ EOS
225
223
 
226
224
  # Extract arguments and options
227
225
  path = arguments[0]
228
- data_source = options[:datasource] || 'filesystem_compact'
226
+ data_source = options[:datasource] || 'filesystem_unified'
229
227
 
230
228
  # Check whether site exists
231
229
  if File.exist?(path)
data/lib/nanoc3/cli.rb CHANGED
@@ -3,7 +3,6 @@
3
3
  # Load Cri
4
4
  require 'cri'
5
5
 
6
- # Module for CLI
7
6
  module Nanoc3::CLI
8
7
  end
9
8
 
@@ -81,7 +81,14 @@ module Nanoc3::DataSources
81
81
  content_filename = filename_for(base_filename, content_ext)
82
82
 
83
83
  # Read content and metadata
84
- meta, content = parse(content_filename, meta_filename, kind)
84
+ is_binary = !!(content_filename && !@site.config[:text_extensions].include?(File.extname(content_filename)[1..-1]))
85
+ if is_binary
86
+ meta = (meta_filename && YAML.load_file(meta_filename)) || {}
87
+ content_or_filename = content_filename
88
+ else
89
+ meta, content_or_filename = parse(
90
+ content_filename, meta_filename, kind)
91
+ end
85
92
 
86
93
  # Get attributes
87
94
  attributes = {
@@ -118,7 +125,10 @@ module Nanoc3::DataSources
118
125
  end
119
126
 
120
127
  # Create layout object
121
- klass.new(content, attributes, identifier, mtime)
128
+ klass.new(
129
+ content_or_filename, attributes, identifier,
130
+ :binary => is_binary, :mtime => mtime
131
+ )
122
132
  end
123
133
  end
124
134
 
@@ -14,10 +14,10 @@ module Nanoc3::DataSources
14
14
  # itself can start with a metadata section: it can be stored at the top of
15
15
  # the file, between `---` (three dashes) separators. For example:
16
16
  #
17
- # ---
18
- # title: "Moo!"
19
- # ---
20
- # h1. Hello!
17
+ # ---
18
+ # title: "Moo!"
19
+ # ---
20
+ # h1. Hello!
21
21
  #
22
22
  # The metadata section can be omitted. If the file does not start with
23
23
  # three or five dashes, the entire file will be considered as content.
@@ -26,7 +26,7 @@ module Nanoc3::DataSources
26
26
  # an `index.*` filename, such as `index.txt`, will have the filesystem path
27
27
  # with the `index.*` part stripped as a identifier. For example:
28
28
  #
29
- # foo/bar/index.html → /foo/bar/
29
+ # foo/bar/index.html → /foo/bar/
30
30
  #
31
31
  # In other cases, the identifier is calculated by stripping the extension.
32
32
  # If the `allow_periods_in_identifiers` attribute in the configuration is
@@ -34,24 +34,24 @@ module Nanoc3::DataSources
34
34
  # extensions; if it is false or unset, all extensions will be stripped.
35
35
  # For example:
36
36
  #
37
- # (`allow_periods_in_identifiers` set to true)
38
- # foo.entry.html → /foo.entry/
39
- #
40
- # (`allow_periods_in_identifiers` set to false)
41
- # foo.html.erb → /foo/
37
+ # (`allow_periods_in_identifiers` set to true)
38
+ # foo.entry.html → /foo.entry/
39
+ #
40
+ # (`allow_periods_in_identifiers` set to false)
41
+ # foo.html.erb → /foo/
42
42
  #
43
43
  # Note that it is possible for two different, separate files to have the
44
44
  # same identifier. It is recommended to avoid such situations.
45
45
  #
46
46
  # Some more examples:
47
47
  #
48
- # content/index.html → /
49
- # content/foo.html → /foo/
50
- # content/foo/index.html → /foo/
51
- # content/foo/bar.html → /foo/bar/
52
- # content/foo/bar.baz.html → /foo/bar/ OR /foo/bar.baz/
53
- # content/foo/bar/index.html → /foo/bar/
54
- # content/foo.bar/index.html → /foo.bar/
48
+ # content/index.html → /
49
+ # content/foo.html → /foo/
50
+ # content/foo/index.html → /foo/
51
+ # content/foo/bar.html → /foo/bar/
52
+ # content/foo/bar.baz.html → /foo/bar/ OR /foo/bar.baz/
53
+ # content/foo/bar/index.html → /foo/bar/
54
+ # content/foo.bar/index.html → /foo.bar/
55
55
  #
56
56
  # The file extension does not determine the filters to run on items; the
57
57
  # Rules file is used to specify processing instructors for each item.
@@ -80,8 +80,11 @@ module Nanoc3::DataSources
80
80
  # Write item
81
81
  FileUtils.mkdir_p(parent_path)
82
82
  File.open(path, 'w') do |io|
83
- io.write(YAML.dump(attributes.stringify_keys) + "\n")
84
- io.write("---\n")
83
+ meta = attributes.stringify_keys
84
+ unless meta == {}
85
+ io.write(YAML.dump(meta).strip + "\n")
86
+ io.write("---\n\n")
87
+ end
85
88
  io.write(content)
86
89
  end
87
90
  end
@@ -2,14 +2,16 @@
2
2
 
3
3
  module Nanoc3::Extra
4
4
 
5
- # Nanoc3::Extra::AutoCompiler is a web server that will automatically compile
6
- # items as they are requested. It also serves static files such as
7
- # stylesheets and images.
5
+ # A web server that will automatically compile items as they are requested.
6
+ # It also serves static files such as stylesheets and images.
8
7
  class AutoCompiler
9
8
 
9
+ # @return [Nanoc3::Site] The site this autocompiler belongs to
10
10
  attr_reader :site
11
11
 
12
12
  # Creates a new autocompiler for the given site.
13
+ #
14
+ # @param [String] site_path The path to the site to autocompile
13
15
  def initialize(site_path)
14
16
  require 'rack'
15
17
  require 'mime/types'
@@ -21,6 +23,13 @@ module Nanoc3::Extra
21
23
  @mutex = Mutex.new
22
24
  end
23
25
 
26
+ # Calls the autocompiler. The behaviour of this method is defined by the
27
+ # [Rack specification](http://rack.rubyforge.org/doc/files/SPEC.html).
28
+ #
29
+ # @param [Hash] env The environment, as defined by the Rack specification
30
+ #
31
+ # @return [Array] An array containing the status, the headers, and the
32
+ # body, as defined by the Rack specification
24
33
  def call(env)
25
34
  @mutex.synchronize do
26
35
  # Start with a new site
@@ -4,10 +4,14 @@ require 'rack/cache'
4
4
 
5
5
  module Nanoc3::Extra
6
6
 
7
- # CHiCk is a caching HTTP client that uses Rack::Cache.
7
+ # @deprecated Use a HTTP library such as
8
+ # [Net::HTTP](http://ruby-doc.org/stdlib/libdoc/net/http/rdoc/) or
9
+ # [Curb](http://curb.rubyforge.org/) instead.
8
10
  module CHiCk
9
11
 
10
- # CHiCk::Client provides a simple API for issuing HTTP requests.
12
+ # @deprecated Use a HTTP library such as
13
+ # [Net::HTTP](http://ruby-doc.org/stdlib/libdoc/net/http/rdoc/) or
14
+ # [Curb](http://curb.rubyforge.org/) instead.
11
15
  class Client
12
16
 
13
17
  DEFAULT_OPTIONS = {
@@ -54,8 +58,9 @@ module Nanoc3::Extra
54
58
 
55
59
  end
56
60
 
57
- # CHiCk::CacheController sets the Cache-Control header (and more
58
- # specifically, max-age) to limit the number of necessary requests.
61
+ # @deprecated Use a HTTP library such as
62
+ # [Net::HTTP](http://ruby-doc.org/stdlib/libdoc/net/http/rdoc/) or
63
+ # [Curb](http://curb.rubyforge.org/) instead.
59
64
  class CacheController
60
65
 
61
66
  def initialize(app, options={})
@@ -73,8 +78,9 @@ module Nanoc3::Extra
73
78
 
74
79
  end
75
80
 
76
- # CHiCk::RackClient performs the actual HTTP requests. It does not perform
77
- # any caching.
81
+ # @deprecated Use a HTTP library such as
82
+ # [Net::HTTP](http://ruby-doc.org/stdlib/libdoc/net/http/rdoc/) or
83
+ # [Curb](http://curb.rubyforge.org/) instead.
78
84
  class RackClient
79
85
 
80
86
  METHOD_TO_CLASS_MAPPING = {
@@ -2,9 +2,10 @@
2
2
 
3
3
  module Nanoc3::Extra::Deployers
4
4
 
5
- # Nanoc3::Extra::Deployers::Rsync is a deployer that deploys a site using rsync.
5
+ # A deployer that deploys a site using rsync.
6
6
  class Rsync
7
7
 
8
+ # Default rsync options
8
9
  DEFAULT_OPTIONS = [
9
10
  '-glpPrtvz',
10
11
  '--exclude=".hg"',
@@ -19,40 +20,40 @@ module Nanoc3::Extra::Deployers
19
20
  # The deployment configurations are stored like this in the site's
20
21
  # configuration file:
21
22
  #
22
- # deploy:
23
- # NAME:
24
- # options: [ OPTIONS ]
25
- # dst: "DST"
23
+ # deploy:
24
+ # NAME:
25
+ # options: [ OPTIONS ]
26
+ # dst: "DST"
26
27
  #
27
- # +NAME+ is a unique name for the deployment configuration. By default,
28
- # the deployer will use the deployment configuration named "default".
28
+ # `NAME` is a unique name for the deployment configuration. By default,
29
+ # the deployer will use the deployment configuration named `"default"`.
29
30
  #
30
- # +OPTIONS+ is an array containing options to pass to the rsync
31
- # executable. This is not required; by default, +-glpPrtvz+ and
32
- # +--exclude+s for +.svn+, +.hg+ and +.git+ are used.
31
+ # `OPTIONS` is an array containing options to pass to the rsync
32
+ # executable. This is not required; by default, {DEFAULT_OPTIONS} options
33
+ # will be used.
33
34
  #
34
- # +DST+ is a string containing the destination to where rsync should
35
- # upload its data. It will likely be in +host:path+ format. For example,
36
- # "example.com:/var/www/sites/mysite/html". It should not end with a
35
+ # `DST` is a string containing the destination to where rsync should
36
+ # upload its data. It will likely be in `host:path` format. For example,
37
+ # `"example.com:/var/www/sites/mysite/html"`. It should not end with a
37
38
  # trailing slash.
38
39
  #
39
40
  # Example: This deployment configuration defines a "default" and a
40
41
  # "staging" deployment configuration. The default options are used.
41
42
  #
42
- # deploy:
43
- # default:
44
- # dst: "ectype:sites/stoneship/public"
45
- # staging:
46
- # dst: "ectype:sites/stoneship-staging/public"
47
- # options: [ "-glpPrtvz" ]
43
+ # deploy:
44
+ # default:
45
+ # dst: "ectype:sites/stoneship/public"
46
+ # staging:
47
+ # dst: "ectype:sites/stoneship-staging/public"
48
+ # options: [ "-glpPrtvz" ]
48
49
  #
49
- # When running the deployer with the "default" resp. "staging"
50
+ # When running the deployer with the `default` resp. `staging`
50
51
  # configurations, the following rsync commands will be executed:
51
52
  #
52
- # rsync -glpPrtvz --exclude=".hg" --exclude=".svn"
53
- # --exclude=".git" output ectype:sites/stoneship/public
53
+ # rsync -glpPrtvz --exclude=".hg" --exclude=".svn"
54
+ # --exclude=".git" output ectype:sites/stoneship/public
54
55
  #
55
- # rsync -glpPrtvz output ectype:sites/stoneship-staging/public
56
+ # rsync -glpPrtvz output ectype:sites/stoneship-staging/public
56
57
  def initialize
57
58
  # Get site
58
59
  error 'No site configuration found' unless File.file?('config.yaml')
@@ -61,11 +62,13 @@ module Nanoc3::Extra::Deployers
61
62
 
62
63
  # Runs the task. Possible params:
63
64
  #
64
- # +:dry_run+:: Set to true when the action itself should not be executed,
65
- # but still printed. Useful for debugging.
65
+ # @option params [Boolean] :dry_run (false) True if the action itself
66
+ # should not be executed, but still printed; false otherwise.
66
67
  #
67
- # +:config_name+:: The name of the deployment configuration to use.
68
- # Defaults to +:default+ (surprise!).
68
+ # @option params [String] :config_name (:default) The name of the
69
+ # deployment configuration to use.
70
+ #
71
+ # @return [void]
69
72
  def run(params={})
70
73
  # Extract params
71
74
  config_name = params.has_key?(:config_name) ? params[:config_name].to_sym : :default
@@ -2,7 +2,6 @@
2
2
 
3
3
  module Nanoc3::Extra
4
4
 
5
- # Nanoc3::Extra::Deployers is the name for all deployers.
6
5
  module Deployers
7
6
 
8
7
  autoload 'Rsync', 'nanoc3/extra/deployers/rsync'
@@ -2,37 +2,24 @@
2
2
 
3
3
  module Nanoc3::Extra
4
4
 
5
- # A FileProxy is a proxy for a File object. It is used to prevent a File
6
- # object from being created until it is actually necessary.
7
- #
8
- # For example, a site with a few thousand items would fail to compile
9
- # because the massive amount of file descriptors necessary, but the file
10
- # proxy will make sure the File object is not created until it is used.
5
+ # @deprecated Create a File instance directly and use that instead.
11
6
  class FileProxy
12
7
 
13
8
  instance_methods.each { |m| undef_method m unless m =~ /^__/ || m.to_s == 'object_id' }
14
9
 
15
10
  @@deprecation_warning_shown = false
16
11
 
17
- # Creates a new file proxy for the given path. This is similar to
18
- # creating a File object with the same path, except that the File object
19
- # will not be created until it is accessed.
20
12
  def initialize(path)
21
13
  @path = path
22
14
  end
23
15
 
24
- # Returns true if File instances respond to the given method; false if
25
- # they do not.
26
16
  def respond_to?(meth)
27
17
  File.instance_methods.any? { |m| m == meth.to_s || m == meth.to_sym }
28
18
  end
29
19
 
30
- # Makes sure all method calls are relayed to a File object, which will
31
- # be created right before the method call takes place and destroyed
32
- # right after.
33
20
  def method_missing(sym, *args, &block)
34
21
  if !@@deprecation_warning_shown
35
- $stderr.puts 'WARNING: The :file attribute is deprecated and will be removed in a future version of nanoc. Instead of using this :file attribute, consider manually creating a File object when it’s needed, using the :content_filename or :meta_filename attributes (for filesystem_verbose and filesystem_compact) or :filename (for filesystem_combined).'
22
+ $stderr.puts 'WARNING: The :file attribute is deprecated and will be removed in a future version of nanoc. Instead of using this :file attribute, consider manually creating a File object when it’s needed, using the :content_filename, :meta_filename or :filename attributes.'
36
23
  @@deprecation_warning_shown = true
37
24
  end
38
25