Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/undr/ox_builder
XML builder with using ox. Fast and convenient DSL.
https://github.com/undr/ox_builder
Last synced: about 1 month ago
JSON representation
XML builder with using ox. Fast and convenient DSL.
- Host: GitHub
- URL: https://github.com/undr/ox_builder
- Owner: undr
- License: mit
- Created: 2013-01-30T02:48:35.000Z (almost 12 years ago)
- Default Branch: master
- Last Pushed: 2013-09-03T14:14:14.000Z (over 11 years ago)
- Last Synced: 2023-03-10T20:33:20.145Z (almost 2 years ago)
- Language: Ruby
- Size: 102 KB
- Stars: 2
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# OxBuilder
XML builder with using ox. Fast and convenient DSL.
[![Build Status](https://secure.travis-ci.org/undr/ox_builder.png?branch=master)](http://travis-ci.org/undr/ox_builder)
## Installation
Add this line to your application's Gemfile:
gem 'ox_builder'
And then execute:
$ bundle
Or install it yourself as:
$ gem install ox_builder
## Usage
```ruby
Ox::Builder.document do |document|
document.element(
'rss', 'xmlns:dc' => 'http://purl.org/dc/elements/1.1/', 'xmlns:atom' => 'http://www.w3.org/2005/Atom',
'xmlns:media' => 'http://search.yahoo.com/mrss/', 'xmlns:content' => 'http://purl.org/rss/1.0/modules/content/',
'xmlns:itunes' => 'http://www.itunes.com/dtds/podcast-1.0.dtd', 'version' => '2.0'
) do |rss|
rss.element('channel') do |channel|
description(channel)Post.all do |post|
channel_item(post)
end
end
end
enddef description node
node.element('title', 'Title of channel')
node.element('link', 'http://www.example.com')
node.element('description', 'Description of channel')
node.element('language', 'ru')
node.element('copyright', 'copyright')
enddef channel_post node, post
node.element('item') do |item|
node.element('title', post.title)
node.element('link', post.permalink)
node.element('guid', post.permalink)
node.element('pubDate', post.published_at)
node.element('description', post.description)
node.element('category', post.category)
mode.element('enclosure', url: post.image.url, type: 'image/jpeg', length: post.image.size)
end
end
```## Contributing
1. Fork it
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Add some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create new Pull Request