Sha256: 7036d02671efe8e25a0bf32307ee2172fe616c3fdfa51af51d0c8218845010a9

Contents?: true

Size: 514 Bytes

Versions: 6

Compression:

Stored size: 514 Bytes

Contents

# Created on 2008-02-12
# Copyright Luke Kanies

# A common module for converting between constants and
# file names.
module Puppet::Util::ConstantInflector
    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

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

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
puppet-0.24.9 lib/puppet/util/constant_inflector.rb
puppet-0.24.4 lib/puppet/util/constant_inflector.rb
puppet-0.24.7 lib/puppet/util/constant_inflector.rb
puppet-0.24.5 lib/puppet/util/constant_inflector.rb
puppet-0.24.6 lib/puppet/util/constant_inflector.rb
puppet-0.24.8 lib/puppet/util/constant_inflector.rb