Module: CucumberSlice::ListCore
- Included in:
- ListsFeatures
- Defined in:
- lib/cucumber_slice/lists_features.rb
Instance Method Summary collapse
- #any_dependencies_in_changeset?(dependencies, changeset) ⇒ Boolean
- #changed_files(git) ⇒ Object
- #dependencies_declared_in(feature_path) ⇒ Object
- #diff_files(git, since) ⇒ Object
- #expand_globs(patterns) ⇒ Object
- #expand_paths(paths) ⇒ Object
- #files_changed_since(rev) ⇒ Object
-
#find_up(dir, root_checked = false) ⇒ Object
file stuff.
- #format_feature_list(feature_list) ⇒ Object
-
#git_repo_path ⇒ Object
git stuff.
- #is_dir?(path) ⇒ Boolean
- #is_root?(path) ⇒ Boolean
-
#list_features_under(path) ⇒ Object
feature stuff.
Instance Method Details
#any_dependencies_in_changeset?(dependencies, changeset) ⇒ Boolean
39 40 41 |
# File 'lib/cucumber_slice/lists_features.rb', line 39 def any_dependencies_in_changeset?(dependencies, changeset) (dependencies & changeset).any? end |
#changed_files(git) ⇒ Object
83 84 85 |
# File 'lib/cucumber_slice/lists_features.rb', line 83 def changed_files(git) git.status.changed.map(&:first) end |
#dependencies_declared_in(feature_path) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/cucumber_slice/lists_features.rb', line 27 def dependencies_declared_in(feature_path) dependencies = nil File.open(feature_path) do |feature| dependencies = feature.each_line.map do |line| if match = line.match(/^#=\s*?depends_on (.*)$/) match[1] end end.compact end dependencies end |
#diff_files(git, since) ⇒ Object
79 80 81 |
# File 'lib/cucumber_slice/lists_features.rb', line 79 def diff_files(git, since) git.diff(since, "HEAD").map(&:path) end |
#expand_globs(patterns) ⇒ Object
57 58 59 60 61 |
# File 'lib/cucumber_slice/lists_features.rb', line 57 def (patterns) (patterns.map do |pattern| Dir.glob(File.join(git_repo_path, pattern)) end.flatten).compact.uniq end |
#expand_paths(paths) ⇒ Object
63 64 65 |
# File 'lib/cucumber_slice/lists_features.rb', line 63 def (paths) paths.map {|path| File.(path) } end |
#files_changed_since(rev) ⇒ Object
72 73 74 75 76 77 |
# File 'lib/cucumber_slice/lists_features.rb', line 72 def files_changed_since(rev) git = Git.open(git_repo_path) changed_files = diff_files(git, rev) + changed_files(git) (changed_files.map {|p| File.join(git_repo_path, p)}).uniq end |
#find_up(dir, root_checked = false) ⇒ Object
file stuff
44 45 46 47 |
# File 'lib/cucumber_slice/lists_features.rb', line 44 def find_up(dir, root_checked = false) raise "No git repository found at or above `#{Dir.pwd}`!" if root_checked is_dir?(File.join(dir, ".git")) ? dir : find_up(File.join(dir,'..'), is_root?(dir)) end |
#format_feature_list(feature_list) ⇒ Object
16 17 18 19 20 21 22 23 24 25 |
# File 'lib/cucumber_slice/lists_features.rb', line 16 def format_feature_list(feature_list) if feature_list.empty? #point to an empty file to insist cucumber not run anything. # cucumber's default behavior is to run everything when it's passed nothing. # Super hacky stuff. File.(File.join(File.dirname(__FILE__), "empty_file")) else feature_list.join(" ") end end |
#git_repo_path ⇒ Object
git stuff
68 69 70 |
# File 'lib/cucumber_slice/lists_features.rb', line 68 def git_repo_path File.(find_up(Dir.pwd)) end |
#is_dir?(path) ⇒ Boolean
49 50 51 |
# File 'lib/cucumber_slice/lists_features.rb', line 49 def is_dir?(path) File.exist?(path) && File.ftype(path) == "directory" end |
#is_root?(path) ⇒ Boolean
53 54 55 |
# File 'lib/cucumber_slice/lists_features.rb', line 53 def is_root?(path) File.(path) == "/" end |
#list_features_under(path) ⇒ Object
feature stuff
6 7 8 9 10 11 12 13 14 |
# File 'lib/cucumber_slice/lists_features.rb', line 6 def list_features_under(path) glob = if path.include?('*') path else File.join(path, "**/*.feature") end Dir.glob(File.join(git_repo_path, glob)) end |