awestruct 0.5.3 → 0.5.4.beta1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/awestruct/cli/init.rb +35 -34
- data/lib/awestruct/cli/invoker.rb +4 -4
- data/lib/awestruct/cli/manifest.rb +57 -55
- data/lib/awestruct/cli/options.rb +11 -0
- data/lib/awestruct/config.rb +17 -14
- data/lib/awestruct/deploy/base_deploy.rb +13 -7
- data/lib/awestruct/deploy/github_pages_deploy.rb +14 -9
- data/lib/awestruct/engine.rb +17 -12
- data/lib/awestruct/extensions/intense_debate.rb +1 -1
- data/lib/awestruct/extensions/minify.rb +1 -1
- data/lib/awestruct/extensions/pipeline.rb +2 -2
- data/lib/awestruct/extensions/relative.rb +7 -1
- data/lib/awestruct/frameworks/base_Gemfile +5 -1
- data/lib/awestruct/frameworks/bootstrap/base_layout.html.haml +2 -2
- data/lib/awestruct/handler_chains.rb +2 -2
- data/lib/awestruct/handlers/asciidoctor_handler.rb +22 -4
- data/lib/awestruct/handlers/base_tilt_handler.rb +34 -10
- data/lib/awestruct/handlers/file_handler.rb +8 -12
- data/lib/awestruct/handlers/front_matter_handler.rb +1 -1
- data/lib/awestruct/handlers/interpolation_handler.rb +1 -6
- data/lib/awestruct/handlers/tilt_handler.rb +1 -7
- data/lib/awestruct/handlers/verbatim_file_handler.rb +12 -0
- data/lib/awestruct/scm/git.rb +14 -0
- data/lib/awestruct/version.rb +1 -1
- data/man/awestruct.1 +14 -3
- data/spec/asciidoc_handler_spec.rb +43 -40
- data/spec/awestruct/scm/git_spec.rb +29 -0
- data/spec/config_spec.rb +8 -2
- data/spec/engine_spec.rb +31 -9
- data/spec/erb_handler_spec.rb +33 -31
- data/spec/front_matter_handler_spec.rb +17 -6
- data/spec/github_pages_deploy_spec.rb +13 -7
- data/spec/haml_handler_spec.rb +62 -59
- data/spec/interpolation_handler_spec.rb +4 -8
- data/spec/javascript_handler_spec.rb +16 -13
- data/spec/minify_spec.rb +3 -1
- data/spec/mustache_handler_spec.rb +11 -7
- data/spec/options_spec.rb +20 -11
- data/spec/page_loader_spec.rb +3 -1
- data/spec/page_loader_spec_for_layouts.rb +3 -1
- data/spec/redirect_handler_spec.rb +21 -17
- data/spec/slim_handler_spec.rb +51 -49
- data/spec/support/shared_handler_example.rb +12 -8
- data/spec/test-data/front-matter-file-utf8.txt +5 -0
- data/spec/test-data/handlers/haml-error.html.haml +4 -0
- data/spec/test-data/handlers/hello.bogus +1 -0
- data/spec/tilt_handler_spec.rb +70 -3
- metadata +16 -25
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'awestruct/scm/git'
|
1
3
|
require 'awestruct/deploy/github_pages_deploy'
|
2
4
|
|
3
5
|
describe Awestruct::Deploy::GitHubPagesDeploy do
|
@@ -9,6 +11,8 @@ describe Awestruct::Deploy::GitHubPagesDeploy do
|
|
9
11
|
@deploy_config = mock
|
10
12
|
@deploy_config.stub(:[]).with('branch').and_return('the-branch')
|
11
13
|
@deploy_config.stub(:[]).with('repository').and_return('the-repo')
|
14
|
+
@deploy_config.stub(:[]).with('scm').and_return('git')
|
15
|
+
@deploy_config.stub(:[]).with('source_dir').and_return('.')
|
12
16
|
@deploy_config.stub(:[]).with('uncommitted').and_return('false')
|
13
17
|
@deployer = Awestruct::Deploy::GitHubPagesDeploy.new( site_config, @deploy_config )
|
14
18
|
|
@@ -21,19 +25,18 @@ describe Awestruct::Deploy::GitHubPagesDeploy do
|
|
21
25
|
Awestruct::Deployers.instance[ :github_pages ].should == Awestruct::Deploy::GitHubPagesDeploy
|
22
26
|
end
|
23
27
|
|
24
|
-
it "should publish the site if there have been changes to the git repo" do
|
25
|
-
::Git.should_receive(:open).with('.').and_return @git
|
26
|
-
@deployer.should_receive(:publish_site)
|
27
|
-
@deployer.run(@deploy_config)
|
28
|
-
end
|
29
|
-
|
30
28
|
it "should warn and noop if no changes have been committed" do
|
31
|
-
|
29
|
+
git_scm = mock()
|
30
|
+
git_scm.stub(:uncommitted_changes?).with('.').and_return true
|
31
|
+
::Awestruct::Scm::Git.stub(:new).and_return git_scm
|
32
32
|
$LOG.should_receive(:error).with(Awestruct::Deploy::Base::UNCOMMITTED_CHANGES)
|
33
33
|
@deployer.run(@deploy_config)
|
34
34
|
end
|
35
35
|
|
36
36
|
it "should save and restore the current branch when publishing" do
|
37
|
+
git_scm = mock()
|
38
|
+
git_scm.stub(:uncommitted_changes?).with('.').and_return false
|
39
|
+
::Awestruct::Scm::Git.stub(:new).and_return git_scm
|
37
40
|
@git.should_receive(:current_branch).and_return( 'bacon' )
|
38
41
|
@git.stub_chain(:branch, :checkout)
|
39
42
|
@git.should_receive(:push).with('the-repo', 'the-branch')
|
@@ -44,6 +47,9 @@ describe Awestruct::Deploy::GitHubPagesDeploy do
|
|
44
47
|
end
|
45
48
|
|
46
49
|
it "should save and restore the current detached branch when publishing" do
|
50
|
+
git_scm = mock()
|
51
|
+
git_scm.stub(:uncommitted_changes?).with('.').and_return false
|
52
|
+
::Awestruct::Scm::Git.stub(:new).and_return git_scm
|
47
53
|
@git.should_receive(:current_branch).and_return( '(no branch)' )
|
48
54
|
@git.should_receive(:revparse).with( 'HEAD' ).and_return( '0123456789' )
|
49
55
|
@git.stub_chain(:branch, :checkout)
|
data/spec/haml_handler_spec.rb
CHANGED
@@ -6,12 +6,12 @@ verify = lambda { |output|
|
|
6
6
|
}
|
7
7
|
|
8
8
|
verify_atom = lambda { |output|
|
9
|
-
output.should ==
|
9
|
+
output.should == '<?xml version="1.0" encoding="utf-8" ?>
|
10
10
|
<feed xmlns="http://www.w3.org/2005/Atom">
|
11
11
|
<id>http://example.com</id>
|
12
12
|
<title>A News Feed</title>
|
13
13
|
</feed>
|
14
|
-
|
14
|
+
'
|
15
15
|
}
|
16
16
|
|
17
17
|
verify_with_markdown = lambda { |output|
|
@@ -31,63 +31,66 @@ verify_with_variables = lambda { |output|
|
|
31
31
|
}
|
32
32
|
|
33
33
|
theories =
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
34
|
+
[
|
35
|
+
{
|
36
|
+
:page => 'haml-page.html.haml',
|
37
|
+
:simple_name => 'haml-page',
|
38
|
+
:syntax => :haml,
|
39
|
+
:extension => '.html',
|
40
|
+
:format => :html5,
|
41
|
+
:matcher => verify
|
42
|
+
},
|
43
|
+
{
|
44
|
+
:page => 'haml-page.xml.haml',
|
45
|
+
:simple_name => 'haml-page',
|
46
|
+
:syntax => :haml,
|
47
|
+
:extension => '.xml',
|
48
|
+
:format => :xhtml,
|
49
|
+
:matcher => verify
|
50
|
+
},
|
51
|
+
{
|
52
|
+
:page => 'haml-page.atom.haml',
|
53
|
+
:simple_name => 'haml-page',
|
54
|
+
:syntax => :haml,
|
55
|
+
:extension => '.atom',
|
56
|
+
:format => :xhtml,
|
57
|
+
:matcher => verify_atom
|
58
|
+
},
|
59
|
+
{
|
60
|
+
:page => 'haml-with-markdown-page.html.haml',
|
61
|
+
:simple_name => 'haml-with-markdown-page',
|
62
|
+
:syntax => :haml,
|
63
|
+
:extension => '.html',
|
64
|
+
:matcher => verify_with_markdown
|
65
|
+
},
|
66
|
+
{
|
67
|
+
:page => 'haml-with-textile-page.html.haml',
|
68
|
+
:simple_name => 'haml-with-textile-page',
|
69
|
+
:syntax => :haml,
|
70
|
+
:extension => '.html',
|
71
|
+
:matcher => verify_with_textile
|
72
|
+
},
|
73
|
+
{
|
74
|
+
:page => 'haml-with-utf.html.haml',
|
75
|
+
:simple_name => 'haml-with-utf',
|
76
|
+
:syntax => :haml,
|
77
|
+
:extension => '.html',
|
78
|
+
:matcher => verify_with_utf8
|
79
|
+
},
|
80
|
+
{
|
81
|
+
:page => 'haml-with-variables.html.haml',
|
82
|
+
:simple_name => 'haml-with-variables',
|
83
|
+
:syntax => :haml,
|
84
|
+
:extension => '.html',
|
85
|
+
:matcher => verify_with_variables
|
86
|
+
}
|
87
|
+
]
|
88
88
|
|
89
|
-
describe Awestruct::Handlers::TiltHandler.to_s + "-Haml" do
|
90
|
-
let(:additional_config) { {:crunchy => 'bacon'} }
|
91
|
-
it_should_behave_like "a handler", theories
|
92
89
|
|
90
|
+
describe Awestruct::Handlers::TiltHandler.to_s + '-Haml' do
|
91
|
+
def additional_config
|
92
|
+
{ :crunchy => 'bacon' }
|
93
|
+
end
|
94
|
+
|
95
|
+
it_should_behave_like 'a handler', theories
|
93
96
|
end
|
@@ -17,14 +17,10 @@ describe Awestruct::Handlers::InterpolationHandler do
|
|
17
17
|
end
|
18
18
|
|
19
19
|
it "should correctly interpolate complicated stuff that includes regular expressions [Issue #139]" do
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
content.should == input
|
25
|
-
else
|
26
|
-
pending "Cannot yet handle this test case with ruby 1.8"
|
27
|
-
end
|
20
|
+
input = %q(url = url.replace(/\/?#$/, '');)
|
21
|
+
handler = build_handler( input )
|
22
|
+
content = handler.rendered_content( Hashery::OpenCascade[] )
|
23
|
+
content.should == input
|
28
24
|
end
|
29
25
|
|
30
26
|
def build_handler( input )
|
@@ -2,22 +2,25 @@
|
|
2
2
|
require 'spec_helper'
|
3
3
|
|
4
4
|
verify = lambda { |output|
|
5
|
-
|
5
|
+
output.should =~ %r(var crunchy = "bacon")
|
6
6
|
}
|
7
7
|
|
8
8
|
theories =
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
9
|
+
[
|
10
|
+
{
|
11
|
+
:page => 'javascript-page.js',
|
12
|
+
:simple_name => 'javascript-page',
|
13
|
+
:syntax => :javascript,
|
14
|
+
:extension => '.js',
|
15
|
+
:matcher => verify
|
16
|
+
}
|
17
|
+
]
|
18
18
|
|
19
|
-
describe Awestruct::Handlers::TiltHandler.to_s + "-JavaScript" do
|
20
|
-
let(:additional_config) { {:interpolate => true, :crunchy => 'bacon'} }
|
21
|
-
it_should_behave_like "a handler", theories
|
22
19
|
|
20
|
+
describe Awestruct::Handlers::TiltHandler.to_s + '-JavaScript' do
|
21
|
+
def additional_config
|
22
|
+
{ :interpolate => true, :crunchy => 'bacon' }
|
23
|
+
end
|
24
|
+
|
25
|
+
it_should_behave_like 'a handler', theories
|
23
26
|
end
|
data/spec/minify_spec.rb
CHANGED
@@ -53,7 +53,9 @@ describe Awestruct::Extensions::Minify do
|
|
53
53
|
page.should_receive(:output_path).any_number_of_times.and_return "test.js"
|
54
54
|
|
55
55
|
input = "function a (a, c) { \n a = \"a\";\n }"
|
56
|
-
|
56
|
+
# we're minifying so we're going to strip dead or unreferenced code
|
57
|
+
# note that htmlcompressor < 0.0.7 generates different output
|
58
|
+
expected_output = "function a(a){a=\"a\"}"
|
57
59
|
|
58
60
|
minifier = Awestruct::Extensions::Minify.new [:js]
|
59
61
|
minifier.transform(site, page, input).should == expected_output
|
@@ -7,23 +7,27 @@ verify = lambda { |output|
|
|
7
7
|
theories =
|
8
8
|
[
|
9
9
|
{
|
10
|
-
:page =>
|
11
|
-
:simple_name =>
|
10
|
+
:page => 'mustache-page.html.mustache',
|
11
|
+
:simple_name => 'mustache-page',
|
12
12
|
:syntax => :mustache,
|
13
13
|
:extension => '.html',
|
14
14
|
:matcher => verify
|
15
15
|
},
|
16
16
|
{
|
17
|
-
:page =>
|
18
|
-
:simple_name =>
|
17
|
+
:page => 'mustache-page.xml.mustache',
|
18
|
+
:simple_name => 'mustache-page',
|
19
19
|
:syntax => :mustache,
|
20
20
|
:extension => '.xml',
|
21
21
|
:matcher => verify
|
22
22
|
}
|
23
23
|
]
|
24
24
|
|
25
|
-
|
26
|
-
|
27
|
-
|
25
|
+
|
26
|
+
describe Awestruct::Handlers::TiltHandler.to_s + '-Mustache' do
|
27
|
+
def additional_config
|
28
|
+
{:markup_type => 'Mustache'}
|
29
|
+
end
|
30
|
+
|
31
|
+
it_should_behave_like 'a handler', theories
|
28
32
|
|
29
33
|
end
|
data/spec/options_spec.rb
CHANGED
@@ -3,7 +3,7 @@ require 'awestruct/cli/options'
|
|
3
3
|
|
4
4
|
describe Awestruct::CLI::Options do
|
5
5
|
|
6
|
-
it
|
6
|
+
it 'should have reasonable defaults' do
|
7
7
|
options = Awestruct::CLI::Options.new
|
8
8
|
options.generate.should == nil
|
9
9
|
options.server.should == false
|
@@ -23,14 +23,17 @@ describe Awestruct::CLI::Options do
|
|
23
23
|
options.profile.should == nil
|
24
24
|
options.script.should == nil
|
25
25
|
options.verbose.should == false
|
26
|
+
|
27
|
+
options.output_dir == File.join( __FILE__, '..', '_site' )
|
28
|
+
options.source_dir == File.join( __FILE__, '..' )
|
26
29
|
end
|
27
30
|
|
28
|
-
describe
|
31
|
+
describe 'parsing' do
|
29
32
|
def parse!(*args)
|
30
33
|
Awestruct::CLI::Options.parse! args
|
31
34
|
end
|
32
35
|
|
33
|
-
it
|
36
|
+
it 'should parse server-related args' do
|
34
37
|
parse!( '-s' ).server.should == true
|
35
38
|
parse!( '--server' ).server.should == true
|
36
39
|
|
@@ -44,12 +47,12 @@ describe Awestruct::CLI::Options do
|
|
44
47
|
parse!( '--url', 'http://mysite.com/' ).base_url.should == 'http://mysite.com/'
|
45
48
|
end
|
46
49
|
|
47
|
-
it
|
50
|
+
it 'should parse profile-related args' do
|
48
51
|
parse!( '-P', 'numberwang' ).profile.should == 'numberwang'
|
49
52
|
parse!( '--profile', 'superhans' ).profile.should == 'superhans'
|
50
53
|
end
|
51
54
|
|
52
|
-
it
|
55
|
+
it 'should parse generation-related args' do
|
53
56
|
parse!( '-g' ).generate.should == true
|
54
57
|
parse!( '--generate' ).generate.should == true
|
55
58
|
parse!( '--no-generate' ).generate.should == false
|
@@ -60,18 +63,18 @@ describe Awestruct::CLI::Options do
|
|
60
63
|
parse!( '--auto' ).auto.should == true
|
61
64
|
end
|
62
65
|
|
63
|
-
it
|
64
|
-
pending
|
66
|
+
it 'should parse script-related args' do
|
67
|
+
pending 'Not yet implemented. See issue #248.'
|
65
68
|
#parse!( '--run', 'puts "hi"' ).script.should == 'puts "hi"'
|
66
69
|
end
|
67
70
|
|
68
|
-
it
|
71
|
+
it 'should turn off generate when doing a --deploy' do
|
69
72
|
result = parse!( '--deploy' )
|
70
73
|
result.deploy.should be_true
|
71
74
|
result.generate.should be_false
|
72
75
|
end
|
73
76
|
|
74
|
-
it
|
77
|
+
it 'should turn off generate when doing a --deploy unless explicitly turned back on' do
|
75
78
|
result = parse!( '--deploy', '--generate' )
|
76
79
|
result.deploy.should be_true
|
77
80
|
result.generate.should be_true
|
@@ -81,7 +84,7 @@ describe Awestruct::CLI::Options do
|
|
81
84
|
result.generate.should be_true
|
82
85
|
end
|
83
86
|
|
84
|
-
it
|
87
|
+
it 'should turn on verbose when -w or --verbose is explicitly turned back on' do
|
85
88
|
result = parse!( '-w' )
|
86
89
|
result.verbose.should be_true
|
87
90
|
|
@@ -89,9 +92,15 @@ describe Awestruct::CLI::Options do
|
|
89
92
|
result.verbose.should be_true
|
90
93
|
end
|
91
94
|
|
92
|
-
it
|
95
|
+
it 'should generate by default' do
|
93
96
|
parse!().generate.should be_true
|
94
97
|
end
|
98
|
+
|
99
|
+
it 'should parse directory options' do
|
100
|
+
result = Awestruct::CLI::Options.parse!(%w(--source-dir /tmp --output-dir /tmp/new-site))
|
101
|
+
result.source_dir.should eql '/tmp'
|
102
|
+
result.output_dir.should eql '/tmp/new-site'
|
103
|
+
end
|
95
104
|
end
|
96
105
|
|
97
106
|
end
|
data/spec/page_loader_spec.rb
CHANGED
@@ -6,7 +6,9 @@ require 'awestruct/config'
|
|
6
6
|
describe Awestruct::PageLoader do
|
7
7
|
|
8
8
|
before :each do
|
9
|
-
@
|
9
|
+
@opts = Awestruct::CLI::Options.new
|
10
|
+
@opts.source_dir = File.dirname(__FILE__) + '/test-data/page-loader'
|
11
|
+
@config = Awestruct::Config.new( @opts )
|
10
12
|
@engine = Awestruct::Engine.new
|
11
13
|
@engine.pipeline.handler_chains << :defaults
|
12
14
|
@site = Awestruct::Site.new( @engine, @config )
|
@@ -6,7 +6,9 @@ require 'awestruct/config'
|
|
6
6
|
describe Awestruct::PageLoader do
|
7
7
|
|
8
8
|
before :each do
|
9
|
-
@
|
9
|
+
@opts = Awestruct::CLI::Options.new
|
10
|
+
@opts.source_dir = File.dirname(__FILE__) + '/test-data/page-loader'
|
11
|
+
@config = Awestruct::Config.new( @opts )
|
10
12
|
@engine = Awestruct::Engine.new
|
11
13
|
@engine.pipeline.handler_chains << :defaults
|
12
14
|
@site = Awestruct::Site.new( @engine, @config )
|
@@ -8,25 +8,29 @@ verify_with_interpol = lambda { |output|
|
|
8
8
|
}
|
9
9
|
|
10
10
|
theories =
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
11
|
+
[
|
12
|
+
{
|
13
|
+
:page => "simple-redirect-page.redirect",
|
14
|
+
:simple_name => "simple-redirect-page",
|
15
|
+
:syntax => :text,
|
16
|
+
:extension => '.html',
|
17
|
+
:matcher => verify
|
18
|
+
},
|
19
|
+
{
|
20
|
+
:page => "redirect-page.redirect",
|
21
|
+
:simple_name => "redirect-page",
|
22
|
+
:syntax => :text,
|
23
|
+
:extension => '.html',
|
24
|
+
:matcher => verify_with_interpol
|
25
|
+
}
|
26
|
+
]
|
27
|
+
|
27
28
|
|
28
29
|
describe Awestruct::Handlers::TiltHandler.to_s + "-Redirect" do
|
29
|
-
|
30
|
+
def additional_config
|
31
|
+
{ :interpolate => true, :crunchy => 'bacon', :base_url => 'http://mysite' }
|
32
|
+
end
|
33
|
+
|
30
34
|
it_should_behave_like "a handler", theories
|
31
35
|
|
32
36
|
end
|