Sha256: 950ad2687a52e2f63f7ce55c6237f7d3e7763a834a7c44bee9a7bf9f60dcc4ed

Contents?: true

Size: 654 Bytes

Versions: 761

Compression:

Stored size: 654 Bytes

Contents

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

# NOTE: I think it might be worth considering moving these methods directly into Puppet::Util.

# A common module for converting between constants and
# file names.


module Puppet
  module Util
    module ConstantInflector
      def file2constant(file)
        file.split("/").collect { |name| name.capitalize }.join("::").gsub(/_+(.)/) { |term| $1.capitalize }
      end
      module_function :file2constant

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

Version data entries

761 entries across 761 versions & 3 rubygems

Version Path
puppet-7.34.0 lib/puppet/util/constant_inflector.rb
puppet-7.34.0-x86-mingw32 lib/puppet/util/constant_inflector.rb
puppet-7.34.0-x64-mingw32 lib/puppet/util/constant_inflector.rb
puppet-7.34.0-universal-darwin lib/puppet/util/constant_inflector.rb
puppet-7.33.0 lib/puppet/util/constant_inflector.rb
puppet-7.33.0-x86-mingw32 lib/puppet/util/constant_inflector.rb
puppet-7.33.0-x64-mingw32 lib/puppet/util/constant_inflector.rb
puppet-7.33.0-universal-darwin lib/puppet/util/constant_inflector.rb
puppet-7.32.1 lib/puppet/util/constant_inflector.rb
puppet-7.32.1-x86-mingw32 lib/puppet/util/constant_inflector.rb
puppet-7.32.1-x64-mingw32 lib/puppet/util/constant_inflector.rb
puppet-7.32.1-universal-darwin lib/puppet/util/constant_inflector.rb
puppet-7.31.0 lib/puppet/util/constant_inflector.rb
puppet-7.31.0-x86-mingw32 lib/puppet/util/constant_inflector.rb
puppet-7.31.0-x64-mingw32 lib/puppet/util/constant_inflector.rb
puppet-7.31.0-universal-darwin lib/puppet/util/constant_inflector.rb
puppet-7.30.0 lib/puppet/util/constant_inflector.rb
puppet-7.30.0-x86-mingw32 lib/puppet/util/constant_inflector.rb
puppet-7.30.0-x64-mingw32 lib/puppet/util/constant_inflector.rb
puppet-7.30.0-universal-darwin lib/puppet/util/constant_inflector.rb