Sha256: 7bdbdddc3e6eb00ec4bf49482e7a9e7c5d7217e9d004c29ff7c3d7c0cd022cae
Contents?: true
Size: 1.13 KB
Versions: 9
Compression:
Stored size: 1.13 KB
Contents
# -*- encoding: utf-8 -*- require 'rbconfig' require 'webgen/core_ext' module Webgen # Namespace for classes and methods that provide common functionality. module Utils # Return the data directory for webgen. def self.data_dir unless defined?(@@data_dir) require 'rbconfig' @@data_dir = File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'data', 'webgen')) @@data_dir = File.expand_path(File.join(RbConfig::CONFIG["datadir"], "webgen")) if !File.exists?(@@data_dir) raise "Could not find webgen data directory! This is a bug, report it please!" unless File.directory?(@@data_dir) end @@data_dir end # Return the object for the given absolute constant +name+. def self.const_for_name(name) name.split('::').inject(Object) {|b,n| b.const_get(n)} end # Transform the string in Module::CamelCase format into module/camel_case format. def self.snake_case(str) str = str.dup str.gsub!(/::/, '/') str.gsub!(/([A-Z]+)([A-Z][a-z])/,'\1_\2') str.gsub!(/([a-z])([A-Z])/,'\1_\2') str.downcase! str end end end
Version data entries
9 entries across 9 versions & 1 rubygems