Sha256: 7a89c19c6eadaa7e46940789fdc025f3bae050f04ca08120ea65176e37bf0b46

Contents?: true

Size: 493 Bytes

Versions: 63

Compression:

Stored size: 493 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

63 entries across 63 versions & 4 rubygems

Version Path
puppet-parse-0.1.4 lib/vendor/puppet/util/constant_inflector.rb
puppet-parse-0.1.3 lib/vendor/puppet/util/constant_inflector.rb
puppet-parse-0.1.2 lib/vendor/puppet/util/constant_inflector.rb
puppet-parse-0.1.1 lib/vendor/puppet/util/constant_inflector.rb
puppet-2.7.26 lib/puppet/util/constant_inflector.rb
puppet-2.7.25 lib/puppet/util/constant_inflector.rb
puppet-2.7.24 lib/puppet/util/constant_inflector.rb
puppet-2.7.23 lib/puppet/util/constant_inflector.rb
puppet-2.7.22 lib/puppet/util/constant_inflector.rb
puppet-parse-0.1.0 lib/vendor/puppet/util/constant_inflector.rb
puppet-parse-0.0.6 lib/vendor/puppet/util/constant_inflector.rb
puppet-2.7.21 lib/puppet/util/constant_inflector.rb
puppet-2.6.18 lib/puppet/util/constant_inflector.rb
puppet-parse-0.0.5 lib/vendor/puppet/util/constant_inflector.rb
puppet-parse-0.0.4 lib/vendor/puppet/util/constant_inflector.rb
puppet-parse-0.0.2 lib/vendor/puppet/util/constant_inflector.rb
puppet-2.7.20 lib/puppet/util/constant_inflector.rb
puppet-2.7.20.rc1 lib/puppet/util/constant_inflector.rb
librarian-puppet-0.9.4 vendor/gems/ruby/1.8/gems/puppet-2.7.18/lib/puppet/util/constant_inflector.rb
puppet-2.7.19 lib/puppet/util/constant_inflector.rb