Module: Puppet::Util::ConstantInflector

Defined in:
lib/puppet/util/constant_inflector.rb

Class Method Summary collapse

Class Method Details

.constant2file(constant) ⇒ Object



18
19
20
# File 'lib/puppet/util/constant_inflector.rb', line 18

def constant2file(constant)
  constant.to_s.gsub(/([a-z])([A-Z])/) { |term| $1 + "_#{$2}" }.gsub("::", "/").downcase
end

.file2constant(file) ⇒ Object



13
14
15
# File 'lib/puppet/util/constant_inflector.rb', line 13

def file2constant(file)
  file.split("/").collect { |name| name.capitalize }.join("::").gsub(/_+(.)/) { |term| $1.capitalize }
end