class CucumberFeatureManager
TODO refactor, use repo full_path and feature not full path
Attributes
info[R]
Public Instance Methods
aggregate()
click to toggle source
# File lib/cucumber_feature_manager.rb, line 52 def aggregate unless patterns_for_aggregator.empty? @raport ||= CucumberFM::Aggregator.new(self, patterns_for_aggregator).collection end end
commit_change_on(feature)
click to toggle source
# File lib/cucumber_feature_manager.rb, line 62 def commit_change_on(feature) # use info to notify user # @info = 'aaaa' add_to_index(feature) repo.commit_index("spec-update: #{feature.filename}") end
config()
click to toggle source
# File lib/cucumber_feature_manager.rb, line 44 def config @config ||= CucumberFM::Config.new((config_parameters || {})) end
features()
click to toggle source
# File lib/cucumber_feature_manager.rb, line 36 def features @features ||= scan_features end
filter()
click to toggle source
# File lib/cucumber_feature_manager.rb, line 48 def filter @filter ||= CucumberFM::TagFilter.new(config.tags) end
prefix()
click to toggle source
# File lib/cucumber_feature_manager.rb, line 58 def prefix config.dir.empty? ? path : File.join(path, config.dir) end
remove_file_from_repo(relative_path)
click to toggle source
# File lib/cucumber_feature_manager.rb, line 69 def remove_file_from_repo(relative_path) `cd #{repo_path} && git rm #{relative_path}` end
scenarios()
click to toggle source
# File lib/cucumber_feature_manager.rb, line 40 def scenarios (features.collect { |feature| feature.scenarios }).flatten end
send_to_remote()
click to toggle source
# File lib/cucumber_feature_manager.rb, line 73 def send_to_remote push_to_remote end
Private Instance Methods
add_to_index(feature)
click to toggle source
# File lib/cucumber_feature_manager.rb, line 79 def add_to_index(feature) # WTF - why this is not works # repo.add(feature.path) `cd #{repo_path} && git add #{feature.path}` end
all_features()
click to toggle source
# File lib/cucumber_feature_manager.rb, line 107 def all_features @all_features ||= scan_all_features end
capistrano_branch_name()
click to toggle source
# File lib/cucumber_feature_manager.rb, line 144 def capistrano_branch_name "stories_#{timestamp_capistrano}" if timestamp_capistrano end
git()
click to toggle source
# File lib/cucumber_feature_manager.rb, line 128 def git repo.git end
last_stories_branch_name()
click to toggle source
# File lib/cucumber_feature_manager.rb, line 140 def last_stories_branch_name repo.remotes.map(& :name).collect { |name| /stories_\d+/.match(name) }.compact.map(& :to_s).sort.last end
new_branch_name()
click to toggle source
# File lib/cucumber_feature_manager.rb, line 155 def new_branch_name "stories_#{Time.now.strftime('%Y%m%d%H%M%S')}" end
patterns_for_aggregator()
click to toggle source
# File lib/cucumber_feature_manager.rb, line 159 def patterns_for_aggregator config.aggregate.map { |label| CucumberFM::FeatureElement::Component::Tags::PATTERN[label.to_sym] unless label.blank? }.compact end
push_to_remote()
click to toggle source
TODO cleanup
# File lib/cucumber_feature_manager.rb, line 86 def push_to_remote # WTF - why this is not works # git.push({}, repo_remote_name, "#{repo_current_branch}:#{repo_remote_branch_name}") if capistrano_branch_name `cd #{repo_path} && git push #{repo_remote_name} #{repo_current_branch}:#{capistrano_branch_name}` elsif last_stories_branch_name begin response = `cd #{repo_path} && git push #{repo_remote_name} #{repo_current_branch}:#{last_stories_branch_name}` throw :not_fast_forward if response =~ /non\-fast\-forward/ rescue => e `cd #{repo_path} && git push #{repo_remote_name} #{repo_current_branch}:#{new_branch_name}` end else `cd #{repo_path} && git push #{repo_remote_name} #{repo_current_branch}:#{new_branch_name}` end end
repo()
click to toggle source
# File lib/cucumber_feature_manager.rb, line 124 def repo @repo ||= Repo.new(repo_path) end
repo_current_branch()
click to toggle source
# File lib/cucumber_feature_manager.rb, line 132 def repo_current_branch repo.head.name end
repo_relative_path(path)
click to toggle source
# File lib/cucumber_feature_manager.rb, line 120 def repo_relative_path(path) path.gsub(repo_path, '').gsub(/^\//, '') end
repo_remote_name()
click to toggle source
# File lib/cucumber_feature_manager.rb, line 136 def repo_remote_name repo.remote_list.first end
scan_all_features()
click to toggle source
# File lib/cucumber_feature_manager.rb, line 111 def scan_all_features features = [] Dir.glob("#{prefix}/**/*.feature").each do |full_path| feature = CucumberFM::Feature.new(full_path, self) features.push(feature) end features end
scan_features()
click to toggle source
# File lib/cucumber_feature_manager.rb, line 103 def scan_features all_features.collect { |feature| feature if filter.pass?(feature.tags_all)}.compact end
timestamp_capistrano()
click to toggle source
# File lib/cucumber_feature_manager.rb, line 148 def timestamp_capistrano pattern = /\d{14}$/ if defined?(Rails) pattern.match(Rails.root.to_s) end end