0.0
No release in over a year
Faraday XML Middleware.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 2.0
~> 13.0
~> 3.0
~> 1.31.0
~> 0.21.0

Runtime

>= 1.10, < 3
 Project Readme

Faraday XML

GitHub Workflow Status Gem License

Faraday XML Middleware.

Installation

Add this line to your application's Gemfile:

gem 'faraday-xml'

And then execute:

bundle install

Or install it yourself as:

gem install faraday-xml

Usage

require 'faraday'
require 'faraday/xml'

conn = Faraday.new do |builder|
  builder.headers.update(
    "Accept" => "application/xml",
    "Content-Type" => "application/xml;charset=UTF-8",
  )
  # or builder.use Faraday::XML::Request
  builder.request :xml # encode Hash as XML
  # or builder.use Faraday::XML::Response
  builder.response :xml # decode response bodies from XML
end

There is also basic support for first class XML encoding/parsing

require 'faraday'
require 'faraday/xml'
hash = { 'user' => { 'name' => 'Erik Michaels-Ober', 'screen_name' => 'sferik' } }
xml = '<user><name>Erik Michaels-Ober</name><screen_name>sferik</screen_name></user>'

encoder = Faraday::XML::Encoder.build!(indent: 0)
encoder.encode(hash) == xml

parser = Faraday::XML::Parser.build!
parser.parse(xml) == hash

Development

After checking out the repo, run bin/setup to install dependencies.

Then, run bin/test to run the tests.

To install this gem onto your local machine, run rake build.

To release a new version, make a commit with a message such as "Bumped to 0.0.2" and then run rake release. See how it works here.

Contributing

Bug reports and pull requests are welcome on GitHub.

License

The gem is available as open source under the terms of the MIT License.