nanoc3 3.2.4 → 3.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (211) hide show
  1. metadata +14 -313
  2. data/.gemtest +0 -0
  3. data/ChangeLog +0 -3
  4. data/Gemfile +0 -29
  5. data/LICENSE +0 -19
  6. data/NEWS.md +0 -449
  7. data/README.md +0 -108
  8. data/Rakefile +0 -14
  9. data/bin/nanoc3 +0 -12
  10. data/doc/yardoc_templates/default/layout/html/footer.erb +0 -10
  11. data/lib/nanoc3.rb +0 -28
  12. data/lib/nanoc3/base.rb +0 -49
  13. data/lib/nanoc3/base/compilation/checksum_store.rb +0 -57
  14. data/lib/nanoc3/base/compilation/compiled_content_cache.rb +0 -62
  15. data/lib/nanoc3/base/compilation/compiler.rb +0 -455
  16. data/lib/nanoc3/base/compilation/compiler_dsl.rb +0 -214
  17. data/lib/nanoc3/base/compilation/dependency_tracker.rb +0 -196
  18. data/lib/nanoc3/base/compilation/filter.rb +0 -165
  19. data/lib/nanoc3/base/compilation/item_rep_proxy.rb +0 -102
  20. data/lib/nanoc3/base/compilation/item_rep_recorder_proxy.rb +0 -88
  21. data/lib/nanoc3/base/compilation/outdatedness_checker.rb +0 -223
  22. data/lib/nanoc3/base/compilation/outdatedness_reasons.rb +0 -46
  23. data/lib/nanoc3/base/compilation/rule.rb +0 -73
  24. data/lib/nanoc3/base/compilation/rule_context.rb +0 -84
  25. data/lib/nanoc3/base/compilation/rule_memory_calculator.rb +0 -40
  26. data/lib/nanoc3/base/compilation/rule_memory_store.rb +0 -53
  27. data/lib/nanoc3/base/compilation/rules_collection.rb +0 -231
  28. data/lib/nanoc3/base/context.rb +0 -47
  29. data/lib/nanoc3/base/core_ext.rb +0 -6
  30. data/lib/nanoc3/base/core_ext/array.rb +0 -62
  31. data/lib/nanoc3/base/core_ext/hash.rb +0 -63
  32. data/lib/nanoc3/base/core_ext/pathname.rb +0 -26
  33. data/lib/nanoc3/base/core_ext/string.rb +0 -46
  34. data/lib/nanoc3/base/directed_graph.rb +0 -275
  35. data/lib/nanoc3/base/errors.rb +0 -174
  36. data/lib/nanoc3/base/memoization.rb +0 -67
  37. data/lib/nanoc3/base/notification_center.rb +0 -84
  38. data/lib/nanoc3/base/ordered_hash.rb +0 -200
  39. data/lib/nanoc3/base/plugin_registry.rb +0 -165
  40. data/lib/nanoc3/base/result_data/item_rep.rb +0 -488
  41. data/lib/nanoc3/base/source_data/code_snippet.rb +0 -58
  42. data/lib/nanoc3/base/source_data/configuration.rb +0 -24
  43. data/lib/nanoc3/base/source_data/data_source.rb +0 -234
  44. data/lib/nanoc3/base/source_data/item.rb +0 -301
  45. data/lib/nanoc3/base/source_data/layout.rb +0 -130
  46. data/lib/nanoc3/base/source_data/site.rb +0 -361
  47. data/lib/nanoc3/base/store.rb +0 -135
  48. data/lib/nanoc3/cli.rb +0 -133
  49. data/lib/nanoc3/cli/command.rb +0 -139
  50. data/lib/nanoc3/cli/commands/autocompile.rb +0 -60
  51. data/lib/nanoc3/cli/commands/compile.rb +0 -280
  52. data/lib/nanoc3/cli/commands/create_item.rb +0 -62
  53. data/lib/nanoc3/cli/commands/create_layout.rb +0 -75
  54. data/lib/nanoc3/cli/commands/create_site.rb +0 -410
  55. data/lib/nanoc3/cli/commands/debug.rb +0 -119
  56. data/lib/nanoc3/cli/commands/info.rb +0 -98
  57. data/lib/nanoc3/cli/commands/nanoc.rb +0 -37
  58. data/lib/nanoc3/cli/commands/update.rb +0 -72
  59. data/lib/nanoc3/cli/commands/view.rb +0 -84
  60. data/lib/nanoc3/cli/commands/watch.rb +0 -125
  61. data/lib/nanoc3/cli/error_handler.rb +0 -193
  62. data/lib/nanoc3/cli/logger.rb +0 -91
  63. data/lib/nanoc3/data_sources.rb +0 -29
  64. data/lib/nanoc3/data_sources/deprecated/delicious.rb +0 -42
  65. data/lib/nanoc3/data_sources/deprecated/last_fm.rb +0 -87
  66. data/lib/nanoc3/data_sources/deprecated/twitter.rb +0 -38
  67. data/lib/nanoc3/data_sources/filesystem.rb +0 -299
  68. data/lib/nanoc3/data_sources/filesystem_unified.rb +0 -116
  69. data/lib/nanoc3/data_sources/filesystem_verbose.rb +0 -86
  70. data/lib/nanoc3/extra.rb +0 -22
  71. data/lib/nanoc3/extra/auto_compiler.rb +0 -103
  72. data/lib/nanoc3/extra/chick.rb +0 -125
  73. data/lib/nanoc3/extra/core_ext.rb +0 -4
  74. data/lib/nanoc3/extra/core_ext/enumerable.rb +0 -33
  75. data/lib/nanoc3/extra/core_ext/time.rb +0 -19
  76. data/lib/nanoc3/extra/deployers.rb +0 -11
  77. data/lib/nanoc3/extra/deployers/rsync.rb +0 -114
  78. data/lib/nanoc3/extra/file_proxy.rb +0 -40
  79. data/lib/nanoc3/extra/validators.rb +0 -12
  80. data/lib/nanoc3/extra/validators/links.rb +0 -264
  81. data/lib/nanoc3/extra/validators/w3c.rb +0 -95
  82. data/lib/nanoc3/extra/vcs.rb +0 -66
  83. data/lib/nanoc3/extra/vcses.rb +0 -17
  84. data/lib/nanoc3/extra/vcses/bazaar.rb +0 -25
  85. data/lib/nanoc3/extra/vcses/dummy.rb +0 -24
  86. data/lib/nanoc3/extra/vcses/git.rb +0 -25
  87. data/lib/nanoc3/extra/vcses/mercurial.rb +0 -25
  88. data/lib/nanoc3/extra/vcses/subversion.rb +0 -25
  89. data/lib/nanoc3/filters.rb +0 -53
  90. data/lib/nanoc3/filters/asciidoc.rb +0 -38
  91. data/lib/nanoc3/filters/bluecloth.rb +0 -19
  92. data/lib/nanoc3/filters/coderay.rb +0 -21
  93. data/lib/nanoc3/filters/colorize_syntax.rb +0 -261
  94. data/lib/nanoc3/filters/erb.rb +0 -35
  95. data/lib/nanoc3/filters/erubis.rb +0 -27
  96. data/lib/nanoc3/filters/haml.rb +0 -27
  97. data/lib/nanoc3/filters/kramdown.rb +0 -20
  98. data/lib/nanoc3/filters/less.rb +0 -53
  99. data/lib/nanoc3/filters/markaby.rb +0 -20
  100. data/lib/nanoc3/filters/maruku.rb +0 -20
  101. data/lib/nanoc3/filters/mustache.rb +0 -24
  102. data/lib/nanoc3/filters/rainpress.rb +0 -19
  103. data/lib/nanoc3/filters/rdiscount.rb +0 -22
  104. data/lib/nanoc3/filters/rdoc.rb +0 -33
  105. data/lib/nanoc3/filters/redcarpet.rb +0 -27
  106. data/lib/nanoc3/filters/redcloth.rb +0 -47
  107. data/lib/nanoc3/filters/relativize_paths.rb +0 -45
  108. data/lib/nanoc3/filters/rubypants.rb +0 -20
  109. data/lib/nanoc3/filters/sass.rb +0 -66
  110. data/lib/nanoc3/filters/slim.rb +0 -25
  111. data/lib/nanoc3/filters/typogruby.rb +0 -23
  112. data/lib/nanoc3/filters/uglify_js.rb +0 -42
  113. data/lib/nanoc3/helpers.rb +0 -16
  114. data/lib/nanoc3/helpers/blogging.rb +0 -319
  115. data/lib/nanoc3/helpers/breadcrumbs.rb +0 -40
  116. data/lib/nanoc3/helpers/capturing.rb +0 -138
  117. data/lib/nanoc3/helpers/filtering.rb +0 -50
  118. data/lib/nanoc3/helpers/html_escape.rb +0 -55
  119. data/lib/nanoc3/helpers/link_to.rb +0 -151
  120. data/lib/nanoc3/helpers/rendering.rb +0 -140
  121. data/lib/nanoc3/helpers/tagging.rb +0 -71
  122. data/lib/nanoc3/helpers/text.rb +0 -44
  123. data/lib/nanoc3/helpers/xml_sitemap.rb +0 -76
  124. data/lib/nanoc3/tasks.rb +0 -10
  125. data/lib/nanoc3/tasks/clean.rake +0 -16
  126. data/lib/nanoc3/tasks/clean.rb +0 -29
  127. data/lib/nanoc3/tasks/deploy/rsync.rake +0 -14
  128. data/lib/nanoc3/tasks/validate.rake +0 -92
  129. data/nanoc3.gemspec +0 -49
  130. data/tasks/doc.rake +0 -16
  131. data/tasks/test.rake +0 -44
  132. data/test/base/core_ext/array_spec.rb +0 -73
  133. data/test/base/core_ext/hash_spec.rb +0 -98
  134. data/test/base/core_ext/pathname_spec.rb +0 -27
  135. data/test/base/core_ext/string_spec.rb +0 -37
  136. data/test/base/test_checksum_store.rb +0 -35
  137. data/test/base/test_code_snippet.rb +0 -31
  138. data/test/base/test_compiler.rb +0 -316
  139. data/test/base/test_compiler_dsl.rb +0 -161
  140. data/test/base/test_context.rb +0 -31
  141. data/test/base/test_data_source.rb +0 -46
  142. data/test/base/test_dependency_tracker.rb +0 -262
  143. data/test/base/test_directed_graph.rb +0 -283
  144. data/test/base/test_filter.rb +0 -83
  145. data/test/base/test_item.rb +0 -179
  146. data/test/base/test_item_rep.rb +0 -553
  147. data/test/base/test_layout.rb +0 -59
  148. data/test/base/test_memoization.rb +0 -90
  149. data/test/base/test_notification_center.rb +0 -34
  150. data/test/base/test_outdatedness_checker.rb +0 -394
  151. data/test/base/test_plugin.rb +0 -30
  152. data/test/base/test_rule.rb +0 -19
  153. data/test/base/test_rule_context.rb +0 -65
  154. data/test/base/test_site.rb +0 -190
  155. data/test/cli/commands/test_compile.rb +0 -33
  156. data/test/cli/commands/test_create_item.rb +0 -14
  157. data/test/cli/commands/test_create_layout.rb +0 -28
  158. data/test/cli/commands/test_create_site.rb +0 -24
  159. data/test/cli/commands/test_help.rb +0 -12
  160. data/test/cli/commands/test_info.rb +0 -11
  161. data/test/cli/commands/test_update.rb +0 -10
  162. data/test/cli/test_cli.rb +0 -102
  163. data/test/cli/test_error_handler.rb +0 -29
  164. data/test/cli/test_logger.rb +0 -10
  165. data/test/data_sources/test_filesystem.rb +0 -433
  166. data/test/data_sources/test_filesystem_unified.rb +0 -536
  167. data/test/data_sources/test_filesystem_verbose.rb +0 -357
  168. data/test/extra/core_ext/test_enumerable.rb +0 -30
  169. data/test/extra/core_ext/test_time.rb +0 -15
  170. data/test/extra/deployers/test_rsync.rb +0 -232
  171. data/test/extra/test_auto_compiler.rb +0 -417
  172. data/test/extra/test_file_proxy.rb +0 -19
  173. data/test/extra/test_vcs.rb +0 -22
  174. data/test/extra/validators/test_links.rb +0 -51
  175. data/test/extra/validators/test_w3c.rb +0 -47
  176. data/test/filters/test_asciidoc.rb +0 -22
  177. data/test/filters/test_bluecloth.rb +0 -18
  178. data/test/filters/test_coderay.rb +0 -44
  179. data/test/filters/test_colorize_syntax.rb +0 -283
  180. data/test/filters/test_erb.rb +0 -99
  181. data/test/filters/test_erubis.rb +0 -70
  182. data/test/filters/test_haml.rb +0 -96
  183. data/test/filters/test_kramdown.rb +0 -18
  184. data/test/filters/test_less.rb +0 -113
  185. data/test/filters/test_markaby.rb +0 -24
  186. data/test/filters/test_maruku.rb +0 -18
  187. data/test/filters/test_mustache.rb +0 -25
  188. data/test/filters/test_rainpress.rb +0 -29
  189. data/test/filters/test_rdiscount.rb +0 -31
  190. data/test/filters/test_rdoc.rb +0 -18
  191. data/test/filters/test_redcarpet.rb +0 -63
  192. data/test/filters/test_redcloth.rb +0 -33
  193. data/test/filters/test_relativize_paths.rb +0 -332
  194. data/test/filters/test_rubypants.rb +0 -18
  195. data/test/filters/test_sass.rb +0 -229
  196. data/test/filters/test_slim.rb +0 -35
  197. data/test/filters/test_typogruby.rb +0 -21
  198. data/test/filters/test_uglify_js.rb +0 -30
  199. data/test/gem_loader.rb +0 -11
  200. data/test/helper.rb +0 -179
  201. data/test/helpers/test_blogging.rb +0 -754
  202. data/test/helpers/test_breadcrumbs.rb +0 -81
  203. data/test/helpers/test_capturing.rb +0 -41
  204. data/test/helpers/test_filtering.rb +0 -106
  205. data/test/helpers/test_html_escape.rb +0 -32
  206. data/test/helpers/test_link_to.rb +0 -249
  207. data/test/helpers/test_rendering.rb +0 -89
  208. data/test/helpers/test_tagging.rb +0 -87
  209. data/test/helpers/test_text.rb +0 -24
  210. data/test/helpers/test_xml_sitemap.rb +0 -103
  211. data/test/tasks/test_clean.rb +0 -67
@@ -1,22 +0,0 @@
1
- # encoding: utf-8
2
-
3
- module Nanoc3::Extra
4
-
5
- autoload 'AutoCompiler', 'nanoc3/extra/auto_compiler'
6
- autoload 'CHiCk', 'nanoc3/extra/chick'
7
- autoload 'Deployers', 'nanoc3/extra/deployers'
8
- autoload 'Validators', 'nanoc3/extra/validators'
9
-
10
- # Deprecated; use {Nanoc3::Context} instead
11
- # TODO [in nanoc 4.0] remove me
12
- Context = ::Nanoc3::Context
13
-
14
- # Deprecated
15
- # TODO [in nanoc 4.0] remove me
16
- autoload 'FileProxy', 'nanoc3/extra/file_proxy'
17
-
18
- end
19
-
20
- require 'nanoc3/extra/core_ext'
21
- require 'nanoc3/extra/vcs'
22
- require 'nanoc3/extra/vcses'
@@ -1,103 +0,0 @@
1
- # encoding: utf-8
2
-
3
- module Nanoc3::Extra
4
-
5
- # A web server that will automatically compile items as they are requested.
6
- # It also serves static files such as stylesheets and images.
7
- class AutoCompiler
8
-
9
- # @return [Nanoc3::Site] The site this autocompiler belongs to
10
- attr_reader :site
11
-
12
- # Creates a new autocompiler for the given site.
13
- #
14
- # @param [String] site_path The path to the site to autocompile
15
- def initialize(site_path)
16
- require 'rack'
17
- require 'mime/types'
18
-
19
- # Set site
20
- @site_path = site_path
21
-
22
- # Create mutex to prevent parallel requests
23
- require 'thread'
24
- @mutex = Mutex.new
25
- end
26
-
27
- # Calls the autocompiler. The behaviour of this method is defined by the
28
- # [Rack specification](http://rack.rubyforge.org/doc/files/SPEC.html).
29
- #
30
- # @param [Hash] env The environment, as defined by the Rack specification
31
- #
32
- # @return [Array] An array containing the status, the headers, and the
33
- # body, as defined by the Rack specification
34
- def call(env)
35
- @mutex.synchronize do
36
- # Start with a new site
37
- build_site
38
-
39
- # Find rep
40
- path = Rack::Utils::unescape(env['PATH_INFO'])
41
- reps = site.items.map { |i| i.reps }.flatten
42
- rep = reps.find do |r|
43
- r.path == path ||
44
- r.raw_path == site.config[:output_dir] + path
45
- end
46
-
47
- # Recompile
48
- site.compile if rep
49
-
50
- # Get paths by appending index filenames
51
- if path =~ /\/$/
52
- possible_paths = site.config[:index_filenames].map { |f| path + f }
53
- else
54
- possible_paths = [ path ]
55
- end
56
-
57
- # Find matching file
58
- modified_path = possible_paths.find { |f| File.file?(site.config[:output_dir] + f) }
59
- modified_path ||= path
60
-
61
- # Serve using Rack::File
62
- puts "*** serving file #{modified_path}"
63
- res = file_server.call(env.merge('PATH_INFO' => modified_path))
64
- puts "*** done serving file #{modified_path}"
65
- res
66
- end
67
- rescue StandardError, ScriptError => e
68
- # Add compilation stack to env
69
- env['nanoc.stack'] = []
70
- stack.reverse.each do |obj|
71
- if obj.is_a?(Nanoc3::ItemRep) # item rep
72
- env['nanoc.stack'] << "[item] #{obj.item.identifier} (rep #{obj.name})"
73
- else # layout
74
- env['nanoc.stack'] << "[layout] #{obj.identifier}"
75
- end
76
- end
77
-
78
- # Re-raise error
79
- raise e
80
- end
81
-
82
- private
83
-
84
- def build_site
85
- @site = Nanoc3::Site.new(@site_path)
86
- end
87
-
88
- def mime_type_of(path, fallback)
89
- mime_type = MIME::Types.of(path).first
90
- mime_type = mime_type.nil? ? fallback : mime_type.simplified
91
- end
92
-
93
- def file_server
94
- @file_server ||= ::Rack::File.new(site.config[:output_dir])
95
- end
96
-
97
- def stack
98
- site.compiler.stack
99
- end
100
-
101
- end
102
-
103
- end
@@ -1,125 +0,0 @@
1
- require 'net/http'
2
- require 'rack'
3
- require 'rack/cache'
4
-
5
- module Nanoc3::Extra
6
-
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.
10
- module CHiCk
11
-
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.
15
- class Client
16
-
17
- DEFAULT_OPTIONS = {
18
- :cache => {
19
- :metastore => 'file:tmp/rack/cache.meta',
20
- :entitystore => 'file:tmp/rack/cache.body'
21
- },
22
- :cache_controller => {
23
- :max_age => 60
24
- }
25
- }
26
-
27
- def initialize(options={})
28
- # Get options
29
- @options = DEFAULT_OPTIONS.merge(options)
30
- @options[:cache] = DEFAULT_OPTIONS[:cache].merge(@options[:cache])
31
- @options[:cache_controller] = DEFAULT_OPTIONS[:cache_controller].merge(@options[:cache_controller])
32
- end
33
-
34
- def get(url)
35
- # Build app
36
- options = @options
37
- @app ||= Rack::Builder.new {
38
- use Rack::Cache, options[:cache].merge(:verbose => true)
39
- use Nanoc3::Extra::CHiCk::CacheController, options[:cache_controller]
40
- run Nanoc3::Extra::CHiCk::RackClient
41
- }
42
-
43
- # Build environment for request
44
- env = Rack::MockRequest.env_for(url, :method => 'GET')
45
-
46
- # Fetch
47
- puts "[CHiCk] Fetching #{url}..." if $DEBUG
48
- status, headers, body_parts = @app.call(env)
49
- puts "[CHiCk] #{url}: #{headers['X-Rack-Cache']}" if $DEBUG
50
-
51
- # Join body
52
- body = ''
53
- body_parts.each { |part| body << part }
54
-
55
- # Done
56
- [ status, headers, body ]
57
- end
58
-
59
- end
60
-
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.
64
- class CacheController
65
-
66
- def initialize(app, options={})
67
- @app = app
68
- @options = options
69
- end
70
-
71
- def call(env)
72
- res = @app.call(env)
73
- unless res[1].has_key?('Cache-Control') || res[1].has_key?('Expires')
74
- res[1]['Cache-Control'] = "max-age=#{@options[:max_age]}"
75
- end
76
- res
77
- end
78
-
79
- end
80
-
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.
84
- class RackClient
85
-
86
- METHOD_TO_CLASS_MAPPING = {
87
- 'DELETE' => Net::HTTP::Delete,
88
- 'GET' => Net::HTTP::Get,
89
- 'HEAD' => Net::HTTP::Head,
90
- 'POST' => Net::HTTP::Post,
91
- 'PUT' => Net::HTTP::Put
92
- }
93
-
94
- def self.call(env)
95
- # Build request
96
- request = Rack::Request.new(env)
97
-
98
- # Build headers and strip HTTP_
99
- request_headers = env.inject({}) do |m,(k,v)|
100
- k =~ /^HTTP_(.*)$/ && v ? m.merge($1.gsub(/_/, '-') => v) : m
101
- end
102
-
103
- # Build Net::HTTP request
104
- http = Net::HTTP.new(request.host, request.port)
105
- net_http_request_class = METHOD_TO_CLASS_MAPPING[request.request_method]
106
- raise ArgumentError, "Unsupported method: #{request.request_method}" if net_http_request_class.nil?
107
- net_http_request = net_http_request_class.new(request.fullpath, request_headers)
108
- net_http_request.body = env['rack.input'].read if [ 'POST', 'PUT' ].include?(request.request_method)
109
-
110
- # Perform request
111
- http.request(net_http_request) do |response|
112
- # Build Rack response triplet
113
- return [
114
- response.code.to_i,
115
- response.to_hash.inject({}) { |m,(k,v)| m.merge(k => v[0]) },
116
- [ response.body ]
117
- ]
118
- end
119
- end
120
-
121
- end
122
-
123
- end
124
-
125
- end
@@ -1,4 +0,0 @@
1
- # encoding: utf-8
2
-
3
- require 'nanoc3/extra/core_ext/enumerable'
4
- require 'nanoc3/extra/core_ext/time'
@@ -1,33 +0,0 @@
1
- # encoding: utf-8
2
-
3
- module Enumerable
4
-
5
- if !Enumerable.instance_methods.include?('group_by')
6
-
7
- # Returns a hash, which keys are evaluated result from the block, and
8
- # values are arrays of elements in enum corresponding to the key. This
9
- # method is provided for backward compatibility with Ruby 1.8.6 and lower,
10
- # since {#group_by} is only available in 1.8.7 and higher.
11
- #
12
- # @yieldparam [Object] obj The object to classify
13
- #
14
- # @return [Hash]
15
- #
16
- # @example Grouping integers by rest by division through 3
17
- #
18
- # (1..6).group_by { |i| i % 3 }
19
- # # => { 0 => [3, 6], 1 => [1, 4], 2 => [2, 5] }
20
- def group_by
21
- groups = {}
22
- each do |item|
23
- key = yield(item)
24
-
25
- groups[key] ||= []
26
- groups[key] << item
27
- end
28
- groups
29
- end
30
-
31
- end
32
-
33
- end
@@ -1,19 +0,0 @@
1
- # encoding: utf-8
2
-
3
- module Nanoc3::Extra::TimeExtensions
4
-
5
- # @return [String] The time in an ISO-8601 date format.
6
- def to_iso8601_date
7
- self.strftime("%Y-%m-%d")
8
- end
9
-
10
- # @return [String] The time in an ISO-8601 time format.
11
- def to_iso8601_time
12
- self.getutc.strftime("%Y-%m-%dT%H:%M:%SZ")
13
- end
14
-
15
- end
16
-
17
- class Time
18
- include Nanoc3::Extra::TimeExtensions
19
- end
@@ -1,11 +0,0 @@
1
- # encoding: utf-8
2
-
3
- module Nanoc3::Extra
4
-
5
- module Deployers
6
-
7
- autoload 'Rsync', 'nanoc3/extra/deployers/rsync'
8
-
9
- end
10
-
11
- end
@@ -1,114 +0,0 @@
1
- # encoding: utf-8
2
-
3
- module Nanoc3::Extra::Deployers
4
-
5
- # A deployer that deploys a site using rsync.
6
- class Rsync
7
-
8
- # Default rsync options
9
- DEFAULT_OPTIONS = [
10
- '-glpPrtvz',
11
- '--exclude=".hg"',
12
- '--exclude=".svn"',
13
- '--exclude=".git"'
14
- ]
15
-
16
- # Creates a new deployer that uses rsync. The deployment configurations
17
- # will be read from the configuration file of the site (which is assumed
18
- # to be the current working directory).
19
- #
20
- # The deployment configurations are stored like this in the site's
21
- # configuration file:
22
- #
23
- # deploy:
24
- # NAME:
25
- # options: [ OPTIONS ]
26
- # dst: "DST"
27
- #
28
- # `NAME` is a unique name for the deployment configuration. By default,
29
- # the deployer will use the deployment configuration named `"default"`.
30
- #
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.
34
- #
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
38
- # trailing slash.
39
- #
40
- # Example: This deployment configuration defines a "default" and a
41
- # "staging" deployment configuration. The default options are used.
42
- #
43
- # deploy:
44
- # default:
45
- # dst: "ectype:sites/stoneship/public"
46
- # staging:
47
- # dst: "ectype:sites/stoneship-staging/public"
48
- # options: [ "-glpPrtvz" ]
49
- #
50
- # When running the deployer with the `default` resp. `staging`
51
- # configurations, the following rsync commands will be executed:
52
- #
53
- # rsync -glpPrtvz --exclude=".hg" --exclude=".svn"
54
- # --exclude=".git" output ectype:sites/stoneship/public
55
- #
56
- # rsync -glpPrtvz output ectype:sites/stoneship-staging/public
57
- def initialize
58
- # Get site
59
- error 'No site configuration found' unless File.file?('config.yaml')
60
- @site = Nanoc3::Site.new('.')
61
- end
62
-
63
- # Runs the task. Possible params:
64
- #
65
- # @option params [Boolean] :dry_run (false) True if the action itself
66
- # should not be executed, but still printed; false otherwise.
67
- #
68
- # @option params [String] :config_name (:default) The name of the
69
- # deployment configuration to use.
70
- #
71
- # @return [void]
72
- def run(params={})
73
- # Extract params
74
- config_name = params.has_key?(:config_name) ? params[:config_name].to_sym : :default
75
- dry_run = params.has_key?(:dry_run) ? params[:dry_run] : false
76
-
77
- # Validate config
78
- error 'No deploy configuration found' if @site.config[:deploy].nil?
79
- error "No deploy configuration found for #{config_name}" if @site.config[:deploy][config_name].nil?
80
-
81
- # Set arguments
82
- src = File.expand_path(@site.config[:output_dir]) + '/'
83
- dst = @site.config[:deploy][config_name][:dst]
84
- options = @site.config[:deploy][config_name][:options] || DEFAULT_OPTIONS
85
-
86
- # Validate arguments
87
- error 'No dst found in deployment configuration' if dst.nil?
88
- error 'dst requires no trailing slash' if dst[-1,1] == '/'
89
-
90
- # Run
91
- if dry_run
92
- warn 'Performing a dry-run; no actions will actually be performed'
93
- run_shell_cmd([ 'echo', 'rsync', options, src, dst ].flatten)
94
- else
95
- run_shell_cmd([ 'rsync', options, src, dst ].flatten)
96
- end
97
- end
98
-
99
- private
100
-
101
- # Prints the given message on stderr and exits.
102
- def error(msg)
103
- raise RuntimeError.new(msg)
104
- end
105
-
106
- # Runs the given shell command. This is a simple wrapper around Kernel#system.
107
- def run_shell_cmd(args)
108
- system(*args)
109
- raise "command exited with a nonzero status code #{$?.exitstatus} (command: #{args.join(' ')})" if !$?.success?
110
- end
111
-
112
- end
113
-
114
- end
@@ -1,40 +0,0 @@
1
- # encoding: utf-8
2
-
3
- module Nanoc3::Extra
4
-
5
- # @deprecated Create a File instance directly and use that instead.
6
- class FileProxy
7
-
8
- instance_methods.each { |m| undef_method m unless m =~ /^__/ || m.to_s == 'object_id' }
9
-
10
- @@deprecation_warning_shown = false
11
-
12
- def initialize(path)
13
- @path = path
14
- end
15
-
16
- def freeze
17
- end
18
-
19
- def respond_to?(meth)
20
- file_instance_methods.include?(meth.to_sym)
21
- end
22
-
23
- def method_missing(sym, *args, &block)
24
- if !@@deprecation_warning_shown
25
- $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.'
26
- @@deprecation_warning_shown = true
27
- end
28
-
29
- File.open(@path, 'r') { |io| io.__send__(sym, *args, &block) }
30
- end
31
-
32
- private
33
-
34
- def file_instance_methods
35
- @@file_instance_methods ||= Set.new(File.instance_methods.map { |m| m.to_sym })
36
- end
37
-
38
- end
39
-
40
- end