Permalink
Browse files

Block format headers in YAML. Fixes #13

  • Loading branch information...
1 parent ca04553 commit 18838351e7b40032761ea2bbe14f59978f6066c9 Rob Fletcher committed Aug 24, 2011
@@ -18,17 +18,23 @@ package betamax.storage.yaml
import groovy.util.logging.Log4j
import org.codehaus.groovy.runtime.typehandling.GroovyCastException
-import org.yaml.snakeyaml.Yaml
+import org.yaml.snakeyaml.DumperOptions.FlowStyle
import betamax.encoding.*
import betamax.storage.*
import org.apache.http.*
import static org.apache.http.HttpHeaders.CONTENT_ENCODING
import org.apache.http.entity.*
import org.apache.http.message.*
+import org.yaml.snakeyaml.*
@Log4j
class YamlTapeLoader extends AbstractTapeLoader {
+ /**
+ * Options controlling the style of the YAML written out.
+ */
+ DumperOptions dumperOptions = new DumperOptions(defaultFlowStyle: FlowStyle.BLOCK)
+
String getFileExtension() {
"yaml"
}
@@ -44,7 +50,7 @@ class YamlTapeLoader extends AbstractTapeLoader {
void writeTape(Tape tape, Writer writer) {
def map = [tape: [name: tape.name, interactions: data(tape.interactions)]]
- def yaml = new Yaml()
+ def yaml = new Yaml(dumperOptions)
yaml.dump(map, writer)
}
@@ -6,12 +6,21 @@ tape:
protocol: HTTP/1.1
method: GET
uri: http://grails.org/
- headers: {Accept: '*/*', Host: grails.org, Proxy-Connection: Keep-Alive, Accept-Encoding: 'gzip,deflate'}
+ headers:
+ Accept: '*/*'
+ Host: grails.org
+ Proxy-Connection: Keep-Alive
+ Accept-Encoding: gzip,deflate
response:
protocol: HTTP/1.1
status: 200
- headers: {Date: 'Wed, 24 Aug 2011 22:42:43 GMT', Server: Apache/2.2.3 (Red Hat),
- Content-Language: en-US, Vary: Accept-Encoding, Content-Encoding: gzip, Content-Type: text/html;charset=UTF-8}
+ headers:
+ Date: Wed, 24 Aug 2011 22:42:43 GMT
+ Server: Apache/2.2.3 (Red Hat)
+ Content-Language: en-US
+ Vary: Accept-Encoding
+ Content-Encoding: gzip
+ Content-Type: text/html;charset=UTF-8
body: "<!DOCTYPE html>\n<!--[if lt IE 7 ]> <html class=\"ie6\"> <![endif]-->\n\
<!--[if IE 7 ]> <html class=\"ie7\"> <![endif]-->\n<!--[if IE 8 ]> <html\
\ class=\"ie8\"> <![endif]-->\n<!--[if IE 9 ]> <html class=\"ie9\"> <![endif]-->\n\
@@ -230,20 +239,37 @@ tape:
protocol: HTTP/1.1
method: GET
uri: http://api.twitter.com/1/statuses/public_timeline.json?count=3&include_entities=true
- headers: {Accept: '*/*', Host: api.twitter.com, Proxy-Connection: Keep-Alive,
- Accept-Encoding: 'gzip,deflate'}
+ headers:
+ Accept: '*/*'
+ Host: api.twitter.com
+ Proxy-Connection: Keep-Alive
+ Accept-Encoding: gzip,deflate
response:
protocol: HTTP/1.1
status: 200
- headers: {Date: 'Wed, 24 Aug 2011 22:42:44 GMT', Server: hi, Status: 200 OK,
- X-Transaction: 1314225764-30587-52999, X-RateLimit-Limit: '150', ETag: '"b703f20bd8fd9f5a0730777d0ed96931"-gzip',
- X-Frame-Options: SAMEORIGIN, Last-Modified: 'Wed, 24 Aug 2011 22:42:44 GMT',
- X-RateLimit-Remaining: '149', X-Runtime: '0.04640', X-Transaction-Mask: a6183ffa5f8ca943ff1b53b5644ef1141bbf1a1b,
- Content-Type: application/json; charset=utf-8, Pragma: no-cache, X-RateLimit-Class: api,
- X-Revision: DEV, Expires: 'Tue, 31 Mar 1981 05:00:00 GMT', Cache-Control: 'no-cache,
- no-store, must-revalidate, pre-check=0, post-check=0', X-MID: cf74ad3a2586a67624219a8e4b3353d08e4e19d7,
- X-RateLimit-Reset: '1314229364', Set-Cookie: _twitter_sess=BAh7CDoPY3JlYXRlZF9hdGwrCJK49f0xAToHaWQiJTU1MjQ5OTJiNTk3NWQx%250AMTJiMTk4MGY5YmU1NTg3MDljIgpmbGFzaElDOidBY3Rpb25Db250cm9sbGVy%250AOjpGbGFzaDo6Rmxhc2hIYXNoewAGOgpAdXNlZHsA--b588f0c2604d425bd57c0c2d9ca3eb8657dc06a6; domain=.twitter.com; path=/; HttpOnly,
- Vary: Accept-Encoding, Content-Encoding: gzip}
+ headers:
+ Date: Wed, 24 Aug 2011 22:42:44 GMT
+ Server: hi
+ Status: 200 OK
+ X-Transaction: 1314225764-30587-52999
+ X-RateLimit-Limit: '150'
+ ETag: '"b703f20bd8fd9f5a0730777d0ed96931"-gzip'
+ X-Frame-Options: SAMEORIGIN
+ Last-Modified: Wed, 24 Aug 2011 22:42:44 GMT
+ X-RateLimit-Remaining: '149'
+ X-Runtime: '0.04640'
+ X-Transaction-Mask: a6183ffa5f8ca943ff1b53b5644ef1141bbf1a1b
+ Content-Type: application/json; charset=utf-8
+ Pragma: no-cache
+ X-RateLimit-Class: api
+ X-Revision: DEV
+ Expires: Tue, 31 Mar 1981 05:00:00 GMT
+ Cache-Control: no-cache, no-store, must-revalidate, pre-check=0, post-check=0
+ X-MID: cf74ad3a2586a67624219a8e4b3353d08e4e19d7
+ X-RateLimit-Reset: '1314229364'
+ Set-Cookie: _twitter_sess=BAh7CDoPY3JlYXRlZF9hdGwrCJK49f0xAToHaWQiJTU1MjQ5OTJiNTk3NWQx%250AMTJiMTk4MGY5YmU1NTg3MDljIgpmbGFzaElDOidBY3Rpb25Db250cm9sbGVy%250AOjpGbGFzaDo6Rmxhc2hIYXNoewAGOgpAdXNlZHsA--b588f0c2604d425bd57c0c2d9ca3eb8657dc06a6; domain=.twitter.com; path=/; HttpOnly
+ Vary: Accept-Encoding
+ Content-Encoding: gzip
body: '[{"in_reply_to_status_id_str":null,"possibly_sensitive":false,"in_reply_to_screen_name":null,"in_reply_to_user_id_str":null,"contributors":null,"retweeted":false,"in_reply_to_user_id":null,"retweet_count":0,"user":{"default_profile":true,"show_all_inline_media":false,"verified":false,"geo_enabled":false,"profile_link_color":"0084B4","protected":false,"location":"Monroe,
La.","notifications":false,"friends_count":433,"profile_sidebar_border_color":"C0DEED","followers_count":1432,"name":"Sermon
Ideas","default_profile_image":false,"contributors_enabled":false,"time_zone":"Central
@@ -401,16 +427,24 @@ tape:
protocol: HTTP/1.1
method: GET
uri: http://feeds.feedburner.com/wondermark
- headers: {Accept: '*/*', Host: feeds.feedburner.com, Proxy-Connection: Keep-Alive,
- Accept-Encoding: 'gzip,deflate'}
+ headers:
+ Accept: '*/*'
+ Host: feeds.feedburner.com
+ Proxy-Connection: Keep-Alive
+ Accept-Encoding: gzip,deflate
response:
protocol: HTTP/1.1
status: 200
- headers: {Content-Type: text/xml; charset=UTF-8, ETag: Zszm705gNlvGRNatA1gBAvZUiWc,
- Last-Modified: 'Wed, 24 Aug 2011 22:25:53 GMT', Date: 'Wed, 24 Aug 2011 22:42:45
- GMT', Expires: 'Wed, 24 Aug 2011 22:42:45 GMT', Cache-Control: 'private,
- max-age=0', X-Content-Type-Options: nosniff, X-XSS-Protection: 1; mode=block,
- Server: GSE}
+ headers:
+ Content-Type: text/xml; charset=UTF-8
+ ETag: Zszm705gNlvGRNatA1gBAvZUiWc
+ Last-Modified: Wed, 24 Aug 2011 22:25:53 GMT
+ Date: Wed, 24 Aug 2011 22:42:45 GMT
+ Expires: Wed, 24 Aug 2011 22:42:45 GMT
+ Cache-Control: private, max-age=0
+ X-Content-Type-Options: nosniff
+ X-XSS-Protection: 1; mode=block
+ Server: GSE
body: "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n<?xml-stylesheet type=\"\
text/xsl\" media=\"screen\" href=\"/~d/styles/rss2full.xsl\"?><?xml-stylesheet\
\ type=\"text/css\" media=\"screen\" href=\"http://feeds.feedburner.com/~d/styles/itemcontent.css\"\

0 comments on commit 1883835

Please sign in to comment.