Skip to content

Commit

Permalink
Refactoring.
Browse files Browse the repository at this point in the history
Put all of the filtering logic in one place and relocated several
'include' commands so that they are in the classes that actually use
the functionality that is mixed in by the inclusion.
  • Loading branch information
enkessler committed Jul 6, 2015
1 parent cb597ad commit ba506c8
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
10 changes: 3 additions & 7 deletions lib/cuke_slicer/extractors/file_extractor.rb
Original file line number Diff line number Diff line change
@@ -1,24 +1,20 @@
require "cuke_slicer/helpers/extraction_helpers"
require "cuke_slicer/helpers/filter_helpers"
require "cuke_slicer/helpers/matching_helpers"
require "cuke_slicer/helpers/filter_helpers"
require "cuke_slicer/helpers/extraction_helpers"


module CukeSlicer
class FileExtractor

include ExtractionHelpers
include FilterHelpers
include MatchingHelpers


def extract(target, filters, format, &block)
Array.new.tap do |test_cases|
unless target.feature.nil?
tests = target.feature.tests

runnable_elements = extract_runnable_elements(extract_runnable_block_elements(tests, filters))

apply_custom_filter(runnable_elements, &block)
runnable_elements = extract_runnable_elements(extract_runnable_block_elements(tests, filters, &block))

runnable_elements.each do |element|
case
Expand Down
7 changes: 6 additions & 1 deletion lib/cuke_slicer/helpers/extraction_helpers.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
module CukeSlicer
module ExtractionHelpers

def extract_runnable_block_elements(things, filters)
include FilterHelpers


def extract_runnable_block_elements(things, filters, &block)
Array.new.tap do |elements|
things.each do |thing|
if thing.is_a?(CukeModeler::Outline)
Expand All @@ -15,6 +18,8 @@ def extract_runnable_block_elements(things, filters)
filter_included_paths(elements, filters[:included_paths])
filter_excluded_tags(elements, filters[:excluded_tags])
filter_included_tags(elements, filters[:included_tags])

apply_custom_filter(elements, &block)
end
end

Expand Down
3 changes: 3 additions & 0 deletions lib/cuke_slicer/helpers/filter_helpers.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
module CukeSlicer
module FilterHelpers

include MatchingHelpers


def apply_custom_filter(elements, &block)
if block
elements.reject! do |element|
Expand Down

0 comments on commit ba506c8

Please sign in to comment.