nanoc 4.4.7 → 4.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (70) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +9 -7
  3. data/NEWS.md +6 -0
  4. data/lib/nanoc.rb +1 -0
  5. data/lib/nanoc/base.rb +0 -1
  6. data/lib/nanoc/base/feature.rb +1 -1
  7. data/lib/nanoc/base/repos/data_source.rb +1 -1
  8. data/lib/nanoc/base/repos/site_loader.rb +1 -1
  9. data/lib/nanoc/base/services/action_provider.rb +1 -1
  10. data/lib/nanoc/base/services/filter.rb +1 -1
  11. data/lib/nanoc/checking.rb +7 -9
  12. data/lib/nanoc/checking/check.rb +1 -1
  13. data/lib/nanoc/checking/checks.rb +9 -17
  14. data/lib/nanoc/checking/checks/internal_links.rb +2 -0
  15. data/lib/nanoc/checking/checks/mixed_content.rb +2 -0
  16. data/lib/nanoc/checking/checks/stale.rb +2 -0
  17. data/lib/nanoc/checking/runner.rb +2 -2
  18. data/lib/nanoc/cli.rb +9 -6
  19. data/lib/nanoc/cli/commands/deploy.rb +4 -4
  20. data/lib/nanoc/cli/commands/show-plugins.rb +12 -12
  21. data/lib/nanoc/cli/stream_cleaners.rb +7 -7
  22. data/lib/nanoc/data_sources.rb +0 -3
  23. data/lib/nanoc/data_sources/filesystem.rb +2 -0
  24. data/lib/nanoc/deploying/deployer.rb +1 -1
  25. data/lib/nanoc/deploying/deployers.rb +6 -9
  26. data/lib/nanoc/deploying/deployers/fog.rb +2 -0
  27. data/lib/nanoc/deploying/deployers/git.rb +118 -0
  28. data/lib/nanoc/deploying/deployers/rsync.rb +2 -0
  29. data/lib/nanoc/extra.rb +5 -6
  30. data/lib/nanoc/filters.rb +28 -55
  31. data/lib/nanoc/filters/asciidoc.rb +2 -0
  32. data/lib/nanoc/filters/bluecloth.rb +2 -0
  33. data/lib/nanoc/filters/coffeescript.rb +2 -0
  34. data/lib/nanoc/filters/colorize_syntax.rb +2 -0
  35. data/lib/nanoc/filters/erb.rb +2 -0
  36. data/lib/nanoc/filters/erubis.rb +9 -8
  37. data/lib/nanoc/filters/haml.rb +2 -0
  38. data/lib/nanoc/filters/handlebars.rb +2 -0
  39. data/lib/nanoc/filters/kramdown.rb +2 -0
  40. data/lib/nanoc/filters/less.rb +2 -0
  41. data/lib/nanoc/filters/markaby.rb +2 -0
  42. data/lib/nanoc/filters/maruku.rb +2 -0
  43. data/lib/nanoc/filters/mustache.rb +2 -0
  44. data/lib/nanoc/filters/pandoc.rb +2 -0
  45. data/lib/nanoc/filters/rainpress.rb +2 -0
  46. data/lib/nanoc/filters/rdiscount.rb +2 -0
  47. data/lib/nanoc/filters/rdoc.rb +2 -0
  48. data/lib/nanoc/filters/redcarpet.rb +2 -0
  49. data/lib/nanoc/filters/redcloth.rb +2 -0
  50. data/lib/nanoc/filters/relativize_paths.rb +2 -0
  51. data/lib/nanoc/filters/rubypants.rb +2 -0
  52. data/lib/nanoc/filters/sass.rb +2 -0
  53. data/lib/nanoc/filters/slim.rb +2 -0
  54. data/lib/nanoc/filters/typogruby.rb +2 -0
  55. data/lib/nanoc/filters/uglify_js.rb +2 -0
  56. data/lib/nanoc/filters/xsl.rb +2 -0
  57. data/lib/nanoc/filters/yui_compressor.rb +2 -0
  58. data/lib/nanoc/helpers.rb +12 -11
  59. data/lib/nanoc/version.rb +1 -1
  60. data/nanoc.gemspec +1 -0
  61. data/spec/nanoc/base/filter_spec.rb +2 -2
  62. data/spec/nanoc/cli/commands/deploy_spec.rb +2 -2
  63. data/spec/nanoc/cli/commands/show_plugins_spec.rb +18 -0
  64. data/spec/nanoc/deploying/git_spec.rb +302 -0
  65. data/spec/spec_helper.rb +2 -0
  66. data/test/deploying/test_git.rb +261 -0
  67. metadata +20 -5
  68. data/lib/nanoc/base/plugin_registry.rb +0 -219
  69. data/spec/nanoc/base/plugin_registry_spec.rb +0 -29
  70. data/test/base/test_plugin.rb +0 -26
@@ -0,0 +1,118 @@
1
+ module Nanoc::Deploying::Deployers
2
+ # A deployer that deploys a site using [Git](http://git-scm.com).
3
+ #
4
+ # @example A deployment configuration for GitHub Pages:
5
+ #
6
+ # deploy:
7
+ # default:
8
+ # kind: git
9
+ # remote: git@github.com:myself/myproject.git
10
+ # branch: gh-pages
11
+ # forced: true
12
+ #
13
+ class Git < ::Nanoc::Deploying::Deployer
14
+ identifier :git
15
+
16
+ module Errors
17
+ class Generic < ::Nanoc::Error
18
+ end
19
+
20
+ class OutputDirDoesNotExist < Generic
21
+ def initialize(path)
22
+ super("The directory to deploy, #{path}, does not exist.")
23
+ end
24
+ end
25
+
26
+ class OutputDirIsNotAGitRepo < Generic
27
+ def initialize(path)
28
+ super("The directory to deploy, #{path}, is not a Git repository.")
29
+ end
30
+ end
31
+
32
+ class RemoteDoesNotExist < Generic
33
+ def initialize(remote)
34
+ super("The remote to deploy to, #{remote}, does not exist.")
35
+ end
36
+ end
37
+
38
+ class BranchDoesNotExist < Generic
39
+ def initialize(branch)
40
+ super("The branch to deploy, #{branch}, does not exist.")
41
+ end
42
+ end
43
+ end
44
+
45
+ def run
46
+ unless File.exist?(source_path)
47
+ raise Errors::OutputDirDoesNotExist.new(source_path)
48
+ end
49
+
50
+ remote = config.fetch(:remote, 'origin')
51
+ branch = config.fetch(:branch, 'master')
52
+ forced = config.fetch(:forced, false)
53
+
54
+ puts "Deploying via Git to branch “#{branch}” on remote “#{remote}”…"
55
+
56
+ Dir.chdir(source_path) do
57
+ unless File.exist?('.git')
58
+ raise Errors::OutputDirIsNotAGitRepo.new(source_path)
59
+ end
60
+
61
+ # Verify existence of remote, if remote is not a URL
62
+ if remote_is_name?(remote)
63
+ begin
64
+ run_cmd(%W(git config --get remote.#{remote}.url))
65
+ rescue Nanoc::Extra::Piper::Error
66
+ raise Errors::RemoteDoesNotExist.new(remote)
67
+ end
68
+ end
69
+
70
+ # If the branch exists then switch to it, otherwise prompt the user to create one.
71
+ begin
72
+ run_cmd_unless_dry(%W(git checkout #{branch}))
73
+ rescue Nanoc::Extra::Piper::Error
74
+ raise Errors::BranchDoesNotExist.new(branch)
75
+ end
76
+
77
+ return if clean_repo?
78
+
79
+ msg = "Automated commit at #{Time.now.utc} by Nanoc #{Nanoc::VERSION}"
80
+ author = 'Nanoc <>'
81
+ run_cmd_unless_dry(%w(git add -A))
82
+ run_cmd_unless_dry(%W(git commit -a --author #{author} -m #{msg}))
83
+
84
+ if forced
85
+ run_cmd_unless_dry(%W(git push -f #{remote} #{branch}))
86
+ else
87
+ run_cmd_unless_dry(%W(git push #{remote} #{branch}))
88
+ end
89
+ end
90
+ end
91
+
92
+ private
93
+
94
+ def remote_is_name?(remote)
95
+ remote !~ /:\/\/|@.+:/
96
+ end
97
+
98
+ def run_cmd(cmd)
99
+ piper = Nanoc::Extra::Piper.new(stdout: $stdout, stderr: $stderr)
100
+ piper.run(cmd, nil)
101
+ end
102
+
103
+ def run_cmd_unless_dry(cmd)
104
+ if dry_run
105
+ puts cmd.join(' ')
106
+ else
107
+ run_cmd(cmd)
108
+ end
109
+ end
110
+
111
+ def clean_repo?
112
+ stdout = StringIO.new
113
+ piper = Nanoc::Extra::Piper.new(stdout: stdout, stderr: $stderr)
114
+ piper.run(%w(git status --porcelain), nil)
115
+ stdout.string.empty?
116
+ end
117
+ end
118
+ end
@@ -19,6 +19,8 @@ module Nanoc::Deploying::Deployers
19
19
  #
20
20
  # @api private
21
21
  class Rsync < ::Nanoc::Deploying::Deployer
22
+ identifier :rsync
23
+
22
24
  # Default rsync options
23
25
  DEFAULT_OPTIONS = [
24
26
  '--group',
data/lib/nanoc/extra.rb CHANGED
@@ -3,10 +3,6 @@ require 'nanoc/deploying'
3
3
 
4
4
  # @api private
5
5
  module Nanoc::Extra
6
- autoload 'LinkCollector', 'nanoc/extra/link_collector.rb'
7
- autoload 'Piper', 'nanoc/extra/piper'
8
- autoload 'JRubyNokogiriWarner', 'nanoc/extra/jruby_nokogiri_warner'
9
-
10
6
  # @deprecated
11
7
  Checking = Nanoc::Checking
12
8
 
@@ -17,5 +13,8 @@ module Nanoc::Extra
17
13
  Pruner = Nanoc::Pruner
18
14
  end
19
15
 
20
- require 'nanoc/extra/core_ext'
21
- require 'nanoc/extra/parallel_collection'
16
+ require_relative 'extra/link_collector.rb'
17
+ require_relative 'extra/piper'
18
+ require_relative 'extra/jruby_nokogiri_warner'
19
+ require_relative 'extra/core_ext'
20
+ require_relative 'extra/parallel_collection'
data/lib/nanoc/filters.rb CHANGED
@@ -1,58 +1,31 @@
1
1
  # @api private
2
2
  module Nanoc::Filters
3
- autoload 'AsciiDoc', 'nanoc/filters/asciidoc'
4
- autoload 'BlueCloth', 'nanoc/filters/bluecloth'
5
- autoload 'ColorizeSyntax', 'nanoc/filters/colorize_syntax'
6
- autoload 'CoffeeScript', 'nanoc/filters/coffeescript'
7
- autoload 'ERB', 'nanoc/filters/erb'
8
- autoload 'Erubis', 'nanoc/filters/erubis'
9
- autoload 'Haml', 'nanoc/filters/haml'
10
- autoload 'Handlebars', 'nanoc/filters/handlebars'
11
- autoload 'Kramdown', 'nanoc/filters/kramdown'
12
- autoload 'Less', 'nanoc/filters/less'
13
- autoload 'Markaby', 'nanoc/filters/markaby'
14
- autoload 'Maruku', 'nanoc/filters/maruku'
15
- autoload 'Mustache', 'nanoc/filters/mustache'
16
- autoload 'Pandoc', 'nanoc/filters/pandoc'
17
- autoload 'Rainpress', 'nanoc/filters/rainpress'
18
- autoload 'RDiscount', 'nanoc/filters/rdiscount'
19
- autoload 'RDoc', 'nanoc/filters/rdoc'
20
- autoload 'Redcarpet', 'nanoc/filters/redcarpet'
21
- autoload 'RedCloth', 'nanoc/filters/redcloth'
22
- autoload 'RelativizePaths', 'nanoc/filters/relativize_paths'
23
- autoload 'RubyPants', 'nanoc/filters/rubypants'
24
- autoload 'Sass', 'nanoc/filters/sass'
25
- autoload 'Slim', 'nanoc/filters/slim'
26
- autoload 'Typogruby', 'nanoc/filters/typogruby'
27
- autoload 'UglifyJS', 'nanoc/filters/uglify_js'
28
- autoload 'XSL', 'nanoc/filters/xsl'
29
- autoload 'YUICompressor', 'nanoc/filters/yui_compressor'
30
-
31
- Nanoc::Filter.register '::Nanoc::Filters::AsciiDoc', :asciidoc
32
- Nanoc::Filter.register '::Nanoc::Filters::BlueCloth', :bluecloth
33
- Nanoc::Filter.register '::Nanoc::Filters::ColorizeSyntax', :colorize_syntax
34
- Nanoc::Filter.register '::Nanoc::Filters::CoffeeScript', :coffeescript
35
- Nanoc::Filter.register '::Nanoc::Filters::ERB', :erb
36
- Nanoc::Filter.register '::Nanoc::Filters::Erubis', :erubis
37
- Nanoc::Filter.register '::Nanoc::Filters::Haml', :haml
38
- Nanoc::Filter.register '::Nanoc::Filters::Handlebars', :handlebars
39
- Nanoc::Filter.register '::Nanoc::Filters::Kramdown', :kramdown
40
- Nanoc::Filter.register '::Nanoc::Filters::Less', :less
41
- Nanoc::Filter.register '::Nanoc::Filters::Markaby', :markaby
42
- Nanoc::Filter.register '::Nanoc::Filters::Maruku', :maruku
43
- Nanoc::Filter.register '::Nanoc::Filters::Mustache', :mustache
44
- Nanoc::Filter.register '::Nanoc::Filters::Pandoc', :pandoc
45
- Nanoc::Filter.register '::Nanoc::Filters::Rainpress', :rainpress
46
- Nanoc::Filter.register '::Nanoc::Filters::RDiscount', :rdiscount
47
- Nanoc::Filter.register '::Nanoc::Filters::RDoc', :rdoc
48
- Nanoc::Filter.register '::Nanoc::Filters::Redcarpet', :redcarpet
49
- Nanoc::Filter.register '::Nanoc::Filters::RedCloth', :redcloth
50
- Nanoc::Filter.register '::Nanoc::Filters::RelativizePaths', :relativize_paths
51
- Nanoc::Filter.register '::Nanoc::Filters::RubyPants', :rubypants
52
- Nanoc::Filter.register '::Nanoc::Filters::Sass', :sass
53
- Nanoc::Filter.register '::Nanoc::Filters::Slim', :slim
54
- Nanoc::Filter.register '::Nanoc::Filters::Typogruby', :typogruby
55
- Nanoc::Filter.register '::Nanoc::Filters::UglifyJS', :uglify_js
56
- Nanoc::Filter.register '::Nanoc::Filters::XSL', :xsl
57
- Nanoc::Filter.register '::Nanoc::Filters::YUICompressor', :yui_compressor
58
3
  end
4
+
5
+ require_relative 'filters/asciidoc'
6
+ require_relative 'filters/bluecloth'
7
+ require_relative 'filters/colorize_syntax'
8
+ require_relative 'filters/coffeescript'
9
+ require_relative 'filters/erb'
10
+ require_relative 'filters/erubis'
11
+ require_relative 'filters/haml'
12
+ require_relative 'filters/handlebars'
13
+ require_relative 'filters/kramdown'
14
+ require_relative 'filters/less'
15
+ require_relative 'filters/markaby'
16
+ require_relative 'filters/maruku'
17
+ require_relative 'filters/mustache'
18
+ require_relative 'filters/pandoc'
19
+ require_relative 'filters/rainpress'
20
+ require_relative 'filters/rdiscount'
21
+ require_relative 'filters/rdoc'
22
+ require_relative 'filters/redcarpet'
23
+ require_relative 'filters/redcloth'
24
+ require_relative 'filters/relativize_paths'
25
+ require_relative 'filters/rubypants'
26
+ require_relative 'filters/sass'
27
+ require_relative 'filters/slim'
28
+ require_relative 'filters/typogruby'
29
+ require_relative 'filters/uglify_js'
30
+ require_relative 'filters/xsl'
31
+ require_relative 'filters/yui_compressor'
@@ -1,6 +1,8 @@
1
1
  module Nanoc::Filters
2
2
  # @api private
3
3
  class AsciiDoc < Nanoc::Filter
4
+ identifier :asciidoc
5
+
4
6
  # Runs the content through [AsciiDoc](http://www.methods.co.nz/asciidoc/).
5
7
  # This method takes no options.
6
8
  #
@@ -1,6 +1,8 @@
1
1
  module Nanoc::Filters
2
2
  # @api private
3
3
  class BlueCloth < Nanoc::Filter
4
+ identifier :bluecloth
5
+
4
6
  requires 'bluecloth'
5
7
 
6
8
  # Runs the content through [BlueCloth](http://deveiate.org/projects/BlueCloth).
@@ -1,6 +1,8 @@
1
1
  module Nanoc::Filters
2
2
  # @api private
3
3
  class CoffeeScript < Nanoc::Filter
4
+ identifier :coffeescript
5
+
4
6
  requires 'coffee-script'
5
7
 
6
8
  # Runs the content through [CoffeeScript](http://coffeescript.org/).
@@ -1,6 +1,8 @@
1
1
  module Nanoc::Filters
2
2
  # @api private
3
3
  class ColorizeSyntax < Nanoc::Filter
4
+ identifier :colorize_syntax
5
+
4
6
  requires 'nokogiri', 'stringio', 'open3'
5
7
 
6
8
  # The default colorizer to use for a language if the colorizer for that
@@ -1,6 +1,8 @@
1
1
  module Nanoc::Filters
2
2
  # @api private
3
3
  class ERB < Nanoc::Filter
4
+ identifier :erb
5
+
4
6
  requires 'erb'
5
7
 
6
8
  # Runs the content through [ERB](http://ruby-doc.org/stdlib/libdoc/erb/rdoc/classes/ERB.html).
@@ -1,14 +1,9 @@
1
1
  module Nanoc::Filters
2
2
  # @api private
3
3
  class Erubis < Nanoc::Filter
4
- requires 'erubis'
4
+ identifier :erubis
5
5
 
6
- # The same as `::Erubis::Eruby` but adds `_erbout` as an alias for the
7
- # `_buf` variable, making it compatible with Nanoc’s helpers that rely
8
- # on `_erbout`, such as {Nanoc::Helpers::Capturing}.
9
- class ErubisWithErbout < ::Erubis::Eruby
10
- include ::Erubis::ErboutEnhancer
11
- end
6
+ requires 'erubis'
12
7
 
13
8
  # Runs the content through [Erubis](http://www.kuwata-lab.com/erubis/).
14
9
  # This method takes no options.
@@ -25,7 +20,13 @@ module Nanoc::Filters
25
20
  assigns_binding = context.get_binding(&proc)
26
21
 
27
22
  # Get result
28
- ErubisWithErbout.new(content, filename: filename).result(assigns_binding)
23
+ erubis_with_erbout.new(content, filename: filename).result(assigns_binding)
24
+ end
25
+
26
+ private
27
+
28
+ def erubis_with_erbout
29
+ @_erubis_with_erbout ||= Class.new(::Erubis::Eruby) { include ::Erubis::ErboutEnhancer }
29
30
  end
30
31
  end
31
32
  end
@@ -1,6 +1,8 @@
1
1
  module Nanoc::Filters
2
2
  # @api private
3
3
  class Haml < Nanoc::Filter
4
+ identifier :haml
5
+
4
6
  requires 'haml'
5
7
 
6
8
  # Runs the content through [Haml](http://haml-lang.com/).
@@ -1,6 +1,8 @@
1
1
  module Nanoc::Filters
2
2
  # @api private
3
3
  class Handlebars < Nanoc::Filter
4
+ identifier :handlebars
5
+
4
6
  requires 'handlebars'
5
7
 
6
8
  # Runs the content through
@@ -1,6 +1,8 @@
1
1
  module Nanoc::Filters
2
2
  # @api private
3
3
  class Kramdown < Nanoc::Filter
4
+ identifier :kramdown
5
+
4
6
  requires 'kramdown'
5
7
 
6
8
  # Runs the content through [Kramdown](http://kramdown.gettalong.org/).
@@ -1,6 +1,8 @@
1
1
  module Nanoc::Filters
2
2
  # @api private
3
3
  class Less < Nanoc::Filter
4
+ identifier :less
5
+
4
6
  requires 'less'
5
7
 
6
8
  # Runs the content through [LESS](http://lesscss.org/).
@@ -1,6 +1,8 @@
1
1
  module Nanoc::Filters
2
2
  # @api private
3
3
  class Markaby < Nanoc::Filter
4
+ identifier :markaby
5
+
4
6
  requires 'markaby'
5
7
 
6
8
  # Runs the content through [Markaby](http://markaby.github.io/).
@@ -1,6 +1,8 @@
1
1
  module Nanoc::Filters
2
2
  # @api private
3
3
  class Maruku < Nanoc::Filter
4
+ identifier :maruku
5
+
4
6
  requires 'maruku'
5
7
 
6
8
  # Runs the content through [Maruku](https://github.com/bhollis/maruku/).
@@ -1,6 +1,8 @@
1
1
  module Nanoc::Filters
2
2
  # @api private
3
3
  class Mustache < Nanoc::Filter
4
+ identifier :mustache
5
+
4
6
  requires 'mustache'
5
7
 
6
8
  # Runs the content through
@@ -1,6 +1,8 @@
1
1
  module Nanoc::Filters
2
2
  # @api private
3
3
  class Pandoc < Nanoc::Filter
4
+ identifier :pandoc
5
+
4
6
  requires 'pandoc-ruby'
5
7
 
6
8
  # Runs the content through [Pandoc](http://johnmacfarlane.net/pandoc/)
@@ -1,6 +1,8 @@
1
1
  module Nanoc::Filters
2
2
  # @api private
3
3
  class Rainpress < Nanoc::Filter
4
+ identifier :rainpress
5
+
4
6
  requires 'rainpress'
5
7
 
6
8
  # Runs the content through [Rainpress](http://code.google.com/p/rainpress/).
@@ -1,6 +1,8 @@
1
1
  module Nanoc::Filters
2
2
  # @api private
3
3
  class RDiscount < Nanoc::Filter
4
+ identifier :rdiscount
5
+
4
6
  requires 'rdiscount'
5
7
 
6
8
  # Runs the content through [RDiscount](http://github.com/rtomayko/rdiscount).
@@ -1,6 +1,8 @@
1
1
  module Nanoc::Filters
2
2
  # @api private
3
3
  class RDoc < Nanoc::Filter
4
+ identifier :rdoc
5
+
4
6
  requires 'rdoc'
5
7
 
6
8
  # Runs the content through [RDoc::Markup](http://docs.seattlerb.org/rdoc/RDoc/Markup.html).
@@ -1,6 +1,8 @@
1
1
  module Nanoc::Filters
2
2
  # @api private
3
3
  class Redcarpet < Nanoc::Filter
4
+ identifier :redcarpet
5
+
4
6
  requires 'redcarpet'
5
7
 
6
8
  # Runs the content through [Redcarpet](https://github.com/vmg/redcarpet).
@@ -1,6 +1,8 @@
1
1
  module Nanoc::Filters
2
2
  # @api private
3
3
  class RedCloth < Nanoc::Filter
4
+ identifier :redcloth
5
+
4
6
  requires 'redcloth'
5
7
 
6
8
  # Runs the content through [RedCloth](http://redcloth.org/). This method