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
data/spec/slim_handler_spec.rb
CHANGED
@@ -26,56 +26,58 @@ verify_with_variables = lambda { |output|
|
|
26
26
|
}
|
27
27
|
|
28
28
|
theories =
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
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
|
-
|
29
|
+
[
|
30
|
+
{
|
31
|
+
:page => 'slim-page.html.slim',
|
32
|
+
:simple_name => 'slim-page',
|
33
|
+
:syntax => :slim,
|
34
|
+
:extension => '.html',
|
35
|
+
:format => :html5,
|
36
|
+
:matcher => verify
|
37
|
+
},
|
38
|
+
{
|
39
|
+
:page => 'slim-page.xml.slim',
|
40
|
+
:simple_name => 'slim-page',
|
41
|
+
:syntax => :slim,
|
42
|
+
:extension => '.xml',
|
43
|
+
:format => :xhtml,
|
44
|
+
:matcher => verify
|
45
|
+
},
|
46
|
+
{
|
47
|
+
:page => 'slim-page.atom.slim',
|
48
|
+
:simple_name => 'slim-page',
|
49
|
+
:syntax => :slim,
|
50
|
+
:extension => '.atom',
|
51
|
+
:format => :xhtml,
|
52
|
+
:matcher => verify_atom
|
53
|
+
},
|
54
|
+
{
|
55
|
+
:page => 'slim-with-markdown-page.html.slim',
|
56
|
+
:simple_name => 'slim-with-markdown-page',
|
57
|
+
:syntax => :slim,
|
58
|
+
:extension => '.html',
|
59
|
+
:matcher => verify_with_markdown
|
60
|
+
},
|
61
|
+
{
|
62
|
+
:page => 'slim-with-utf.html.slim',
|
63
|
+
:simple_name => 'slim-with-utf',
|
64
|
+
:syntax => :slim,
|
65
|
+
:extension => '.html',
|
66
|
+
:matcher => verify_with_utf8
|
67
|
+
},
|
68
|
+
{
|
69
|
+
:page => 'slim-with-variables.html.slim',
|
70
|
+
:simple_name => 'slim-with-variables',
|
71
|
+
:syntax => :slim,
|
72
|
+
:extension => '.html',
|
73
|
+
:matcher => verify_with_variables
|
74
|
+
}
|
75
|
+
]
|
76
76
|
|
77
77
|
describe Awestruct::Handlers::TiltHandler.to_s + '-Slim' do
|
78
|
-
|
79
|
-
|
78
|
+
def additional_config
|
79
|
+
{ :crunchy => 'bacon' }
|
80
|
+
end
|
80
81
|
|
82
|
+
it_should_behave_like 'a handler', theories
|
81
83
|
end
|
@@ -7,25 +7,29 @@ require 'hashery'
|
|
7
7
|
REQUIRED_VARIABLES = [:page, :simple_name, :syntax, :extension]
|
8
8
|
ALL_VARIABLES = REQUIRED_VARIABLES + [:format, :matcher, :unless]
|
9
9
|
|
10
|
-
shared_examples
|
10
|
+
shared_examples 'a handler' do |theories|
|
11
11
|
|
12
12
|
def handler_file(path)
|
13
13
|
"#{@site.config.dir}/#{path}"
|
14
14
|
end
|
15
15
|
|
16
16
|
def create_context
|
17
|
-
Hashery::OpenCascade[
|
17
|
+
Hashery::OpenCascade[{ :site => @site }]
|
18
18
|
end
|
19
19
|
|
20
20
|
describe Awestruct::Handlers do
|
21
21
|
|
22
22
|
before :all do
|
23
|
+
@opts = Awestruct::CLI::Options.new
|
24
|
+
@opts.source_dir = File.dirname(__FILE__) + '/../test-data/handlers'
|
25
|
+
@config = Awestruct::Config.new( @opts )
|
23
26
|
|
24
|
-
@engine = Awestruct::Engine.new(
|
25
|
-
Awestruct::Config.new( File.expand_path(File.dirname(__FILE__) + '/../') + '/test-data/handlers' ))
|
27
|
+
@engine = Awestruct::Engine.new( @config )
|
26
28
|
@engine.load_default_site_yaml
|
27
29
|
@site = @engine.site
|
30
|
+
end
|
28
31
|
|
32
|
+
before :each do
|
29
33
|
@site.merge! additional_config if respond_to?("additional_config")
|
30
34
|
end
|
31
35
|
|
@@ -62,7 +66,7 @@ shared_examples "a handler" do |theories|
|
|
62
66
|
handler.output_extension.should == theory[:extension]
|
63
67
|
end
|
64
68
|
|
65
|
-
|
69
|
+
unless theory[:format].nil?
|
66
70
|
it "should set the engine format '#{theory[:format]}' for page '#{theory[:page]}'" do
|
67
71
|
page = create_handler theory[:page]
|
68
72
|
handler = page.handler
|
@@ -74,13 +78,13 @@ shared_examples "a handler" do |theories|
|
|
74
78
|
end
|
75
79
|
end
|
76
80
|
|
77
|
-
|
81
|
+
unless theory[:matcher].nil?
|
78
82
|
|
79
83
|
it "should render page '#{theory[:page]}'" do
|
80
84
|
if theory[:unless].nil? or !theory[:unless][:exp].call()
|
81
85
|
handler = create_handler theory[:page]
|
82
|
-
handler.update(additional_config_page) {|k, oldval, newval| oldval } if respond_to?(
|
83
|
-
output = handler.rendered_content(
|
86
|
+
handler.update(additional_config_page) { |k, oldval, newval| oldval } if respond_to?('additional_config_page')
|
87
|
+
output = handler.rendered_content(handler.create_context)
|
84
88
|
output.should_not be_nil
|
85
89
|
|
86
90
|
theory[:matcher].call(output, handler) if theory[:matcher].arity == 2
|
@@ -0,0 +1 @@
|
|
1
|
+
xml.em('Hello World!')
|
data/spec/tilt_handler_spec.rb
CHANGED
@@ -1,16 +1,44 @@
|
|
1
|
-
|
1
|
+
require 'logger'
|
2
2
|
require 'awestruct/config'
|
3
|
+
#require 'awestruct/engine'
|
3
4
|
require 'awestruct/handlers/file_handler'
|
4
5
|
require 'awestruct/handlers/tilt_handler'
|
5
6
|
|
6
7
|
require 'hashery'
|
8
|
+
require 'tilt/template'
|
9
|
+
|
10
|
+
|
11
|
+
module Tilt
|
12
|
+
class BogusTemplate < Template
|
13
|
+
self.default_mime_type = 'text/html'
|
14
|
+
|
15
|
+
def self.engine_initialized?
|
16
|
+
defined? ::Bogus::Document
|
17
|
+
end
|
18
|
+
|
19
|
+
def initialize_engine
|
20
|
+
require_template_library 'fake-gem-name'
|
21
|
+
end
|
22
|
+
|
23
|
+
def evaluate(scope, locals, &block)
|
24
|
+
@output ||= "bogus, bogus, bogus"
|
25
|
+
end
|
26
|
+
|
27
|
+
def allows_script?
|
28
|
+
false
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
7
33
|
|
8
34
|
describe Awestruct::Handlers::TiltHandler do
|
9
35
|
|
10
36
|
before do
|
11
|
-
dir = Pathname.new( File.dirname(__FILE__) + '/test-data/handlers' )
|
37
|
+
dir = Pathname.new( File.dirname(__FILE__) + '/test-data/handlers' )
|
38
|
+
opts = Awestruct::CLI::Options.new
|
39
|
+
opts.source_dir = dir
|
12
40
|
|
13
|
-
@site = Hashery::OpenCascade[ { :encoding=>false, :dir=>dir, :config=>Awestruct::Config.new(
|
41
|
+
@site = Hashery::OpenCascade[ { :encoding=>false, :dir=>dir, :config=>Awestruct::Config.new( opts ) } ]
|
14
42
|
end
|
15
43
|
|
16
44
|
def handler_file(path)
|
@@ -76,4 +104,43 @@ describe Awestruct::Handlers::TiltHandler do
|
|
76
104
|
handler.output_filename.should eql 'warp-1.0.0.Alpha2.html'
|
77
105
|
|
78
106
|
end
|
107
|
+
|
108
|
+
context 'when loading an engine not installed' do
|
109
|
+
specify 'should not throw exceptions; instead have the error in the rendered output' do
|
110
|
+
# setup
|
111
|
+
Tilt::register Tilt::BogusTemplate, '.bogus',
|
112
|
+
log = StringIO.new
|
113
|
+
$LOG = Logger.new(log)
|
114
|
+
$LOG.level = Logger::DEBUG
|
115
|
+
@site.dir = Pathname.new( File.dirname(__FILE__) + '/test-data/handlers/' )
|
116
|
+
path = handler_file( "hello.bogus" )
|
117
|
+
expect(Awestruct::Handlers::TiltMatcher.new().match(path)).to be_false
|
118
|
+
expect(log.string).to include('missing required gem')
|
119
|
+
|
120
|
+
# we don't even want to process a file if we cannot load its Tilt template
|
121
|
+
#file_handler = Awestruct::Handlers::FileHandler.new( @site, path )
|
122
|
+
#handler = Awestruct::Handlers::TiltHandler.new( @site, file_handler )
|
123
|
+
#content = handler.rendered_content(create_context)
|
124
|
+
|
125
|
+
#expect(content).to_not eql ('bogus, bogus, bogus')
|
126
|
+
#expect(content).to include('load', 'fake-gem-name')
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
130
|
+
context 'when rendering a file with an error' do
|
131
|
+
specify 'should not stop processing, but render the error as the file' do
|
132
|
+
# setup
|
133
|
+
log = StringIO.new
|
134
|
+
$LOG = Logger.new(log)
|
135
|
+
$LOG.level = Logger::DEBUG
|
136
|
+
@site.dir = Pathname.new( File.dirname(__FILE__) + '/test-data/handlers/' )
|
137
|
+
file_handler = Awestruct::Handlers::FileHandler.new( @site, handler_file( "haml-error.html.haml" ) )
|
138
|
+
handler = Awestruct::Handlers::TiltHandler.new( @site, file_handler )
|
139
|
+
content = handler.rendered_content(create_context)
|
140
|
+
|
141
|
+
expect(content).to_not be_empty
|
142
|
+
expect(content).to include('Illegal', 'nesting', 'Line', '2')
|
143
|
+
end
|
144
|
+
end
|
145
|
+
|
79
146
|
end
|
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: awestruct
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
5
|
-
prerelease:
|
4
|
+
version: 0.5.4.beta1
|
5
|
+
prerelease: 6
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Bob McWhirter and other contributors
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-08-14 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: haml
|
@@ -139,22 +139,6 @@ dependencies:
|
|
139
139
|
- - ! '>='
|
140
140
|
- !ruby/object:Gem::Version
|
141
141
|
version: 1.6.7
|
142
|
-
- !ruby/object:Gem::Dependency
|
143
|
-
name: git
|
144
|
-
requirement: !ruby/object:Gem::Requirement
|
145
|
-
none: false
|
146
|
-
requirements:
|
147
|
-
- - ~>
|
148
|
-
- !ruby/object:Gem::Version
|
149
|
-
version: 1.2.5
|
150
|
-
type: :runtime
|
151
|
-
prerelease: false
|
152
|
-
version_requirements: !ruby/object:Gem::Requirement
|
153
|
-
none: false
|
154
|
-
requirements:
|
155
|
-
- - ~>
|
156
|
-
- !ruby/object:Gem::Version
|
157
|
-
version: 1.2.5
|
158
142
|
- !ruby/object:Gem::Dependency
|
159
143
|
name: ruby-s3cmd
|
160
144
|
requirement: !ruby/object:Gem::Requirement
|
@@ -239,6 +223,7 @@ files:
|
|
239
223
|
- lib/awestruct/handlers/page_delegating_handler.rb
|
240
224
|
- lib/awestruct/handlers/string_handler.rb
|
241
225
|
- lib/awestruct/handlers/interpolation_handler.rb
|
226
|
+
- lib/awestruct/handlers/verbatim_file_handler.rb
|
242
227
|
- lib/awestruct/handlers/restructuredtext_handler.rb
|
243
228
|
- lib/awestruct/handlers/no_op_handler.rb
|
244
229
|
- lib/awestruct/handlers/tilt_handler.rb
|
@@ -259,6 +244,7 @@ files:
|
|
259
244
|
- lib/awestruct/config/default-site.yml
|
260
245
|
- lib/awestruct/site.rb
|
261
246
|
- lib/awestruct/deployers.rb
|
247
|
+
- lib/awestruct/scm/git.rb
|
262
248
|
- lib/awestruct/astruct_mixin.rb
|
263
249
|
- lib/awestruct/version.rb
|
264
250
|
- lib/awestruct/page_loader.rb
|
@@ -305,6 +291,7 @@ files:
|
|
305
291
|
- man/awestruct.1
|
306
292
|
- spec/yaml_handler_spec.rb
|
307
293
|
- spec/mustache_handler_spec.rb
|
294
|
+
- spec/awestruct/scm/git_spec.rb
|
308
295
|
- spec/options_spec.rb
|
309
296
|
- spec/posts_archive_spec.rb
|
310
297
|
- spec/front_matter_handler_spec.rb
|
@@ -335,8 +322,11 @@ files:
|
|
335
322
|
- spec/test-data/stylesheets/screen.css
|
336
323
|
- spec/test-data/out-of-site/page-three.html.haml
|
337
324
|
- spec/test-data/subdir/index.html
|
325
|
+
- spec/test-data/front-matter-file-utf8.txt
|
326
|
+
- spec/test-data/handlers/hello.bogus
|
338
327
|
- spec/test-data/handlers/scss-page-include.scss
|
339
328
|
- spec/test-data/handlers/haml-layout-two.html.haml
|
329
|
+
- spec/test-data/handlers/haml-error.html.haml
|
340
330
|
- spec/test-data/handlers/haml-page.xml.haml
|
341
331
|
- spec/test-data/handlers/markdown-page.mkd
|
342
332
|
- spec/test-data/handlers/outside_relative/git_keep
|
@@ -430,16 +420,13 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
430
420
|
version: '0'
|
431
421
|
segments:
|
432
422
|
- 0
|
433
|
-
hash: -
|
423
|
+
hash: -305438061854300207
|
434
424
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
435
425
|
none: false
|
436
426
|
requirements:
|
437
|
-
- - ! '
|
427
|
+
- - ! '>'
|
438
428
|
- !ruby/object:Gem::Version
|
439
|
-
version:
|
440
|
-
segments:
|
441
|
-
- 0
|
442
|
-
hash: -3726188984491065778
|
429
|
+
version: 1.3.1
|
443
430
|
requirements:
|
444
431
|
- Any markup languages you are using and its dependencies
|
445
432
|
- Haml and markdown filters are touchy things. Rdiscount works well if you're running
|
@@ -452,6 +439,7 @@ summary: Static site-baking utility
|
|
452
439
|
test_files:
|
453
440
|
- spec/yaml_handler_spec.rb
|
454
441
|
- spec/mustache_handler_spec.rb
|
442
|
+
- spec/awestruct/scm/git_spec.rb
|
455
443
|
- spec/options_spec.rb
|
456
444
|
- spec/posts_archive_spec.rb
|
457
445
|
- spec/front_matter_handler_spec.rb
|
@@ -482,8 +470,11 @@ test_files:
|
|
482
470
|
- spec/test-data/stylesheets/screen.css
|
483
471
|
- spec/test-data/out-of-site/page-three.html.haml
|
484
472
|
- spec/test-data/subdir/index.html
|
473
|
+
- spec/test-data/front-matter-file-utf8.txt
|
474
|
+
- spec/test-data/handlers/hello.bogus
|
485
475
|
- spec/test-data/handlers/scss-page-include.scss
|
486
476
|
- spec/test-data/handlers/haml-layout-two.html.haml
|
477
|
+
- spec/test-data/handlers/haml-error.html.haml
|
487
478
|
- spec/test-data/handlers/haml-page.xml.haml
|
488
479
|
- spec/test-data/handlers/markdown-page.mkd
|
489
480
|
- spec/test-data/handlers/outside_relative/git_keep
|