nanoc 4.4.7 → 4.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +9 -7
- data/NEWS.md +6 -0
- data/lib/nanoc.rb +1 -0
- data/lib/nanoc/base.rb +0 -1
- data/lib/nanoc/base/feature.rb +1 -1
- data/lib/nanoc/base/repos/data_source.rb +1 -1
- data/lib/nanoc/base/repos/site_loader.rb +1 -1
- data/lib/nanoc/base/services/action_provider.rb +1 -1
- data/lib/nanoc/base/services/filter.rb +1 -1
- data/lib/nanoc/checking.rb +7 -9
- data/lib/nanoc/checking/check.rb +1 -1
- data/lib/nanoc/checking/checks.rb +9 -17
- data/lib/nanoc/checking/checks/internal_links.rb +2 -0
- data/lib/nanoc/checking/checks/mixed_content.rb +2 -0
- data/lib/nanoc/checking/checks/stale.rb +2 -0
- data/lib/nanoc/checking/runner.rb +2 -2
- data/lib/nanoc/cli.rb +9 -6
- data/lib/nanoc/cli/commands/deploy.rb +4 -4
- data/lib/nanoc/cli/commands/show-plugins.rb +12 -12
- data/lib/nanoc/cli/stream_cleaners.rb +7 -7
- data/lib/nanoc/data_sources.rb +0 -3
- data/lib/nanoc/data_sources/filesystem.rb +2 -0
- data/lib/nanoc/deploying/deployer.rb +1 -1
- data/lib/nanoc/deploying/deployers.rb +6 -9
- data/lib/nanoc/deploying/deployers/fog.rb +2 -0
- data/lib/nanoc/deploying/deployers/git.rb +118 -0
- data/lib/nanoc/deploying/deployers/rsync.rb +2 -0
- data/lib/nanoc/extra.rb +5 -6
- data/lib/nanoc/filters.rb +28 -55
- data/lib/nanoc/filters/asciidoc.rb +2 -0
- data/lib/nanoc/filters/bluecloth.rb +2 -0
- data/lib/nanoc/filters/coffeescript.rb +2 -0
- data/lib/nanoc/filters/colorize_syntax.rb +2 -0
- data/lib/nanoc/filters/erb.rb +2 -0
- data/lib/nanoc/filters/erubis.rb +9 -8
- data/lib/nanoc/filters/haml.rb +2 -0
- data/lib/nanoc/filters/handlebars.rb +2 -0
- data/lib/nanoc/filters/kramdown.rb +2 -0
- data/lib/nanoc/filters/less.rb +2 -0
- data/lib/nanoc/filters/markaby.rb +2 -0
- data/lib/nanoc/filters/maruku.rb +2 -0
- data/lib/nanoc/filters/mustache.rb +2 -0
- data/lib/nanoc/filters/pandoc.rb +2 -0
- data/lib/nanoc/filters/rainpress.rb +2 -0
- data/lib/nanoc/filters/rdiscount.rb +2 -0
- data/lib/nanoc/filters/rdoc.rb +2 -0
- data/lib/nanoc/filters/redcarpet.rb +2 -0
- data/lib/nanoc/filters/redcloth.rb +2 -0
- data/lib/nanoc/filters/relativize_paths.rb +2 -0
- data/lib/nanoc/filters/rubypants.rb +2 -0
- data/lib/nanoc/filters/sass.rb +2 -0
- data/lib/nanoc/filters/slim.rb +2 -0
- data/lib/nanoc/filters/typogruby.rb +2 -0
- data/lib/nanoc/filters/uglify_js.rb +2 -0
- data/lib/nanoc/filters/xsl.rb +2 -0
- data/lib/nanoc/filters/yui_compressor.rb +2 -0
- data/lib/nanoc/helpers.rb +12 -11
- data/lib/nanoc/version.rb +1 -1
- data/nanoc.gemspec +1 -0
- data/spec/nanoc/base/filter_spec.rb +2 -2
- data/spec/nanoc/cli/commands/deploy_spec.rb +2 -2
- data/spec/nanoc/cli/commands/show_plugins_spec.rb +18 -0
- data/spec/nanoc/deploying/git_spec.rb +302 -0
- data/spec/spec_helper.rb +2 -0
- data/test/deploying/test_git.rb +261 -0
- metadata +20 -5
- data/lib/nanoc/base/plugin_registry.rb +0 -219
- data/spec/nanoc/base/plugin_registry_spec.rb +0 -29
- 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
|
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
|
-
|
21
|
-
|
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'
|
data/lib/nanoc/filters/erb.rb
CHANGED
data/lib/nanoc/filters/erubis.rb
CHANGED
@@ -1,14 +1,9 @@
|
|
1
1
|
module Nanoc::Filters
|
2
2
|
# @api private
|
3
3
|
class Erubis < Nanoc::Filter
|
4
|
-
|
4
|
+
identifier :erubis
|
5
5
|
|
6
|
-
|
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
|
-
|
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
|
data/lib/nanoc/filters/haml.rb
CHANGED
data/lib/nanoc/filters/less.rb
CHANGED
data/lib/nanoc/filters/maruku.rb
CHANGED
data/lib/nanoc/filters/pandoc.rb
CHANGED
data/lib/nanoc/filters/rdoc.rb
CHANGED