Class: Xcov::Source
Instance Attribute Summary collapse
-
#coverage ⇒ Object
Returns the value of attribute coverage.
-
#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.
-
#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
-
.map(dictionary) ⇒ Object
Class methods.
- .type(name) ⇒ Object
Instance Method Summary collapse
- #html_value ⇒ Object
-
#initialize(name, location, coverage, functions) ⇒ 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, functions) ⇒ Source
Returns a new instance of Source.
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/xcov/model/source.rb', line 14 def initialize (name, location, coverage, functions) @name = CGI::escapeHTML(name) @location = CGI::escapeHTML(location) @coverage = coverage @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) 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 |
#function_templates ⇒ Object
Returns the value of attribute function_templates.
12 13 14 |
# File 'lib/xcov/model/source.rb', line 12 def function_templates @function_templates end |
#functions ⇒ Object
Returns the value of attribute functions.
11 12 13 |
# File 'lib/xcov/model/source.rb', line 11 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 |
#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
66 67 68 69 70 71 72 73 |
# File 'lib/xcov/model/source.rb', line 66 def self.map (dictionary) name = dictionary["name"] location = dictionary["location"] coverage = dictionary["coverage"] functions = dictionary["functions"].map { |function| Function.map(function)} Source.new(name, location, coverage, functions) end |
.type(name) ⇒ Object
75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/xcov/model/source.rb', line 75 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
37 38 39 40 41 42 43 44 |
# File 'lib/xcov/model/source.rb', line 37 def html_value @function_templates = "" @functions.each do |function| @function_templates << function.html_value end Function.template("file").result(binding) end |
#json_value ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/xcov/model/source.rb', line 50 def json_value value = { "name" => @name, "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
46 47 48 |
# File 'lib/xcov/model/source.rb', line 46 def markdown_value "#{@name} | `#{@displayable_coverage}` | #{coverage_emoji}\n" end |
#print_description ⇒ Object
30 31 32 33 34 35 |
# File 'lib/xcov/model/source.rb', line 30 def print_description puts "\t\t#{@name} (#{@coverage})" @functions.each do |function| function.print_description end end |