module Hanami::Utils

Ruby core extentions and Hanami utilities

@since 0.1.0

Constants

HANAMI_JRUBY

@since 0.3.1 @api private

HANAMI_RUBINIUS

@since 0.3.1 @api private

VERSION

The current hanami-utils version.

@since 0.1.0 @api public

Public Class Methods

for_each_file_in(directory, &blk) click to toggle source

Recursively scans through the given directory and yields the given block for each Ruby source file.

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 "path/to/files" will work both on *NIX and Windows machines.

@param directory [String, Pathname] the directory @param blk [Proc] the block to yield

@since 1.0.0 @api private

# File lib/hanami/utils.rb, line 73
def self.for_each_file_in(directory, &blk)
  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(&blk)
end
jruby?() click to toggle source

Checks if the current VM is JRuby

@return [TrueClass,FalseClass] info whether the VM is JRuby or not

@since 0.3.1 @api private

# File lib/hanami/utils.rb, line 30
def self.jruby?
  RUBY_PLATFORM == HANAMI_JRUBY
end
require!(directory) click to toggle source

Recursively requires 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 "path/to/files" will work both on *NIX and Windows machines.

@param directory [String, Pathname] the directory

@since 0.9.0

# File lib/hanami/utils.rb, line 55
def self.require!(directory)
  for_each_file_in(directory) { |file| require_relative(file) }
end
rubinius?() click to toggle source

Checks if the current VM is Rubinius

@return [TrueClass,FalseClass] info whether the VM is Rubinius or not

@since 0.3.1 @api private

# File lib/hanami/utils.rb, line 40
def self.rubinius?
  RUBY_ENGINE == HANAMI_RUBINIUS
end