Sha256: 982652bea858576db664165df0253d3c4dc4da5b793c21a1ef315b5510cbee9f
Contents?: true
Size: 723 Bytes
Versions: 11
Compression:
Stored size: 723 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
11 entries across 11 versions & 1 rubygems