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
@@ -41,7 +41,7 @@
|
|
41
41
|
# Now you're Awestruct with rake!
|
42
42
|
|
43
43
|
$use_bundle_exec = true
|
44
|
-
$install_gems = ['awestruct -v "~> 0.5.
|
44
|
+
$install_gems = ['awestruct -v "~> 0.5.4.rc"', 'rb-inotify -v "~> 0.9.0"']
|
45
45
|
$awestruct_cmd = nil
|
46
46
|
task :default => :preview
|
47
47
|
|
@@ -161,8 +161,27 @@ task :check => :init do
|
|
161
161
|
end
|
162
162
|
|
163
163
|
# Execute Awestruct
|
164
|
-
def run_awestruct(args)
|
165
|
-
|
164
|
+
def run_awestruct(args, opts = {})
|
165
|
+
cmd = "#{$use_bundle_exec ? 'bundle exec ' : ''}awestruct #{args}"
|
166
|
+
if RUBY_VERSION < '1.9'
|
167
|
+
opts[:spawn] = false
|
168
|
+
else
|
169
|
+
opts[:spawn] ||= true
|
170
|
+
end
|
171
|
+
|
172
|
+
puts "Running command: #{cmd}"
|
173
|
+
if opts[:spawn]
|
174
|
+
pid = spawn cmd
|
175
|
+
Signal.trap(:INT) {
|
176
|
+
# wait for rack server to receive signal and shutdown
|
177
|
+
Process.wait pid
|
178
|
+
# now we go down
|
179
|
+
exit
|
180
|
+
}
|
181
|
+
Process.wait pid
|
182
|
+
else
|
183
|
+
system cmd
|
184
|
+
end
|
166
185
|
end
|
167
186
|
|
168
187
|
# A cross-platform means of finding an executable in the $PATH.
|
@@ -40,6 +40,7 @@ module Awestruct
|
|
40
40
|
CHAIN = Awestruct::HandlerChain.new( Awestruct::Handlers::AsciidoctorTiltMatcher.new(),
|
41
41
|
Awestruct::Handlers::FileHandler,
|
42
42
|
Awestruct::Handlers::FrontMatterHandler,
|
43
|
+
Awestruct::Handlers::InterpolationHandler,
|
43
44
|
Awestruct::Handlers::AsciidoctorHandler,
|
44
45
|
Awestruct::Handlers::LayoutHandler
|
45
46
|
)
|
@@ -47,13 +48,19 @@ module Awestruct
|
|
47
48
|
def initialize(site, delegate)
|
48
49
|
super( site, delegate )
|
49
50
|
|
51
|
+
@site = site
|
50
52
|
@front_matter = {}
|
51
53
|
end
|
52
54
|
|
53
55
|
|
54
56
|
def front_matter
|
55
57
|
parse_header()
|
56
|
-
|
58
|
+
if @delegate
|
59
|
+
@front_matter.update @delegate.front_matter
|
60
|
+
# push front matter forward as well
|
61
|
+
@delegate.front_matter.replace @front_matter
|
62
|
+
@front_matter
|
63
|
+
end
|
57
64
|
end
|
58
65
|
|
59
66
|
def raw_content
|
@@ -68,29 +75,49 @@ module Awestruct
|
|
68
75
|
|
69
76
|
def rendered_content(context, with_layouts)
|
70
77
|
parse_header()
|
78
|
+
front_matter_ref = front_matter
|
71
79
|
types = [String, Numeric, TrueClass, FalseClass, Array]
|
72
|
-
|
80
|
+
front_matter_ref.update(context.page.inject({}) {|hash, (k,v)|
|
73
81
|
hash[k.to_s] = v if not k.to_s.start_with?('__') and types.detect { |t| v.kind_of? t }
|
74
82
|
hash
|
75
|
-
|
83
|
+
})
|
76
84
|
if with_layouts && !context.page.layout
|
77
|
-
|
85
|
+
front_matter_ref['header_footer'] = true
|
78
86
|
end
|
79
87
|
super
|
80
88
|
end
|
81
89
|
|
82
90
|
def options
|
83
91
|
opts = super
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
92
|
+
opts[:attributes] ||= {}
|
93
|
+
opts[:attributes].update(@front_matter.inject({}) {|collector, (key,val)|
|
94
|
+
collector["page-#{key}"] = "#{val}@"
|
95
|
+
collector
|
96
|
+
})
|
97
|
+
# Keep only values that can be coerced to as string
|
98
|
+
types = [String, Numeric, TrueClass, FalseClass, Date, Time]
|
99
|
+
opts[:attributes].update(@site.inject({}) {|collector, (key,val)|
|
100
|
+
collector["site-#{key}"] = "#{val}@" if types.detect {|t| val.kind_of? t }
|
101
|
+
collector
|
102
|
+
})
|
89
103
|
opts[:attributes]['awestruct'] = true
|
90
104
|
opts[:attributes]['awestruct-version'] = Awestruct::VERSION
|
91
105
|
if @front_matter['header_footer']
|
92
106
|
opts[:header_footer] = true
|
93
107
|
end
|
108
|
+
path_expanded = File.expand_path path
|
109
|
+
opts[:attributes]['docdir'] = File.dirname path_expanded
|
110
|
+
opts[:attributes]['docfile'] = path_expanded
|
111
|
+
opts[:attributes]['docname'] = simple_name
|
112
|
+
path_mtime = path.mtime
|
113
|
+
opts[:attributes]['docdate'] = docdate = path_mtime.strftime('%Y-%m-%d')
|
114
|
+
opts[:attributes]['doctime'] = doctime = path_mtime.strftime('%H:%M:%S %Z')
|
115
|
+
opts[:attributes]['docdatetime'] = %(#{docdate} #{doctime})
|
116
|
+
# TODO once Asciidoctor 1.5.0 is release, we should set the base_dir as a jail
|
117
|
+
# we can't do this before 1.5.0 due to a bug in how includes are resolved
|
118
|
+
if (Object.const_defined? 'Asciidoctor') && Asciidoctor::VERSION >= '1.5.0'
|
119
|
+
opts[:base_dir] ||= @site.config.dir
|
120
|
+
end
|
94
121
|
opts
|
95
122
|
end
|
96
123
|
|
@@ -116,8 +143,9 @@ module Awestruct
|
|
116
143
|
end
|
117
144
|
|
118
145
|
def parse_document_attributes(content)
|
146
|
+
warned = false
|
119
147
|
template = Tilt::new(delegate.path.to_s, delegate.content_line_offset + 1, options)
|
120
|
-
template.parse_headers(content, /^awestruct
|
148
|
+
template.parse_headers(content, /^(?:page|awestruct)\-(?=.)/).inject({'interpolate' => false}) do |hash, (k,v)|
|
121
149
|
unless v.nil?
|
122
150
|
hash[k] = v.empty? ? v : YAML.load(v)
|
123
151
|
if hash[k].kind_of? Time
|
@@ -51,35 +51,40 @@ module Awestruct
|
|
51
51
|
dash_lines = 0
|
52
52
|
mode = :yaml
|
53
53
|
|
54
|
-
@raw_content =
|
54
|
+
@raw_content = nil
|
55
55
|
@content_line_offset = 0
|
56
56
|
|
57
|
+
first_line = true
|
57
58
|
full_content.each_line do |line|
|
58
|
-
if
|
59
|
-
|
59
|
+
if line.rstrip == '---' && mode == :yaml
|
60
|
+
unless first_line
|
61
|
+
@content_line_offset += 1
|
62
|
+
yaml_content << line
|
63
|
+
mode = :page
|
64
|
+
next
|
65
|
+
end
|
66
|
+
elsif first_line
|
67
|
+
mode = :page
|
60
68
|
end
|
61
|
-
|
69
|
+
|
70
|
+
if mode == :yaml
|
62
71
|
@content_line_offset += 1
|
63
72
|
yaml_content << line
|
73
|
+
elsif @raw_content.nil?
|
74
|
+
@raw_content = line
|
64
75
|
else
|
65
76
|
@raw_content << line
|
66
77
|
end
|
67
|
-
|
68
|
-
mode = :page
|
69
|
-
end
|
78
|
+
first_line = false
|
70
79
|
end
|
71
80
|
|
72
|
-
if
|
73
|
-
@raw_content = yaml_content
|
74
|
-
yaml_content = ''
|
75
|
-
@content_line_offset = 0
|
76
|
-
elsif ( mode == :yaml )
|
81
|
+
if mode == :yaml
|
77
82
|
@raw_content = nil
|
78
83
|
@content_line_offset = -1
|
79
84
|
end
|
80
85
|
|
81
86
|
begin
|
82
|
-
@front_matter = YAML.load
|
87
|
+
@front_matter = yaml_content.empty? ? {} : (YAML.load yaml_content)
|
83
88
|
rescue => e
|
84
89
|
$LOG.error "could not parse #{relative_source_path}" if $LOG.error?
|
85
90
|
raise e
|
@@ -13,7 +13,7 @@ module Awestruct
|
|
13
13
|
content = delegate.raw_content
|
14
14
|
|
15
15
|
return nil if content.nil?
|
16
|
-
return content unless site.interpolate
|
16
|
+
return content unless front_matter.fetch('interpolate', site.interpolate)
|
17
17
|
|
18
18
|
content = content.gsub( /\\/, '\\\\\\\\' )
|
19
19
|
content = content.gsub( /\\\\#/, '\\#' )
|
@@ -33,7 +33,28 @@ module Tilt
|
|
33
33
|
|
34
34
|
filtered['title'] = filtered['doctitle'] = doc.doctitle
|
35
35
|
filtered['date'] ||= doc.attributes['revdate'] unless doc.attributes['revdate'].nil?
|
36
|
-
|
36
|
+
if (cnt = doc.attributes['authorcount'].to_i) > 1
|
37
|
+
authors = []
|
38
|
+
(1..cnt).each do |idx|
|
39
|
+
author = {}
|
40
|
+
author[:name] = doc.attributes["author_#{idx}"]
|
41
|
+
if doc.attributes.has_key? "email_#{idx}"
|
42
|
+
author[:email] = doc.attributes["email_#{idx}"]
|
43
|
+
end
|
44
|
+
authors << author
|
45
|
+
end
|
46
|
+
filtered['author'] = authors.first[:name]
|
47
|
+
filtered['email'] = authors.first[:email] if authors.first.has_key? :email
|
48
|
+
filtered['authors'] = authors.to_yaml
|
49
|
+
elsif !doc.attributes['author'].nil?
|
50
|
+
author = {}
|
51
|
+
author[:name] = doc.attributes['author']
|
52
|
+
if doc.attributes.has_key? 'email'
|
53
|
+
author[:email] = doc.attributes['email']
|
54
|
+
end
|
55
|
+
filtered['author'] = author[:name]
|
56
|
+
filtered['authors'] = [author].to_yaml
|
57
|
+
end
|
37
58
|
|
38
59
|
filtered
|
39
60
|
end
|
@@ -46,7 +46,7 @@ module Awestruct
|
|
46
46
|
unless path.directory?
|
47
47
|
$LOG.debug "loading #{relative_path}" if (site.config.verbose) if $LOG.debug?
|
48
48
|
page = load_page( path, prepare )
|
49
|
-
if ( page && !page.draft )
|
49
|
+
if ( page && (!page.draft || @site.show_drafts) )
|
50
50
|
$LOG.debug "loaded! #{path} and added to site" if $LOG.debug?
|
51
51
|
#inherit_front_matter( page )
|
52
52
|
site.send( @target ) << page
|
data/lib/awestruct/version.rb
CHANGED
@@ -15,6 +15,13 @@ verify_front_matter = lambda { |output, page|
|
|
15
15
|
verify_headers = lambda { |output, page|
|
16
16
|
extend RSpec::Matchers
|
17
17
|
page.author.should == 'Stuart Rackham'
|
18
|
+
page.email.should == 'srackham@example.com'
|
19
|
+
page.authors.should_not be_nil
|
20
|
+
page.authors.size.should == 2
|
21
|
+
page.authors.first.name.should == 'Stuart Rackham'
|
22
|
+
page.authors.first.email.should == 'srackham@example.com'
|
23
|
+
page.authors.last.name.should == 'Dan Allen'
|
24
|
+
page.authors.last.email.should be_nil
|
18
25
|
page.title.should == 'AsciiDoc'
|
19
26
|
page.doctitle.should == 'AsciiDoc'
|
20
27
|
page.name.should == 'Awestruct'
|
@@ -22,8 +29,28 @@ verify_headers = lambda { |output, page|
|
|
22
29
|
page.tags.should be_a_kind_of(Array)
|
23
30
|
page.tags.should == %w(a b c)
|
24
31
|
page.date.should be_a_kind_of(Date)
|
25
|
-
output.should =~ %r(This is <strong>AsciiDoc</strong> in Awestruct.)
|
32
|
+
output.should =~ %r(This is <strong>AsciiDoc</strong> page named Awestruct in an Awestruct site.)
|
26
33
|
output.should =~ %r(#{Awestruct::VERSION})
|
34
|
+
output.should =~ %r(UTF-8)
|
35
|
+
}
|
36
|
+
|
37
|
+
verify_attributes = lambda { |output, page|
|
38
|
+
extend RSpec::Matchers
|
39
|
+
expect(output).to RSpec::Matchers::BuiltIn::Include.new("docname=#{page.simple_name};")
|
40
|
+
expect(output).to RSpec::Matchers::BuiltIn::Include.new("docfile=#{File.expand_path page.source_path};")
|
41
|
+
expect(output).to RSpec::Matchers::BuiltIn::Include.new("docdir=#{File.expand_path File.dirname(page.source_path)};")
|
42
|
+
}
|
43
|
+
|
44
|
+
verify_interpolation = lambda { |output, page|
|
45
|
+
extend RSpec::Matchers
|
46
|
+
output.should =~ %r(UTF-8)
|
47
|
+
page.site.interpolate.should == true
|
48
|
+
}
|
49
|
+
|
50
|
+
verify_no_interpolation = lambda { |output, page|
|
51
|
+
extend RSpec::Matchers
|
52
|
+
output.should =~ %r(\#\{site\.encoding\})
|
53
|
+
page.site.interpolate.should == true
|
27
54
|
}
|
28
55
|
|
29
56
|
theories =
|
@@ -62,6 +89,29 @@ theories =
|
|
62
89
|
:syntax => :asciidoc,
|
63
90
|
:extension => '.html',
|
64
91
|
:matcher => verify_headers
|
92
|
+
},
|
93
|
+
{
|
94
|
+
:page => 'asciidoc_with_attributes.ad',
|
95
|
+
:simple_name => 'asciidoc_with_attributes',
|
96
|
+
:syntax => :asciidoc,
|
97
|
+
:extension => '.html',
|
98
|
+
:matcher => verify_attributes
|
99
|
+
},
|
100
|
+
{
|
101
|
+
:page => 'asciidoc_with_interpolation.ad',
|
102
|
+
:simple_name => 'asciidoc_with_interpolation',
|
103
|
+
:syntax => :asciidoc,
|
104
|
+
:extension => '.html',
|
105
|
+
:matcher => verify_interpolation,
|
106
|
+
:site_overrides => { :interpolate => true }
|
107
|
+
},
|
108
|
+
{
|
109
|
+
:page => 'asciidoc_without_interpolation.ad',
|
110
|
+
:simple_name => 'asciidoc_without_interpolation',
|
111
|
+
:syntax => :asciidoc,
|
112
|
+
:extension => '.html',
|
113
|
+
:matcher => verify_no_interpolation,
|
114
|
+
:site_overrides => { :interpolate => true }
|
65
115
|
}
|
66
116
|
]
|
67
117
|
|
@@ -1,5 +1,5 @@
|
|
1
1
|
require 'spec_helper'
|
2
|
-
require 'awestruct/
|
2
|
+
require 'awestruct/deploy/base_deploy'
|
3
3
|
|
4
4
|
describe Awestruct::Scm::Git do
|
5
5
|
specify 'should respond_to :uncommitted_changes?' do
|
@@ -26,4 +26,4 @@ describe Awestruct::Scm::Git do
|
|
26
26
|
expect(subject.uncommitted_changes? '.').to be_true
|
27
27
|
end
|
28
28
|
end
|
29
|
-
end
|
29
|
+
end
|
data/spec/deploy_spec.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
require 'spec_helper'
|
2
2
|
require 'awestruct/cli/deploy'
|
3
3
|
|
4
4
|
describe Awestruct::CLI::Deploy do
|
@@ -38,4 +38,69 @@ describe Awestruct::CLI::Deploy do
|
|
38
38
|
deployer.deploy_type.should == :github_pages
|
39
39
|
end
|
40
40
|
|
41
|
+
it "should gzip if deploy['gzip'] is true" do
|
42
|
+
site_config = mock
|
43
|
+
site_config.stub(:output_dir).and_return '_site'
|
44
|
+
|
45
|
+
deploy_config = mock
|
46
|
+
deploy_config.stub(:[]).with('gzip').and_return true
|
47
|
+
deploy_config.stub(:[]).with('source_dir').and_return '.'
|
48
|
+
deploy_config.stub(:[]).with('scm').and_return nil
|
49
|
+
deploy_config.stub(:[]).with('uncommitted').and_return true
|
50
|
+
|
51
|
+
deployer = Awestruct::Deploy::Base.new(site_config, deploy_config)
|
52
|
+
deployer.should_receive(:gzip_site)
|
53
|
+
deployer.run
|
54
|
+
end
|
55
|
+
|
56
|
+
it "should only gzip html, css and js files" do
|
57
|
+
site_tmp_dir = Dir.mktmpdir("site_dir")
|
58
|
+
site_src_dir = File.join(File.dirname(__FILE__), 'test-data/gzip')
|
59
|
+
FileUtils.cp_r(site_src_dir, site_tmp_dir)
|
60
|
+
site_dir = "#{site_tmp_dir}/gzip"
|
61
|
+
|
62
|
+
site_config = mock
|
63
|
+
site_config.stub(:output_dir).and_return "#{site_dir}"
|
64
|
+
|
65
|
+
deploy_config = mock
|
66
|
+
deploy_config.stub(:[]).with('gzip').and_return true
|
67
|
+
deploy_config.stub(:[]).with('source_dir').and_return '.'
|
68
|
+
deploy_config.stub(:[]).with('scm').and_return nil
|
69
|
+
deploy_config.stub(:[]).with('uncommitted').and_return nil
|
70
|
+
|
71
|
+
deployer = Awestruct::Deploy::Base.new(site_config, deploy_config)
|
72
|
+
deployer.should_receive(:gzip_file).with("#{site_dir}/yes.html")
|
73
|
+
deployer.should_receive(:gzip_file).with("#{site_dir}/yes.js")
|
74
|
+
deployer.should_receive(:gzip_file).with("#{site_dir}/subdir/yes.css")
|
75
|
+
deployer.should_not_receive(:gzip_file).with("#{site_dir}/no.txt")
|
76
|
+
deployer.should_not_receive(:gzip_file).with("#{site_dir}/no.html.gz")
|
77
|
+
deployer.gzip_site(site_dir)
|
78
|
+
end
|
79
|
+
|
80
|
+
it "should gzip only once" do
|
81
|
+
site_tmp_dir = Dir.mktmpdir("site_dir")
|
82
|
+
site_src_dir = File.join(File.dirname(__FILE__), 'test-data/gzip')
|
83
|
+
FileUtils.cp_r(site_src_dir, site_tmp_dir)
|
84
|
+
site_dir = "#{site_tmp_dir}/gzip"
|
85
|
+
|
86
|
+
site_config = mock
|
87
|
+
site_config.stub(:output_dir).and_return "#{site_dir}"
|
88
|
+
|
89
|
+
deploy_config = mock
|
90
|
+
deploy_config.stub(:[]).with('gzip').and_return true
|
91
|
+
deploy_config.stub(:[]).with('source_dir').and_return '.'
|
92
|
+
deploy_config.stub(:[]).with('scm').and_return nil
|
93
|
+
deploy_config.stub(:[]).with('uncommitted').and_return nil
|
94
|
+
|
95
|
+
deployer = Awestruct::Deploy::Base.new(site_config, deploy_config)
|
96
|
+
deployer.gzip_site(site_dir)
|
97
|
+
|
98
|
+
# Gzip only once
|
99
|
+
deployer.should_not_receive(:gzip_file).with("#{site_dir}/yes.html")
|
100
|
+
deployer.should_not_receive(:gzip_file).with("#{site_dir}/yes.js")
|
101
|
+
deployer.should_not_receive(:gzip_file).with("#{site_dir}/subdir/yes.css")
|
102
|
+
deployer.should_not_receive(:gzip_file).with("#{site_dir}/no.txt")
|
103
|
+
deployer.gzip_site(site_dir)
|
104
|
+
end
|
105
|
+
|
41
106
|
end
|
data/spec/engine_spec.rb
CHANGED
@@ -16,6 +16,7 @@ describe Awestruct::Engine do
|
|
16
16
|
engine.site.asciidoctor.backend.should == 'html5'
|
17
17
|
engine.site.asciidoctor.safe.should == 1
|
18
18
|
engine.site.asciidoctor.attributes['imagesdir'].should == '/images'
|
19
|
+
engine.site.profiles.development.show_drafts.should == true
|
19
20
|
end
|
20
21
|
|
21
22
|
it "should be able to override default with site" do
|
@@ -25,12 +26,13 @@ describe Awestruct::Engine do
|
|
25
26
|
|
26
27
|
engine = Awestruct::Engine.new(config)
|
27
28
|
engine.load_default_site_yaml
|
28
|
-
engine.
|
29
|
+
engine.load_user_site_yaml( 'development' )
|
29
30
|
|
30
31
|
engine.site.asciidoctor.safe.should == 0
|
31
32
|
engine.site.asciidoctor.eruby.should == 'erubis'
|
32
33
|
engine.site.asciidoctor.attributes['imagesdir'].should == '/assets/images'
|
33
34
|
engine.site.asciidoctor.attributes['idprefix'].should == ''
|
35
|
+
engine.site.show_drafts.should == false
|
34
36
|
end
|
35
37
|
|
36
38
|
it "should be able to load site.yml with the correct profile" do
|
@@ -40,17 +42,19 @@ describe Awestruct::Engine do
|
|
40
42
|
|
41
43
|
engine = Awestruct::Engine.new(config)
|
42
44
|
engine.load_default_site_yaml
|
43
|
-
engine.
|
45
|
+
engine.load_user_site_yaml( 'development' )
|
44
46
|
engine.site.cook.should == 'microwave'
|
45
47
|
engine.site.title.should == 'Awestruction!'
|
48
|
+
engine.site.show_drafts.should == false
|
46
49
|
|
47
50
|
engine = Awestruct::Engine.new(config)
|
48
51
|
engine.load_default_site_yaml
|
49
|
-
engine.
|
52
|
+
engine.load_user_site_yaml( 'production' )
|
50
53
|
engine.site.cook.should == 'oven'
|
51
54
|
engine.site.title.should == 'Awestruction!'
|
52
55
|
engine.site.asciidoctor.eruby.should == 'erb'
|
53
56
|
engine.site.asciidoctor.attributes['imagesdir'].should == '/img'
|
57
|
+
engine.site.show_drafts.should == true
|
54
58
|
end
|
55
59
|
|
56
60
|
it "should be able to load arbitrary _config/*.yml files" do
|
@@ -81,7 +85,7 @@ describe Awestruct::Engine do
|
|
81
85
|
opts.source_dir = File.dirname(__FILE__) + '/test-data/engine'
|
82
86
|
config = Awestruct::Config.new( opts )
|
83
87
|
engine = Awestruct::Engine.new(config)
|
84
|
-
engine.
|
88
|
+
engine.load_user_site_yaml( 'production' )
|
85
89
|
Compass.stub(:configuration).and_return(compass)
|
86
90
|
compass.should_receive(:line_comments=).with(false)
|
87
91
|
compass.stub(:line_comments).and_return(false)
|
@@ -102,7 +106,7 @@ describe Awestruct::Engine do
|
|
102
106
|
opts.source_dir = File.dirname(__FILE__) + '/test-data/engine'
|
103
107
|
config = Awestruct::Config.new( opts )
|
104
108
|
engine = Awestruct::Engine.new(config)
|
105
|
-
engine.
|
109
|
+
engine.load_user_site_yaml( 'development' )
|
106
110
|
Compass.stub(:configuration).and_return(compass)
|
107
111
|
compass.should_receive(:line_comments=).with(true)
|
108
112
|
compass.stub(:line_comments).and_return(true)
|
@@ -123,7 +127,7 @@ describe Awestruct::Engine do
|
|
123
127
|
opts.source_dir = File.dirname(__FILE__) + '/test-data/engine'
|
124
128
|
config = Awestruct::Config.new( opts )
|
125
129
|
engine = Awestruct::Engine.new(config)
|
126
|
-
engine.
|
130
|
+
engine.load_user_site_yaml( 'staging' )
|
127
131
|
Compass.stub(:configuration).and_return(compass)
|
128
132
|
compass.should_receive(:line_comments=).with(false)
|
129
133
|
compass.stub(:line_comments).and_return(false)
|