class CucumberFM::Feature

Public Instance Methods

<=>(_f) click to toggle source
# File lib/cucumber_f_m/feature.rb, line 63
def <=>(_f)
  info.title <=> _f.info.title
end
background() click to toggle source
# File lib/cucumber_f_m/feature.rb, line 26
def background
  @background ||= FeatureElement::Background.new(self, scan_for_background_from_raw)
end
destroy() click to toggle source
# File lib/cucumber_f_m/feature.rb, line 49
def destroy
  File.delete(path)
  remove_file_from_repo
  push
end
filename() click to toggle source
# File lib/cucumber_f_m/feature.rb, line 55
def filename
  File.basename(path)
end
filename_without_extension() click to toggle source
# File lib/cucumber_f_m/feature.rb, line 59
def filename_without_extension
  File.basename(path, '.feature')
end
id() click to toggle source
# File lib/cucumber_f_m/feature.rb, line 6
def id
  Base64.encode64(relative_path)
end
info() click to toggle source
# File lib/cucumber_f_m/feature.rb, line 22
def info
  @info ||= FeatureElement::Info.new(self, scan_for_feature_info_from_raw)
end
raw() click to toggle source
# File lib/cucumber_f_m/feature.rb, line 14
def raw
  @raw ||= read_content_from_file
end
raw=(content) click to toggle source
# File lib/cucumber_f_m/feature.rb, line 18
def raw= content
  @raw = content
end
relative_path() click to toggle source
# File lib/cucumber_f_m/feature.rb, line 10
def relative_path
  path.gsub(/^#{cfm.path}\//, '')
end
save() click to toggle source
# File lib/cucumber_f_m/feature.rb, line 42
def save
  write_content_to_file
  commit
  push
  true
end
scenarios() click to toggle source
# File lib/cucumber_f_m/feature.rb, line 30
def scenarios
  @scenarios ||= fetch_scenarios
end
tags() click to toggle source
# File lib/cucumber_f_m/feature.rb, line 34
def tags
  info.tags
end
tags_all() click to toggle source
# File lib/cucumber_f_m/feature.rb, line 38
def tags_all
  scenarios.collect{|scenario| scenario.tags }.flatten.uniq
end

Private Instance Methods

commit() click to toggle source

TODO we need to detect it in more clever way

# File lib/cucumber_f_m/feature.rb, line 79
def commit
  cfm.commit_change_on(self) if do_commit?
end
do_commit?() click to toggle source
# File lib/cucumber_f_m/feature.rb, line 96
def do_commit?
  cfm && cfm.respond_to?(:commit_change_on) && cfm.config.cvs_commit=='1'
end
do_push?() click to toggle source
# File lib/cucumber_f_m/feature.rb, line 92
def do_push?
  cfm && cfm.respond_to?(:send_to_remote) && cfm.config.cvs_commit=='1' && cfm.config.cvs_push=='1'
end
fetch_scenarios() click to toggle source
# File lib/cucumber_f_m/feature.rb, line 100
def fetch_scenarios
  scenarios = []
  text = raw
  while match = scan_for_scenarios_and_scenario_outline_from(text)
    scenario = case match[0]
      when FeatureElement::Scenario::PATTERN
        FeatureElement::Scenario.new(self, match[0])
      when FeatureElement::ScenarioOutline::PATTERN
        FeatureElement::ScenarioOutline.new(self, match[0])
    end
    scenarios.push(scenario) if cfm.filter.pass?(scenario.tags)
    text = match.post_match
  end
  scenarios
end
push() click to toggle source

TODO we need to detect it in more clever way

# File lib/cucumber_f_m/feature.rb, line 84
def push
  cfm.send_to_remote if do_push?
end
read_content_from_file() click to toggle source
# File lib/cucumber_f_m/feature.rb, line 69
def read_content_from_file
  File.open(path, 'r') { |stream| stream.read }
end
remove_file_from_repo() click to toggle source
# File lib/cucumber_f_m/feature.rb, line 88
def remove_file_from_repo
  cfm.remove_file_from_repo(relative_path) if do_commit?
end
scan_for_background_from_raw() click to toggle source
# File lib/cucumber_f_m/feature.rb, line 124
def scan_for_background_from_raw
  if match = FeatureElement::Background::PATTERN.match(raw)
    match[0]
  else
    ''
  end
end
scan_for_feature_info_from_raw() click to toggle source
# File lib/cucumber_f_m/feature.rb, line 116
def scan_for_feature_info_from_raw
  if match = FeatureElement::Info::PATTERN.match(raw)
    match[0]
  else
    ''
  end
end
scan_for_scenarios_and_scenario_outline_from(string) click to toggle source
# File lib/cucumber_f_m/feature.rb, line 132
def scan_for_scenarios_and_scenario_outline_from(string)
  scenario_or_scenario_outline.match(string)
end
scenario_or_scenario_outline() click to toggle source
# File lib/cucumber_f_m/feature.rb, line 136
def scenario_or_scenario_outline
  Regexp.union(FeatureElement::Scenario::PATTERN,
               FeatureElement::ScenarioOutline::PATTERN)
end
write_content_to_file() click to toggle source
# File lib/cucumber_f_m/feature.rb, line 73
def write_content_to_file
  File.open(path, 'w') { |stream| stream.write raw }
end