Class: CucumberMonitor::Definition

Inherits:
Object
  • Object
show all
Defined in:
lib/cucumber_monitor/definition.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(description, file, line) ⇒ Definition

Returns a new instance of Definition.



9
10
11
12
13
# File 'lib/cucumber_monitor/definition.rb', line 9

def initialize(description, file, line)
  @description = description
  @file = file
  @line = line
end

Instance Attribute Details

#descriptionObject

Returns the value of attribute description.



7
8
9
# File 'lib/cucumber_monitor/definition.rb', line 7

def description
  @description
end

#fileObject

Returns the value of attribute file.



7
8
9
# File 'lib/cucumber_monitor/definition.rb', line 7

def file
  @file
end

#lineObject

Returns the value of attribute line.



7
8
9
# File 'lib/cucumber_monitor/definition.rb', line 7

def line
  @line
end

Instance Method Details

#contentObject



40
41
42
# File 'lib/cucumber_monitor/definition.rb', line 40

def content
  raw_content.collect{|c| c.strip }
end

#core_contentObject



44
45
46
# File 'lib/cucumber_monitor/definition.rb', line 44

def core_content
  content[1..-2].collect{|c| c.strip }
end

#locationObject



48
49
50
# File 'lib/cucumber_monitor/definition.rb', line 48

def location
  "#{file.file}:#{line}"
end

#location_pathObject



52
53
54
# File 'lib/cucumber_monitor/definition.rb', line 52

def location_path
  "#{file.path}:#{line}"
end

#matcherObject



15
16
17
# File 'lib/cucumber_monitor/definition.rb', line 15

def matcher
  description.scan(/\/(.*)\//).flatten.first
end

#raw_contentObject



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/cucumber_monitor/definition.rb', line 19

def raw_content
  df = []
  started = false
  stopped = false
  record = false
  count = 0

  file.lines.each_with_index do |line, i|

    if line.include?(description)
      started = true
    end
    if started && !stopped
      df << line
      stopped = true if line.strip.match(/^end$/)
      count += 1
    end
  end
  df
end