Class: Xcov::Source
Instance Attribute Summary collapse
-
#coverage ⇒ Object
Returns the value of attribute coverage.
-
#coveredLines ⇒ Object
Returns the value of attribute coveredLines.
-
#executableLines ⇒ Object
Returns the value of attribute executableLines.
-
#function_templates ⇒ Object
Returns the value of attribute function_templates.
-
#functions ⇒ Object
Returns the value of attribute functions.
-
#ignored ⇒ Object
Returns the value of attribute ignored.
-
#lines ⇒ Object
Returns the value of attribute lines.
-
#location ⇒ Object
Returns the value of attribute location.
-
#name ⇒ Object
Returns the value of attribute name.
-
#type ⇒ Object
Returns the value of attribute type.
Attributes inherited from Base
#coverage_color, #displayable_coverage, #id
Class Method Summary collapse
Instance Method Summary collapse
- #html_value ⇒ Object
-
#initialize(name, location, coverage, coveredLines, executableLines, functions, lines = nil) ⇒ Source
constructor
A new instance of Source.
- #json_value ⇒ Object
- #markdown_value ⇒ Object
- #print_description ⇒ Object
Methods inherited from Base
#coverage_emoji, #create_coverage_color, #create_displayable_coverage, create_id, #create_summary, template
Constructor Details
#initialize(name, location, coverage, coveredLines, executableLines, functions, lines = nil) ⇒ Source
Returns a new instance of Source.
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# 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. "Ignoring #{name} coverage".yellow end end |
Instance Attribute Details
#coverage ⇒ Object
Returns the value of attribute coverage.
10 11 12 |
# File 'lib/xcov/model/source.rb', line 10 def coverage @coverage end |
#coveredLines ⇒ Object
Returns the value of attribute coveredLines.
11 12 13 |
# File 'lib/xcov/model/source.rb', line 11 def coveredLines @coveredLines end |
#executableLines ⇒ Object
Returns the value of attribute executableLines.
12 13 14 |
# File 'lib/xcov/model/source.rb', line 12 def executableLines @executableLines end |
#function_templates ⇒ Object
Returns the value of attribute function_templates.
14 15 16 |
# File 'lib/xcov/model/source.rb', line 14 def function_templates @function_templates end |
#functions ⇒ Object
Returns the value of attribute functions.
13 14 15 |
# File 'lib/xcov/model/source.rb', line 13 def functions @functions end |
#ignored ⇒ Object
Returns the value of attribute ignored.
9 10 11 |
# File 'lib/xcov/model/source.rb', line 9 def ignored @ignored end |
#lines ⇒ Object
Returns the value of attribute lines.
15 16 17 |
# File 'lib/xcov/model/source.rb', line 15 def lines @lines end |
#location ⇒ Object
Returns the value of attribute location.
7 8 9 |
# File 'lib/xcov/model/source.rb', line 7 def location @location end |
#name ⇒ Object
Returns the value of attribute name.
6 7 8 |
# File 'lib/xcov/model/source.rb', line 6 def name @name end |
#type ⇒ Object
Returns the value of attribute type.
8 9 10 |
# File 'lib/xcov/model/source.rb', line 8 def type @type end |
Class Method Details
.map(dictionary) ⇒ Object
Class methods
72 73 74 75 76 77 78 79 80 81 |
# 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) ⇒ Object
83 84 85 86 |
# 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 |
.type(name) ⇒ Object
88 89 90 91 92 93 94 95 96 97 98 99 100 101 |
# 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 |
Instance Method Details
#html_value ⇒ Object
43 44 45 46 47 48 49 50 |
# 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 ⇒ Object
56 57 58 59 60 61 62 63 64 65 66 67 68 |
# 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 ⇒ Object
52 53 54 |
# File 'lib/xcov/model/source.rb', line 52 def markdown_value "#{@name} | `#{@displayable_coverage}` | #{coverage_emoji}\n" end |
#print_description ⇒ Object
36 37 38 39 40 41 |
# 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 |