awestruct 0.5.4.2 → 0.5.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (32) hide show
  1. checksums.yaml +4 -4
  2. data/awestruct.gemspec +1 -1
  3. data/lib/awestruct/cli/auto.rb +22 -16
  4. data/lib/awestruct/cli/invoker.rb +7 -1
  5. data/lib/awestruct/cli/manifest.rb +14 -11
  6. data/lib/awestruct/cli/options.rb +1 -0
  7. data/lib/awestruct/engine.rb +21 -9
  8. data/lib/awestruct/extensions/google_analytics.rb +14 -1
  9. data/lib/awestruct/handler_chains.rb +0 -2
  10. data/lib/awestruct/handlers/base_tilt_handler.rb +4 -4
  11. data/lib/awestruct/page.rb +7 -1
  12. data/lib/awestruct/version.rb +1 -1
  13. data/spec/awestruct/cli/init_spec.rb +18 -0
  14. data/spec/awestruct/cli/invoker_spec.rb +10 -2
  15. data/spec/awestruct/cli/options_spec.rb +6 -0
  16. data/spec/{config_spec.rb → awestruct/config_spec.rb} +0 -0
  17. data/spec/{context_helper_spec.rb → awestruct/context_helper_spec.rb} +0 -0
  18. data/spec/{engine_spec.rb → awestruct/engine_spec.rb} +0 -0
  19. data/spec/{disqus_spec.rb → awestruct/extensions/disqus_spec.rb} +0 -0
  20. data/spec/{minify_spec.rb → awestruct/extensions/minify_spec.rb} +0 -0
  21. data/spec/{posts_archive_spec.rb → awestruct/extensions/posts_spec.rb} +0 -0
  22. data/spec/{handler_chain_spec.rb → awestruct/handler_chain_spec.rb} +0 -0
  23. data/spec/{handler_chains_spec.rb → awestruct/handler_chains_spec.rb} +0 -0
  24. data/spec/awestruct/handlers/file_handler_spec.rb +42 -22
  25. data/spec/awestruct/handlers/tilt_handler_spec.rb +1 -1
  26. data/spec/{layouts_spec.rb → awestruct/layouts_spec.rb} +0 -0
  27. data/spec/{page_loader_spec.rb → awestruct/page_loader_spec.rb} +33 -0
  28. data/spec/{pipeline_spec.rb → awestruct/pipeline_spec.rb} +0 -0
  29. data/spec/{server_spec.rb → awestruct/rack/app_spec.rb} +0 -0
  30. metadata +28 -29
  31. data/spec/page_loader_spec_for_layouts.rb +0 -38
  32. data/spec/page_spec.rb +0 -66
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3395e26727ea024244aa5f9fc19fb31ba13ddd6d
4
- data.tar.gz: 0beaba554f25c504f48dde6a931ce3dc6377d5ec
3
+ metadata.gz: 42707b3e65d935704a6a4b4e70950897dbe43c26
4
+ data.tar.gz: e51aab1ecb9a80daf22f5cad51a01150a4b546e9
5
5
  SHA512:
6
- metadata.gz: 0cf85e4674ff4b16893ec8a7d386cae463d6569ba03f9cdcdbc14e26ab8c5d34e2083aeb658e3dfda0233627db38443b2f1092456338933f013a9a02db9781be
7
- data.tar.gz: a9e1803a461f21be4bdd838358bc81d03825398a4fa49b3004da43dc641954027771673c0926946714b5710d55113646634f9f308ca866cd87767d3da7de802f
6
+ metadata.gz: 910fb313268c6b32697d557cf7864ed609027a53231df08859dce06e8e8667613286d0360341668b5a90f4a0ad2417b47f68fe7a2ee19aa89713bb9663e3881a
7
+ data.tar.gz: 0136ae84bbea1d15b311f0c627d40e7f810446cad2a64b2f98dc0dd280515ee521e3abfe5d08739958b549ae093d1b03125d07bf6596b18f213f386fbf3e214a
data/awestruct.gemspec CHANGED
@@ -4,7 +4,7 @@ require 'awestruct/version'
4
4
  spec = Gem::Specification.new do |s|
5
5
  s.name = 'awestruct'
6
6
  s.version = Awestruct::VERSION
7
- s.date = '2014-04-09'
7
+ s.date = '2014-04-23'
8
8
 
9
9
  s.authors = ['Bob McWhirter', 'Jason Porter', 'Lance Ball', 'Dan Allen', 'Torsten Curdt', 'other contributors']
10
10
  s.email = ['bob@mcwhirter.org', 'lightguard.jp@gmail.com', 'lball@redhat.com', 'dan.j.allen@gmail.com', 'tcurdt@vafer.org']
@@ -2,6 +2,7 @@ require 'awestruct/util/exception_helper'
2
2
 
3
3
  require 'listen'
4
4
  require 'guard/livereload'
5
+ require 'compass'
5
6
 
6
7
  module Awestruct
7
8
  module CLI
@@ -29,8 +30,9 @@ module Awestruct
29
30
  modified.each do |path| # path is absolute path
30
31
  engine = ::Awestruct::Engine.instance
31
32
 
32
- unless ( path =~ %r(#{File.basename( engine.config.output_dir) }) || path =~ /.awestruct/ )
33
+ unless ( path =~ %r(#{File.basename( engine.config.output_dir) }) || path =~ /.awestruct/ || path =~ /sass-cache/ )
33
34
  begin
35
+ $LOG.info "Change detected for file #{path}" if $LOG.info?
34
36
  if path.eql? current_path
35
37
  unless generate_thread.nil?
36
38
  $LOG.info "Same path triggered, stopping previous generation" if generate_thread.alive? && $LOG.info?
@@ -43,25 +45,29 @@ module Awestruct
43
45
 
44
46
  generate_thread = Thread.new {
45
47
  begin
46
-
47
- # TODO: Have to figure something out for extensions and other files without an output path
48
- # Probably add another method in engin to to do the regen w/o mucking with site.pages and run through things again
49
- page = engine.page_by_output_path(path)
50
- if ( page )
51
- pages = engine.generate_page_and_dependencies( page )
52
-
53
- if ( guard )
54
- urls = pages.map do |p|
55
- @base_url + p.url.to_s
48
+ if ( File.extname(path) == '.sass' || File.extname(path) == '.scss' )
49
+ ::Compass::Commands::UpdateProject.new(engine.site.dir, {}).perform
50
+ else
51
+ page = engine.page_by_output_path(path)
52
+ pages = []
53
+ if ( page )
54
+ pages = engine.generate_page_and_dependencies( page )
55
+ else
56
+ if File.exist? path
57
+ # chances are this is an extension or yaml file
58
+ pages = engine.run_auto_for_non_page(path)
56
59
  end
57
-
58
- guard.run_on_modifications(urls)
59
60
  end
61
+ end
60
62
 
61
- $LOG.info "Regeneration finished." if $LOG.info?
63
+ $LOG.info "Regeneration finished." if $LOG.info?
62
64
 
63
- else
64
- $LOG.error "Failed to find page from path #{path}"
65
+ if ( guard )
66
+ urls = pages.map do |p|
67
+ @base_url + p.url.to_s
68
+ end
69
+
70
+ guard.run_on_modifications(urls)
65
71
  end
66
72
 
67
73
  rescue => e
@@ -52,7 +52,13 @@ module Awestruct
52
52
  invoke_auto() if ( options.auto )
53
53
 
54
54
  wait_for_completion()
55
- @success = false if ExceptionHelper.build_failed?
55
+
56
+ if ExceptionHelper.build_failed? || @success == false
57
+ @success = false
58
+ false
59
+ else
60
+ true
61
+ end
56
62
  rescue
57
63
  @success = false
58
64
  false
@@ -8,10 +8,10 @@ require 'compass/commands/registry'
8
8
  require 'compass/commands/create_project'
9
9
  require 'compass/installers/bare_installer'
10
10
 
11
- module Compass::AppIntegration::StandAlone
11
+ module ::Compass::AppIntegration::StandAlone
12
12
  end
13
13
 
14
- class Compass::AppIntegration::StandAlone::Installer
14
+ class ::Compass::AppIntegration::StandAlone::Installer
15
15
  def write_configuration_files(config_file = nil)
16
16
  # no!
17
17
  end
@@ -74,13 +74,15 @@ module Awestruct
74
74
 
75
75
  def perform(dir)
76
76
  parent.perform(dir) if parent
77
- steps.each do |step|
78
- begin
77
+ begin
78
+ steps.each do |step|
79
79
  step.perform(dir)
80
- rescue => e
81
- ExceptionHelper.log_error e
82
- ExceptionHelper.log_backtrace e
83
80
  end
81
+ true
82
+ rescue => e
83
+ ExceptionHelper.log_error e
84
+ ExceptionHelper.log_backtrace e
85
+ false
84
86
  end
85
87
  end
86
88
 
@@ -88,6 +90,7 @@ module Awestruct
88
90
  steps.each do |step|
89
91
  begin
90
92
  step.unperform(dir)
93
+ true
91
94
  rescue => e
92
95
  ExceptionHelper.log_error e
93
96
  ExceptionHelper.log_backtrace e
@@ -235,11 +238,11 @@ module Awestruct
235
238
  end
236
239
 
237
240
  def perform(dir)
238
- Compass.configuration.sass_dir = 'stylesheets'
239
- Compass.configuration.css_dir = '_site/stylesheets'
240
- Compass.configuration.images_dir = 'images'
241
+ ::Compass.configuration.sass_dir = 'stylesheets'
242
+ ::Compass.configuration.css_dir = '_site/stylesheets'
243
+ ::Compass.configuration.images_dir = 'images'
241
244
 
242
- cmd = Compass::Commands::CreateProject.new(dir, {
245
+ cmd = ::Compass::Commands::CreateProject.new(dir, {
243
246
  :framework => @framework,
244
247
  :project_type => :stand_alone,
245
248
  :css_dir => '_site/stylesheets',
@@ -124,6 +124,7 @@ module Awestruct
124
124
  #end
125
125
  opts.on( '--source-dir DIR', 'Location of sources (default: .' ) do |source_dir|
126
126
  self.source_dir = File.expand_path source_dir
127
+ self.output_dir = File.expand_path File.join(self.source_dir, '_site')
127
128
  end
128
129
 
129
130
  opts.on( '--output-dir DIR', 'Location to output generated site (default: _site' ) do |output_dir|
@@ -15,6 +15,8 @@ require 'set'
15
15
 
16
16
  require 'compass'
17
17
 
18
+ require 'pry'
19
+
18
20
  class OpenStruct
19
21
  def inspect
20
22
  "OpenStruct{...}"
@@ -356,17 +358,13 @@ module Awestruct
356
358
 
357
359
  $LOG.debug "Starting regeneration of content dependent pages:" if regen_pages.size > 0 && $LOG.debug?
358
360
 
359
- old_site_pages = site.pages
360
- site.pages = regen_pages
361
-
362
361
  @pipeline = Pipeline.new
363
362
  load_yamls
364
363
  load_pipeline
365
364
  execute_pipeline
366
- @site.pages = old_site_pages
367
365
 
368
366
  regen_pages.each do |p|
369
- puts "Regenerating page #{p.output_path}"
367
+ puts "Regenerating page #{p.output_path}" unless config.quiet
370
368
  generate_page_internal(p)
371
369
  pages << p
372
370
  end
@@ -374,11 +372,25 @@ module Awestruct
374
372
  pages
375
373
  end
376
374
 
375
+ def run_auto_for_non_page(file)
376
+ if File.extname(file) == '.rb'
377
+ load file
378
+ end
379
+ @pipeline = Pipeline.new
380
+ load_yamls
381
+ load_pipeline
382
+ execute_pipeline
383
+ site.pages.each do |p|
384
+ generate_page_internal(p)
385
+ end
386
+ site.pages
387
+ end
388
+
377
389
  def generate_page_internal(p)
378
- unless ( p.output_path.nil? || p.__is_layout )
379
- generated_path = File.join( site.config.output_dir, p.output_path )
380
- generate_page( p, generated_path )
381
- end
390
+ unless ( p.output_path.nil? || p.__is_layout || !p.stale_output?(p.output_path) )
391
+ generated_path = File.join( site.config.output_dir, p.output_path )
392
+ generate_page( p, generated_path )
393
+ end
382
394
  end
383
395
 
384
396
  ####
@@ -4,6 +4,8 @@
4
4
  # account: UA-something
5
5
  # anonymizeIp: true
6
6
  # bounceTime: 15
7
+ # demographics: true
8
+ # linkAttribution: true
7
9
  #
8
10
  # of course only "account" is required
9
11
 
@@ -27,9 +29,18 @@ module Awestruct
27
29
  html += %Q(_gaq.push(['_gat._anonymizeIp']);\n) if options[:anonymizeIp]
28
30
  html += %Q(_gaq.push(['_trackPageview']);\n)
29
31
  html += %Q(setTimeout("_gaq.push(['_trackEvent','#{options[:bounceTime]}_seconds','read'])", #{options[:bounceTime]}000);\n) if options[:bounceTime]
32
+ html += %Q(_gaq.push(['_require', 'inpage_linkid', '//www.google-analytics.com/plugins/ga/inpage_linkid.js']);\n) if options[:linkAttribution]
30
33
  html += %Q[(function() {\n]
31
34
  html += %Q( var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;\n)
32
- html += %Q( ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';\n)
35
+
36
+
37
+ if options[:demographics]
38
+ html += %Q( ga.src = ('https:' == document.location.protocol ? 'https://' : 'http://') + 'stats.g.doubleclick.net/dc.js';\n)
39
+ else
40
+ html += %Q( ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';\n)
41
+ end
42
+
43
+
33
44
  html += %Q( var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);\n)
34
45
  html += %Q[})();\n</script>\n]
35
46
  html
@@ -48,6 +59,8 @@ module Awestruct
48
59
  html += %Q(ga('create', '#{options[:account]}', 'auto');\n)
49
60
  html += %Q(ga('send', 'pageview');\n)
50
61
  html += %Q(ga('set', 'anonymizeIp', true);\n) if options[:anonymizeIp]
62
+ html += %Q(ga('require', 'displayfeatures');\n) if options[:demographics]
63
+ html += %Q(ga('require', 'linkid', 'linkid.js');\n) if options[:linkAttribution]
51
64
  html += %Q(setTimeout("ga('send', 'event', 'read', '#{options[:bounceTime]} seconds')", #{options[:bounceTime]}000);\n) if options[:bounceTime]
52
65
  html += %Q(\n)
53
66
  html += %Q(</script>\n)
@@ -18,8 +18,6 @@ module Awestruct
18
18
  Awestruct::Handlers::RedirectHandler::CHAIN,
19
19
  Awestruct::Handlers::RestructuredtextHandler::CHAIN,
20
20
  Awestruct::Handlers::JavascriptHandler::CHAIN,
21
- # TC: shouldn't the asciidoctor be covered by the tilt handler?
22
- # JP: We have some additional asciidoctor integration that the tilt handler doesn't handle (yet, working on it)
23
21
  Awestruct::Handlers::AsciidoctorHandler::CHAIN,
24
22
  Awestruct::Handlers::TiltHandler::NON_INTERPOLATION_CHAIN,
25
23
  Awestruct::Handlers::TiltHandler::INTERPOLATION_CHAIN,
@@ -14,10 +14,10 @@ module Awestruct
14
14
  def match(path)
15
15
  matcher = ::Tilt[File.basename(path)]
16
16
  if matcher.nil?
17
- $LOG.warn(%(Copying #{path} to generated site without processing; could not load engine for type))
17
+ $LOG.warn(%(Copying #{path}))
18
18
  return false
19
19
  end
20
-
20
+
21
21
  # We have our own extra integration with Asciidoctor
22
22
  if matcher.name.include? 'Asciidoctor'
23
23
  return false
@@ -141,9 +141,9 @@ module Awestruct
141
141
  rescue Exception => e
142
142
  error_page = context[:page]
143
143
  if error_page[:__is_layout] == true
144
- ExceptionHelper.log_message "An error during rendering layout file #{File.join site.dir, error_page.source_path} occurred."
144
+ ExceptionHelper.log_message "An error during rendering layout file #{File.join site.dir, error_page.source_path} occurred."
145
145
  else
146
- ExceptionHelper.log_message "An error during rendering #{File.join site.dir, error_page.source_path} occurred."
146
+ ExceptionHelper.log_message "An error during rendering #{File.join site.dir, error_page.source_path} occurred."
147
147
  end
148
148
  ExceptionHelper.log_message "Please see #{File.join site.dir, error_page.output_path} for more information"
149
149
  return ExceptionHelper.html_error_report e, error_page.source_path
@@ -94,10 +94,16 @@ module Awestruct
94
94
  return true if ! File.exist?( output_path )
95
95
  return true if input_mtime > File.mtime( output_path )
96
96
  return true if stale?
97
- # TODO: Add stale callback and execute it
97
+ return true if @stale_output_callback && @stale_output_callback.call(self)
98
98
  false
99
99
  end
100
100
 
101
+ # Define a stale check specific for this page. The parameter is expected
102
+ # to be a lambda or proc and is called with self as the argument.
103
+ def stale_output_callback= code
104
+ @stale_output_callback = block
105
+ end
106
+
101
107
  def input_mtime
102
108
  handler.input_mtime( self )
103
109
  end
@@ -1,3 +1,3 @@
1
1
  module Awestruct
2
- VERSION = '0.5.4.2'
2
+ VERSION = '0.5.5'
3
3
  end
@@ -0,0 +1,18 @@
1
+ require 'spec_helper'
2
+ require 'awestruct/cli/init'
3
+ require 'logger'
4
+
5
+ describe Awestruct::CLI::Init do
6
+ before(:each) do
7
+ FileUtils.mkdir_p 'spec/support/clean_init'
8
+ end
9
+
10
+ after(:each) do
11
+ FileUtils.rm_rf 'spec/support/clean_init'
12
+ end
13
+
14
+ it "should not fail during init" do
15
+ init = Awestruct::CLI::Init.new('spec/support/clean_init', 'compass', true)
16
+ expect(init.run).to eql true
17
+ end
18
+ end
@@ -1,7 +1,15 @@
1
-
1
+ require 'spec_helper'
2
+ require 'fileutils'
2
3
  require 'awestruct/cli/invoker'
3
4
 
4
5
  describe Awestruct::CLI::Invoker do
6
+ before(:each) do
7
+ FileUtils.mkdir_p 'spec/support/clean_init'
8
+ end
9
+
10
+ after(:each) do
11
+ FileUtils.rm_rf 'spec/support/clean_init'
12
+ end
5
13
 
6
14
  it "should invoke generation by default" do
7
15
  invoker = Awestruct::CLI::Invoker.new(%w(--source-dir spec/support/test-config/))
@@ -61,7 +69,7 @@ describe Awestruct::CLI::Invoker do
61
69
  invoker.should_not_receive( :invoke_auto )
62
70
  invoker.should_not_receive( :invoke_server )
63
71
  invoker.invoke!
64
- end
72
+ end
65
73
 
66
74
  it "should return false on failure" do
67
75
  require 'awestruct/cli/generate'
@@ -101,6 +101,12 @@ describe Awestruct::CLI::Options do
101
101
  result.source_dir.should eql '/tmp'
102
102
  result.output_dir.should eql '/tmp/new-site'
103
103
  end
104
+
105
+ it 'by default, output_dir should be "_site" under source_dir' do
106
+ result = Awestruct::CLI::Options.parse!(%w(--source-dir /tmp))
107
+ result.source_dir.should eql '/tmp'
108
+ result.output_dir.should eql '/tmp/_site'
109
+ end
104
110
  end
105
111
 
106
112
  end
File without changes
File without changes
@@ -3,15 +3,26 @@ require 'hashery'
3
3
  require 'awestruct/handlers/file_handler'
4
4
 
5
5
  describe Awestruct::Handlers::FileHandler do
6
+ class TestTransformer
7
+ def transform(site, page, rendered)
8
+ rendered.gsub( /howdy/, 'adios' )
9
+ end
10
+ end
6
11
 
7
12
  before :all do
8
13
  @site = Hashery::OpenCascade[ { :encoding=>false, :dir=>Pathname.new( test_data_dir '' )}]
14
+ @site.engine = Hashery::OpenCascade[]
15
+ end
16
+
17
+ before :each do
18
+ @filename = Pathname.new( test_data_dir 'simple-file.txt' )
19
+ @handler = Awestruct::Handlers::FileHandler.new( @site, @filename )
20
+ @page = Awestruct::Page.new( @site, @handler )
21
+ @site.engine.pipeline = Awestruct::Pipeline.new
9
22
  end
10
23
 
11
24
  it "should be able to read a valid absolute file handler" do
12
- filename = Pathname.new( test_data_dir 'simple-file.txt' )
13
- handler = Awestruct::Handlers::FileHandler.new( @site, filename )
14
- handler.raw_content.strip.should == 'howdy'
25
+ @handler.raw_content.strip.should == 'howdy'
15
26
  end
16
27
 
17
28
  it "should be able to read a valid relative file handler" do
@@ -22,35 +33,44 @@ describe Awestruct::Handlers::FileHandler do
22
33
  end
23
34
 
24
35
  it "should be stale before being read" do
25
- filename = Pathname.new( test_data_dir 'simple-file.txt' )
26
- handler = Awestruct::Handlers::FileHandler.new( @site, filename )
27
- handler.should be_stale
36
+ @handler.should be_stale
28
37
  end
29
38
 
30
39
  it "should not be stale after being read" do
31
- filename = Pathname.new( test_data_dir 'simple-file.txt' )
32
- handler = Awestruct::Handlers::FileHandler.new( @site, filename )
33
- handler.raw_content.strip.should == 'howdy'
34
- handler.should_not be_stale
40
+ @handler.raw_content.strip.should == 'howdy'
41
+ @handler.should_not be_stale
35
42
  end
36
43
 
37
44
  it "should be stale if touched after being read" do
38
- filename = Pathname.new( test_data_dir 'simple-file.txt' )
39
- handler = Awestruct::Handlers::FileHandler.new( @site, filename )
40
- handler.raw_content.strip.should == 'howdy'
41
- handler.should_not be_stale
45
+ @handler.raw_content.strip.should == 'howdy'
46
+ @handler.should_not be_stale
42
47
  sleep(1)
43
- FileUtils.touch( filename )
44
- handler.should be_stale
48
+ FileUtils.touch( @filename )
49
+ @handler.should be_stale
45
50
  end
46
51
 
47
52
  it "should provide reasonable paths" do
48
- filename = Pathname.new( test_data_dir 'simple-file.txt' )
49
- handler = Awestruct::Handlers::FileHandler.new( @site, filename )
50
- handler.relative_source_path.should == '/simple-file.txt'
51
- handler.output_filename.should == 'simple-file.txt'
52
- handler.output_extension.should == '.txt'
53
- handler.output_path.should == '/simple-file.txt'
53
+ @handler.relative_source_path.should == '/simple-file.txt'
54
+ @handler.output_filename.should == 'simple-file.txt'
55
+ @handler.output_extension.should == '.txt'
56
+ @handler.output_path.should == '/simple-file.txt'
57
+ end
58
+
59
+ it "should be able to create an appropriate context" do
60
+ context = @page.create_context
61
+ context.site.should == @site
62
+ context.page.should == @page
63
+ context.content.should == ''
64
+ end
65
+
66
+ it "should allow relative_source_path to be assignable" do
67
+ @page.relative_source_path = '/taco'
68
+ @page.relative_source_path.should == '/taco'
69
+ end
70
+
71
+ it "should not apply transformers, even if present" do
72
+ @site.engine.pipeline.transformer TestTransformer.new
73
+ @page.rendered_content.strip.should == 'howdy'
54
74
  end
55
75
 
56
76
  end
@@ -113,7 +113,7 @@ describe Awestruct::Handlers::TiltHandler do
113
113
  @site.dir = Pathname.new( test_data_dir 'handlers' )
114
114
  path = handler_file( "hello.bogus" )
115
115
  expect(Awestruct::Handlers::TiltMatcher.new().match(path)).to be_false
116
- expect(log.string).to include('could not load engine for type')
116
+ expect(log.string).to include('Copying')
117
117
 
118
118
  # we don't even want to process a file if we cannot load its Tilt template
119
119
  #file_handler = Awestruct::Handlers::FileHandler.new( @site, path )
File without changes
@@ -60,4 +60,37 @@ describe Awestruct::PageLoader do
60
60
 
61
61
  end
62
62
 
63
+ context 'with layouts' do
64
+ before :each do
65
+ @opts = Awestruct::CLI::Options.new
66
+ @opts.source_dir = test_data_dir 'page-loader'
67
+ @config = Awestruct::Config.new( @opts )
68
+ @engine = Awestruct::Engine.new
69
+ @engine.pipeline.handler_chains << :defaults
70
+ @site = Awestruct::Site.new( @engine, @config )
71
+ @loader = Awestruct::PageLoader.new( @site, :layouts )
72
+ end
73
+
74
+ it "should be able to load a site layout" do
75
+ page = @loader.load_page( File.join( @config.dir, "_layouts", "layout-one.md" ) )
76
+ page.should_not be_nil
77
+ page.handler.to_chain.collect{|e| e.class}.should be_include Awestruct::Handlers::TiltHandler
78
+ page.relative_source_path.to_s.should == "/_layouts/layout-one.md"
79
+ end
80
+
81
+ it "should be able to load all site layouts" do
82
+ @loader.load_all
83
+ @site.layouts.size.should == 2
84
+
85
+ @site.layouts.sort!{|l,r| l.relative_source_path <=> r.relative_source_path }
86
+
87
+ @site.layouts[0].relative_source_path.should == '/_layouts/layout-one.md'
88
+ @site.layouts[0].output_path.should == '/_layouts/layout-one.html'
89
+
90
+ @site.layouts[1].relative_source_path.should == '/_layouts/layout-two.html.haml'
91
+ @site.layouts[1].output_path.should == '/_layouts/layout-two.html'
92
+ end
93
+
94
+ end
95
+
63
96
  end
File without changes
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: awestruct
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.4.2
4
+ version: 0.5.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bob McWhirter
@@ -13,7 +13,7 @@ authors:
13
13
  autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
- date: 2014-04-09 00:00:00.000000000 Z
16
+ date: 2014-04-23 00:00:00.000000000 Z
17
17
  dependencies:
18
18
  - !ruby/object:Gem::Dependency
19
19
  name: haml
@@ -362,12 +362,21 @@ files:
362
362
  - man/awestruct.1
363
363
  - man/awestruct.adoc
364
364
  - spec/awestruct/astruct_spec.rb
365
+ - spec/awestruct/cli/init_spec.rb
365
366
  - spec/awestruct/cli/invoker_spec.rb
366
367
  - spec/awestruct/cli/options_spec.rb
368
+ - spec/awestruct/config_spec.rb
369
+ - spec/awestruct/context_helper_spec.rb
367
370
  - spec/awestruct/deploy/base_deploy_spec.rb
368
371
  - spec/awestruct/deploy/deploy_spec.rb
369
372
  - spec/awestruct/deploy/github_pages_deploy_spec.rb
370
373
  - spec/awestruct/deploy/rsync_deploy_spec.rb
374
+ - spec/awestruct/engine_spec.rb
375
+ - spec/awestruct/extensions/disqus_spec.rb
376
+ - spec/awestruct/extensions/minify_spec.rb
377
+ - spec/awestruct/extensions/posts_spec.rb
378
+ - spec/awestruct/handler_chain_spec.rb
379
+ - spec/awestruct/handler_chains_spec.rb
371
380
  - spec/awestruct/handlers/asciidoc_handler_spec.rb
372
381
  - spec/awestruct/handlers/coffeescript_handler_spec.rb
373
382
  - spec/awestruct/handlers/erb_handler_spec.rb
@@ -390,21 +399,11 @@ files:
390
399
  - spec/awestruct/handlers/textile_handler_spec.rb
391
400
  - spec/awestruct/handlers/tilt_handler_spec.rb
392
401
  - spec/awestruct/handlers/yaml_handler_spec.rb
402
+ - spec/awestruct/layouts_spec.rb
403
+ - spec/awestruct/page_loader_spec.rb
404
+ - spec/awestruct/pipeline_spec.rb
405
+ - spec/awestruct/rack/app_spec.rb
393
406
  - spec/awestruct/scm/git_spec.rb
394
- - spec/config_spec.rb
395
- - spec/context_helper_spec.rb
396
- - spec/disqus_spec.rb
397
- - spec/engine_spec.rb
398
- - spec/handler_chain_spec.rb
399
- - spec/handler_chains_spec.rb
400
- - spec/layouts_spec.rb
401
- - spec/minify_spec.rb
402
- - spec/page_loader_spec.rb
403
- - spec/page_loader_spec_for_layouts.rb
404
- - spec/page_spec.rb
405
- - spec/pipeline_spec.rb
406
- - spec/posts_archive_spec.rb
407
- - spec/server_spec.rb
408
407
  - spec/spec_helper.rb
409
408
  - spec/support/awestruct_setup.rb
410
409
  - spec/support/emmet_matchers.rb
@@ -527,12 +526,21 @@ specification_version: 4
527
526
  summary: Static site baking and publishing tool
528
527
  test_files:
529
528
  - spec/awestruct/astruct_spec.rb
529
+ - spec/awestruct/cli/init_spec.rb
530
530
  - spec/awestruct/cli/invoker_spec.rb
531
531
  - spec/awestruct/cli/options_spec.rb
532
+ - spec/awestruct/config_spec.rb
533
+ - spec/awestruct/context_helper_spec.rb
532
534
  - spec/awestruct/deploy/base_deploy_spec.rb
533
535
  - spec/awestruct/deploy/deploy_spec.rb
534
536
  - spec/awestruct/deploy/github_pages_deploy_spec.rb
535
537
  - spec/awestruct/deploy/rsync_deploy_spec.rb
538
+ - spec/awestruct/engine_spec.rb
539
+ - spec/awestruct/extensions/disqus_spec.rb
540
+ - spec/awestruct/extensions/minify_spec.rb
541
+ - spec/awestruct/extensions/posts_spec.rb
542
+ - spec/awestruct/handler_chain_spec.rb
543
+ - spec/awestruct/handler_chains_spec.rb
536
544
  - spec/awestruct/handlers/asciidoc_handler_spec.rb
537
545
  - spec/awestruct/handlers/coffeescript_handler_spec.rb
538
546
  - spec/awestruct/handlers/erb_handler_spec.rb
@@ -555,17 +563,8 @@ test_files:
555
563
  - spec/awestruct/handlers/textile_handler_spec.rb
556
564
  - spec/awestruct/handlers/tilt_handler_spec.rb
557
565
  - spec/awestruct/handlers/yaml_handler_spec.rb
566
+ - spec/awestruct/layouts_spec.rb
567
+ - spec/awestruct/page_loader_spec.rb
568
+ - spec/awestruct/pipeline_spec.rb
569
+ - spec/awestruct/rack/app_spec.rb
558
570
  - spec/awestruct/scm/git_spec.rb
559
- - spec/config_spec.rb
560
- - spec/context_helper_spec.rb
561
- - spec/disqus_spec.rb
562
- - spec/engine_spec.rb
563
- - spec/handler_chain_spec.rb
564
- - spec/handler_chains_spec.rb
565
- - spec/layouts_spec.rb
566
- - spec/minify_spec.rb
567
- - spec/page_loader_spec.rb
568
- - spec/page_spec.rb
569
- - spec/pipeline_spec.rb
570
- - spec/posts_archive_spec.rb
571
- - spec/server_spec.rb
@@ -1,38 +0,0 @@
1
- require 'awestruct/engine'
2
- require 'awestruct/site'
3
- require 'awestruct/page_loader'
4
- require 'awestruct/config'
5
-
6
- describe Awestruct::PageLoader do
7
-
8
- before :each do
9
- @opts = Awestruct::CLI::Options.new
10
- @opts.source_dir = test_data_dir 'page-loader'
11
- @config = Awestruct::Config.new( @opts )
12
- @engine = Awestruct::Engine.new
13
- @engine.pipeline.handler_chains << :defaults
14
- @site = Awestruct::Site.new( @engine, @config )
15
- @loader = Awestruct::PageLoader.new( @site, :layouts )
16
- end
17
-
18
- it "should be able to load a site layout" do
19
- page = @loader.load_page( File.join( @config.dir, "_layouts", "layout-one.md" ) )
20
- page.should_not be_nil
21
- page.handler.to_chain.collect{|e| e.class}.should be_include Awestruct::Handlers::TiltHandler
22
- page.relative_source_path.to_s.should == "/_layouts/layout-one.md"
23
- end
24
-
25
- it "should be able to load all site layouts" do
26
- @loader.load_all
27
- @site.layouts.size.should == 2
28
-
29
- @site.layouts.sort!{|l,r| l.relative_source_path <=> r.relative_source_path }
30
-
31
- @site.layouts[0].relative_source_path.should == '/_layouts/layout-one.md'
32
- @site.layouts[0].output_path.should == '/_layouts/layout-one.html'
33
-
34
- @site.layouts[1].relative_source_path.should == '/_layouts/layout-two.html.haml'
35
- @site.layouts[1].output_path.should == '/_layouts/layout-two.html'
36
- end
37
-
38
- end
data/spec/page_spec.rb DELETED
@@ -1,66 +0,0 @@
1
- require 'spec_helper'
2
- require 'fileutils'
3
-
4
- require 'awestruct/page'
5
- require 'awestruct/pipeline'
6
- require 'awestruct/handlers/file_handler'
7
- require 'hashery'
8
-
9
- describe Awestruct::Handlers::FileHandler do
10
-
11
- class TestTransformer
12
- def transform(site, page, rendered)
13
- rendered.gsub( /howdy/, 'adios' )
14
- end
15
- end
16
-
17
- before :all do
18
- @site = Hashery::OpenCascade[ { :encoding=>false } ]
19
- @site.engine = Hashery::OpenCascade[]
20
- end
21
-
22
- before :each do
23
- @filename = Pathname.new( test_data_dir 'simple-file.txt' )
24
- @handler = Awestruct::Handlers::FileHandler.new( @site, @filename )
25
- @page = Awestruct::Page.new( @site, @handler )
26
- @site.engine.pipeline = Awestruct::Pipeline.new
27
- end
28
-
29
- it "should be stale before being read" do
30
- @page.should be_stale
31
- end
32
-
33
- it "should not be stale after being read" do
34
- @page.raw_content.strip.should == 'howdy'
35
- @page.should_not be_stale
36
- end
37
-
38
- it "should be stale if touched after being read" do
39
- @page.raw_content.strip.should == 'howdy'
40
- @page.should_not be_stale
41
- sleep(1)
42
- FileUtils.touch( @filename )
43
- @page.should be_stale
44
- end
45
-
46
- it "should be able to create an appropriate context" do
47
- context = @page.create_context
48
- context.site.should == @site
49
- context.page.should == @page
50
- context.content.should == ''
51
- end
52
-
53
- it "should allow relative_source_path to be assignable" do
54
- @page.relative_source_path.should be_nil
55
- @page.relative_source_path = '/taco'
56
- @page.relative_source_path.should == '/taco'
57
- end
58
-
59
- it "should not apply transformers, even if present" do
60
- @site.engine.pipeline.transformer TestTransformer.new
61
- @page.rendered_content.strip.should == 'howdy'
62
- end
63
-
64
-
65
- end
66
-