Class: Teabag::Suite
- Inherits:
-
Object
- Object
- Teabag::Suite
- Defined in:
- lib/teabag/suite.rb
Instance Attribute Summary collapse
-
#config ⇒ Object
Returns the value of attribute config.
-
#name ⇒ Object
Returns the value of attribute name.
Class Method Summary collapse
Instance Method Summary collapse
- #core_javascripts ⇒ Object
- #helper ⇒ Object
- #include_spec?(file) ⇒ Boolean
- #include_spec_for?(file) ⇒ Boolean
-
#initialize(options = {}) ⇒ Suite
constructor
A new instance of Suite.
- #instrument_file?(file) ⇒ Boolean
- #javascripts ⇒ Object
- #link(params = {}) ⇒ Object
- #spec_files ⇒ Object
- #spec_javascripts ⇒ Object
- #stylesheets ⇒ Object
- #suites ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Suite
Returns a new instance of Suite.
19 20 21 22 23 |
# File 'lib/teabag/suite.rb', line 19 def initialize( = {}) @options = @name = (@options[:suite] || :default).to_s @config = suite_configuration end |
Instance Attribute Details
#config ⇒ Object
Returns the value of attribute config.
4 5 6 |
# File 'lib/teabag/suite.rb', line 4 def config @config end |
#name ⇒ Object
Returns the value of attribute name.
4 5 6 |
# File 'lib/teabag/suite.rb', line 4 def name @name end |
Class Method Details
.all ⇒ Object
6 7 8 |
# File 'lib/teabag/suite.rb', line 6 def self.all Teabag.configuration.suites.keys.map { |suite| Teabag::Suite.new(suite: suite) } end |
.resolve_spec_for(file) ⇒ Object
10 11 12 13 14 15 16 17 |
# File 'lib/teabag/suite.rb', line 10 def self.resolve_spec_for(file) suites = all suites.each do |suite| spec = suite.include_spec_for?(file) return {suite: suite.name, path: spec} if spec end false end |
Instance Method Details
#core_javascripts ⇒ Object
37 38 39 |
# File 'lib/teabag/suite.rb', line 37 def core_javascripts config.javascripts end |
#helper ⇒ Object
29 30 31 |
# File 'lib/teabag/suite.rb', line 29 def helper config.helper end |
#include_spec?(file) ⇒ Boolean
70 71 72 |
# File 'lib/teabag/suite.rb', line 70 def include_spec?(file) glob.include?(file) end |
#include_spec_for?(file) ⇒ Boolean
74 75 76 77 78 79 80 |
# File 'lib/teabag/suite.rb', line 74 def include_spec_for?(file) return file if glob.include?(file) glob.each do |spec| return spec if spec.include?(file) end false end |
#instrument_file?(file) ⇒ Boolean
58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/teabag/suite.rb', line 58 def instrument_file?(file) return false if include_spec?(file) for ignored in @config.no_coverage if ignored.is_a?(String) return false if File.basename(file) == ignored elsif ignored.is_a?(Regexp) return false if file =~ ignored end end true end |
#javascripts ⇒ Object
33 34 35 |
# File 'lib/teabag/suite.rb', line 33 def javascripts [core_javascripts, spec_javascripts].flatten end |
#link(params = {}) ⇒ Object
53 54 55 56 |
# File 'lib/teabag/suite.rb', line 53 def link(params = {}) query = "?#{params.to_query}" if params.present? [Teabag.configuration.mount_at, name, query].compact.join("/") end |
#spec_files ⇒ Object
49 50 51 |
# File 'lib/teabag/suite.rb', line 49 def spec_files glob.map { |file| {path: file, name: asset_from_file(file)} } end |
#spec_javascripts ⇒ Object
41 42 43 |
# File 'lib/teabag/suite.rb', line 41 def spec_javascripts [helper, specs].flatten end |
#stylesheets ⇒ Object
25 26 27 |
# File 'lib/teabag/suite.rb', line 25 def stylesheets config.stylesheets end |
#suites ⇒ Object
45 46 47 |
# File 'lib/teabag/suite.rb', line 45 def suites {all: Teabag.configuration.suites.keys, active: name} end |