Module: Puppet::Util::ConstantInflector
- Defined in:
- lib/vendor/puppet/util/constant_inflector.rb
Overview
A common module for converting between constants and file names.
Instance Method Summary collapse
Instance Method Details
#constant2file(constant) ⇒ Object
12 13 14 |
# File 'lib/vendor/puppet/util/constant_inflector.rb', line 12 def constant2file(constant) constant.to_s.gsub(/([a-z])([A-Z])/) { |term| $1 + "_#{$2}" }.gsub("::", "/").downcase end |
#file2constant(file) ⇒ Object
7 8 9 10 |
# File 'lib/vendor/puppet/util/constant_inflector.rb', line 7 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 |