Sha256: 950ad2687a52e2f63f7ce55c6237f7d3e7763a834a7c44bee9a7bf9f60dcc4ed
Contents?: true
Size: 654 Bytes
Versions: 761
Compression:
Stored size: 654 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) 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
761 entries across 761 versions & 3 rubygems