Skip to content

Instantly share code, notes, and snippets.

@mrchrisadams
Created August 17, 2009 16:23

Revisions

  1. chris-d-adams revised this gist Aug 17, 2009. 1 changed file with 18 additions and 0 deletions.
    18 changes: 18 additions & 0 deletions what-i-get.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,18 @@
    ### I'm trying to output as yaml. I can do this with rails fine. Does Rails add loads of new methods?

    >> require 'hpricot'
    => true
    >> b = Hpricot.XML(open('blogs.xml'))
    >> y b
    NoMethodError: undefined method `yaml_tag_subclasses?' for Hpricot::Doc:Class
    from /usr/local/lib/ruby/1.8/yaml/tag.rb:69:in `taguri'
    from /usr/local/lib/ruby/1.8/yaml/rubytypes.rb:16:in `to_yaml'
    from /usr/local/lib/ruby/1.8/yaml.rb:391:in `call'
    from /usr/local/lib/ruby/1.8/yaml.rb:391:in `emit'
    from /usr/local/lib/ruby/1.8/yaml.rb:391:in `quick_emit'
    from /usr/local/lib/ruby/1.8/yaml/rubytypes.rb:15:in `to_yaml'
    from /usr/local/lib/ruby/1.8/yaml.rb:117:in `dump'
    from /usr/local/lib/ruby/1.8/yaml.rb:432:in `y'
    from (irb):6
    from :0
    >>
  2. chris-d-adams revised this gist Aug 17, 2009. 1 changed file with 40 additions and 17 deletions.
    57 changes: 40 additions & 17 deletions what-i-want.yaml
    Original file line number Diff line number Diff line change
    @@ -1,17 +1,40 @@
    - &page-4
    id: 3
    title: Shopping Cart
    handle: shopping-cart
    url: /pages/shopping-cart
    author: Tobi
    content: "<ul><li>Your order is safe with us. Our checkout uses industry standard security to protect your information.</li><li>Your order will be billed immediately upon checkout.</li><li><b>ALL SALES ARE FINAL:</b> Defective or damaged product will be exchanged</li><li>All orders are processed expediently: usually in under 24 hours.</li></ul>"
    created_at: 2005-04-04 12:00

    - &page-5
    id: 4
    title: Shipping and Handling
    handle: shipping
    url: /pages/shipping
    author: Tobi
    content: <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
    created_at: 2005-04-04 12:00
    - id: 2
    handle: bigcheese-blog
    title: Bigcheese blog
    url: /blogs/bigcheese-blog
    articles:
    - id: 1
    title: 'One thing you probably did not know yet...'
    author: Justin
    content: Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
    created_at: 2005-04-04 16:00
    comments:
    -
    id: 1
    author: John Smith
    email: john@smith.com
    content: Wow...great article man.
    status: published
    created_at: 2009-01-01 12:00
    updated_at: 2009-02-01 12:00
    url: ""
    -
    id: 2
    author: John Jones
    email: john@jones.com
    content: I really enjoyed this article. And I love your shop! It's awesome. Shopify rocks!
    status: published
    created_at: 2009-03-01 12:00
    updated_at: 2009-02-01 12:00
    url: "http://somesite.com/"
    - id: 2
    title: Fascinating
    author: Tobi
    content: Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
    created_at: 2005-04-06 12:00
    comments:
    articles_count: 2
    comments_enabled?: true
    comment_post_url: ""
    comments_count: 2
    moderated?: true
  3. chris-d-adams created this gist Aug 17, 2009.
    17 changes: 17 additions & 0 deletions what-i-have.xml
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,17 @@
    #not the same, but indicative of what it looks like

    <article>
    <author>Rouska Mellor</author>
    <blog-id type="integer">273932</blog-id>
    <body>Worn Again are hiring for a new Sales Director.

    To view the full job description and details of how to apply click &quot;here&quot;:http://antiapathy.org/?page_id=83</body>
    <body-html>&lt;p&gt;Worn Again are hiring for a new Sales Director.&lt;/p&gt;
    &lt;p&gt;To view the full job description and details of how to apply click &lt;a href=&quot;http://antiapathy.org/?page_id=83&quot;&gt;here&lt;/a&gt;&lt;/p&gt;</body-html>
    <created-at type="datetime">2009-07-29T13:58:59+01:00</created-at>
    <id type="integer">1179072</id>
    <published-at type="datetime">2009-07-29T13:58:59+01:00</published-at>
    <title>Worn Again are hiring!</title>
    <updated-at type="datetime">2009-07-29T13:59:40+01:00</updated-at>
    </article>
    <article>
    17 changes: 17 additions & 0 deletions what-i-want.yaml
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,17 @@
    - &page-4
    id: 3
    title: Shopping Cart
    handle: shopping-cart
    url: /pages/shopping-cart
    author: Tobi
    content: "<ul><li>Your order is safe with us. Our checkout uses industry standard security to protect your information.</li><li>Your order will be billed immediately upon checkout.</li><li><b>ALL SALES ARE FINAL:</b> Defective or damaged product will be exchanged</li><li>All orders are processed expediently: usually in under 24 hours.</li></ul>"
    created_at: 2005-04-04 12:00

    - &page-5
    id: 4
    title: Shipping and Handling
    handle: shipping
    url: /pages/shipping
    author: Tobi
    content: <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
    created_at: 2005-04-04 12:00