Sha256: 1295c64e39d84fe1878b0d7fdb435e6a8ecab2f000e5429ea65e2c4338b450de
Contents?: true
Size: 686 Bytes
Versions: 12
Compression:
Stored size: 686 Bytes
Contents
# frozen_string_literal: true # 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
12 entries across 12 versions & 1 rubygems