Class: ChefSpec::Coverage::ResourceWrapper

Inherits:
Object
  • Object
show all
Defined in:
lib/chefspec/coverage.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(resource = nil) ⇒ ResourceWrapper


155
156
157
# File 'lib/chefspec/coverage.rb', line 155

def initialize(resource = nil)
  @resource = resource
end

Instance Attribute Details

#resourceObject (readonly)

Returns the value of attribute resource


153
154
155
# File 'lib/chefspec/coverage.rb', line 153

def resource
  @resource
end

Instance Method Details

#source_fileObject


163
164
165
166
167
168
169
# File 'lib/chefspec/coverage.rb', line 163

def source_file
  @source_file ||= if @resource.source_line
    shortname(@resource.source_line.split(':').first)
  else
    'Unknown'
  end
end

#source_lineObject


171
172
173
174
175
176
177
# File 'lib/chefspec/coverage.rb', line 171

def source_line
  @source_line ||= if @resource.source_line
    @resource.source_line.split(':', 2).last.to_i
  else
    'Unknown'
  end
end

#to_sObject


159
160
161
# File 'lib/chefspec/coverage.rb', line 159

def to_s
  @resource.to_s
end

#touch!Object


179
180
181
# File 'lib/chefspec/coverage.rb', line 179

def touch!
  @touched = true
end

#touched?Boolean


183
184
185
# File 'lib/chefspec/coverage.rb', line 183

def touched?
  !!@touched
end