~ubuntu-branches/ubuntu/wily/puppet/wily-proposed

« back to all changes in this revision

Viewing changes to lib/puppet/vendor/rgen/lib/rgen/util/name_helper.rb

  • Committer: Package Import Robot
  • Author(s): Stig Sandbeck Mathisen
  • Date: 2014-10-24 13:47:15 UTC
  • mfrom: (3.1.64 sid)
  • Revision ID: package-import@ubuntu.com-20141024134715-6ig54u0c4gar36ss
Tags: 3.7.2-1
* Imported upstream release 3.7.2
* Declare compliance with Debian Policy 3.9.6

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# RGen Framework
 
2
# (c) Martin Thiede, 2006
 
3
 
 
4
module RGen
 
5
 
 
6
module Util
 
7
 
 
8
module NameHelper
 
9
 
 
10
        def normalize(name)
 
11
                name.gsub(/\W/,'_')
 
12
        end
 
13
        
 
14
        def className(object)
 
15
                object.class.name =~ /::(\w+)$/; $1
 
16
        end
 
17
        
 
18
        def firstToUpper(str)
 
19
                str[0..0].upcase + ( str[1..-1] || "" )
 
20
        end
 
21
        
 
22
        def firstToLower(str)
 
23
                str[0..0].downcase + ( str[1..-1] || "" )
 
24
        end
 
25
        
 
26
        def saneClassName(str)
 
27
                firstToUpper(normalize(str)).sub(/^Class$/, 'Clazz')
 
28
        end
 
29
        
 
30
        def saneMethodName(str)
 
31
                firstToLower(normalize(str)).sub(/^class$/, 'clazz')
 
32
        end     
 
33
        
 
34
  def camelize(str)
 
35
    str.split(/[\W_]/).collect{|s| firstToUpper(s.downcase)}.join
 
36
  end
 
37
end
 
38
 
 
39
end
 
40
 
 
41
end
 
42