Sha256: 89c01a3bed92bf726bbe1f2d2e5e759794856014fbad7e53165e3ed693bbf9f1

Contents?: true

Size: 1.57 KB

Versions: 3

Compression:

Stored size: 1.57 KB

Contents

# Hanami - The web, with simplicity
#
# @since 0.1.0
module Hanami
  require 'hanami/utils/version'
  require 'hanami/utils/file_list'

  # Ruby core extentions and Hanami utilities
  #
  # @since 0.1.0
  module Utils
    # @since 0.3.1
    # @api private
    HANAMI_JRUBY = 'java'.freeze

    # @since 0.3.1
    # @api private
    HANAMI_RUBINIUS = 'rbx'.freeze

    # Checks if the current VM is JRuby
    #
    # @return [TrueClass,FalseClass] return if the VM is JRuby or not
    #
    # @since 0.3.1
    # @api private
    def self.jruby?
      RUBY_PLATFORM == HANAMI_JRUBY
    end

    # Checks if the current VM is Rubinius
    #
    # @return [TrueClass,FalseClass] return if the VM is Rubinius or not
    #
    # @since 0.3.1
    # @api private
    def self.rubinius?
      RUBY_ENGINE == HANAMI_RUBINIUS
    end

    # Recursively require Ruby files under the given directory.
    #
    # If the directory is relative, it implies it's the path from current directory.
    # If the directory is absolute, it uses as it is.
    #
    # It respects file separator of the current operating system.
    # A pattern like <tt>"path/to/files"</tt> will work both on *NIX and Windows machines.
    #
    # @param directory [String, Pathname] the directory
    #
    # @since 0.9.0
    def self.require!(directory)
      directory = directory.to_s.gsub(%r{(\/|\\)}, File::SEPARATOR)
      directory = Pathname.new(Dir.pwd).join(directory).to_s
      directory = File.join(directory, '**', '*.rb') unless directory =~ /(\*\*)/

      FileList[directory].each { |file| require_relative file }
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
hanami-utils-0.9.2 lib/hanami/utils.rb
hanami-utils-0.9.1 lib/hanami/utils.rb
hanami-utils-0.9.0 lib/hanami/utils.rb