Class: CassetteRack::Drawer
- Inherits:
-
Object
- Object
- CassetteRack::Drawer
- Defined in:
- lib/cassette-rack/drawer.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #cassette ⇒ Object
- #delete ⇒ Object
- #exist? ⇒ Boolean
- #http ⇒ Object
-
#initialize(name, options = {}) ⇒ Drawer
constructor
A new instance of Drawer.
- #pull ⇒ Object
- #render ⇒ Object
Constructor Details
#initialize(name, options = {}) ⇒ Drawer
Returns a new instance of Drawer.
10 11 12 |
# File 'lib/cassette-rack/drawer.rb', line 10 def initialize(name, ={}) @name = name end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
8 9 10 |
# File 'lib/cassette-rack/drawer.rb', line 8 def name @name end |
Instance Method Details
#cassette ⇒ Object
14 15 16 |
# File 'lib/cassette-rack/drawer.rb', line 14 def cassette @cassette ||= VCR::Cassette.new(name) end |
#delete ⇒ Object
22 23 24 |
# File 'lib/cassette-rack/drawer.rb', line 22 def delete File.delete cassette.file if self.exist? end |
#exist? ⇒ Boolean
26 27 28 |
# File 'lib/cassette-rack/drawer.rb', line 26 def exist? File.exist?(cassette.file) end |
#http ⇒ Object
38 39 40 |
# File 'lib/cassette-rack/drawer.rb', line 38 def http cassette.http_interactions.interactions.last end |
#pull ⇒ Object
30 31 32 33 34 35 36 |
# File 'lib/cassette-rack/drawer.rb', line 30 def pull request = CassetteRack::Decorator::Request.new(http.request) response = CassetteRack::Decorator::Response.new(http.response) template = Liquid::Template.parse(CassetteRack::Configure.content_template) template.render('title' => name, 'request' => request, 'response' => response) end |
#render ⇒ Object
18 19 20 |
# File 'lib/cassette-rack/drawer.rb', line 18 def render Kramdown::Document.new(self.pull).to_html end |