Sha256: c42751199b0cd7d02e6b665fc68d375684a57da901c6d277d5ea92638decc509

Contents?: true

Size: 513 Bytes

Versions: 6

Compression:

Stored size: 513 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.25.5 lib/puppet/util/constant_inflector.rb
puppet-0.25.4 lib/puppet/util/constant_inflector.rb
puppet-0.25.3 lib/puppet/util/constant_inflector.rb
puppet-0.25.2 lib/puppet/util/constant_inflector.rb
puppet-0.25.1 lib/puppet/util/constant_inflector.rb
puppet-0.25.0 lib/puppet/util/constant_inflector.rb