Sha256: 65e56266322f042f1d10ca0caa7c5e7b25d970d0f3972f0739215eaf6ded9ae1
Contents?: true
Size: 725 Bytes
Versions: 14
Compression:
Stored size: 725 Bytes
Contents
# Created on 2008-02-12 # Copyright Luke Kanies # NOTE: I think it might be worth considering moving these methods directly into Puppet::Util. # A common module for converting between constants and # file names. module Puppet module Util module ConstantInflector def file2constant(file) # LAK:NOTE See http://snurl.com/21zf8 [groups_google_com] x = file.split("/").collect { |name| name.capitalize }.join("::").gsub(/_+(.)/) { |term| $1.capitalize } end module_function :file2constant def constant2file(constant) constant.to_s.gsub(/([a-z])([A-Z])/) { |term| $1 + "_#{$2}" }.gsub("::", "/").downcase end module_function :constant2file end end end
Version data entries
14 entries across 14 versions & 2 rubygems