Git Product home page Git Product logo

wadlgen's Introduction

wadlgen

An experiment to try to generate WADL (http://www.w3.org/Submission/wadl/) based on the routing information found in Rails 3 config/routes.rb.

Approach:

  • Minimal rake task that calls a library to generate the WADL
  • Save application.wadl in public/
  • Let the user edit application.wadl to add information that can't be extracted, and preserve what the user has added the next time the task is run
  • Needs Ruby 1.9.2 for ordered hashes in tests, also works on 1.8.7.

What works:

  • Parse a WADL file to an object model
  • Generate a WADL file from an object model
  • Parse a Rails Route file to a object model
  • Rake task to parse the rails route
  • merge two object models
  • make the rails task write a public/application.wadl file
  • 100% code coverage by unit tests

Rails 3 Usage:

Add this to the Gemfile: gem 'wadlgen', :git => 'git://github.com/austvik/wadlgen.git'

To generate a public/application.wadl: rake wadlgen

Now you can edit public/application.wadl. The next time you run rake wadlgen, any changes to the application will be merged into your WADL file, while your changes are preserved.

Programmatic usage:

There are several methods that can be used to generate, merge and write wadl object structures:

require 'wadlgen'

Generate a WADL XML document based on a Rails application

and base.

Wadlgen::Wadl.generate(application, base)

parses a given XML string, and generates a Wadlgen::Application

object from it.

Wadlgen::Wadl.parse_xml(xml_doc)

Parses routes from Rails 3, and generates a Wadlgen::Application

object from it.

Wadlgen::Wadl.parse_route(application, base)

Generates a WADL XML string based on a Wadlgen::Application object

Wadlgen::Wadl.generate_wadl(application)

Merges two Wadlgen::Application objects and returns the result

as another Wadlgen::Application object.

Wadlgen::Wadl.merge(initial_application, additional_application)

In addition the Wadlgen::* classes in src/wadlgen/classes.rb can be used to understand the object model created from these methods, or to generate structures to write to a WADL XML file.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.