class Cellophane::Parser
Public Class Methods
new(options)
click to toggle source
# File lib/cellophane/parser.rb, line 3 def initialize(options) @options = options end
Public Instance Methods
features()
click to toggle source
# File lib/cellophane/parser.rb, line 7 def features # if no pattern is specified, let cucumber run 'em all return [] if @options[:pattern].nil? collected_features = @options[:regexp] ? collect_features_by_regexp : collect_features_by_glob return collected_features.any? ? collected_features : nil end
Private Instance Methods
collect_features_by_glob()
click to toggle source
# File lib/cellophane/parser.rb, line 99 def collect_features_by_glob only = [] except = [] features_to_include = [] features_to_exclude = [] pattern = @options[:pattern].dup # want to run certain ones and/or exclude certain ones pattern.split(',').each do |f| if f[0].chr == '~' except << f[1..f.length] else only << f end end # if we have an exception, we want to get all features by default pattern = '**/*' if except.any? # unless we specifically say we want only certain ones pattern = nil if only.any? if only.any? only.each do |f| features_to_include += Dir.glob("#{@options[:feature_path]}/#{f}.feature") end else features_to_include += Dir.glob("#{@options[:feature_path]}/#{pattern}.feature") end if except.any? except.each do |f| features_to_exclude = Dir.glob("#{@options[:feature_path]}/#{f}.feature") end end (features_to_include - features_to_exclude).uniq end
collect_features_by_regexp()
click to toggle source
# File lib/cellophane/parser.rb, line 87 def collect_features_by_regexp features = [] # start by globbing all feature files Dir.glob("#{@options[:feature_path]}/**/*.feature").each do |feature_file| # keep the ones that match the regexp features << feature_file if @options[:pattern].match(feature_file) end features.uniq end