forked from austvik/wadlgen
-
Notifications
You must be signed in to change notification settings - Fork 1
/
README
66 lines (49 loc) · 2.1 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
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.