class ChefSpec::Coverage::ResourceWrapper
Attributes
resource[R]
Public Class Methods
new(resource = nil)
click to toggle source
# File lib/chefspec/coverage.rb, line 193 def initialize(resource = nil) @resource = resource end
Public Instance Methods
source_file()
click to toggle source
# File lib/chefspec/coverage.rb, line 210 def source_file @source_file ||= if @resource.source_line shortname(@resource.source_line.split(":").first) else "Unknown" end end
source_line()
click to toggle source
# File lib/chefspec/coverage.rb, line 218 def source_line @source_line ||= if @resource.source_line @resource.source_line.split(":", 2).last.to_i else "Unknown" end end
to_json()
click to toggle source
# File lib/chefspec/coverage.rb, line 201 def to_json { "source_file" => source_file, "source_line" => source_line, "touched" => touched?, "resource" => to_s, }.to_json end
to_s()
click to toggle source
# File lib/chefspec/coverage.rb, line 197 def to_s @resource.to_s end
touch!()
click to toggle source
# File lib/chefspec/coverage.rb, line 226 def touch! @touched = true end
touched?()
click to toggle source
# File lib/chefspec/coverage.rb, line 230 def touched? !!@touched end
Private Instance Methods
shortname(file)
click to toggle source
# File lib/chefspec/coverage.rb, line 236 def shortname(file) if file.include?(Dir.pwd) file.split(Dir.pwd, 2).last elsif file.include?("cookbooks") file.split("cookbooks/", 2).last else file end end