Class: Whisperer::Generator

Inherits:
Object
  • Object
show all
Extended by:
Helpers
Defined in:
lib/whisperer/generator.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Helpers

add_builder

Constructor Details

#initialize(record, name) ⇒ Generator

Returns a new instance of Generator.



9
10
11
# File 'lib/whisperer/generator.rb', line 9

def initialize(record, name)
  @record, @name = record, name
end

Instance Attribute Details

#recordObject (readonly)

Returns the value of attribute record.



7
8
9
# File 'lib/whisperer/generator.rb', line 7

def record
  @record
end

Instance Method Details

#generateObject



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/whisperer/generator.rb', line 13

def generate
  Preprocessors.process!(record)

  interaction = Convertors::Interaction.convert(record)

  self.uniq_cassette!

  cassette = VCR::Cassette.new("#{record.sub_path}/#{@name}")
  cassette.record_http_interaction(
    interaction
  )

  cassette.eject

  File.read(path_to_cassette)
end