awestruct 0.5.4.beta1 → 0.5.4.rc
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/awestruct/cli/deploy.rb +2 -2
- data/lib/awestruct/cli/generate.rb +3 -3
- data/lib/awestruct/cli/init.rb +1 -1
- data/lib/awestruct/cli/invoker.rb +11 -10
- data/lib/awestruct/cli/manifest.rb +1 -1
- data/lib/awestruct/cli/options.rb +16 -6
- data/lib/awestruct/cli/server.rb +4 -1
- data/lib/awestruct/compatibility.rb +5 -0
- data/lib/awestruct/config/default-site.yml +7 -0
- data/lib/awestruct/deploy/base_deploy.rb +74 -7
- data/lib/awestruct/deploy/github_pages_deploy.rb +20 -7
- data/lib/awestruct/deploy/rsync_deploy.rb +1 -1
- data/lib/awestruct/deploy/s3_deploy.rb +1 -1
- data/lib/awestruct/engine.rb +34 -30
- data/lib/awestruct/frameworks/base_Rakefile +22 -3
- data/lib/awestruct/handlers/asciidoctor_handler.rb +38 -10
- data/lib/awestruct/handlers/front_matter_handler.rb +18 -13
- data/lib/awestruct/handlers/interpolation_handler.rb +1 -1
- data/lib/awestruct/handlers/template/asciidoc.rb +22 -1
- data/lib/awestruct/page_loader.rb +1 -1
- data/lib/awestruct/version.rb +1 -1
- data/spec/asciidoc_handler_spec.rb +51 -1
- data/spec/awestruct/scm/git_spec.rb +2 -2
- data/spec/coffeescript_handler_spec.rb +1 -3
- data/spec/deploy_spec.rb +66 -1
- data/spec/engine_spec.rb +10 -6
- data/spec/erb_handler_spec.rb +4 -6
- data/spec/front_matter_handler_spec.rb +14 -0
- data/spec/github_pages_deploy_spec.rb +14 -9
- data/spec/haml_handler_spec.rb +2 -5
- data/spec/invoker_spec.rb +1 -0
- data/spec/javascript_handler_spec.rb +3 -6
- data/spec/markdown_handler_spec.rb +0 -2
- data/spec/mustache_handler_spec.rb +5 -8
- data/spec/orgmode_handler_spec.rb +1 -3
- data/spec/page_loader_spec.rb +18 -0
- data/spec/redirect_handler_spec.rb +2 -6
- data/spec/restructuredtext_handler_spec.rb +1 -3
- data/spec/sass_handler_spec.rb +1 -3
- data/spec/scss_handler_spec.rb +1 -3
- data/spec/slim_handler_spec.rb +2 -5
- data/spec/support/shared_handler_example.rb +18 -10
- data/spec/test-data/engine/_config/site.yml +2 -0
- data/spec/test-data/front-matter-file-no-content.txt +1 -0
- data/spec/test-data/front-matter-looking.txt +9 -0
- data/spec/test-data/front-matter-middle.txt +12 -0
- data/spec/test-data/gzip/no.html.gz +0 -0
- data/spec/test-data/gzip/no.txt +0 -0
- data/spec/test-data/gzip/subdir/yes.css +3 -0
- data/spec/test-data/gzip/yes.html +10 -0
- data/spec/test-data/gzip/yes.js +1 -0
- data/spec/test-data/handlers/asciidoc_with_attributes.ad +3 -0
- data/spec/test-data/handlers/asciidoc_with_interpolation.ad +4 -0
- data/spec/test-data/handlers/asciidoc_without_interpolation.ad +3 -0
- data/spec/test-data/handlers/asciidoctor_with_headers.ad +7 -4
- data/spec/test-data/handlers/textile-page.textile +3 -1
- data/spec/textile_handler_spec.rb +16 -6
- metadata +28 -7
data/spec/erb_handler_spec.rb
CHANGED
@@ -27,14 +27,16 @@ theories =
|
|
27
27
|
:simple_name => 'erb-page',
|
28
28
|
:syntax => :erb,
|
29
29
|
:extension => '.html',
|
30
|
-
:matcher => verify
|
30
|
+
:matcher => verify,
|
31
|
+
:site_overrides => { :crunchy => 'bacon' }
|
31
32
|
},
|
32
33
|
{
|
33
34
|
:page => 'erb-page.xml.erb',
|
34
35
|
:simple_name => 'erb-page',
|
35
36
|
:syntax => :erb,
|
36
37
|
:extension => '.xml',
|
37
|
-
:matcher => verify_with_xml
|
38
|
+
:matcher => verify_with_xml,
|
39
|
+
:site_overrides => { :crunchy => 'bacon' }
|
38
40
|
},
|
39
41
|
{
|
40
42
|
:page => 'erb-utf-page.html.erb',
|
@@ -46,9 +48,5 @@ theories =
|
|
46
48
|
]
|
47
49
|
|
48
50
|
describe Awestruct::Handlers::TiltHandler.to_s + '-Erb' do
|
49
|
-
def additional_config
|
50
|
-
{ :crunchy => 'bacon' }
|
51
|
-
end
|
52
51
|
it_should_behave_like 'a handler', theories
|
53
|
-
|
54
52
|
end
|
@@ -42,6 +42,20 @@ describe Awestruct::Handlers::FrontMatterHandler do
|
|
42
42
|
handler.raw_content.should be_nil
|
43
43
|
end
|
44
44
|
|
45
|
+
it 'should not match front matter in the middle of a file' do
|
46
|
+
handler = Awestruct::Handlers::FrontMatterHandler.new( @site, file_input('front-matter-middle.txt') )
|
47
|
+
handler.front_matter.should_not be_nil
|
48
|
+
handler.front_matter.should be_empty
|
49
|
+
handler.raw_content.should_not be_nil
|
50
|
+
end
|
51
|
+
|
52
|
+
it 'should not mistake horizontal rule for front matter' do
|
53
|
+
handler = Awestruct::Handlers::FrontMatterHandler.new( @site, file_input('front-matter-looking.txt') )
|
54
|
+
handler.front_matter.should_not be_nil
|
55
|
+
handler.front_matter.should be_empty
|
56
|
+
handler.raw_content.should_not be_nil
|
57
|
+
end
|
58
|
+
|
45
59
|
it 'should be able to handle UTF-8 characters' do
|
46
60
|
handler = Awestruct::Handlers::FrontMatterHandler.new( @site, file_input('front-matter-file-utf8.txt') )
|
47
61
|
handler.front_matter.should_not be_nil
|
@@ -1,5 +1,4 @@
|
|
1
1
|
require 'spec_helper'
|
2
|
-
require 'awestruct/scm/git'
|
3
2
|
require 'awestruct/deploy/github_pages_deploy'
|
4
3
|
|
5
4
|
describe Awestruct::Deploy::GitHubPagesDeploy do
|
@@ -11,6 +10,7 @@ describe Awestruct::Deploy::GitHubPagesDeploy do
|
|
11
10
|
@deploy_config = mock
|
12
11
|
@deploy_config.stub(:[]).with('branch').and_return('the-branch')
|
13
12
|
@deploy_config.stub(:[]).with('repository').and_return('the-repo')
|
13
|
+
@deploy_config.stub(:[]).with('gzip').and_return('false')
|
14
14
|
@deploy_config.stub(:[]).with('scm').and_return('git')
|
15
15
|
@deploy_config.stub(:[]).with('source_dir').and_return('.')
|
16
16
|
@deploy_config.stub(:[]).with('uncommitted').and_return('false')
|
@@ -28,35 +28,40 @@ describe Awestruct::Deploy::GitHubPagesDeploy do
|
|
28
28
|
it "should warn and noop if no changes have been committed" do
|
29
29
|
git_scm = mock()
|
30
30
|
git_scm.stub(:uncommitted_changes?).with('.').and_return true
|
31
|
-
|
31
|
+
@deployer.instance_variable_set('@scm', git_scm)
|
32
32
|
$LOG.should_receive(:error).with(Awestruct::Deploy::Base::UNCOMMITTED_CHANGES)
|
33
|
-
@deployer.run
|
33
|
+
@deployer.run
|
34
34
|
end
|
35
35
|
|
36
36
|
it "should save and restore the current branch when publishing" do
|
37
37
|
git_scm = mock()
|
38
38
|
git_scm.stub(:uncommitted_changes?).with('.').and_return false
|
39
|
-
|
39
|
+
@deployer.instance_variable_set('@scm', git_scm)
|
40
40
|
@git.should_receive(:current_branch).and_return( 'bacon' )
|
41
41
|
@git.stub_chain(:branch, :checkout)
|
42
42
|
@git.should_receive(:push).with('the-repo', 'the-branch')
|
43
43
|
@git.should_receive(:checkout).with( 'bacon' )
|
44
44
|
|
45
45
|
@deployer.stub(:add_and_commit_site)
|
46
|
-
@deployer.run
|
46
|
+
@deployer.run
|
47
47
|
end
|
48
48
|
|
49
49
|
it "should save and restore the current detached branch when publishing" do
|
50
50
|
git_scm = mock()
|
51
51
|
git_scm.stub(:uncommitted_changes?).with('.').and_return false
|
52
|
-
|
52
|
+
@deployer.instance_variable_set('@scm', git_scm)
|
53
53
|
@git.should_receive(:current_branch).and_return( '(no branch)' )
|
54
|
-
@git.
|
55
|
-
@git.
|
54
|
+
@git.stub_chain(:log, :first, :sha).and_return( '0123456789' )
|
55
|
+
@git.should_receive(:branch).with('__awestruct_deploy__').and_return @git
|
56
|
+
@git.should_receive(:checkout)
|
57
|
+
@git.should_receive(:branch).with('the-branch').and_return @git
|
58
|
+
@git.should_receive(:checkout)
|
56
59
|
@git.should_receive(:push).with('the-repo', 'the-branch')
|
57
60
|
@git.should_receive(:checkout).with( '0123456789' )
|
61
|
+
@git.should_receive(:branch).with('__awestruct_deploy__').and_return @git
|
62
|
+
@git.should_receive(:delete)
|
58
63
|
|
59
64
|
@deployer.stub(:add_and_commit_site)
|
60
|
-
@deployer.run
|
65
|
+
@deployer.run
|
61
66
|
end
|
62
67
|
end
|
data/spec/haml_handler_spec.rb
CHANGED
@@ -82,15 +82,12 @@ theories =
|
|
82
82
|
:simple_name => 'haml-with-variables',
|
83
83
|
:syntax => :haml,
|
84
84
|
:extension => '.html',
|
85
|
-
:matcher => verify_with_variables
|
85
|
+
:matcher => verify_with_variables,
|
86
|
+
:site_overrides => { :crunchy => 'bacon' }
|
86
87
|
}
|
87
88
|
]
|
88
89
|
|
89
90
|
|
90
91
|
describe Awestruct::Handlers::TiltHandler.to_s + '-Haml' do
|
91
|
-
def additional_config
|
92
|
-
{ :crunchy => 'bacon' }
|
93
|
-
end
|
94
|
-
|
95
92
|
it_should_behave_like 'a handler', theories
|
96
93
|
end
|
data/spec/invoker_spec.rb
CHANGED
@@ -64,6 +64,7 @@ describe Awestruct::CLI::Invoker do
|
|
64
64
|
end
|
65
65
|
|
66
66
|
it "should return false on failure" do
|
67
|
+
require 'awestruct/cli/generate'
|
67
68
|
generator = mock
|
68
69
|
Awestruct::CLI::Generate.should_receive( :new ).and_return( generator )
|
69
70
|
generator.should_receive( :run ).and_return( false )
|
@@ -12,15 +12,12 @@ theories =
|
|
12
12
|
:simple_name => 'javascript-page',
|
13
13
|
:syntax => :javascript,
|
14
14
|
:extension => '.js',
|
15
|
-
:matcher => verify
|
15
|
+
:matcher => verify,
|
16
|
+
:site_overrides => { :interpolate => true, :crunchy => 'bacon' }
|
16
17
|
}
|
17
18
|
]
|
18
19
|
|
19
20
|
|
20
21
|
describe Awestruct::Handlers::TiltHandler.to_s + '-JavaScript' do
|
21
|
-
def additional_config
|
22
|
-
{ :interpolate => true, :crunchy => 'bacon' }
|
23
|
-
end
|
24
|
-
|
25
22
|
it_should_behave_like 'a handler', theories
|
26
|
-
end
|
23
|
+
end
|
@@ -11,23 +11,20 @@ theories =
|
|
11
11
|
:simple_name => 'mustache-page',
|
12
12
|
:syntax => :mustache,
|
13
13
|
:extension => '.html',
|
14
|
-
:matcher => verify
|
14
|
+
:matcher => verify,
|
15
|
+
:site_overrides => { :markup_type => 'Mustache' }
|
15
16
|
},
|
16
17
|
{
|
17
18
|
:page => 'mustache-page.xml.mustache',
|
18
19
|
:simple_name => 'mustache-page',
|
19
20
|
:syntax => :mustache,
|
20
21
|
:extension => '.xml',
|
21
|
-
:matcher => verify
|
22
|
+
:matcher => verify,
|
23
|
+
:site_overrides => { :markup_type => 'Mustache' }
|
22
24
|
}
|
23
25
|
]
|
24
26
|
|
25
27
|
|
26
28
|
describe Awestruct::Handlers::TiltHandler.to_s + '-Mustache' do
|
27
|
-
def additional_config
|
28
|
-
{:markup_type => 'Mustache'}
|
29
|
-
end
|
30
|
-
|
31
29
|
it_should_behave_like 'a handler', theories
|
32
|
-
|
33
|
-
end
|
30
|
+
end
|
data/spec/page_loader_spec.rb
CHANGED
@@ -42,4 +42,22 @@ describe Awestruct::PageLoader do
|
|
42
42
|
@site.pages[1].output_path.should == '/page-two.html'
|
43
43
|
end
|
44
44
|
|
45
|
+
it "should be able to load all site pages (even drafts) if show_drafts is true" do
|
46
|
+
@site.show_drafts = true
|
47
|
+
@loader.load_all
|
48
|
+
@site.pages.size.should == 3
|
49
|
+
|
50
|
+
@site.pages.sort!{|l,r| l.relative_source_path <=> r.relative_source_path }
|
51
|
+
|
52
|
+
@site.pages[0].relative_source_path.should == '/page-draft.md'
|
53
|
+
@site.pages[0].output_path.should == '/page-draft.html'
|
54
|
+
|
55
|
+
@site.pages[1].relative_source_path.should == '/page-one.md'
|
56
|
+
@site.pages[1].output_path.should == '/page-one.html'
|
57
|
+
|
58
|
+
@site.pages[2].relative_source_path.should == '/page-two.html.haml'
|
59
|
+
@site.pages[2].output_path.should == '/page-two.html'
|
60
|
+
|
61
|
+
end
|
62
|
+
|
45
63
|
end
|
@@ -21,16 +21,12 @@ theories =
|
|
21
21
|
:simple_name => "redirect-page",
|
22
22
|
:syntax => :text,
|
23
23
|
:extension => '.html',
|
24
|
-
:matcher => verify_with_interpol
|
24
|
+
:matcher => verify_with_interpol,
|
25
|
+
:site_overrides => { :interpolate => true, :crunchy => 'bacon', :base_url => 'http://mysite' }
|
25
26
|
}
|
26
27
|
]
|
27
28
|
|
28
29
|
|
29
30
|
describe Awestruct::Handlers::TiltHandler.to_s + "-Redirect" do
|
30
|
-
def additional_config
|
31
|
-
{ :interpolate => true, :crunchy => 'bacon', :base_url => 'http://mysite' }
|
32
|
-
end
|
33
|
-
|
34
31
|
it_should_behave_like "a handler", theories
|
35
|
-
|
36
32
|
end
|
data/spec/sass_handler_spec.rb
CHANGED
data/spec/scss_handler_spec.rb
CHANGED
data/spec/slim_handler_spec.rb
CHANGED
@@ -70,14 +70,11 @@ theories =
|
|
70
70
|
:simple_name => 'slim-with-variables',
|
71
71
|
:syntax => :slim,
|
72
72
|
:extension => '.html',
|
73
|
-
:matcher => verify_with_variables
|
73
|
+
:matcher => verify_with_variables,
|
74
|
+
:site_overrides => { :crunchy => 'bacon' }
|
74
75
|
}
|
75
76
|
]
|
76
77
|
|
77
78
|
describe Awestruct::Handlers::TiltHandler.to_s + '-Slim' do
|
78
|
-
def additional_config
|
79
|
-
{ :crunchy => 'bacon' }
|
80
|
-
end
|
81
|
-
|
82
79
|
it_should_behave_like 'a handler', theories
|
83
80
|
end
|
@@ -5,7 +5,7 @@ require 'rspec'
|
|
5
5
|
require 'hashery'
|
6
6
|
|
7
7
|
REQUIRED_VARIABLES = [:page, :simple_name, :syntax, :extension]
|
8
|
-
ALL_VARIABLES = REQUIRED_VARIABLES + [:format, :matcher, :unless]
|
8
|
+
ALL_VARIABLES = REQUIRED_VARIABLES + [:format, :matcher, :unless, :site_overrides]
|
9
9
|
|
10
10
|
shared_examples 'a handler' do |theories|
|
11
11
|
|
@@ -19,24 +19,29 @@ shared_examples 'a handler' do |theories|
|
|
19
19
|
|
20
20
|
describe Awestruct::Handlers do
|
21
21
|
|
22
|
-
before :
|
23
|
-
@
|
24
|
-
@opts.source_dir = File.dirname(__FILE__) + '/../test-data/handlers'
|
25
|
-
@config = Awestruct::Config.new( @opts )
|
26
|
-
|
27
|
-
@engine = Awestruct::Engine.new( @config )
|
28
|
-
@engine.load_default_site_yaml
|
22
|
+
before :each do
|
23
|
+
@engine = init
|
29
24
|
@site = @engine.site
|
30
25
|
end
|
31
26
|
|
32
|
-
|
33
|
-
|
27
|
+
def init
|
28
|
+
opts = Awestruct::CLI::Options.new
|
29
|
+
opts.source_dir = File.dirname(__FILE__) + '/../test-data/handlers'
|
30
|
+
config = Awestruct::Config.new( opts )
|
31
|
+
|
32
|
+
engine = Awestruct::Engine.new( config )
|
33
|
+
engine.load_default_site_yaml
|
34
|
+
engine
|
34
35
|
end
|
35
36
|
|
36
37
|
def create_handler(page)
|
37
38
|
@engine.load_page File.join(@engine.config.dir, page)
|
38
39
|
end
|
39
40
|
|
41
|
+
def merge_site_overrides(overrides)
|
42
|
+
@site.update overrides
|
43
|
+
end
|
44
|
+
|
40
45
|
theories.each do |theory|
|
41
46
|
|
42
47
|
# Validate input
|
@@ -82,6 +87,9 @@ shared_examples 'a handler' do |theories|
|
|
82
87
|
|
83
88
|
it "should render page '#{theory[:page]}'" do
|
84
89
|
if theory[:unless].nil? or !theory[:unless][:exp].call()
|
90
|
+
if theory.has_key? :site_overrides
|
91
|
+
merge_site_overrides(theory[:site_overrides])
|
92
|
+
end
|
85
93
|
handler = create_handler theory[:page]
|
86
94
|
handler.update(additional_config_page) { |k, oldval, newval| oldval } if respond_to?('additional_config_page')
|
87
95
|
output = handler.rendered_content(handler.create_context)
|
File without changes
|
File without changes
|
@@ -0,0 +1 @@
|
|
1
|
+
var awestruct = {"description": "A static site-baking tool"};
|