@@ -73,6 +73,9 @@ def to_hash
7373 class Property < Parameter
7474 end
7575
76+ class Check < Parameter
77+ end
78+
7679 # Represents a resource type feature.
7780 class Feature
7881 attr_reader :name , :docstring
@@ -95,7 +98,7 @@ def to_hash
9598 end
9699 end
97100
98- attr_reader :properties , :features
101+ attr_reader :properties , :features , :checks
99102
100103 # Initializes a new resource type.
101104 # @param [String] name The resource type name.
@@ -134,6 +137,14 @@ def add_feature(feature)
134137 @features << feature
135138 end
136139
140+ # Adds a check to the resource type.
141+ # @param [PuppetStrings::Yard::CodeObjects::Type::Check] check The check to add.
142+ # @return [void]
143+ def add_check ( check )
144+ @checks ||= [ ]
145+ @checks << check
146+ end
147+
137148 def parameters
138149 # just return params if there are no providers
139150 return @parameters if providers . empty?
@@ -163,14 +174,18 @@ def providers
163174 # @return [Hash] Returns a hash representation of the code object.
164175 def to_hash
165176 hash = { }
177+
166178 hash [ :name ] = name
167179 hash [ :file ] = file
168180 hash [ :line ] = line
169- hash [ :docstring ] = PuppetStrings ::Yard ::Util . docstring_to_hash ( docstring )
170- hash [ :properties ] = properties . map ( &:to_hash ) if properties && !properties . empty?
171- hash [ :parameters ] = parameters . map ( &:to_hash ) if parameters && !parameters . empty?
172- hash [ :features ] = features . map ( &:to_hash ) if features && !features . empty?
173- hash [ :providers ] = self . providers . map ( &:to_hash ) if providers && !providers . empty?
181+
182+ hash [ :docstring ] = PuppetStrings ::Yard ::Util . docstring_to_hash ( docstring )
183+ hash [ :properties ] = properties . sort_by { |p | p . name } . map ( &:to_hash ) if properties && !properties . empty?
184+ hash [ :parameters ] = parameters . sort_by { |p | p . name } . map ( &:to_hash ) if parameters && !parameters . empty?
185+ hash [ :checks ] = checks . sort_by { |c | c . name } . map ( &:to_hash ) if checks && !checks . empty?
186+ hash [ :features ] = features . sort_by { |f | f . name } . map ( &:to_hash ) if features && !features . empty?
187+ hash [ :providers ] = providers . sort_by { |p | p . name } . map ( &:to_hash ) if providers && !providers . empty?
188+
174189 hash
175190 end
176191end
0 commit comments