Module: Wright::Util
- 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_permissions.rb,
lib/wright/util/recursive_autoloader.rb,
lib/wright/util/stolen_from_activesupport.rb
Overview
:nodoc:
Defined Under Namespace
Modules: ActiveSupport, Color, File, RecursiveAutoloader, User Classes: FilePermissions
Class Method Summary collapse
-
.class_to_resource_name(klass) ⇒ Object
Internal: Get the resource name corresponding to a class.
-
.filename_to_classname(filename) ⇒ Object
Internal: Get the class name corresponding to a file path.
-
.os_family ⇒ Object
Internal: Get the system’s OS family.
Class Method Details
.class_to_resource_name(klass) ⇒ Object
Internal: Get the resource name corresponding to a class.
klass - The class constant for which to get the resource name.
Examples
Wright::Util.class_to_resource_name(Wright::Resource::Package)
# => "package"
Wright::Util.class_to_resource_name(Foo::Bar::BazQux)
# => "baz_qux"
Returns the String resource name of the given class.
19 20 21 |
# File 'lib/wright/util.rb', line 19 def self.class_to_resource_name(klass) ActiveSupport.underscore(klass.name).split('/').last end |
.filename_to_classname(filename) ⇒ Object
Internal: Get the class name corresponding to a file path.
filename - The filename for which to get the class name.
Examples
Wright::Util.filename_to_classname("foo/bar/baz.rb")
# => "Foo::Bar::Baz"
Wright::Util.filename_to_classname("foo/bar/")
# => "Foo::Bar"
Returns the String class name for the given filename.
36 37 38 |
# File 'lib/wright/util.rb', line 36 def self.filename_to_classname(filename) ActiveSupport.camelize(filename.chomp('.rb').chomp('/')) end |
.os_family ⇒ Object
60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/wright/util.rb', line 60 def self.os_family system_arch = RbConfig::CONFIG['target_os'] case system_arch when /darwin/ 'macosx' when /linux/ distro else 'other' end end |