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 ⇒ Object
- #to_hash ⇒ Object
- #to_s ⇒ Object
- #touch! ⇒ Object
- #touched? ⇒ Boolean
Constructor Details
#initialize(resource = nil) ⇒ ResourceWrapper
Returns a new instance of ResourceWrapper.
132 133 134 |
# File 'lib/chefspec/coverage.rb', line 132 def initialize(resource = nil) @resource = resource end |
Instance Attribute Details
#resource ⇒ Object (readonly)
Returns the value of attribute resource.
130 131 132 |
# File 'lib/chefspec/coverage.rb', line 130 def resource @resource end |
Instance Method Details
#source ⇒ Object
140 141 142 143 144 145 146 147 148 |
# File 'lib/chefspec/coverage.rb', line 140 def source return {} unless @resource.source_line file, line, *_ = @resource.source_line.split(':') { file: file, line: line.to_i, } end |
#to_hash ⇒ Object
150 151 152 153 154 155 |
# File 'lib/chefspec/coverage.rb', line 150 def to_hash { source: source, touched: touched?, } end |
#to_s ⇒ Object
136 137 138 |
# File 'lib/chefspec/coverage.rb', line 136 def to_s @resource.to_s end |
#touch! ⇒ Object
157 158 159 |
# File 'lib/chefspec/coverage.rb', line 157 def touch! @touched = true end |
#touched? ⇒ Boolean
161 162 163 |
# File 'lib/chefspec/coverage.rb', line 161 def touched? !!@touched end |