<commit_before># Xdrgen

[![Build Status](https://travis-ci.org/stellar/xdrgen.svg)](https://travis-ci.org/stellar/xdrgen)
[![Code Climate](https://codeclimate.com/github/stellar/xdrgen/badges/gpa.svg)](https://codeclimate.com/github/stellar/xdrgen)

`xdrgen` is a code generator that takes XDR IDL files (`.x` files) as specfified 
in [RFC 4506](http://tools.ietf.org/html/rfc4506.html) and spits code out in 
various languages.

## Status

Xdrgen is a very early project.  Aside from the test fixtures in 
[spec/fixtures](spec/fixtures), the only .x files that have been thrown at it
are the .x files used for the 
[stellar-core project](https://github.com/stellar/stellar-core).

Xdrgen presently supports three output languages:  ruby, javacript, and golang:

- ruby: complete support
- javascript: complete but only lightly exercised
- golang: buggy and experimental

Testing is _very_ sparse, but will improve over time.

## Usage as a binary

Xdrgen is a rubygem, compatible with ruby 2.1 or higher

    $ gem install xdrgen

The command line:

`xdrgen [-o OUTPUT_DIR] [-l LANGUAGE] [-n NAMESPACE] [INPUT_FILES ...]`

## Usage as a library

Add this line to your application's Gemfile:

```ruby
gem 'xdrgen'
```

And then execute:

    $ bundle

Example usage:

```ruby
require 'xdrgen'

# create a compilation object, specifying your options

c = Xdrgen::Compilation.new(
  ["MyProgram.x"], 
  output_dir:"src/generated",
  language: :ruby
  namespace: "MyProgram::XDR"
)<commit_msg>Add notes for go support<commit_after># Xdrgen

[![Build Status](https://travis-ci.org/stellar/xdrgen.svg)](https://travis-ci.org/stellar/xdrgen)
[![Code Climate](https://codeclimate.com/github/stellar/xdrgen/badges/gpa.svg)](https://codeclimate.com/github/stellar/xdrgen)

`xdrgen` is a code generator that takes XDR IDL files (`.x` files) as specfified
in [RFC 4506](http://tools.ietf.org/html/rfc4506.html) and spits code out in
various languages.

## Status

Xdrgen is a very early project.  Aside from the test fixtures in
[spec/fixtures](spec/fixtures), the only .x files that have been thrown at it
are the .x files used for the
[stellar-core project](https://github.com/stellar/stellar-core).

Xdrgen presently supports three output languages:  ruby, javacript, and golang:

- ruby: complete support
- javascript: complete support
- golang: currently using a fork of go-xdr, but has complete support

Testing is _very_ sparse, but will improve over time.

## Usage as a binary

Xdrgen is a rubygem, compatible with ruby 2.1 or higher

    $ gem install xdrgen

The command line:

`xdrgen [-o OUTPUT_DIR] [-l LANGUAGE] [-n NAMESPACE] [INPUT_FILES ...]`

## Usage as a library

Add this line to your application's Gemfile:

```ruby
gem 'xdrgen'
```

And then execute:

    $ bundle

Example usage:

```ruby
require 'xdrgen'

# create a compilation object, specifying your options

c = Xdrgen::Compilation.new(
  ["MyProgram.x"],
  output_dir:"src/generated",
  language: :ruby
  namespace: "MyProgram::XDR"
)
{'fraction_non_alphanumeric': 0.11980033277870217, 'fraction_numerical': 0.0066555740432612314, 'mean_word_length': 4.301587301587301, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 10, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4453170', 'n_tokens_mistral': 1074, 'n_tokens_neox': 1000, 'n_words': 330}