class Xcov::Source
Attributes
coverage[RW]
coveredLines[RW]
executableLines[RW]
function_templates[RW]
functions[RW]
ignored[RW]
lines[RW]
location[RW]
name[RW]
type[RW]
Public Class Methods
map(dictionary)
click to toggle source
Class methods
# File lib/xcov/model/source.rb, line 72 def self.map(dictionary) name = dictionary["name"] location = dictionary["location"] coverage = dictionary["coverage"] coveredLines = dictionary["coveredLines"] executableLines = dictionary["executableLines"] functions = dictionary["functions"].map { |function| Function.map(function)} lines = map_lines(dictionary["lines"]) Source.new(name, location, coverage, coveredLines, executableLines, functions, lines) end
map_lines(dictionaries)
click to toggle source
# File lib/xcov/model/source.rb, line 83 def self.map_lines(dictionaries) return nil if dictionaries.nil? dictionaries.map { |line| Line.map(line) } end
new(name, location, coverage, coveredLines, executableLines, functions, lines = nil)
click to toggle source
# File lib/xcov/model/source.rb, line 17 def initialize(name, location, coverage, coveredLines, executableLines, functions, lines = nil) @name = CGI::escapeHTML(name) @location = CGI::escapeHTML(location) @coverage = coverage @coveredLines = coveredLines @executableLines = executableLines @functions = functions @ignored = Xcov.ignore_handler.should_ignore_file_at_path(location) @displayable_coverage = self.create_displayable_coverage @coverage_color = self.create_coverage_color @id = Source.create_id(name) @type = Source.type(name) @lines = lines if @ignored UI.message "Ignoring #{name} coverage".yellow end end
type(name)
click to toggle source
# File lib/xcov/model/source.rb, line 88 def self.type(name) types_map = { ".swift" => "swift", ".m" => "objc", ".cpp" => "cpp", ".mm" => "cpp" } extension = File.extname(name) type = types_map[extension] type = "objc" if type.nil? type end
Public Instance Methods
html_value()
click to toggle source
# File lib/xcov/model/source.rb, line 43 def html_value @function_templates = "" @functions.each do |function| @function_templates << function.html_value end Function.template("file").result(binding) end
json_value()
click to toggle source
# File lib/xcov/model/source.rb, line 56 def json_value value = { "name" => @name, "path" => @location, "coverage" => @coverage, "type" => @type, "functions" => @functions ? @functions.map{ |function| function.json_value } : [] } if @ignored then value["ignored"] = true end return value end
markdown_value()
click to toggle source
# File lib/xcov/model/source.rb, line 52 def markdown_value "#{@name} | `#{@displayable_coverage}` | #{coverage_emoji}\n" end
print_description()
click to toggle source
# File lib/xcov/model/source.rb, line 36 def print_description puts "\t\t#{@name} (#{@coverage})" @functions.each do |function| function.print_description end end