awestruct 0.2.10 → 0.2.11

Sign up to get free protection for your applications and to get access to all the features.
data/bin/awestruct CHANGED
@@ -34,7 +34,7 @@ def parse(args)
34
34
  options.init = init
35
35
  options.generate = false
36
36
  end
37
- opts.on( '-f', '--framework FRAMEWORK', 'Specify a framework during initialization' ) do |framework|
37
+ opts.on( '-f', '--framework FRAMEWORK', 'Specify a compass framework during initialization (blueprint, 960)' ) do |framework|
38
38
  options.framework = framework
39
39
  end
40
40
  opts.on( '--[no-]scaffold', 'Create scaffolding during initialization (default: true)' ) do |s|
@@ -91,6 +91,7 @@ def parse(args)
91
91
  opts.on_tail("-v", "--version", "Display the version") do
92
92
  puts "Awestruct: #{Awestruct::VERSION}"
93
93
  puts "http://awestruct.org/"
94
+ exit
94
95
  end
95
96
 
96
97
 
@@ -212,37 +213,45 @@ if ( options.auto )
212
213
  monitor = FSSM::Monitor.new
213
214
 
214
215
  call_generate = lambda do |base, relative|
215
- if !(relative =~ /.*~/)
216
- puts "Triggered regeneration #{base} #{relative}"
217
- generate_cmd.run
218
- puts "Done"
219
- if relative == '.'
220
- # It's necessary to restart the monitor on individual files
221
- # after a change is handled
222
- monitor.file(base) do
223
- update &call_generate
224
- create &call_generate
225
- end
226
- end
216
+ # Convert to absolute path and append file separator if necessary.
217
+ base = File::expand_path(base)
218
+ if base[base.length - 1] != File::SEPARATOR
219
+ base += File::SEPARATOR
227
220
  end
228
- end
229
221
 
230
- Dir.entries(config.input_dir).each do |sub|
231
- if !(sub =~ /^(_site|_tmp|\.git|\.gitignore|\.sass-cache|\.|\.\.).*/)
232
- if File::directory? File.join(config.input_dir, sub)
233
- monitor.path(sub) do
234
- update &call_generate
235
- create &call_generate
236
- end
237
- elsif
238
- monitor.file(sub) do
239
- update &call_generate
240
- create &call_generate
241
- end
222
+ # Filter out bad input just in case.
223
+ if base.length < config.input_dir.length or config.input_dir != base[0..config.input_dir.length]
224
+ return
225
+ end
226
+
227
+ path = base + relative
228
+ path = path[config.input_dir.length..path.length]
229
+
230
+ if path =~ /^(_site|_tmp|\.git|\.gitignore|\.sass-cache|\.|\.\.).*/
231
+ return
232
+ end
233
+ if path =~ /.*(~|\.(swp|bak|tmp))$/
234
+ return
235
+ end
236
+
237
+ puts "Triggered regeneration: #{path}"
238
+ generate_cmd.run
239
+ puts "Done"
240
+ if relative == '.'
241
+ # It's necessary to restart the monitor on individual files
242
+ # after a change is handled
243
+ monitor.file(base) do
244
+ update &call_generate
245
+ create &call_generate
242
246
  end
243
247
  end
244
248
  end
245
249
 
250
+ monitor.path(config.input_dir) do
251
+ update &call_generate
252
+ create &call_generate
253
+ end
254
+
246
255
  monitor.run
247
256
  }
248
257
  end
@@ -20,7 +20,8 @@ module Awestruct
20
20
  @extension_dir = File.join(dir, '_ext')
21
21
  @skin_dir = File.join(dir, '_skin')
22
22
  @tmp_dir = File.join(dir, '_tmp')
23
- @ignore = [ ]
23
+ @ignore = File.exists?(ignore_file = File.join(dir, ".awestruct_ignore")) ? IO.read(ignore_file).each_line.map(&:strip) : []
24
+ @ignore = Dir[*@ignore]
24
25
  end
25
26
 
26
27
  end
@@ -166,7 +166,7 @@ module Awestruct
166
166
  private
167
167
 
168
168
  def adjust_load_path
169
- ext_dir = File.join( config.extension_dir )
169
+ ext_dir = File.join( config.extension_dir )
170
170
  if ( $LOAD_PATH.index( ext_dir ).nil? )
171
171
  $LOAD_PATH << ext_dir
172
172
  end
@@ -325,7 +325,7 @@ module Awestruct
325
325
 
326
326
  def load_yamls
327
327
  Dir[ File.join( config.config_dir, '*.yml' ) ].each do |yaml_path|
328
- load_yaml( yaml_path ) unless ( File.basename( yaml_path ) == 'site.yml' )
328
+ load_yaml( yaml_path ) unless ( File.basename( yaml_path ) == 'site.yml' )
329
329
  end
330
330
  end
331
331
 
@@ -350,25 +350,27 @@ module Awestruct
350
350
  end
351
351
 
352
352
  def load_pages()
353
- site.pages.clear
353
+ visited_pages = {}
354
354
  dir_pathname = Pathname.new( dir )
355
355
  Find.find( dir ) do |path|
356
356
  next if path == dir
357
357
  basename = File.basename( path )
358
358
  if ( basename == '.htaccess' )
359
359
  #special case
360
- elsif ( config.ignore.include?( basename ) || ( basename =~ /^[_.]/ ) )
360
+ elsif ( basename =~ /^[_.]/ )
361
361
  Find.prune
362
362
  next
363
363
  end
364
- unless ( site.has_page?( path ) )
365
- file_pathname = Pathname.new( path )
366
- relative_path = file_pathname.relative_path_from( dir_pathname ).to_s
367
- page = load_page( path, :relative_path => relative_path )
368
- if ( page )
369
- inherit_front_matter( page )
370
- site.pages << page
371
- end
364
+ file_pathname = Pathname.new( path )
365
+ relative_path = file_pathname.relative_path_from( dir_pathname ).to_s
366
+ if config.ignore.include?(relative_path)
367
+ Find.prune
368
+ next
369
+ end
370
+ page = load_page( path, :relative_path => relative_path )
371
+ if ( page )
372
+ inherit_front_matter( page )
373
+ visited_pages[ path ] = page
372
374
  end
373
375
  end
374
376
 
@@ -379,21 +381,25 @@ module Awestruct
379
381
  basename = File.basename( path )
380
382
  if ( basename == '.htaccess' )
381
383
  #special case
382
- elsif ( config.ignore.include?( basename ) || ( basename =~ /^[_.]/ ) )
384
+ elsif ( basename =~ /^[_.]/ )
383
385
  Find.prune
384
386
  next
385
387
  end
386
- unless ( site.has_page?( path ) )
387
- file_pathname = Pathname.new( path )
388
- relative_path = file_pathname.relative_path_from( skin_dir_pathname ).to_s
389
- page = load_page( path, :relative_path => relative_path )
390
- if ( page )
391
- inherit_front_matter( page )
392
- site.pages << page
393
- end
388
+ file_pathname = Pathname.new( path )
389
+ relative_path = file_pathname.relative_path_from( skin_dir_pathname ).to_s
390
+ if config.ignore.include?(relative_path)
391
+ Find.prune
392
+ next
393
+ end
394
+ page = load_page( path, :relative_path => relative_path )
395
+ if ( page )
396
+ inherit_front_matter( page )
397
+ visited_pages[ path ] = page
394
398
  end
395
399
  end
396
400
  end
401
+
402
+ site.pages = visited_pages.values
397
403
  end
398
404
 
399
405
  def massage_yaml(obj)
@@ -419,43 +425,43 @@ module Awestruct
419
425
  pipeline = nil
420
426
  skin_pipeline = nil
421
427
 
422
- ext_dir = File.join( config.extension_dir )
428
+ ext_dir = File.join( config.extension_dir )
423
429
  pipeline_file = File.join( ext_dir, 'pipeline.rb' )
424
430
  if ( File.exists?( pipeline_file ) )
425
- pipeline = eval File.read( pipeline_file )
431
+ pipeline = eval(File.read( pipeline_file ), nil, pipeline_file, 1)
426
432
  @helpers = pipeline.helpers || []
427
433
  @transformers = pipeline.transformers || []
428
434
  watched_dirs << ext_dir.to_s
429
435
  end
430
436
 
431
437
  if ( skin_dir )
432
- skin_ext_dir = File.join( skin_dir, config.extension_dir )
438
+ skin_ext_dir = File.join( skin_dir, config.extension_dir.sub(/^#{Dir.pwd}/, "") )
433
439
  if ( $LOAD_PATH.index( skin_ext_dir ).nil? )
434
440
  $LOAD_PATH << skin_ext_dir
435
441
  end
436
442
  skin_pipeline_file = File.join( skin_ext_dir, 'pipeline.rb' )
437
443
  if ( File.exists?( skin_pipeline_file ) )
438
- skin_pipeline = eval File.read( skin_pipeline_file )
444
+ skin_pipeline = eval(File.read( skin_pipeline_file ), nil, skin_pipeline_file, 1)
439
445
  @helpers = ( @helpers + skin_pipeline.helpers || [] ).flatten
440
446
  @transformers = ( @transformers + skin_pipeline.transformers || [] ).flatten
441
447
  watched_dirs << skin_dir.to_s
442
448
  end
443
449
  end
444
-
450
+
445
451
  #if _partials directory (from Partial helper) is present, watch
446
452
  partials = File.join( '_partials' )
447
453
  if ( File.exists?( partials ) )
448
454
  watched_dirs << partials
449
455
  end
450
-
456
+
451
457
  pipeline.watch(watched_dirs) if pipeline
452
458
  skin_pipeline.watch(watched_dirs) if skin_pipeline
453
459
  check_dir_for_change(watched_dirs)
454
-
460
+
455
461
  pipeline.execute( site ) if pipeline
456
462
  skin_pipeline.execute( site ) if skin_pipeline
457
463
  end
458
-
464
+
459
465
  def check_dir_for_change(watched_dirs)
460
466
  watched_dirs.each do |dir|
461
467
  Dir.chdir(dir){check_dir_for_change_recursively()}
@@ -52,7 +52,7 @@ module Awestruct
52
52
  @window_size = opts[:window_size] || 2
53
53
  @remove_input = opts.has_key?( :remove_input ) ? opts[:remove_input] : true
54
54
  @output_prefix = opts[:output_prefix] || File.dirname( @input_path )
55
- @collection = opts[:collection]
55
+ @collection = opts[:collection]
56
56
  end
57
57
 
58
58
  def execute(site)
@@ -74,7 +74,7 @@ module Awestruct
74
74
  site.pages << page
75
75
  paginated_pages << page
76
76
  i = i + 1
77
- end
77
+ end
78
78
 
79
79
  if ( @remove_input )
80
80
  site.pages.reject!{|page|
@@ -84,10 +84,10 @@ module Awestruct
84
84
 
85
85
  prev_page = nil
86
86
  paginated_pages.each_with_index do |page,i|
87
- page.posts.current_page = page
88
- page.posts.current_page_index = i
89
- page.posts.pages = paginated_pages
90
- page.posts.window = 1
87
+ page.send( @prop_name ).current_page = page
88
+ page.send( @prop_name ).current_page_index = i
89
+ page.send( @prop_name ).pages = paginated_pages
90
+ page.send( @prop_name ).window = 1
91
91
 
92
92
  if ( prev_page != nil )
93
93
  prev_page.send( @prop_name ).next_page = page
@@ -25,7 +25,7 @@ module Awestruct
25
25
  end
26
26
 
27
27
  def has_page?(path)
28
- ! pages.find{|e| e.path == path}.nil?
28
+ ! pages.find{|e| e.source_path == path}.nil?
29
29
  end
30
30
 
31
31
  def output_path(path, ext=nil)
@@ -1,4 +1,4 @@
1
1
 
2
2
  module Awestruct
3
- VERSION='0.2.10'
3
+ VERSION='0.2.11'
4
4
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 2
8
- - 10
9
- version: 0.2.10
8
+ - 11
9
+ version: 0.2.11
10
10
  platform: ruby
11
11
  authors:
12
12
  - Bob McWhirter
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2011-11-17 00:00:00 -05:00
17
+ date: 2012-01-06 00:00:00 -05:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency