Class: Gherkin::Stream::SourceEvents

Inherits:
Object
  • Object
show all
Defined in:
lib/gherkin/stream/source_events.rb

Instance Method Summary collapse

Constructor Details

#initialize(paths) ⇒ SourceEvents

Returns a new instance of SourceEvents.



4
5
6
# File 'lib/gherkin/stream/source_events.rb', line 4

def initialize(paths)
  @paths = paths
end

Instance Method Details

#enumObject



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/gherkin/stream/source_events.rb', line 8

def enum
  Enumerator.new do |y|
    @paths.each do |path|
      event = {
        type: 'source',
        uri: path,
        data: File.open(path, 'r:UTF-8', &:read),
        media: {
          encoding: 'utf-8',
          type: 'text/x.cucumber.gherkin+plain'
        }
      }
      y.yield(event)
    end
  end
end