Module: Puppet::Util::ConstantInflector
- Defined in:
- lib/puppet/util/constant_inflector.rb
Class Method Summary collapse
Class Method Details
.constant2file(constant) ⇒ Object
19 20 21 |
# File 'lib/puppet/util/constant_inflector.rb', line 19 def constant2file(constant) constant.to_s.gsub(/([a-z])([A-Z])/) { |_term| ::Regexp.last_match(1) + "_#{::Regexp.last_match(2)}" }.gsub("::", "/").downcase end |
.file2constant(file) ⇒ Object
14 15 16 |
# File 'lib/puppet/util/constant_inflector.rb', line 14 def file2constant(file) file.split("/").collect(&:capitalize).join("::").gsub(/_+(.)/) { |_term| ::Regexp.last_match(1).capitalize } end |