Class: Puppet::Pops::Model::ModelLabelProvider

Inherits:
Object
  • Object
show all
Includes:
LabelProvider
Defined in:
lib/puppet/pops/model/model_label_provider.rb

Overview

A provider of labels for model object, producing a human name for the model object. As an example, if object is an ArithmeticExpression with operator , `#a_an(o)` produces “a '' Expression”, #the(o) produces “the + Expression”, and #label produces “+ Expression”.

Constant Summary

Constants included from LabelProvider

LabelProvider::A, LabelProvider::AN, LabelProvider::SKIPPED_CHARACTERS, LabelProvider::VOWELS

Instance Method Summary collapse

Methods included from LabelProvider

#a_an, #a_an_uc, #article, #combine_strings, #plural_s, #the, #the_uc

Constructor Details

#initializeModelLabelProvider

Returns a new instance of ModelLabelProvider


10
11
12
# File 'lib/puppet/pops/model/model_label_provider.rb', line 10

def initialize
  @@label_visitor ||= Visitor.new(self,"label",0,0)
end

Instance Method Details

#label(o) ⇒ Object

Produces a label for the given objects type/operator without article. If a Class is given, its name is used as label


17
18
19
# File 'lib/puppet/pops/model/model_label_provider.rb', line 17

def label o
  @@label_visitor.visit_this_0(self, o)
end

#label_AccessExpression(o) ⇒ Object


26
# File 'lib/puppet/pops/model/model_label_provider.rb', line 26

def label_AccessExpression o            ; "'[]' expression"                   end

#label_AndExpression(o) ⇒ Object


34
# File 'lib/puppet/pops/model/model_label_provider.rb', line 34

def label_AndExpression o               ; "'and' expression"                  end

#label_Application(o) ⇒ Object


105
# File 'lib/puppet/pops/model/model_label_provider.rb', line 105

def label_Application o                 ; "Application"                       end

#label_ApplyBlockExpression(o) ⇒ Object


59
# File 'lib/puppet/pops/model/model_label_provider.rb', line 59

def label_ApplyBlockExpression o        ; "Apply Block Expression"            end

#label_ApplyExpression(o) ⇒ Object


75
# File 'lib/puppet/pops/model/model_label_provider.rb', line 75

def label_ApplyExpression o             ; "'apply' expression"                end

#label_ArithmeticExpression(o) ⇒ Object


25
# File 'lib/puppet/pops/model/model_label_provider.rb', line 25

def label_ArithmeticExpression o        ; "'#{o.operator}' expression"        end

#label_Array(o) ⇒ Object


22
# File 'lib/puppet/pops/model/model_label_provider.rb', line 22

def label_Array o                       ; "Array"                             end

#label_AssignmentExpression(o) ⇒ Object


37
# File 'lib/puppet/pops/model/model_label_provider.rb', line 37

def label_AssignmentExpression o        ; "'#{o.operator}' expression"        end

#label_AttributeOperation(o) ⇒ Object


38
# File 'lib/puppet/pops/model/model_label_provider.rb', line 38

def label_AttributeOperation o          ; "'#{o.operator}' expression"        end

#label_Bignum(o) ⇒ Object


89
# File 'lib/puppet/pops/model/model_label_provider.rb', line 89

def label_Bignum o                      ; "Integer"                           end

#label_Binary(o) ⇒ Object


104
# File 'lib/puppet/pops/model/model_label_provider.rb', line 104

def label_Binary o                      ; "Binary"                            end

#label_BlockExpression(o) ⇒ Object


58
# File 'lib/puppet/pops/model/model_label_provider.rb', line 58

def label_BlockExpression o             ; "Block Expression"                  end

#label_CallMethodExpression(o) ⇒ Object


74
# File 'lib/puppet/pops/model/model_label_provider.rb', line 74

def label_CallMethodExpression o        ; "Method call"                       end

#label_CallNamedFunctionExpression(o) ⇒ Object


73
# File 'lib/puppet/pops/model/model_label_provider.rb', line 73

def label_CallNamedFunctionExpression o ; "Function Call"                     end

#label_CapabilityMapping(o) ⇒ Object


76
# File 'lib/puppet/pops/model/model_label_provider.rb', line 76

def label_CapabilityMapping o           ; "Capability Mapping"                end

#label_CaseExpression(o) ⇒ Object


77
# File 'lib/puppet/pops/model/model_label_provider.rb', line 77

def label_CaseExpression o              ; "'case' statement"                  end

#label_CaseOption(o) ⇒ Object


78
# File 'lib/puppet/pops/model/model_label_provider.rb', line 78

def label_CaseOption o                  ; "Case Option"                       end

#label_CatalogCollector(o) ⇒ Object


99
# File 'lib/puppet/pops/model/model_label_provider.rb', line 99

def label_CatalogCollector o            ; "Catalog-Collector"                 end

#label_Class(o) ⇒ Object


125
126
127
128
129
130
131
132
133
134
135
136
# File 'lib/puppet/pops/model/model_label_provider.rb', line 125

def label_Class o
  if o <= Types::PAnyType
    simple_name = o.name.split('::').last
    simple_name[1..-5] + "-Type"
  else
    n = o.name
    if n.nil?
      n = o.respond_to?(:_pcore_type) ? o._pcore_type.name : 'Anonymous Class'
    end
    n
  end
end

#label_CollectExpression(o) ⇒ Object


28
# File 'lib/puppet/pops/model/model_label_provider.rb', line 28

def label_CollectExpression o           ; label(o.query)                      end

#label_ComparisonExpression(o) ⇒ Object


33
# File 'lib/puppet/pops/model/model_label_provider.rb', line 33

def label_ComparisonExpression o        ; "'#{o.operator}' expression"        end

#label_ConcatenatedString(o) ⇒ Object


60
# File 'lib/puppet/pops/model/model_label_provider.rb', line 60

def label_ConcatenatedString o          ; "Double Quoted String"              end

#label_EppExpression(o) ⇒ Object


29
# File 'lib/puppet/pops/model/model_label_provider.rb', line 29

def label_EppExpression o               ; "Epp Template"                      end

#label_ExportedCollector(o) ⇒ Object


100
# File 'lib/puppet/pops/model/model_label_provider.rb', line 100

def label_ExportedCollector o           ; "Exported-Collector"                end

#label_ExportedQuery(o) ⇒ Object


30
# File 'lib/puppet/pops/model/model_label_provider.rb', line 30

def label_ExportedQuery o               ; "Exported Query"                    end

#label_Factory(o) ⇒ Object


21
# File 'lib/puppet/pops/model/model_label_provider.rb', line 21

def label_Factory o                     ; label(o.model)                      end

#label_FalseClass(o) ⇒ Object


44
# File 'lib/puppet/pops/model/model_label_provider.rb', line 44

def label_FalseClass o                  ; "Boolean"                           end

#label_Fixnum(o) ⇒ Object


88
# File 'lib/puppet/pops/model/model_label_provider.rb', line 88

def label_Fixnum o                      ; "Integer"                           end

#label_Float(o) ⇒ Object


90
# File 'lib/puppet/pops/model/model_label_provider.rb', line 90

def label_Float o                       ; "Float"                             end

#label_FunctionDefinition(o) ⇒ Object


63
# File 'lib/puppet/pops/model/model_label_provider.rb', line 63

def label_FunctionDefinition o          ; "Function Definition"               end

#label_Hash(o) ⇒ Object


94
# File 'lib/puppet/pops/model/model_label_provider.rb', line 94

def label_Hash o                        ; "Hash"                              end

#label_HeredocExpression(o) ⇒ Object


61
# File 'lib/puppet/pops/model/model_label_provider.rb', line 61

def label_HeredocExpression o           ; "'@(#{o.syntax})' expression"       end

#label_HostClassDefinition(o) ⇒ Object


62
# File 'lib/puppet/pops/model/model_label_provider.rb', line 62

def label_HostClassDefinition o         ; "Host Class Definition"             end

#label_IfExpression(o) ⇒ Object


71
# File 'lib/puppet/pops/model/model_label_provider.rb', line 71

def label_IfExpression o                ; "'if' statement"                    end

#label_InExpression(o) ⇒ Object


36
# File 'lib/puppet/pops/model/model_label_provider.rb', line 36

def label_InExpression o                ; "'in' expression"                   end

#label_Integer(o) ⇒ Object


87
# File 'lib/puppet/pops/model/model_label_provider.rb', line 87

def label_Integer o                     ; "Integer"                           end

#label_KeyedEntry(o) ⇒ Object


41
# File 'lib/puppet/pops/model/model_label_provider.rb', line 41

def label_KeyedEntry o                  ; "Hash Entry"                        end

#label_LambdaExpression(o) ⇒ Object


46
# File 'lib/puppet/pops/model/model_label_provider.rb', line 46

def label_LambdaExpression o            ; "Lambda"                            end

#label_LiteralBoolean(o) ⇒ Object


42
# File 'lib/puppet/pops/model/model_label_provider.rb', line 42

def label_LiteralBoolean o              ; "Boolean"                           end

#label_LiteralDefault(o) ⇒ Object


47
# File 'lib/puppet/pops/model/model_label_provider.rb', line 47

def label_LiteralDefault o              ; "'default' expression"              end

#label_LiteralFloat(o) ⇒ Object


24
# File 'lib/puppet/pops/model/model_label_provider.rb', line 24

def label_LiteralFloat o                ; "Literal Float"                     end

#label_LiteralHash(o) ⇒ Object


40
# File 'lib/puppet/pops/model/model_label_provider.rb', line 40

def label_LiteralHash o                 ; "Hash Expression"                   end

#label_LiteralInteger(o) ⇒ Object


23
# File 'lib/puppet/pops/model/model_label_provider.rb', line 23

def label_LiteralInteger o              ; "Literal Integer"                   end

#label_LiteralList(o) ⇒ Object


39
# File 'lib/puppet/pops/model/model_label_provider.rb', line 39

def label_LiteralList o                 ; "Array Expression"                  end

#label_LiteralRegularExpression(o) ⇒ Object


49
# File 'lib/puppet/pops/model/model_label_provider.rb', line 49

def label_LiteralRegularExpression o    ; "Regular Expression"                end

#label_LiteralString(o) ⇒ Object


45
# File 'lib/puppet/pops/model/model_label_provider.rb', line 45

def label_LiteralString o               ; "String"                            end

#label_LiteralUndef(o) ⇒ Object


48
# File 'lib/puppet/pops/model/model_label_provider.rb', line 48

def label_LiteralUndef o                ; "'undef' expression"                end

#label_MatchExpression(o) ⇒ Object


27
# File 'lib/puppet/pops/model/model_label_provider.rb', line 27

def label_MatchExpression o             ; "'#{o.operator}' expression"        end

#label_NamedAccessExpression(o) ⇒ Object


51
# File 'lib/puppet/pops/model/model_label_provider.rb', line 51

def label_NamedAccessExpression o       ; "'.' expression"                    end

#label_NilClass(o) ⇒ Object


52
# File 'lib/puppet/pops/model/model_label_provider.rb', line 52

def label_NilClass o                    ; "Undef Value"                       end

#label_NodeDefinition(o) ⇒ Object


65
# File 'lib/puppet/pops/model/model_label_provider.rb', line 65

def label_NodeDefinition o              ; "Node Definition"                   end

#label_Nop(o) ⇒ Object


50
# File 'lib/puppet/pops/model/model_label_provider.rb', line 50

def label_Nop o                         ; "Nop Expression"                    end

#label_NotExpression(o) ⇒ Object


53
# File 'lib/puppet/pops/model/model_label_provider.rb', line 53

def label_NotExpression o               ; "'not' expression"                  end

#label_Object(o) ⇒ Object


93
# File 'lib/puppet/pops/model/model_label_provider.rb', line 93

def label_Object o                      ; "Object"                            end

#label_OrExpression(o) ⇒ Object


35
# File 'lib/puppet/pops/model/model_label_provider.rb', line 35

def label_OrExpression o                ; "'or' expression"                   end

#label_PAnyType(o) ⇒ Object


97
# File 'lib/puppet/pops/model/model_label_provider.rb', line 97

def label_PAnyType o                    ; "#{o}-Type" end

#label_Parameter(o) ⇒ Object


69
# File 'lib/puppet/pops/model/model_label_provider.rb', line 69

def label_Parameter o                   ; "Parameter Definition"              end

#label_ParenthesizedExpression(o) ⇒ Object


70
# File 'lib/puppet/pops/model/model_label_provider.rb', line 70

def label_ParenthesizedExpression o     ; "Parenthesized Expression"          end

#label_PlanDefinition(o) ⇒ Object


64
# File 'lib/puppet/pops/model/model_label_provider.rb', line 64

def label_PlanDefinition o              ; "Plan Definition"                   end

#label_PResourceType(o) ⇒ Object


112
113
114
115
116
117
118
# File 'lib/puppet/pops/model/model_label_provider.rb', line 112

def label_PResourceType o
  if o.title
    "#{o} Resource-Reference"
  else
    "#{o}-Type"
  end
end

#label_QualifiedName(o) ⇒ Object


95
# File 'lib/puppet/pops/model/model_label_provider.rb', line 95

def label_QualifiedName o               ; "Name"                              end

#label_QualifiedReference(o) ⇒ Object


96
# File 'lib/puppet/pops/model/model_label_provider.rb', line 96

def label_QualifiedReference o          ; "Type-Name"                         end

#label_QueryExpression(o) ⇒ Object


32
# File 'lib/puppet/pops/model/model_label_provider.rb', line 32

def label_QueryExpression o             ; "Collect Query"                     end

#label_Regexp(o) ⇒ Object


92
# File 'lib/puppet/pops/model/model_label_provider.rb', line 92

def label_Regexp o                      ; "Regexp"                            end

#label_RelationshipExpression(o) ⇒ Object


81
# File 'lib/puppet/pops/model/model_label_provider.rb', line 81

def label_RelationshipExpression o      ; "'#{o.operator}' expression"        end

#label_RenderExpression(o) ⇒ Object


80
# File 'lib/puppet/pops/model/model_label_provider.rb', line 80

def label_RenderExpression o            ; "Epp Interpolated Expression"       end

#label_RenderStringExpression(o) ⇒ Object


79
# File 'lib/puppet/pops/model/model_label_provider.rb', line 79

def label_RenderStringExpression o      ; "Epp Text"                          end

#label_ReservedWord(o) ⇒ Object


98
# File 'lib/puppet/pops/model/model_label_provider.rb', line 98

def label_ReservedWord o                ; "Reserved Word '#{o.word}'"         end

#label_Resource(o) ⇒ Object


120
121
122
# File 'lib/puppet/pops/model/model_label_provider.rb', line 120

def label_Resource o
  'Resource Statement'
end

#label_ResourceBody(o) ⇒ Object


82
# File 'lib/puppet/pops/model/model_label_provider.rb', line 82

def label_ResourceBody o                ; "Resource Instance Definition"      end

#label_ResourceDefaultsExpression(o) ⇒ Object


83
# File 'lib/puppet/pops/model/model_label_provider.rb', line 83

def label_ResourceDefaultsExpression o  ; "Resource Defaults Expression"      end

#label_ResourceExpression(o) ⇒ Object


84
# File 'lib/puppet/pops/model/model_label_provider.rb', line 84

def label_ResourceExpression o          ; "Resource Statement"                end

#label_ResourceOverrideExpression(o) ⇒ Object


68
# File 'lib/puppet/pops/model/model_label_provider.rb', line 68

def label_ResourceOverrideExpression o  ; "Resource Override"                 end

#label_ResourceTypeDefinition(o) ⇒ Object


67
# File 'lib/puppet/pops/model/model_label_provider.rb', line 67

def label_ResourceTypeDefinition o      ; "'define' expression"               end

#label_SelectorEntry(o) ⇒ Object


86
# File 'lib/puppet/pops/model/model_label_provider.rb', line 86

def label_SelectorEntry o               ; "Selector Option"                   end

#label_SelectorExpression(o) ⇒ Object


85
# File 'lib/puppet/pops/model/model_label_provider.rb', line 85

def label_SelectorExpression o          ; "Selector Expression"               end

#label_Sensitive(o) ⇒ Object


106
# File 'lib/puppet/pops/model/model_label_provider.rb', line 106

def label_Sensitive o                   ; "Sensitive"                         end

#label_SiteDefinition(o) ⇒ Object


66
# File 'lib/puppet/pops/model/model_label_provider.rb', line 66

def label_SiteDefinition o              ; "Site Definition"                   end

#label_String(o) ⇒ Object


91
# File 'lib/puppet/pops/model/model_label_provider.rb', line 91

def label_String o                      ; "String"                            end

#label_TextExpression(o) ⇒ Object


55
# File 'lib/puppet/pops/model/model_label_provider.rb', line 55

def label_TextExpression o              ; "Expression in Interpolated String" end

#label_Timespan(o) ⇒ Object


108
# File 'lib/puppet/pops/model/model_label_provider.rb', line 108

def label_Timespan o                    ; "Timespan"                          end

#label_Timestamp(o) ⇒ Object


107
# File 'lib/puppet/pops/model/model_label_provider.rb', line 107

def label_Timestamp o                   ; "Timestamp"                         end

#label_TrueClass(o) ⇒ Object


43
# File 'lib/puppet/pops/model/model_label_provider.rb', line 43

def label_TrueClass o                   ; "Boolean"                           end

#label_TypeAlias(o) ⇒ Object


101
# File 'lib/puppet/pops/model/model_label_provider.rb', line 101

def label_TypeAlias o                   ; "Type Alias"                        end

#label_TypeDefinition(o) ⇒ Object


103
# File 'lib/puppet/pops/model/model_label_provider.rb', line 103

def label_TypeDefinition o              ; "Type Definition"                   end

#label_TypeMapping(o) ⇒ Object


102
# File 'lib/puppet/pops/model/model_label_provider.rb', line 102

def label_TypeMapping o                 ; "Type Mapping"                      end

#label_UnaryMinusExpression(o) ⇒ Object


56
# File 'lib/puppet/pops/model/model_label_provider.rb', line 56

def label_UnaryMinusExpression o        ; "Unary Minus"                       end

#label_UnfoldExpression(o) ⇒ Object


57
# File 'lib/puppet/pops/model/model_label_provider.rb', line 57

def label_UnfoldExpression o            ; "Unfold"                            end

#label_UnlessExpression(o) ⇒ Object


72
# File 'lib/puppet/pops/model/model_label_provider.rb', line 72

def label_UnlessExpression o            ; "'unless' Statement"                end

#label_VariableExpression(o) ⇒ Object


54
# File 'lib/puppet/pops/model/model_label_provider.rb', line 54

def label_VariableExpression o          ; "Variable"                          end

#label_Version(o) ⇒ Object


109
# File 'lib/puppet/pops/model/model_label_provider.rb', line 109

def label_Version o                     ; "Semver"                            end

#label_VersionRange(o) ⇒ Object


110
# File 'lib/puppet/pops/model/model_label_provider.rb', line 110

def label_VersionRange o                ; "SemverRange"                       end

#label_VirtualQuery(o) ⇒ Object


31
# File 'lib/puppet/pops/model/model_label_provider.rb', line 31

def label_VirtualQuery o                ; "Virtual Query"                     end