Module: Wright::Util Private
- Defined in:
- lib/wright/util.rb,
lib/wright/util/file.rb,
lib/wright/util/user.rb,
lib/wright/util/color.rb,
lib/wright/util/file_owner.rb,
lib/wright/util/erb_renderer.rb,
lib/wright/util/file_renderer.rb,
lib/wright/util/pencil_mustache.rb,
lib/wright/util/file_permissions.rb,
lib/wright/util/mustache_renderer.rb,
lib/wright/util/recursive_autoloader.rb,
lib/wright/util/stolen_from_activesupport.rb
Overview
This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.
Various utility functions.
Defined Under Namespace
Modules: ActiveSupport, Color, File, RecursiveAutoloader, User Classes: ErbRenderer, FileOwner, FilePermissions, FileRenderer, MustacheRenderer, PencilMustache
Class Method Summary collapse
-
.bundler_clean_env ⇒ Object
private
Runs a code block in a clean bundler environment.
-
.class_to_resource_name(klass) ⇒ String
private
Converts a class constant into its corresponding resource name.
-
.fetch_last(hash, candidate_keys, default = nil) ⇒ Object
private
Fetches the value of the candidate key that occurs last in a hash.
-
.filename_to_classname(filename) ⇒ String
private
Converts a file path into its corresponding class name.
-
.os_family ⇒ String
private
Determines the system’s OS family.
Class Method Details
.bundler_clean_env ⇒ 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.
Runs a code block in a clean bundler environment.
81 82 83 84 85 86 87 |
# File 'lib/wright/util.rb', line 81 def self.bundler_clean_env if defined?(Bundler) Bundler.with_clean_env { yield } else yield end end |
.class_to_resource_name(klass) ⇒ String
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.
Converts a class constant into its corresponding resource name.
19 20 21 |
# File 'lib/wright/util.rb', line 19 def self.class_to_resource_name(klass) ActiveSupport.underscore(klass.name).split('/').last end |
.fetch_last(hash, candidate_keys, default = nil) ⇒ 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.
Fetches the value of the candidate key that occurs last in a hash.
96 97 98 99 |
# File 'lib/wright/util.rb', line 96 def self.fetch_last(hash, candidate_keys, default = nil) candidates = hash.select { |k, _v| candidate_keys.include?(k) } candidates.empty? ? default : candidates.values.last end |
.filename_to_classname(filename) ⇒ String
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.
Converts a file path into its corresponding class name.
35 36 37 |
# File 'lib/wright/util.rb', line 35 def self.filename_to_classname(filename) ActiveSupport.camelize(filename.chomp('.rb').chomp('/')) end |
.os_family ⇒ String
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.
Determines the system’s OS family.
63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/wright/util.rb', line 63 def self.os_family system_arch = RbConfig::CONFIG['target_os'] case system_arch when /darwin/ 'osx' when /linux/ distro else 'other' end end |