awestruct 0.4.8 → 0.5.0.cr

Sign up to get free protection for your applications and to get access to all the features.
Files changed (167) hide show
  1. data/lib/awestruct/astruct.rb +4 -0
  2. data/lib/awestruct/astruct_mixin.rb +3 -0
  3. data/lib/awestruct/cli/auto.rb +6 -6
  4. data/lib/awestruct/cli/deploy.rb +3 -3
  5. data/lib/awestruct/cli/generate.rb +5 -3
  6. data/lib/awestruct/cli/init.rb +1 -1
  7. data/lib/awestruct/cli/invoker.rb +10 -3
  8. data/lib/awestruct/cli/manifest.rb +18 -17
  9. data/lib/awestruct/cli/options.rb +7 -6
  10. data/lib/awestruct/cli/server.rb +7 -14
  11. data/lib/awestruct/config.rb +7 -1
  12. data/lib/awestruct/config/default-site.yml +30 -0
  13. data/lib/awestruct/context_helper.rb +7 -7
  14. data/lib/awestruct/dependencies.rb +14 -11
  15. data/lib/awestruct/deploy/base_deploy.rb +2 -2
  16. data/lib/awestruct/deploy/github_pages_deploy.rb +1 -1
  17. data/lib/awestruct/deploy/rsync_deploy.rb +11 -15
  18. data/lib/awestruct/deploy/s3_deploy.rb +9 -0
  19. data/lib/awestruct/engine.rb +72 -21
  20. data/lib/awestruct/extensions/minify.rb +21 -20
  21. data/lib/awestruct/extensions/paginator.rb +5 -5
  22. data/lib/awestruct/extensions/partial.rb +1 -1
  23. data/lib/awestruct/extensions/pipeline.rb +5 -1
  24. data/lib/awestruct/extensions/posts.rb +8 -4
  25. data/lib/awestruct/extensions/relative.rb +7 -2
  26. data/lib/awestruct/extensions/remotePartial.rb +1 -1
  27. data/lib/awestruct/extensions/sitemap.rb +1 -1
  28. data/lib/awestruct/frameworks/bootstrap/base_index.html.haml +1 -1
  29. data/lib/awestruct/frameworks/bootstrap/base_layout.html.haml +1 -1
  30. data/lib/awestruct/handler_chains.rb +8 -23
  31. data/lib/awestruct/handlers/asciidoctor_handler.rb +114 -0
  32. data/lib/awestruct/handlers/base_tilt_handler.rb +114 -0
  33. data/lib/awestruct/handlers/css_tilt_handler.rb +43 -0
  34. data/lib/awestruct/handlers/front_matter_handler.rb +1 -1
  35. data/lib/awestruct/handlers/interpolation_handler.rb +3 -3
  36. data/lib/awestruct/handlers/layout_handler.rb +6 -4
  37. data/lib/awestruct/handlers/restructuredtext_handler.rb +5 -5
  38. data/lib/awestruct/handlers/template/asciidoc.rb +41 -0
  39. data/lib/awestruct/handlers/template/mustache.rb +25 -0
  40. data/lib/awestruct/handlers/tilt_handler.rb +73 -0
  41. data/lib/awestruct/layouts.rb +1 -1
  42. data/lib/awestruct/logger.rb +59 -0
  43. data/lib/awestruct/page.rb +16 -3
  44. data/lib/awestruct/page_loader.rb +5 -5
  45. data/lib/awestruct/version.rb +1 -1
  46. data/man/awestruct.1 +163 -0
  47. data/spec/asciidoc_handler_spec.rb +75 -0
  48. data/spec/astruct_spec.rb +52 -0
  49. data/spec/coffeescript_handler_spec.rb +23 -0
  50. data/spec/config_spec.rb +22 -0
  51. data/spec/context_helper_spec.rb +115 -0
  52. data/spec/deploy_spec.rb +41 -0
  53. data/spec/disqus_spec.rb +43 -0
  54. data/spec/engine_spec.rb +115 -0
  55. data/spec/erb_handler_spec.rb +52 -0
  56. data/spec/file_handler_spec.rb +57 -0
  57. data/spec/front_matter_handler_spec.rb +42 -0
  58. data/spec/github_pages_deploy_spec.rb +56 -0
  59. data/spec/haml_handler_spec.rb +93 -0
  60. data/spec/handler_chain_spec.rb +44 -0
  61. data/spec/handler_chains_spec.rb +25 -0
  62. data/spec/interpolation_handler_spec.rb +35 -0
  63. data/spec/invoker_spec.rb +74 -0
  64. data/spec/javascript_handler_spec.rb +23 -0
  65. data/spec/layout_handler_spec.rb +77 -0
  66. data/spec/layouts_spec.rb +32 -0
  67. data/spec/less_handler_spec.rb +33 -0
  68. data/spec/markdown_handler_spec.rb +41 -0
  69. data/spec/minify_spec.rb +61 -0
  70. data/spec/mustache_handler_spec.rb +29 -0
  71. data/spec/options_spec.rb +97 -0
  72. data/spec/orgmode_handler_spec.rb +24 -0
  73. data/spec/page_delegating_handler_spec.rb +79 -0
  74. data/spec/page_loader_spec.rb +43 -0
  75. data/spec/page_loader_spec_for_layouts.rb +36 -0
  76. data/spec/page_spec.rb +65 -0
  77. data/spec/pipeline_spec.rb +12 -0
  78. data/spec/posts_archive_spec.rb +108 -0
  79. data/spec/redirect_handler_spec.rb +32 -0
  80. data/spec/restructuredtext_handler_spec.rb +22 -0
  81. data/spec/rsync_deploy_spec.rb +9 -0
  82. data/spec/sass_handler_spec.rb +23 -0
  83. data/spec/scss_handler_spec.rb +23 -0
  84. data/spec/server_spec.rb +45 -0
  85. data/spec/slim_handler_spec.rb +81 -0
  86. data/spec/spec_helper.rb +18 -0
  87. data/spec/support/nokogiri_matchers.rb +21 -0
  88. data/spec/support/shared_handler_example.rb +98 -0
  89. data/spec/test-data/engine/_config/arbitrary.yml +2 -0
  90. data/spec/test-data/engine/_config/other.yml +1 -0
  91. data/spec/test-data/engine/_config/site.yml +14 -0
  92. data/spec/test-data/front-matter-file-no-content.txt +2 -0
  93. data/spec/test-data/front-matter-file-no-front.txt +1 -0
  94. data/spec/test-data/front-matter-file.txt +4 -0
  95. data/spec/test-data/handlers/asciidoc-page.ad +3 -0
  96. data/spec/test-data/handlers/asciidoc-page.adoc +3 -0
  97. data/spec/test-data/handlers/asciidoc-page.asciidoc +3 -0
  98. data/spec/test-data/handlers/asciidoctor_with_front_matter.ad +6 -0
  99. data/spec/test-data/handlers/asciidoctor_with_headers.ad +8 -0
  100. data/spec/test-data/handlers/coffeescript-page.coffee +8 -0
  101. data/spec/test-data/handlers/erb-page.html.erb +6 -0
  102. data/spec/test-data/handlers/erb-page.xml.erb +2 -0
  103. data/spec/test-data/handlers/erb-utf-page.html.erb +2 -0
  104. data/spec/test-data/handlers/haml-layout-two.html.haml +7 -0
  105. data/spec/test-data/handlers/haml-layout.html.haml +4 -0
  106. data/spec/test-data/handlers/haml-page.atom.haml +4 -0
  107. data/spec/test-data/handlers/haml-page.html.haml +2 -0
  108. data/spec/test-data/handlers/haml-page.xml.haml +1 -0
  109. data/spec/test-data/handlers/haml-with-markdown-page.html.haml +6 -0
  110. data/spec/test-data/handlers/haml-with-textile-page.html.haml +6 -0
  111. data/spec/test-data/handlers/haml-with-utf.html.haml +2 -0
  112. data/spec/test-data/handlers/haml-with-variables.html.haml +2 -0
  113. data/spec/test-data/handlers/inner-page.html.haml +4 -0
  114. data/spec/test-data/handlers/javascript-page.js +1 -0
  115. data/spec/test-data/handlers/less-page-include.less +1 -0
  116. data/spec/test-data/handlers/less-page-with-import.less +4 -0
  117. data/spec/test-data/handlers/less-page.less +4 -0
  118. data/spec/test-data/handlers/markdown-page.markdown +2 -0
  119. data/spec/test-data/handlers/markdown-page.md +2 -0
  120. data/spec/test-data/handlers/markdown-page.mkd +2 -0
  121. data/spec/test-data/handlers/mustache-page.html.mustache +2 -0
  122. data/spec/test-data/handlers/mustache-page.xml.mustache +1 -0
  123. data/spec/test-data/handlers/orgmode-page.org +6 -0
  124. data/spec/test-data/handlers/outer-layout.html.haml +2 -0
  125. data/spec/test-data/handlers/outside_relative/git_keep +3 -0
  126. data/spec/test-data/handlers/redirect-page.redirect +1 -0
  127. data/spec/test-data/handlers/restructuredtext-page.rst +8 -0
  128. data/spec/test-data/handlers/sass-page-include.sass +1 -0
  129. data/spec/test-data/handlers/sass-page.sass +4 -0
  130. data/spec/test-data/handlers/scss-page-include.scss +1 -0
  131. data/spec/test-data/handlers/scss-page.scss +5 -0
  132. data/spec/test-data/handlers/simple-redirect-page.redirect +1 -0
  133. data/spec/test-data/handlers/slim-page.atom.slim +4 -0
  134. data/spec/test-data/handlers/slim-page.html.slim +1 -0
  135. data/spec/test-data/handlers/slim-page.xml.slim +1 -0
  136. data/spec/test-data/handlers/slim-with-markdown-page.html.slim +5 -0
  137. data/spec/test-data/handlers/slim-with-utf.html.slim +2 -0
  138. data/spec/test-data/handlers/slim-with-variables.html.slim +1 -0
  139. data/spec/test-data/handlers/textile-page.textile +1 -0
  140. data/spec/test-data/images/logo.png +0 -0
  141. data/spec/test-data/index.html +242 -0
  142. data/spec/test-data/javascript/bootstrap-dropdown.js +92 -0
  143. data/spec/test-data/out-of-site/page-three.html.haml +2 -0
  144. data/spec/test-data/page-loader/_layouts/layout-one.md +2 -0
  145. data/spec/test-data/page-loader/_layouts/layout-two.html.haml +2 -0
  146. data/spec/test-data/page-loader/page-draft.md +5 -0
  147. data/spec/test-data/page-loader/page-one.md +2 -0
  148. data/spec/test-data/page-loader/page-two.html.haml +2 -0
  149. data/spec/test-data/simple-data.yaml +1 -0
  150. data/spec/test-data/simple-file.txt +1 -0
  151. data/spec/test-data/stylesheets/screen.css +688 -0
  152. data/spec/textile_handler_spec.rb +22 -0
  153. data/spec/tilt_handler_spec.rb +81 -0
  154. data/spec/yaml_handler_spec.rb +21 -0
  155. metadata +243 -202
  156. data/lib/awestruct/handlers/asciidoc_handler.rb +0 -86
  157. data/lib/awestruct/handlers/base_sass_handler.rb +0 -42
  158. data/lib/awestruct/handlers/coffeescript_handler.rb +0 -48
  159. data/lib/awestruct/handlers/erb_handler.rb +0 -43
  160. data/lib/awestruct/handlers/haml_handler.rb +0 -54
  161. data/lib/awestruct/handlers/less_handler.rb +0 -37
  162. data/lib/awestruct/handlers/markdown_handler.rb +0 -50
  163. data/lib/awestruct/handlers/mustache_handler.rb +0 -44
  164. data/lib/awestruct/handlers/orgmode_handler.rb +0 -48
  165. data/lib/awestruct/handlers/sass_handler.rb +0 -21
  166. data/lib/awestruct/handlers/scss_handler.rb +0 -21
  167. data/lib/awestruct/handlers/textile_handler.rb +0 -58
@@ -0,0 +1,23 @@
1
+ # -*- coding: UTF-8 -*-
2
+ require 'spec_helper'
3
+
4
+ verify = lambda { |output|
5
+ output.should =~ %r(var crunchy = "bacon")
6
+ }
7
+
8
+ theories =
9
+ [
10
+ {
11
+ :page => "javascript-page.js",
12
+ :simple_name => "javascript-page",
13
+ :syntax => :javascript,
14
+ :extension => '.js',
15
+ :matcher => verify
16
+ }
17
+ ]
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
+
23
+ end
@@ -0,0 +1,77 @@
1
+
2
+ require 'awestruct/handlers/layout_handler'
3
+ require 'awestruct/handlers/string_handler'
4
+ require 'awestruct/engine'
5
+ require 'awestruct/handler_chains'
6
+ require 'awestruct/site'
7
+ require 'awestruct/page'
8
+ require 'awestruct/page_loader'
9
+
10
+ require 'hashery/open_cascade'
11
+ require 'ostruct'
12
+
13
+ describe Awestruct::Handlers::LayoutHandler do
14
+
15
+
16
+ before :all do
17
+ @config = OpenCascade.new( :dir=>Pathname.new( File.dirname(__FILE__) + '/test-data/handlers' ) )
18
+ @engine = Awestruct::Engine.new
19
+ @site = Awestruct::Site.new( @engine, @config )
20
+ layout_loader = Awestruct::PageLoader.new( @site, :layouts )
21
+ layout = layout_loader.load_page( File.join( @config.dir, 'haml-layout.html.haml' ) )
22
+ layout.class.should == Awestruct::Page
23
+ layout.should_not be_nil
24
+
25
+ @site.layouts << layout
26
+
27
+ layout = layout_loader.load_page( File.join( @config.dir, 'haml-layout-two.html.haml' ) )
28
+ layout.class.should == Awestruct::Page
29
+ layout.should_not be_nil
30
+
31
+ @site.layouts << layout
32
+ end
33
+
34
+ it "should be able to find layouts by simple name" do
35
+ layout = @site.layouts.find_matching( 'haml-layout', '.html' )
36
+ layout.class.should == Awestruct::Page
37
+ end
38
+
39
+ it "should apply the layout to its delegate's content" do
40
+ primary_handler = Awestruct::Handlers::StringHandler.new( @site, "this is the content" )
41
+ layout_handler = Awestruct::Handlers::LayoutHandler.new( @site, primary_handler )
42
+
43
+ page = Awestruct::Page.new( @site, layout_handler )
44
+
45
+ context = page.create_context
46
+ context.page.layout = 'haml-layout'
47
+
48
+ @site.layouts.find_matching( 'haml-layout', '.html' ).should_not be_nil
49
+ rendered = layout_handler.rendered_content( context )
50
+
51
+ end
52
+
53
+ it "should recursively apply the layout to its delegate's content" do
54
+ primary_handler = Awestruct::Handlers::StringHandler.new( @site, "this is the content" )
55
+ layout_handler = Awestruct::Handlers::LayoutHandler.new( @site, primary_handler )
56
+
57
+ page = Awestruct::Page.new( @site, layout_handler )
58
+ page.layout = 'haml-layout-two'
59
+
60
+ context = page.create_context
61
+
62
+ @site.layouts.find_matching('haml-layout', '.html').should_not be_nil
63
+ rendered = layout_handler.rendered_content( context )
64
+
65
+ haml_index = ( rendered =~ %r(This is a haml layout) )
66
+ awestruct_index = ( rendered =~ %r(Welcome to Awestruct) )
67
+ content_index = ( rendered =~ %r(this is the content) )
68
+
69
+ haml_index.should > 0
70
+ awestruct_index.should > 0
71
+ content_index.should > 0
72
+
73
+ haml_index.should < awestruct_index
74
+ awestruct_index.should < content_index
75
+ end
76
+
77
+ end
@@ -0,0 +1,32 @@
1
+
2
+ require 'awestruct/layouts'
3
+ require 'awestruct/page'
4
+ require 'awestruct/handlers/file_handler'
5
+ require 'awestruct/handlers/tilt_handler'
6
+
7
+ require 'hashery/open_cascade'
8
+
9
+ describe Awestruct::Layouts do
10
+
11
+ it "should be able to index layouts by simple name and output extension" do
12
+ dir = Pathname.new( File.dirname( __FILE__ ) + '/test-data/handlers' )
13
+ site = OpenCascade.new( :dir=>dir )
14
+ file_handler = Awestruct::Handlers::FileHandler.new( site, File.join( dir, 'haml-layout.html.haml' ) )
15
+ haml_handler = Awestruct::Handlers::TiltHandler.new( site, file_handler )
16
+ page = Awestruct::Page.new( nil, haml_handler )
17
+
18
+ layouts = Awestruct::Layouts.new
19
+ layouts << page
20
+
21
+ located = layouts[0]
22
+ located.should_not be_nil
23
+ located.class.should == Awestruct::Page
24
+ located.simple_name.should == 'haml-layout'
25
+
26
+ located = layouts.find_matching( 'haml-layout', '.html' )
27
+ located.should_not be_nil
28
+ located.class.should == Awestruct::Page
29
+ located.simple_name.should == 'haml-layout'
30
+ end
31
+
32
+ end
@@ -0,0 +1,33 @@
1
+ require 'spec_helper'
2
+
3
+ verify = lambda { |output|
4
+ output.should =~ /\.class {\n width: 2;\n}/
5
+ }
6
+
7
+ theories =
8
+ [
9
+ {
10
+ :page => "less-page.less",
11
+ :simple_name => "less-page",
12
+ :syntax => :less,
13
+ :extension => '.css',
14
+ :matcher => verify
15
+ },
16
+ {
17
+ :page => "less-page-with-import.less",
18
+ :simple_name => "less-page-with-import",
19
+ :syntax => :less,
20
+ :extension => '.css',
21
+ :matcher => verify,
22
+ :unless => {
23
+ :message => "Tilt 1.3.3 does not forward given options to Less parser. @import won't work unless :paths are set",
24
+ :exp => lambda { Tilt::VERSION.eql? "1.3.3" }
25
+ }
26
+ }
27
+ ]
28
+
29
+ describe Awestruct::Handlers::TiltHandler.to_s + "-Less" do
30
+
31
+ it_should_behave_like "a handler", theories
32
+
33
+ end
@@ -0,0 +1,41 @@
1
+ require 'spec_helper'
2
+
3
+ verify = lambda { |output|
4
+ include NokogiriMatchers
5
+ output.should have_tag('h1')
6
+ # TODO: This is the next phase
7
+ #output.should have_tag('h1') do
8
+ # with_text 'This is a Markdown page'
9
+ #end
10
+ }
11
+
12
+ theories =
13
+ [
14
+ {
15
+ :page => "markdown-page.md",
16
+ :simple_name => "markdown-page",
17
+ :syntax => :markdown,
18
+ :extension => '.html',
19
+ :matcher => verify
20
+ },
21
+ {
22
+ :page => "markdown-page.markdown",
23
+ :simple_name => "markdown-page",
24
+ :syntax => :markdown,
25
+ :extension => '.html',
26
+ :matcher => verify
27
+ },
28
+ {
29
+ :page => "markdown-page.mkd",
30
+ :simple_name => "markdown-page",
31
+ :syntax => :markdown,
32
+ :extension => '.html',
33
+ :matcher => verify
34
+ }
35
+ ]
36
+
37
+ describe Awestruct::Handlers::TiltHandler.to_s + "-Markdown" do
38
+
39
+ it_should_behave_like "a handler", theories
40
+
41
+ end
@@ -0,0 +1,61 @@
1
+ require 'spec_helper'
2
+ require 'awestruct/extensions/minify'
3
+
4
+ describe Awestruct::Extensions::Minify do
5
+
6
+ it "should ignore files with no extension" do
7
+ site = mock
8
+ page = mock
9
+
10
+ site.should_receive(:minify).and_return true
11
+ page.should_receive(:output_path).and_return "CNAME"
12
+ input = "some input"
13
+
14
+ minifier = Awestruct::Extensions::Minify.new
15
+ minifier.transform(site, page, input).should == input
16
+ end
17
+
18
+ it "should compress html files" do
19
+ site = mock
20
+ page = mock
21
+
22
+ site.should_receive(:minify).and_return true
23
+ site.should_receive(:minify_html_opts).and_return( {:remove_comments => false} )
24
+ page.should_receive(:output_path).any_number_of_times.and_return "test.html"
25
+
26
+ input = "<html><a href='' /> \n</html><!--test-->"
27
+ expected_output = "<html><a href=''/> </html><!--test-->"
28
+
29
+ minifier = Awestruct::Extensions::Minify.new [:html]
30
+ minifier.transform(site, page, input).should == expected_output
31
+ end
32
+
33
+ # Doing this if it's production now
34
+ #it "should compress css files" do
35
+ #site = mock
36
+ #page = mock
37
+
38
+ #site.should_receive(:minify).and_return true
39
+ #page.should_receive(:output_path).any_number_of_times.and_return "test.css"
40
+
41
+ #input = ".class { \n a: b ;}"
42
+ #expected_output = ".class{a:b}"
43
+
44
+ #minifier = Awestruct::Extensions::Minify.new [:css]
45
+ #minifier.transform(site, page, input).should == expected_output
46
+ #end
47
+
48
+ it "should compress js files" do
49
+ site = mock
50
+ page = mock
51
+
52
+ site.should_receive(:minify).and_return true
53
+ page.should_receive(:output_path).any_number_of_times.and_return "test.js"
54
+
55
+ input = "function a (a, c) { \n a = \"a\";\n }"
56
+ expected_output = "function a(a,c){a=\"a\"};"
57
+
58
+ minifier = Awestruct::Extensions::Minify.new [:js]
59
+ minifier.transform(site, page, input).should == expected_output
60
+ end
61
+ end
@@ -0,0 +1,29 @@
1
+ require 'spec_helper'
2
+
3
+ verify = lambda { |output|
4
+ output.should =~ %r(<h1>This is a Mustache page</h1>)
5
+ }
6
+
7
+ theories =
8
+ [
9
+ {
10
+ :page => "mustache-page.html.mustache",
11
+ :simple_name => "mustache-page",
12
+ :syntax => :mustache,
13
+ :extension => '.html',
14
+ :matcher => verify
15
+ },
16
+ {
17
+ :page => "mustache-page.xml.mustache",
18
+ :simple_name => "mustache-page",
19
+ :syntax => :mustache,
20
+ :extension => '.xml',
21
+ :matcher => verify
22
+ }
23
+ ]
24
+
25
+ describe Awestruct::Handlers::TiltHandler.to_s + "-Mustache" do
26
+ let(:additional_config) { {:markup_type => 'Mustache'} }
27
+ it_should_behave_like "a handler", theories
28
+
29
+ end
@@ -0,0 +1,97 @@
1
+
2
+ require 'awestruct/cli/options'
3
+
4
+ describe Awestruct::CLI::Options do
5
+
6
+ it "should have reasonable defaults" do
7
+ options = Awestruct::CLI::Options.new
8
+ options.generate.should == nil
9
+ options.server.should == false
10
+ options.deploy.should == false
11
+
12
+ options.port.should == 4242
13
+ options.bind_addr.should == '0.0.0.0'
14
+
15
+ options.auto.should == false
16
+ options.force.should == false
17
+ options.init.should == false
18
+
19
+ options.framework.should == 'compass'
20
+ options.scaffold.should == true
21
+
22
+ options.base_url.should == nil
23
+ options.profile.should == nil
24
+ options.script.should == nil
25
+ options.verbose.should == false
26
+ end
27
+
28
+ describe "parsing" do
29
+ def parse!(*args)
30
+ Awestruct::CLI::Options.parse! args
31
+ end
32
+
33
+ it "should parse server-related args" do
34
+ parse!( '-s' ).server.should == true
35
+ parse!( '--server' ).server.should == true
36
+
37
+ parse!( '-p', '8180' ).port.should == 8180
38
+ parse!( '--port', '8181' ).port.should == 8181
39
+
40
+ parse!( '-b', '1.2.3.4' ).bind_addr.should == '1.2.3.4'
41
+ parse!( '--bind', '5.6.7.8' ).bind_addr.should == '5.6.7.8'
42
+
43
+ parse!( '-u', 'http://mysite.com/' ).base_url.should == 'http://mysite.com/'
44
+ parse!( '--url', 'http://mysite.com/' ).base_url.should == 'http://mysite.com/'
45
+ end
46
+
47
+ it "should parse profile-related args" do
48
+ parse!( '-P', 'numberwang' ).profile.should == 'numberwang'
49
+ parse!( '--profile', 'superhans' ).profile.should == 'superhans'
50
+ end
51
+
52
+ it "should parse generation-related args" do
53
+ parse!( '-g' ).generate.should == true
54
+ parse!( '--generate' ).generate.should == true
55
+ parse!( '--no-generate' ).generate.should == false
56
+
57
+ parse!( '--force' ).force.should == true
58
+
59
+ parse!( '-a' ).auto.should == true
60
+ parse!( '--auto' ).auto.should == true
61
+ end
62
+
63
+ it "should parse script-related args" do
64
+ pending "Not yet implemented. See issue #248."
65
+ #parse!( '--run', 'puts "hi"' ).script.should == 'puts "hi"'
66
+ end
67
+
68
+ it "should turn off generate when doing a --deploy" do
69
+ result = parse!( '--deploy' )
70
+ result.deploy.should be_true
71
+ result.generate.should be_false
72
+ end
73
+
74
+ it "should turn off generate when doing a --deploy unless explicitly turned back on" do
75
+ result = parse!( '--deploy', '--generate' )
76
+ result.deploy.should be_true
77
+ result.generate.should be_true
78
+
79
+ result = parse!( '--generate', '--deploy' )
80
+ result.deploy.should be_true
81
+ result.generate.should be_true
82
+ end
83
+
84
+ it "should turn on verbose when -w or --verbose is explicitly turned back on" do
85
+ result = parse!( '-w' )
86
+ result.verbose.should be_true
87
+
88
+ result = parse!( '--verbose' )
89
+ result.verbose.should be_true
90
+ end
91
+
92
+ it "should generate by default" do
93
+ parse!().generate.should be_true
94
+ end
95
+ end
96
+
97
+ end
@@ -0,0 +1,24 @@
1
+ require 'spec_helper'
2
+ require 'org-ruby'
3
+
4
+ verify = lambda { |output|
5
+ output.should =~ %r(<h1>Fruit</h1>)
6
+ output.should =~ %r(<p>Apples are red</p>)
7
+ }
8
+
9
+ theories =
10
+ [
11
+ {
12
+ :page => "orgmode-page.org",
13
+ :simple_name => "orgmode-page",
14
+ :syntax => :orgmod,
15
+ :extension => '.html',
16
+ :matcher => verify
17
+ }
18
+ ]
19
+
20
+ describe Awestruct::Handlers::TiltHandler.to_s + "-OrgMode" do
21
+
22
+ it_should_behave_like "a handler", theories
23
+
24
+ end
@@ -0,0 +1,79 @@
1
+
2
+ require 'awestruct/engine'
3
+ require 'awestruct/site'
4
+ require 'awestruct/page'
5
+ require 'awestruct/handlers/page_delegating_handler'
6
+
7
+ describe Awestruct::Handlers::PageDelegatingHandler do
8
+
9
+ before :all do
10
+ @config = OpenCascade.new( :dir=>Pathname.new( File.dirname(__FILE__) + '/test-data/handlers' ) )
11
+ @engine = Awestruct::Engine.new( @config )
12
+ @site = @engine.site
13
+ layout_loader = Awestruct::PageLoader.new( @site, :layouts )
14
+
15
+ layout = layout_loader.load_page( File.join( @config.dir, 'haml-layout.html.haml' ) )
16
+ layout.class.should == Awestruct::Page
17
+ layout.should_not be_nil
18
+
19
+ @site.layouts << layout
20
+
21
+ layout = layout_loader.load_page( File.join( @config.dir, 'haml-layout-two.html.haml' ) )
22
+ layout.class.should == Awestruct::Page
23
+ layout.should_not be_nil
24
+
25
+ @site.layouts << layout
26
+
27
+ layout = layout_loader.load_page( File.join( @config.dir, 'outer-layout.html.haml' ) )
28
+ layout.class.should == Awestruct::Page
29
+ layout.should_not be_nil
30
+
31
+ @site.layouts << layout
32
+ end
33
+
34
+ it "should provide layed-out content for the page's content" do
35
+ inner_page = @engine.load_site_page( "inner-page.html.haml" )
36
+
37
+ page = Awestruct::Page.new( @site, Awestruct::Handlers::PageDelegatingHandler.new( @site, inner_page) )
38
+ c = page.content
39
+ c.should =~ %r(<h1>This is a haml layout</h1>)
40
+ c.should =~ %r(<h2>This is the inner page</h2>)
41
+ c.should_not =~ %r(<b>)
42
+ end
43
+
44
+ it "should provide for laying out both inner and outer page content" do
45
+ inner_page = @engine.load_site_page( "inner-page.html.haml" )
46
+
47
+ page = Awestruct::Page.new( @site, Awestruct::Handlers::LayoutHandler.new( @site, Awestruct::Handlers::PageDelegatingHandler.new( @site, inner_page) ) )
48
+ page.layout = 'outer-layout'
49
+ page.output_path = '/outer-page.html'
50
+
51
+ c = page.content
52
+ c.should =~ %r(<h1>This is a haml layout</h1>)
53
+ c.should =~ %r(<h2>This is the inner page</h2>)
54
+ c.should_not =~ %r(<b>)
55
+
56
+ c.should_not =~ %r(<b>)
57
+ c = page.rendered_content
58
+ c.should =~ %r(<h1>This is a haml layout</h1>)
59
+ c.should =~ %r(<h2>This is the inner page</h2>)
60
+ c.should =~ %r(<b>)
61
+ end
62
+
63
+ it "should provide a simple Page-ctor to delegate" do
64
+ inner_page = @engine.load_site_page( "inner-page.html.haml" )
65
+ page = Awestruct::Page.new( @site, inner_page )
66
+ page.layout= 'outer-layout'
67
+
68
+ c = page.content
69
+ c.should =~ %r(<h1>This is a haml layout</h1>)
70
+ c.should =~ %r(<h2>This is the inner page</h2>)
71
+ c.should_not =~ %r(<b>)
72
+
73
+ c = page.rendered_content
74
+ c.should =~ %r(<h1>This is a haml layout</h1>)
75
+ c.should =~ %r(<h2>This is the inner page</h2>)
76
+ c.should =~ %r(<b>)
77
+ end
78
+
79
+ end