nanoc 4.0.0b2 → 4.0.0b3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (255) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +11 -22
  3. data/NEWS.md +20 -0
  4. data/Rakefile +0 -2
  5. data/bin/nanoc +0 -2
  6. data/lib/nanoc.rb +0 -2
  7. data/lib/nanoc/base.rb +1 -2
  8. data/lib/nanoc/base/checksummer.rb +0 -2
  9. data/lib/nanoc/base/compilation/checksum_store.rb +0 -2
  10. data/lib/nanoc/base/compilation/compiled_content_cache.rb +0 -2
  11. data/lib/nanoc/base/compilation/compiler.rb +0 -2
  12. data/lib/nanoc/base/compilation/compiler_dsl.rb +0 -2
  13. data/lib/nanoc/base/compilation/dependency_tracker.rb +0 -2
  14. data/lib/nanoc/base/compilation/filter.rb +0 -2
  15. data/lib/nanoc/base/compilation/item_rep_proxy.rb +0 -2
  16. data/lib/nanoc/base/compilation/item_rep_recorder_proxy.rb +0 -2
  17. data/lib/nanoc/base/compilation/outdatedness_checker.rb +0 -2
  18. data/lib/nanoc/base/compilation/outdatedness_reasons.rb +0 -2
  19. data/lib/nanoc/base/compilation/rule.rb +0 -2
  20. data/lib/nanoc/base/compilation/rule_context.rb +0 -2
  21. data/lib/nanoc/base/compilation/rule_memory_calculator.rb +0 -2
  22. data/lib/nanoc/base/compilation/rule_memory_store.rb +0 -2
  23. data/lib/nanoc/base/compilation/rules_collection.rb +0 -2
  24. data/lib/nanoc/base/context.rb +0 -2
  25. data/lib/nanoc/base/core_ext.rb +0 -2
  26. data/lib/nanoc/base/core_ext/array.rb +0 -2
  27. data/lib/nanoc/base/core_ext/hash.rb +0 -2
  28. data/lib/nanoc/base/core_ext/pathname.rb +0 -2
  29. data/lib/nanoc/base/core_ext/string.rb +0 -2
  30. data/lib/nanoc/base/directed_graph.rb +0 -2
  31. data/lib/nanoc/base/error.rb +0 -2
  32. data/lib/nanoc/base/errors.rb +0 -2
  33. data/lib/nanoc/base/identifiable_collection.rb +0 -2
  34. data/lib/nanoc/base/memoization.rb +0 -2
  35. data/lib/nanoc/base/notification_center.rb +0 -2
  36. data/lib/nanoc/base/pattern.rb +0 -2
  37. data/lib/nanoc/base/plugin_registry.rb +0 -2
  38. data/lib/nanoc/base/result_data/item_rep.rb +0 -2
  39. data/lib/nanoc/base/source_data/code_snippet.rb +0 -2
  40. data/lib/nanoc/base/source_data/configuration.rb +0 -2
  41. data/lib/nanoc/base/source_data/data_source.rb +0 -2
  42. data/lib/nanoc/base/source_data/identifier.rb +0 -2
  43. data/lib/nanoc/base/source_data/item.rb +0 -2
  44. data/lib/nanoc/base/source_data/layout.rb +0 -2
  45. data/lib/nanoc/base/source_data/site.rb +1 -3
  46. data/lib/nanoc/base/store.rb +0 -2
  47. data/lib/nanoc/base/temp_filename_factory.rb +0 -2
  48. data/lib/nanoc/base/views/config.rb +0 -2
  49. data/lib/nanoc/base/views/identifiable_collection.rb +0 -2
  50. data/lib/nanoc/base/views/item.rb +3 -5
  51. data/lib/nanoc/base/views/item_collection.rb +0 -2
  52. data/lib/nanoc/base/views/item_rep.rb +0 -2
  53. data/lib/nanoc/base/views/item_rep_collection.rb +48 -0
  54. data/lib/nanoc/base/views/layout.rb +0 -2
  55. data/lib/nanoc/base/views/layout_collection.rb +0 -2
  56. data/lib/nanoc/base/views/mutable_config.rb +0 -2
  57. data/lib/nanoc/base/views/mutable_identifiable_collection.rb +0 -2
  58. data/lib/nanoc/base/views/mutable_item.rb +0 -2
  59. data/lib/nanoc/base/views/mutable_item_collection.rb +0 -2
  60. data/lib/nanoc/base/views/mutable_layout.rb +0 -2
  61. data/lib/nanoc/base/views/mutable_layout_collection.rb +0 -2
  62. data/lib/nanoc/base/views/site.rb +0 -2
  63. data/lib/nanoc/cli.rb +0 -2
  64. data/lib/nanoc/cli/ansi_string_colorizer.rb +0 -2
  65. data/lib/nanoc/cli/cleaning_stream.rb +0 -2
  66. data/lib/nanoc/cli/command_runner.rb +0 -2
  67. data/lib/nanoc/cli/commands/check.rb +0 -2
  68. data/lib/nanoc/cli/commands/compile.rb +0 -2
  69. data/lib/nanoc/cli/commands/create-site.rb +7 -25
  70. data/lib/nanoc/cli/commands/deploy.rb +0 -2
  71. data/lib/nanoc/cli/commands/nanoc.rb +0 -2
  72. data/lib/nanoc/cli/commands/prune.rb +0 -2
  73. data/lib/nanoc/cli/commands/shell.rb +0 -2
  74. data/lib/nanoc/cli/commands/show-data.rb +0 -2
  75. data/lib/nanoc/cli/commands/show-plugins.rb +0 -2
  76. data/lib/nanoc/cli/commands/show-rules.rb +0 -2
  77. data/lib/nanoc/cli/commands/view.rb +0 -2
  78. data/lib/nanoc/cli/error_handler.rb +0 -2
  79. data/lib/nanoc/cli/logger.rb +0 -2
  80. data/lib/nanoc/cli/stream_cleaners.rb +0 -2
  81. data/lib/nanoc/cli/stream_cleaners/abstract.rb +0 -2
  82. data/lib/nanoc/cli/stream_cleaners/ansi_colors.rb +0 -2
  83. data/lib/nanoc/cli/stream_cleaners/utf8.rb +0 -2
  84. data/lib/nanoc/data_sources.rb +1 -5
  85. data/lib/nanoc/data_sources/filesystem.rb +2 -2
  86. data/lib/nanoc/data_sources/filesystem_unified.rb +0 -2
  87. data/lib/nanoc/extra.rb +0 -2
  88. data/lib/nanoc/extra/checking.rb +0 -2
  89. data/lib/nanoc/extra/checking/check.rb +23 -15
  90. data/lib/nanoc/extra/checking/checks.rb +0 -2
  91. data/lib/nanoc/extra/checking/checks/css.rb +1 -3
  92. data/lib/nanoc/extra/checking/checks/external_links.rb +0 -2
  93. data/lib/nanoc/extra/checking/checks/html.rb +1 -3
  94. data/lib/nanoc/extra/checking/checks/internal_links.rb +3 -5
  95. data/lib/nanoc/extra/checking/checks/mixed_content.rb +0 -2
  96. data/lib/nanoc/extra/checking/checks/stale.rb +2 -4
  97. data/lib/nanoc/extra/checking/dsl.rb +0 -2
  98. data/lib/nanoc/extra/checking/issue.rb +0 -2
  99. data/lib/nanoc/extra/checking/runner.rb +1 -3
  100. data/lib/nanoc/extra/core_ext.rb +0 -2
  101. data/lib/nanoc/extra/core_ext/pathname.rb +0 -2
  102. data/lib/nanoc/extra/core_ext/time.rb +0 -2
  103. data/lib/nanoc/extra/deployer.rb +0 -2
  104. data/lib/nanoc/extra/deployers.rb +0 -2
  105. data/lib/nanoc/extra/deployers/fog.rb +40 -8
  106. data/lib/nanoc/extra/deployers/rsync.rb +0 -2
  107. data/lib/nanoc/extra/filesystem_tools.rb +0 -2
  108. data/lib/nanoc/extra/jruby_nokogiri_warner.rb +0 -2
  109. data/lib/nanoc/extra/link_collector.rb +0 -2
  110. data/lib/nanoc/extra/piper.rb +0 -2
  111. data/lib/nanoc/extra/pruner.rb +0 -2
  112. data/lib/nanoc/filters.rb +0 -2
  113. data/lib/nanoc/filters/asciidoc.rb +0 -2
  114. data/lib/nanoc/filters/bluecloth.rb +0 -2
  115. data/lib/nanoc/filters/coffeescript.rb +0 -2
  116. data/lib/nanoc/filters/colorize_syntax.rb +0 -2
  117. data/lib/nanoc/filters/erb.rb +0 -2
  118. data/lib/nanoc/filters/erubis.rb +0 -2
  119. data/lib/nanoc/filters/haml.rb +0 -2
  120. data/lib/nanoc/filters/handlebars.rb +0 -2
  121. data/lib/nanoc/filters/kramdown.rb +0 -2
  122. data/lib/nanoc/filters/less.rb +0 -2
  123. data/lib/nanoc/filters/markaby.rb +0 -2
  124. data/lib/nanoc/filters/maruku.rb +0 -2
  125. data/lib/nanoc/filters/mustache.rb +0 -2
  126. data/lib/nanoc/filters/pandoc.rb +0 -2
  127. data/lib/nanoc/filters/rainpress.rb +0 -2
  128. data/lib/nanoc/filters/rdiscount.rb +0 -2
  129. data/lib/nanoc/filters/rdoc.rb +0 -2
  130. data/lib/nanoc/filters/redcarpet.rb +0 -2
  131. data/lib/nanoc/filters/redcloth.rb +0 -2
  132. data/lib/nanoc/filters/relativize_paths.rb +0 -2
  133. data/lib/nanoc/filters/rubypants.rb +0 -2
  134. data/lib/nanoc/filters/sass.rb +0 -2
  135. data/lib/nanoc/filters/sass/sass_filesystem_importer.rb +0 -2
  136. data/lib/nanoc/filters/slim.rb +0 -2
  137. data/lib/nanoc/filters/typogruby.rb +0 -2
  138. data/lib/nanoc/filters/uglify_js.rb +0 -2
  139. data/lib/nanoc/filters/xsl.rb +0 -2
  140. data/lib/nanoc/filters/yui_compressor.rb +0 -2
  141. data/lib/nanoc/helpers.rb +0 -2
  142. data/lib/nanoc/helpers/blogging.rb +0 -2
  143. data/lib/nanoc/helpers/breadcrumbs.rb +0 -2
  144. data/lib/nanoc/helpers/capturing.rb +0 -2
  145. data/lib/nanoc/helpers/filtering.rb +0 -2
  146. data/lib/nanoc/helpers/html_escape.rb +0 -2
  147. data/lib/nanoc/helpers/link_to.rb +0 -2
  148. data/lib/nanoc/helpers/rendering.rb +0 -2
  149. data/lib/nanoc/helpers/tagging.rb +0 -2
  150. data/lib/nanoc/helpers/text.rb +0 -2
  151. data/lib/nanoc/helpers/xml_sitemap.rb +0 -2
  152. data/lib/nanoc/version.rb +1 -3
  153. data/nanoc.gemspec +1 -3
  154. data/tasks/doc.rake +0 -2
  155. data/tasks/test.rake +0 -2
  156. data/test/base/checksummer_spec.rb +0 -2
  157. data/test/base/core_ext/array_spec.rb +0 -2
  158. data/test/base/core_ext/hash_spec.rb +0 -2
  159. data/test/base/core_ext/pathname_spec.rb +0 -2
  160. data/test/base/core_ext/string_spec.rb +0 -2
  161. data/test/base/temp_filename_factory_spec.rb +0 -2
  162. data/test/base/test_checksum_store.rb +0 -2
  163. data/test/base/test_code_snippet.rb +0 -2
  164. data/test/base/test_compiler.rb +0 -2
  165. data/test/base/test_compiler_dsl.rb +1 -3
  166. data/test/base/test_context.rb +0 -2
  167. data/test/base/test_data_source.rb +0 -2
  168. data/test/base/test_dependency_tracker.rb +0 -2
  169. data/test/base/test_directed_graph.rb +0 -2
  170. data/test/base/test_filter.rb +0 -2
  171. data/test/base/test_item.rb +0 -2
  172. data/test/base/test_item_array.rb +0 -2
  173. data/test/base/test_item_rep.rb +0 -2
  174. data/test/base/test_item_rep_recorder_proxy.rb +0 -2
  175. data/test/base/test_layout.rb +0 -2
  176. data/test/base/test_memoization.rb +0 -2
  177. data/test/base/test_notification_center.rb +0 -2
  178. data/test/base/test_outdatedness_checker.rb +1 -3
  179. data/test/base/test_plugin.rb +0 -2
  180. data/test/base/test_rule.rb +0 -2
  181. data/test/base/test_rule_context.rb +0 -2
  182. data/test/base/test_site.rb +1 -3
  183. data/test/base/test_store.rb +0 -2
  184. data/test/cli/commands/test_check.rb +0 -2
  185. data/test/cli/commands/test_compile.rb +0 -2
  186. data/test/cli/commands/test_create_site.rb +1 -3
  187. data/test/cli/commands/test_deploy.rb +0 -2
  188. data/test/cli/commands/test_help.rb +0 -2
  189. data/test/cli/commands/test_info.rb +0 -2
  190. data/test/cli/commands/test_prune.rb +2 -4
  191. data/test/cli/test_cleaning_stream.rb +0 -2
  192. data/test/cli/test_cli.rb +0 -6
  193. data/test/cli/test_error_handler.rb +0 -2
  194. data/test/cli/test_logger.rb +0 -2
  195. data/test/data_sources/test_filesystem.rb +0 -2
  196. data/test/data_sources/test_filesystem_unified.rb +15 -2
  197. data/test/extra/checking/checks/test_css.rb +3 -5
  198. data/test/extra/checking/checks/test_external_links.rb +5 -7
  199. data/test/extra/checking/checks/test_html.rb +2 -4
  200. data/test/extra/checking/checks/test_internal_links.rb +5 -7
  201. data/test/extra/checking/checks/test_mixed_content.rb +8 -10
  202. data/test/extra/checking/checks/test_stale.rb +1 -3
  203. data/test/extra/checking/test_check.rb +2 -6
  204. data/test/extra/checking/test_dsl.rb +0 -2
  205. data/test/extra/checking/test_runner.rb +0 -2
  206. data/test/extra/core_ext/test_pathname.rb +0 -2
  207. data/test/extra/core_ext/test_time.rb +0 -2
  208. data/test/extra/deployers/test_fog.rb +147 -2
  209. data/test/extra/deployers/test_rsync.rb +0 -2
  210. data/test/extra/test_filesystem_tools.rb +0 -2
  211. data/test/extra/test_link_collector.rb +0 -2
  212. data/test/extra/test_piper.rb +0 -2
  213. data/test/filters/test_asciidoc.rb +0 -2
  214. data/test/filters/test_bluecloth.rb +0 -2
  215. data/test/filters/test_coffeescript.rb +0 -2
  216. data/test/filters/test_colorize_syntax.rb +0 -2
  217. data/test/filters/test_erb.rb +0 -2
  218. data/test/filters/test_erubis.rb +0 -2
  219. data/test/filters/test_haml.rb +0 -2
  220. data/test/filters/test_handlebars.rb +0 -2
  221. data/test/filters/test_kramdown.rb +0 -2
  222. data/test/filters/test_less.rb +0 -2
  223. data/test/filters/test_markaby.rb +0 -2
  224. data/test/filters/test_maruku.rb +0 -2
  225. data/test/filters/test_mustache.rb +0 -2
  226. data/test/filters/test_pandoc.rb +0 -2
  227. data/test/filters/test_rainpress.rb +0 -2
  228. data/test/filters/test_rdiscount.rb +0 -2
  229. data/test/filters/test_rdoc.rb +0 -2
  230. data/test/filters/test_redcarpet.rb +0 -2
  231. data/test/filters/test_redcloth.rb +0 -2
  232. data/test/filters/test_relativize_paths.rb +0 -2
  233. data/test/filters/test_rubypants.rb +0 -2
  234. data/test/filters/test_sass.rb +0 -2
  235. data/test/filters/test_slim.rb +0 -2
  236. data/test/filters/test_typogruby.rb +0 -2
  237. data/test/filters/test_uglify_js.rb +0 -2
  238. data/test/filters/test_xsl.rb +0 -2
  239. data/test/filters/test_yui_compressor.rb +0 -2
  240. data/test/gem_loader.rb +0 -2
  241. data/test/helper.rb +1 -3
  242. data/test/helpers/test_blogging.rb +0 -2
  243. data/test/helpers/test_breadcrumbs.rb +0 -2
  244. data/test/helpers/test_capturing.rb +0 -2
  245. data/test/helpers/test_filtering.rb +0 -2
  246. data/test/helpers/test_html_escape.rb +0 -2
  247. data/test/helpers/test_link_to.rb +0 -2
  248. data/test/helpers/test_rendering.rb +0 -2
  249. data/test/helpers/test_tagging.rb +0 -2
  250. data/test/helpers/test_text.rb +0 -2
  251. data/test/helpers/test_xml_sitemap.rb +0 -2
  252. data/test/test_gem.rb +0 -5
  253. metadata +5 -6
  254. data/lib/nanoc/data_sources/filesystem_verbose.rb +0 -71
  255. data/test/data_sources/test_filesystem_verbose.rb +0 -308
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  module Nanoc::DataSources
4
2
  # The filesystem_unified data source stores its items and layouts in nested
5
3
  # directories. Items and layouts are represented by one or two files; if it
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  # @api private
4
2
  module Nanoc::Extra
5
3
  autoload 'Checking', 'nanoc/extra/checking'
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  module Nanoc::Extra
4
2
  # @api private
5
3
  module Checking
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  module Nanoc::Extra::Checking
4
2
  # @api private
5
3
  class OutputDirNotFoundError < Nanoc::Int::Errors::Generic
@@ -9,14 +7,32 @@ module Nanoc::Extra::Checking
9
7
  end
10
8
 
11
9
  # @api private
12
- class Check
10
+ class Check < Nanoc::Int::Context
13
11
  extend Nanoc::Int::PluginRegistry::PluginMethods
14
12
 
15
- attr_reader :site
16
13
  attr_reader :issues
17
14
 
18
- def initialize(site)
19
- @site = site
15
+ def self.create(site)
16
+ output_dir = site.config[:output_dir]
17
+ unless File.exist?(output_dir)
18
+ raise Nanoc::Extra::Checking::OutputDirNotFoundError.new(output_dir)
19
+ end
20
+ output_filenames = Dir[output_dir + '/**/*'].select { |f| File.file?(f) }
21
+
22
+ context = {
23
+ items: Nanoc::ItemCollectionView.new(site.items),
24
+ layouts: Nanoc::LayoutCollectionView.new(site.layouts),
25
+ config: Nanoc::ConfigView.new(site.config),
26
+ site: Nanoc::SiteView.new(site), # TODO: remove me
27
+ output_filenames: output_filenames,
28
+ }
29
+
30
+ new(context)
31
+ end
32
+
33
+ def initialize(context)
34
+ super(context)
35
+
20
36
  @issues = Set.new
21
37
  end
22
38
 
@@ -25,17 +41,9 @@ module Nanoc::Extra::Checking
25
41
  end
26
42
 
27
43
  def add_issue(desc, params = {})
28
- subject = params.fetch(:subject, nil)
44
+ subject = params.fetch(:subject, nil)
29
45
 
30
46
  @issues << Issue.new(desc, subject, self.class)
31
47
  end
32
-
33
- def output_filenames
34
- output_dir = @site.config[:output_dir]
35
- unless File.exist?(output_dir)
36
- raise Nanoc::Extra::Checking::OutputDirNotFoundError.new(output_dir)
37
- end
38
- Dir[output_dir + '/**/*'].select { |f| File.file?(f) }
39
- end
40
48
  end
41
49
  end
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  # @api private
4
2
  module Nanoc::Extra::Checking::Checks
5
3
  autoload 'CSS', 'nanoc/extra/checking/checks/css'
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  module ::Nanoc::Extra::Checking::Checks
4
2
  # @api private
5
3
  class CSS < ::Nanoc::Extra::Checking::Check
@@ -8,7 +6,7 @@ module ::Nanoc::Extra::Checking::Checks
8
6
  def run
9
7
  require 'w3c_validators'
10
8
 
11
- Dir[site.config[:output_dir] + '/**/*.css'].each do |filename|
9
+ Dir[@config[:output_dir] + '/**/*.css'].each do |filename|
12
10
  results = ::W3CValidators::CSSValidator.new.validate_file(filename)
13
11
  lines = File.readlines(filename)
14
12
  results.errors.each do |e|
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  require 'net/http'
4
2
  require 'net/https'
5
3
  require 'nokogiri'
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  module ::Nanoc::Extra::Checking::Checks
4
2
  # @api private
5
3
  class HTML < ::Nanoc::Extra::Checking::Check
@@ -8,7 +6,7 @@ module ::Nanoc::Extra::Checking::Checks
8
6
  def run
9
7
  require 'w3c_validators'
10
8
 
11
- Dir[site.config[:output_dir] + '/**/*.{htm,html}'].each do |filename|
9
+ Dir[@config[:output_dir] + '/**/*.{htm,html}'].each do |filename|
12
10
  results = ::W3CValidators::MarkupValidator.new.validate_file(filename)
13
11
  lines = File.readlines(filename)
14
12
  results.errors.each do |e|
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  require 'uri'
4
2
 
5
3
  module Nanoc::Extra::Checking::Checks
@@ -51,7 +49,7 @@ module Nanoc::Extra::Checking::Checks
51
49
 
52
50
  # Make absolute
53
51
  if path[0, 1] == '/'
54
- path = @site.config[:output_dir] + path
52
+ path = @config[:output_dir] + path
55
53
  else
56
54
  path = ::File.expand_path(path, ::File.dirname(origin))
57
55
  end
@@ -60,14 +58,14 @@ module Nanoc::Extra::Checking::Checks
60
58
  return true if File.file?(path)
61
59
 
62
60
  # Check whether directory with index file exists
63
- return true if File.directory?(path) && @site.config[:index_filenames].any? { |fn| File.file?(File.join(path, fn)) }
61
+ return true if File.directory?(path) && @config[:index_filenames].any? { |fn| File.file?(File.join(path, fn)) }
64
62
 
65
63
  # Nope :(
66
64
  false
67
65
  end
68
66
 
69
67
  def excluded?(href)
70
- excludes = @site.config.fetch(:checks, {}).fetch(:internal_links, {}).fetch(:exclude, [])
68
+ excludes = @config.fetch(:checks, {}).fetch(:internal_links, {}).fetch(:exclude, [])
71
69
  excludes.any? { |pattern| Regexp.new(pattern).match(href) }
72
70
  end
73
71
  end
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  module Nanoc::Extra::Checking::Checks
4
2
  # A check that verifies HTML files do not reference external resources with
5
3
  # URLs that would trigger "mixed content" warnings.
@@ -1,12 +1,10 @@
1
- # encoding: utf-8
2
-
3
1
  module Nanoc::Extra::Checking::Checks
4
2
  # @api private
5
3
  class Stale < ::Nanoc::Extra::Checking::Check
6
4
  def run
7
5
  require 'set'
8
6
 
9
- item_rep_paths = Set.new(@site.items.map(&:reps).flatten.map(&:raw_path))
7
+ item_rep_paths = Set.new(@items.map(&:reps).flatten.map(&:raw_path))
10
8
 
11
9
  output_filenames.each do |f|
12
10
  next if pruner.filename_excluded?(f)
@@ -21,7 +19,7 @@ module Nanoc::Extra::Checking::Checks
21
19
  protected
22
20
 
23
21
  def pruner
24
- exclude_config = @site.config.fetch(:prune, {}).fetch(:exclude, [])
22
+ exclude_config = @config.fetch(:prune, {}).fetch(:exclude, [])
25
23
  @pruner ||= Nanoc::Extra::Pruner.new(@site, exclude: exclude_config)
26
24
  end
27
25
  end
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  module Nanoc::Extra::Checking
4
2
  # @api private
5
3
  class DSL
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  module Nanoc::Extra::Checking
4
2
  # @api private
5
3
  class Issue
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  module Nanoc::Extra::Checking
4
2
  # Runner is reponsible for running issue checks.
5
3
  #
@@ -116,7 +114,7 @@ module Nanoc::Extra::Checking
116
114
  classes.each do |klass|
117
115
  print format(" %-#{length}s", "Running check #{klass.identifier}… ")
118
116
 
119
- check = klass.new(@site)
117
+ check = klass.create(@site)
120
118
  check.run
121
119
 
122
120
  checks << check
@@ -1,4 +1,2 @@
1
- # encoding: utf-8
2
-
3
1
  require 'nanoc/extra/core_ext/pathname'
4
2
  require 'nanoc/extra/core_ext/time'
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  module Nanoc::Extra
4
2
  # @api private
5
3
  module PathnameExtensions
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  # @api private
4
2
  module Nanoc::Extra::TimeExtensions
5
3
  # @return [String] The time in an ISO-8601 date format.
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  module Nanoc::Extra
4
2
  # Represents a deployer, an object that allows uploading the compiled site
5
3
  # to a specific (remote) location.
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  module Nanoc::Extra
4
2
  # @api private
5
3
  module Deployers
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  module Nanoc::Extra::Deployers
4
2
  # A deployer that deploys a site using [fog](https://github.com/geemus/fog).
5
3
  #
@@ -73,6 +71,7 @@ module Nanoc::Extra::Deployers
73
71
  end
74
72
  keys_to_destroy = files.all.map(&:key)
75
73
  keys_to_invalidate = []
74
+ etags = read_etags(files)
76
75
 
77
76
  # Upload all the files in the output folder to the clouds
78
77
  puts 'Uploading local files'
@@ -80,12 +79,7 @@ module Nanoc::Extra::Deployers
80
79
  files = Dir['**/*'].select { |f| File.file?(f) }
81
80
  files.each do |file_path|
82
81
  key = path ? File.join(path, file_path) : file_path
83
- directory.files.create(
84
- key: key,
85
- body: File.open(file_path),
86
- public: true)
87
- keys_to_destroy.delete(key)
88
- keys_to_invalidate.push(key)
82
+ upload(key, file_path, etags, keys_to_destroy, keys_to_invalidate, directory)
89
83
  end
90
84
  end
91
85
 
@@ -115,6 +109,44 @@ module Nanoc::Extra::Deployers
115
109
 
116
110
  private
117
111
 
112
+ def upload(key, file_path, etags, keys_to_destroy, keys_to_invalidate, dir)
113
+ keys_to_destroy.delete(key)
114
+
115
+ return unless needs_upload?(key, file_path, etags)
116
+
117
+ dir.files.create(
118
+ key: key,
119
+ body: File.open(file_path),
120
+ public: true)
121
+ keys_to_invalidate.push(key)
122
+ end
123
+
124
+ def needs_upload?(key, file_path, etags)
125
+ remote_etag = etags[key]
126
+ return true if remote_etag.nil?
127
+
128
+ local_etag = calc_local_etag(file_path)
129
+ remote_etag != local_etag
130
+ end
131
+
132
+ def read_etags(files)
133
+ case config[:provider]
134
+ when 'aws'
135
+ files.each_with_object({}) do |file, etags|
136
+ etags[file.key] = file.etag
137
+ end
138
+ else
139
+ {}
140
+ end
141
+ end
142
+
143
+ def calc_local_etag(file_path)
144
+ case config[:provider]
145
+ when 'aws'
146
+ Digest::MD5.file(file_path).hexdigest
147
+ end
148
+ end
149
+
118
150
  # Prints the given message on stderr and exits.
119
151
  def error(msg)
120
152
  raise RuntimeError.new(msg)
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  module Nanoc::Extra::Deployers
4
2
  # A deployer that deploys a site using rsync.
5
3
  #
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  module Nanoc::Extra
4
2
  # Contains useful functions for managing the filesystem.
5
3
  #
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  require 'singleton'
4
2
 
5
3
  module Nanoc::Extra
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  require 'set'
4
2
 
5
3
  module ::Nanoc::Extra
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  require 'open3'
4
2
 
5
3
  module Nanoc::Extra
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  module Nanoc::Extra
4
2
  # Responsible for finding and deleting files in the site’s output directory
5
3
  # that are not managed by nanoc.
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  # @api private
4
2
  module Nanoc::Filters
5
3
  autoload 'AsciiDoc', 'nanoc/filters/asciidoc'
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  module Nanoc::Filters
4
2
  # @since 3.2.0
5
3
  #
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  module Nanoc::Filters
4
2
  # @api private
5
3
  class BlueCloth < Nanoc::Filter
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  module Nanoc::Filters
4
2
  # @since 3.3.0
5
3
  #
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  module Nanoc::Filters
4
2
  # @api private
5
3
  class ColorizeSyntax < Nanoc::Filter
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  module Nanoc::Filters
4
2
  # @api private
5
3
  class ERB < Nanoc::Filter
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  module Nanoc::Filters
4
2
  # @api private
5
3
  class Erubis < Nanoc::Filter
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  module Nanoc::Filters
4
2
  # @api private
5
3
  class Haml < Nanoc::Filter
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  module Nanoc::Filters
4
2
  # @since 3.4.0
5
3
  #
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  module Nanoc::Filters
4
2
  # @api private
5
3
  class Kramdown < Nanoc::Filter
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  module Nanoc::Filters
4
2
  # @api private
5
3
  class Less < Nanoc::Filter
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  module Nanoc::Filters
4
2
  # @api private
5
3
  class Markaby < Nanoc::Filter