Sha256: 7f0d1d7bfefbfbce234bd78134c39d236ae4e60553c581e7a8eba860b632a4a1

Contents?: true

Size: 778 Bytes

Versions: 5

Compression:

Stored size: 778 Bytes

Contents

require Owl::CORE + '/classes/error'

module Owl

  DEFAULT_THEME_DIR       = 'themes' 
  DEFAULT_DATA_DIR        = 'data'
  REQUIRED_DATA_SUB_DIRS  = ['post', 'page', 'home']

  module Lib
    class Checker

      def self.check!
        unless self.base_dirs? and self.sub_dirs?
          raise Owl::Error.new('Directory structure is not correct! Have you run the `owl new` command?') 
        end
      end

      def self.base_dirs?
        Cabi.file(DEFAULT_DATA_DIR) and
        Cabi.file(DEFAULT_THEME_DIR)
      end

      def self.sub_dirs?
        ok = nil
        REQUIRED_DATA_SUB_DIRS.each do |dir|
          ok = Cabi.file( [DEFAULT_DATA_DIR, dir].join(':') )
          break if not ok
        end
        ok
      end

    end
  end
end

Owl::Lib::Checker.check!

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
owl-cms-0.1.5 core/classes/checker.rb
owl-cms-0.1.3 core/classes/checker.rb
owl-cms-0.1.2 core/classes/checker.rb
owl-cms-0.1.1 core/classes/checker.rb
owl-cms-0.1.0 core/classes/checker.rb