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/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/basic_object.rb,
lib/hanami/utils/class_attribute.rb
Overview
Ruby core extentions and Hanami utilities
Defined Under Namespace
Modules: Callbacks, ClassAttribute, Duplicable, Escape, FileList, Inflector, Json, Kernel 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.
'java'.freeze
- 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.
'rbx'.freeze
- VERSION =
Defines the version
'1.0.0'.freeze
Class Method Summary collapse
-
.for_each_file_in(directory, &blk) ⇒ Object
private
Recursively scans through the given directory and yields the given block for each Ruby source file.
-
.jruby? ⇒ TrueClass, FalseClass
private
Checks if the current VM is JRuby.
-
.reload!(directory) ⇒ Object
private
Recursively reload Ruby files under the given directory.
-
.require!(directory) ⇒ Object
Recursively require Ruby files under the given directory.
-
.rubinius? ⇒ TrueClass, FalseClass
private
Checks if the current VM is Rubinius.
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.
85 86 87 88 89 90 91 |
# File 'lib/hanami/utils.rb', line 85 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
26 27 28 |
# File 'lib/hanami/utils.rb', line 26 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 reload 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.
67 68 69 |
# File 'lib/hanami/utils.rb', line 67 def self.reload!(directory) for_each_file_in(directory) { |file| load(file) } end |
.require!(directory) ⇒ Object
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 "path/to/files"
will work both on *NIX and Windows machines.
51 52 53 |
# File 'lib/hanami/utils.rb', line 51 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
36 37 38 |
# File 'lib/hanami/utils.rb', line 36 def self.rubinius? RUBY_ENGINE == HANAMI_RUBINIUS end |