Sha256: 95d9d45b159804b08f0d561dd45718c9d141de24960cc40e2f922f65436bbc4f

Contents?: true

Size: 1.27 KB

Versions: 37

Compression:

Stored size: 1.27 KB

Contents

module PowerStencil
  module Engine

    module EntitiesDefinition

      SYSTEM_ENTITY_DEFINITION_ENTRY_POINT = 'power_stencil/system_entity_definitions/all'.freeze

      include PowerStencil::Utils::SecureRequire

      def require_definition_files(files_or_dirs)
        required_files = []
        files_or_dirs.each do |file_or_dir|
          if File.directory? file_or_dir and File.readable? file_or_dir
            Dir.entries(file_or_dir).grep(/\.rb$/).each do |file|
              required_files << File.join(file_or_dir, file)
            end
            next
          end
          if File.file? file_or_dir and File.readable? file_or_dir
            required_files << file_or_dir
            next
          end
          # This is a ruby library or there is something wrong
          securely_require file_or_dir
          # unless securely_require file_or_dir
          #   logger.warn "While trying to load definition files, found that '#{file_or_dir}' has a problem. Ignored..."
          # end
        end
        required_files.sort!.each {|file| securely_require file, fail_on_error: true}
        required_files
      end

      private

      def load_system_entities_definition
        require_definition_files [SYSTEM_ENTITY_DEFINITION_ENTRY_POINT]
      end

    end

  end
end

Version data entries

37 entries across 37 versions & 1 rubygems

Version Path
power_stencil-0.6.1 lib/power_stencil/engine/entities_definitions.rb
power_stencil-0.6.0 lib/power_stencil/engine/entities_definitions.rb
power_stencil-0.5.1 lib/power_stencil/engine/entities_definitions.rb
power_stencil-0.5.0 lib/power_stencil/engine/entities_definitions.rb
power_stencil-0.4.22 lib/power_stencil/engine/entities_definitions.rb
power_stencil-0.4.21 lib/power_stencil/engine/entities_definitions.rb
power_stencil-0.4.20 lib/power_stencil/engine/entities_definitions.rb
power_stencil-0.4.19 lib/power_stencil/engine/entities_definitions.rb
power_stencil-0.4.18 lib/power_stencil/engine/entities_definitions.rb
power_stencil-0.4.17 lib/power_stencil/engine/entities_definitions.rb
power_stencil-0.4.16 lib/power_stencil/engine/entities_definitions.rb
power_stencil-0.4.15 lib/power_stencil/engine/entities_definitions.rb
power_stencil-0.4.14 lib/power_stencil/engine/entities_definitions.rb
power_stencil-0.4.13 lib/power_stencil/engine/entities_definitions.rb
power_stencil-0.4.12 lib/power_stencil/engine/entities_definitions.rb
power_stencil-0.4.11 lib/power_stencil/engine/entities_definitions.rb
power_stencil-0.4.10 lib/power_stencil/engine/entities_definitions.rb
power_stencil-0.4.9 lib/power_stencil/engine/entities_definitions.rb
power_stencil-0.4.8 lib/power_stencil/engine/entities_definitions.rb
power_stencil-0.4.7 lib/power_stencil/engine/entities_definitions.rb