Module: Hanami::Utils

Defined in:
lib/hanami/utils.rb,
lib/hanami/utils/io.rb,
lib/hanami/utils/hash.rb,
lib/hanami/utils/json.rb,
lib/hanami/utils/blank.rb,
lib/hanami/utils/class.rb,
lib/hanami/utils/files.rb,
lib/hanami/utils/escape.rb,
lib/hanami/utils/kernel.rb,
lib/hanami/utils/string.rb,
lib/hanami/utils/version.rb,
lib/hanami/utils/callbacks.rb,
lib/hanami/utils/file_list.rb,
lib/hanami/utils/inflector.rb,
lib/hanami/utils/duplicable.rb,
lib/hanami/utils/load_paths.rb,
lib/hanami/utils/deprecation.rb,
lib/hanami/utils/path_prefix.rb,
lib/hanami/utils/shell_color.rb,
lib/hanami/utils/basic_object.rb,
lib/hanami/utils/query_string.rb,
lib/hanami/utils/class_attribute.rb

Overview

Ruby core extentions and Hanami utilities

Since:

  • 0.1.0

Defined Under Namespace

Modules: Callbacks, ClassAttribute, Duplicable, Escape, FileList, Files, Inflector, Json, Kernel, QueryString, ShellColor Classes: BasicObject, Blank, Class, Deprecation, Hash, IO, LoadPaths, PathPrefix, String

Constant Summary collapse

HANAMI_JRUBY =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

Since:

  • 0.3.1

"java"
HANAMI_RUBINIUS =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

Since:

  • 0.3.1

"rbx"
VERSION =

Defines the version

Since:

  • 0.1.0

"1.3.8"

Class Method Summary collapse

Class Method Details

.for_each_file_in(directory, &blk) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

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.

Parameters:

  • directory (String, Pathname)

    the directory

  • blk (Proc)

    the block to yield

Since:

  • 1.0.0


89
90
91
92
93
94
95
# File 'lib/hanami/utils.rb', line 89

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?TrueClass, FalseClass

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Checks if the current VM is JRuby

Returns:

  • (TrueClass, FalseClass)

    info whether the VM is JRuby or not

Since:

  • 0.3.1


30
31
32
# File 'lib/hanami/utils.rb', line 30

def self.jruby?
  RUBY_PLATFORM == HANAMI_JRUBY
end

.reload!(directory) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Recursively reloads 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.

Parameters:

  • directory (String, Pathname)

    the directory

Since:

  • 1.0.0


71
72
73
# File 'lib/hanami/utils.rb', line 71

def self.reload!(directory)
  for_each_file_in(directory) { |file| load(file) }
end

.require!(directory) ⇒ Object

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.

Parameters:

  • directory (String, Pathname)

    the directory

Since:

  • 0.9.0


55
56
57
# File 'lib/hanami/utils.rb', line 55

def self.require!(directory)
  for_each_file_in(directory) { |file| require_relative(file) }
end

.rubinius?TrueClass, FalseClass

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Checks if the current VM is Rubinius

Returns:

  • (TrueClass, FalseClass)

    info whether the VM is Rubinius or not

Since:

  • 0.3.1


40
41
42
# File 'lib/hanami/utils.rb', line 40

def self.rubinius?
  RUBY_ENGINE == HANAMI_RUBINIUS
end