Class: RailChaser::ExampleCollection
- Inherits:
-
Object
- Object
- RailChaser::ExampleCollection
- Defined in:
- lib/rail_chaser/example_collection.rb
Instance Attribute Summary collapse
-
#examples ⇒ Object
Returns the value of attribute examples.
-
#options ⇒ Object
Returns the value of attribute options.
Instance Method Summary collapse
- #add_class?(file, classes) ⇒ Boolean
- #add_example(file) ⇒ Object
- #classes ⇒ Object
- #each_spec_and_classes ⇒ Object
- #gem?(file) ⇒ Boolean
- #gem_path_pattern ⇒ Object
-
#initialize(options = {}) ⇒ ExampleCollection
constructor
A new instance of ExampleCollection.
- #ruby_core?(file) ⇒ Boolean
- #spec?(file) ⇒ Boolean
Constructor Details
#initialize(options = {}) ⇒ ExampleCollection
Returns a new instance of ExampleCollection.
5 6 7 8 |
# File 'lib/rail_chaser/example_collection.rb', line 5 def initialize(={}) @examples = Hash.new { |h, spec| h[spec] = [] } @options = end |
Instance Attribute Details
#examples ⇒ Object
Returns the value of attribute examples.
3 4 5 |
# File 'lib/rail_chaser/example_collection.rb', line 3 def examples @examples end |
#options ⇒ Object
Returns the value of attribute options.
3 4 5 |
# File 'lib/rail_chaser/example_collection.rb', line 3 def @options end |
Instance Method Details
#add_class?(file, classes) ⇒ Boolean
26 27 28 29 30 31 32 |
# File 'lib/rail_chaser/example_collection.rb', line 26 def add_class?(file, classes) return false if @options[:skip_spec] && spec?(file) return false if @options[:skip_gem] && gem?(file) return false if @options[:skip_ruby_core] && ruby_core?(file) return false if classes.include?(file) return true end |
#add_example(file) ⇒ Object
34 35 36 37 38 39 40 41 |
# File 'lib/rail_chaser/example_collection.rb', line 34 def add_example(file) @spec = file if spec?(file) if @spec classes = @examples[@spec] classes << file if add_class?(file, classes) end end |
#classes ⇒ Object
51 52 53 |
# File 'lib/rail_chaser/example_collection.rb', line 51 def classes @examples.values.flatten.uniq end |
#each_spec_and_classes ⇒ Object
43 44 45 46 47 48 49 |
# File 'lib/rail_chaser/example_collection.rb', line 43 def each_spec_and_classes if block_given? @examples.each_pair do |spec, classes| yield spec, classes end end end |
#gem?(file) ⇒ Boolean
14 15 16 |
# File 'lib/rail_chaser/example_collection.rb', line 14 def gem?(file) file =~ gem_path_pattern end |
#gem_path_pattern ⇒ Object
10 11 12 |
# File 'lib/rail_chaser/example_collection.rb', line 10 def gem_path_pattern @gem_path_pattern ||= Regexp.compile ENV['GEM_HOME'].gsub(':', '|') end |
#ruby_core?(file) ⇒ Boolean
18 19 20 |
# File 'lib/rail_chaser/example_collection.rb', line 18 def ruby_core?(file) file =~ /#{ENV['MY_RUBY_HOME']}/ end |
#spec?(file) ⇒ Boolean
22 23 24 |
# File 'lib/rail_chaser/example_collection.rb', line 22 def spec?(file) file =~ /\/spec\// end |