Class: ChefSpec::Coverage::ResourceWrapper
- Inherits:
-
Object
- Object
- ChefSpec::Coverage::ResourceWrapper
- Defined in:
- lib/chefspec/coverage.rb
Instance Attribute Summary collapse
-
#resource ⇒ Object
readonly
Returns the value of attribute resource.
Instance Method Summary collapse
-
#initialize(resource = nil) ⇒ ResourceWrapper
constructor
A new instance of ResourceWrapper.
- #source_file ⇒ Object
- #source_line ⇒ Object
- #to_json ⇒ Object
- #to_s ⇒ Object
- #touch! ⇒ Object
- #touched? ⇒ Boolean
Constructor Details
#initialize(resource = nil) ⇒ ResourceWrapper
Returns a new instance of ResourceWrapper.
179 180 181 |
# File 'lib/chefspec/coverage.rb', line 179 def initialize(resource = nil) @resource = resource end |
Instance Attribute Details
#resource ⇒ Object (readonly)
Returns the value of attribute resource.
177 178 179 |
# File 'lib/chefspec/coverage.rb', line 177 def resource @resource end |
Instance Method Details
#source_file ⇒ Object
196 197 198 199 200 201 202 |
# File 'lib/chefspec/coverage.rb', line 196 def source_file @source_file ||= if @resource.source_line shortname(@resource.source_line.split(':').first) else 'Unknown' end end |
#source_line ⇒ Object
204 205 206 207 208 209 210 |
# File 'lib/chefspec/coverage.rb', line 204 def source_line @source_line ||= if @resource.source_line @resource.source_line.split(':', 2).last.to_i else 'Unknown' end end |
#to_json ⇒ Object
187 188 189 190 191 192 193 194 |
# File 'lib/chefspec/coverage.rb', line 187 def to_json { "source_file" => source_file, "source_line" => source_line, "touched" => touched?, "resource" => to_s }.to_json end |
#to_s ⇒ Object
183 184 185 |
# File 'lib/chefspec/coverage.rb', line 183 def to_s @resource.to_s end |
#touch! ⇒ Object
212 213 214 |
# File 'lib/chefspec/coverage.rb', line 212 def touch! @touched = true end |
#touched? ⇒ Boolean
216 217 218 |
# File 'lib/chefspec/coverage.rb', line 216 def touched? !!@touched end |