class DVR::Episode
Attributes
content[R]
Public Class Methods
batch_record(contents)
click to toggle source
# File lib/dvr/episode.rb, line 5 def self.batch_record contents contents.map {|c| record(c)} end
new(content)
click to toggle source
# File lib/dvr/episode.rb, line 13 def initialize content @content = content end
record(content)
click to toggle source
# File lib/dvr/episode.rb, line 9 def self.record content new(content) end
Public Instance Methods
build_request_path(req)
click to toggle source
# File lib/dvr/episode.rb, line 37 def build_request_path req path = ['POST', 'PATCH', 'DELETE'].include?(req['request_method']) ? "/#{req['request_path']}" : req['request_path'] path.gsub('?', '/') end
build_response(req)
click to toggle source
# File lib/dvr/episode.rb, line 42 def build_response req OpenStruct.new( :status_code => req['response_status'], :status_text => req['response_status_text'], :body => req['response_body'], :content_type => req['response_content_type'], :headers => req['response_headers'] ) end
data()
click to toggle source
# File lib/dvr/episode.rb, line 33 def data content.fetch('requests') end
play()
click to toggle source
# File lib/dvr/episode.rb, line 17 def play translate.map do |e| "#{e[:method]} '#{e[:path]}' do\n\tstatus #{e[:response].status_code}\n\tbody '#{e[:response].body}'\nend" end.join end
translate()
click to toggle source
# File lib/dvr/episode.rb, line 23 def translate data.map do |req| { :method => req['request_method'].downcase, :path => build_request_path(req), :response => build_response(req) } end end