wadl_generator 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -1,4 +1,3 @@
1
1
  *.gem
2
2
  .bundle
3
- Gemfile.lock
4
3
  pkg/*
@@ -0,0 +1,16 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ wadl_generator (0.1.2)
5
+ builder
6
+
7
+ GEM
8
+ remote: http://rubygems.org/
9
+ specs:
10
+ builder (3.0.0)
11
+
12
+ PLATFORMS
13
+ ruby
14
+
15
+ DEPENDENCIES
16
+ wadl_generator!
@@ -40,9 +40,11 @@
40
40
  :base => "#{request.url.gsub('/description.wadl', '')}",
41
41
  :resources => {
42
42
  'posts' => {
43
+ :index => true,
43
44
  :index_formats => {
44
45
  :json => 'application/json',
45
46
  },
47
+ :show => true,
46
48
  :show_formats => {
47
49
  :json => 'application/json',
48
50
  :html => 'application/html',
@@ -50,6 +52,12 @@
50
52
  },
51
53
  :example_id => 28,
52
54
  },
55
+ 'categories' => {
56
+ :index => true,
57
+ :index_formats => {
58
+ :json => 'application/json',
59
+ },
60
+ }
53
61
  }
54
62
  }
55
63
  end
@@ -1,6 +1,8 @@
1
+ require 'builder'
2
+
1
3
  module WADL
2
4
  class Generator
3
- VERSION = '0.1.1'
5
+ VERSION = '0.1.2'
4
6
 
5
7
  attr_reader :description, :options, :wadl
6
8
 
@@ -33,38 +35,42 @@ module WADL
33
35
  xml.resources(:base => description[:base]) do
34
36
  description[:resources].each do |name, config|
35
37
  # index
36
- xml.resource(:path => "#{name.pluralize.underscore}.{format}") do
37
- xml.param(:name => 'format', :type => 'xsd:string', :style => 'template',
38
- :required => true, :default => config[:index_formats].keys.first) do
39
- config[:index_formats].each do |format, mime_type|
40
- xml.option(:value => format, :mediaType => mime_type)
38
+ if config[:index] && config[:index_formats].present?
39
+ xml.resource(:path => "#{name.pluralize.underscore}.{format}") do
40
+ xml.param(:name => 'format', :type => 'xsd:string', :style => 'template',
41
+ :required => true, :default => config[:index_formats].keys.first) do
42
+ config[:index_formats].each do |format, mime_type|
43
+ xml.option(:value => format, :mediaType => mime_type)
44
+ end
41
45
  end
42
- end
43
46
 
44
- xml.method('id' => name.pluralize.underscore, 'name' => 'GET') do
45
- if options[:apigee]
46
- xml.tag!('apigee:tags') { xml.tag!('apigee:tag', name.singularize.camelcase, :primary => true) }
47
- xml.tag!('apigee:authentication', :required => false)
48
- xml.tag!('apigee:example', :url => "/#{name.pluralize.underscore}.#{config[:index_formats].keys.first}")
47
+ xml.method('id' => name.pluralize.underscore, 'name' => 'GET') do
48
+ if options[:apigee]
49
+ xml.tag!('apigee:tags') { xml.tag!('apigee:tag', name.singularize.camelcase, :primary => true) }
50
+ xml.tag!('apigee:authentication', :required => false)
51
+ xml.tag!('apigee:example', :url => "/#{name.pluralize.underscore}.#{config[:index_formats].keys.first}")
52
+ end
49
53
  end
50
54
  end
51
55
  end
52
56
 
53
57
  # show
54
- xml.resource(:path => "#{name.pluralize.underscore}/{id}.{format}") do
55
- xml.param(:name => 'format', :type => 'xsd:string', :style => 'template',
56
- :required => true, :default => config[:show_formats].keys.first) do
57
- config[:show_formats].each do |format, mime_type|
58
- xml.option(:value => format, :mediaType => mime_type)
58
+ if config[:show] && config[:show_formats].present?
59
+ xml.resource(:path => "#{name.pluralize.underscore}/{id}.{format}") do
60
+ xml.param(:name => 'format', :type => 'xsd:string', :style => 'template',
61
+ :required => true, :default => config[:show_formats].keys.first) do
62
+ config[:show_formats].each do |format, mime_type|
63
+ xml.option(:value => format, :mediaType => mime_type)
64
+ end
59
65
  end
60
- end
61
- xml.param(:name => 'id', :type => 'xsd:string', :style => 'query', :required => true)
66
+ xml.param(:name => 'id', :type => 'xsd:string', :style => 'query', :required => true)
62
67
 
63
- xml.method('id' => name.singularize.underscore, 'name' => 'GET') do
64
- if options[:apigee]
65
- xml.tag!('apigee:tags') { xml.tag!('apigee:tag', name.singularize.camelcase, :primary => true) }
66
- xml.tag!('apigee:authentication', :required => false)
67
- xml.tag!('apigee:example', :url => "/#{name.pluralize.underscore}/#{config[:example_id]}.#{config[:show_formats].keys.first}")
68
+ xml.method('id' => name.singularize.underscore, 'name' => 'GET') do
69
+ if options[:apigee]
70
+ xml.tag!('apigee:tags') { xml.tag!('apigee:tag', name.singularize.camelcase, :primary => true) }
71
+ xml.tag!('apigee:authentication', :required => false)
72
+ xml.tag!('apigee:example', :url => "/#{name.pluralize.underscore}/#{config[:example_id]}.#{config[:show_formats].keys.first}")
73
+ end
68
74
  end
69
75
  end
70
76
  end
@@ -14,6 +14,8 @@ Gem::Specification.new do |s|
14
14
 
15
15
  s.rubyforge_project = "wadl_generator"
16
16
 
17
+ s.add_dependency 'builder'
18
+
17
19
  s.files = `git ls-files`.split("\n")
18
20
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
19
21
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wadl_generator
3
3
  version: !ruby/object:Gem::Version
4
- hash: 25
4
+ hash: 31
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 1
10
- version: 0.1.1
9
+ - 2
10
+ version: 0.1.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Thomas Maurer
@@ -15,10 +15,23 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-03-10 00:00:00 +01:00
18
+ date: 2011-03-14 00:00:00 +01:00
19
19
  default_executable:
20
- dependencies: []
21
-
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: builder
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ hash: 3
30
+ segments:
31
+ - 0
32
+ version: "0"
33
+ type: :runtime
34
+ version_requirements: *id001
22
35
  description: Simple WADL Generator targeted on REST APIs with optional Apigee Flavour
23
36
  email:
24
37
  - tma@freshbit.ch
@@ -31,6 +44,7 @@ extra_rdoc_files: []
31
44
  files:
32
45
  - .gitignore
33
46
  - Gemfile
47
+ - Gemfile.lock
34
48
  - README.markdown
35
49
  - Rakefile
36
50
  - lib/wadl/generator.rb
@@ -66,7 +80,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
66
80
  requirements: []
67
81
 
68
82
  rubyforge_project: wadl_generator
69
- rubygems_version: 1.5.3
83
+ rubygems_version: 1.6.2
70
84
  signing_key:
71
85
  specification_version: 3
72
86
  summary: Simple WADL Generator targeted on REST APIs with optional Apigee Flavour