Method: Voog::Dtk::FileManager#check

Defined in:
lib/voog/dtk/filemanager.rb

#checkObject



527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
# File 'lib/voog/dtk/filemanager.rb', line 527

def check
  ok_char = '.'
  not_ok_char = '!'
  @notifier.info 'Checking manifest.json...'

  if File.exist? 'manifest.json'
    @manifest = read_manifest
    @notifier.success 'OK!'
  else
    @notifier.error 'Manifest file not found! Use the \'manifest\' command to generate one.'
    return false
  end

  # Check for files in manifest
  layouts = @manifest.fetch('layouts', [])
  missing_layouts = %w()

  @notifier.newline
  @notifier.info 'Checking layouts and components'
  layouts.reject(&:nil?).each do |layout|
    if File.exist? layout['file']
      @notifier.success ok_char
    else
      missing_layouts << layout['file']
      @notifier.error not_ok_char
    end
  end

  if missing_layouts.count > 0
    @notifier.error " (#{missing_layouts.count} missing)"
    @notifier.newline
    missing_layouts.each do |a|
      @notifier.normal "    #{a}"
      @notifier.newline
    end if @verbose
  else
    @notifier.success 'OK!'
  end

  assets = @manifest['assets']
  missing_assets = %w()

  @notifier.newline
  @notifier.info 'Checking assets'
  assets.reject(&:nil?).each do |asset|
    if File.exist? asset['file']
      @notifier.success ok_char
    else
      missing_assets << asset['file']
      @notifier.error not_ok_char
    end
  end

  if missing_assets.count > 0
    @notifier.error " (#{missing_assets.count} missing)"
    @notifier.newline
    missing_assets.each do |a|
      @notifier.normal "    #{a}"
      @notifier.newline
    end if @verbose
  else
    @notifier.success 'OK!'
  end

  (missing_assets.count + missing_layouts.count == 0)
end