Skip to content

officeluv/cxml-ruby

This branch is 126 commits ahead of, 48 commits behind cef/cxml:master.

Folders and files

NameName
Last commit message
Last commit date

Latest commit

f6a4434 · Feb 3, 2025
Feb 3, 2025
Nov 4, 2024
Apr 22, 2021
Apr 14, 2020
Feb 25, 2020
Sep 4, 2020
Dec 22, 2021
Sep 10, 2013
Apr 9, 2020
Apr 19, 2020
Apr 10, 2020
Sep 4, 2020

Repository files navigation

cXML-Ruby

Ruby Specs

Ruby implementation of the cXML protocol.

Currently supports these top-level documents in v1.2.037:

  • Request
    • InvoiceDetailRequest
    • OrderRequest
    • PunchOutSetupRequest
    • ConfirmationRequest
  • Response
    • Status
    • PunchOutSetupResponse
  • Message
    • PunchOutOrderMessage
  • Pull requests welcome to support more!

Usage

some_xml = '....'
parsed_hash = CXML::Parser.new(data: some_xml).parse
# or
doc = CXML::Document.new.from_xml(some_xml)
# or
doc = CXML::Document.new(parsed_hash)
# raises CXML::UnknownAttributeError if unknown fields are present

doc.response.status.code
# => 200
doc.response.status.success?
# => true

# initialize docs with a hash
CXML::Document.new(response: { status: { code: '200' } }).to_xml
# => '<?xml.....'

# initialize docs with instances
status = CXML::Status.new(code: '200')
response = CXML::Response.new(status: status)
CXML::Document.new(response: response).to_xml
# => '<?xml.....'

# Set a different version
CXML::Document.new(version: '1.1.0', response: { status: { code: '200' } }).to_xml
# => '<?xml.....'

Installation

Add this line to the application's Gemfile:

gem 'cxml-ruby'

And then execute:

$ bundle

Or install it yourself as:

$ gem install cxml-ruby

Configuration

CXML.configure do |config|
  # Set this to false to log intead of raise exception on unknown elements
  # defaults to true, raises CXML::UnknownAttributeError
  config.raise_unknown_elements = true

  # Optionally set a custom logger, used for parsing error logging
  # defaults to Logger.new(STDOUT, level: :warn)
  config.logger = Logger.new(STDOUT, level: :warn)
end

Running Tests

Install dependencies:

bundle install

Run suite:

rspec

Documentation

Procotol specifications could be found here http://xml.cxml.org/current/cXMLUsersGuide.pdf

About

Ruby implementation of cXML communication protocol

Resources

License

Stars

Watchers

Forks

Languages

  • Ruby 100.0%