prmd 0.6.2 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -13
- data/CONTRIBUTORS.md +8 -0
- data/Gemfile.lock +6 -6
- data/README.md +57 -8
- data/Rakefile +4 -4
- data/bin/prmd +3 -117
- data/docs/schemata.md +11 -11
- data/lib/prmd.rb +7 -18
- data/lib/prmd/cli.rb +108 -0
- data/lib/prmd/cli/base.rb +151 -0
- data/lib/prmd/cli/combine.rb +42 -0
- data/lib/prmd/cli/doc.rb +69 -0
- data/lib/prmd/cli/generate.rb +44 -0
- data/lib/prmd/cli/render.rb +48 -0
- data/lib/prmd/cli/verify.rb +49 -0
- data/lib/prmd/commands.rb +4 -0
- data/lib/prmd/commands/combine.rb +85 -58
- data/lib/prmd/commands/init.rb +30 -98
- data/lib/prmd/commands/render.rb +30 -17
- data/lib/prmd/commands/verify.rb +78 -35
- data/lib/prmd/core/combiner.rb +91 -0
- data/lib/prmd/core/generator.rb +27 -0
- data/lib/prmd/core/renderer.rb +56 -0
- data/lib/prmd/core/schema_hash.rb +47 -0
- data/lib/prmd/core_ext/optparse.rb +6 -0
- data/lib/prmd/hash_helpers.rb +38 -0
- data/lib/prmd/load_schema_file.rb +25 -0
- data/lib/prmd/rake_tasks/base.rb +33 -0
- data/lib/prmd/rake_tasks/combine.rb +50 -0
- data/lib/prmd/rake_tasks/doc.rb +73 -0
- data/lib/prmd/rake_tasks/verify.rb +60 -0
- data/lib/prmd/schema.rb +86 -34
- data/lib/prmd/template.rb +65 -8
- data/lib/prmd/templates/combine_head.json +6 -0
- data/lib/prmd/templates/init_default.json +9 -0
- data/lib/prmd/templates/init_resource.json.erb +90 -0
- data/lib/prmd/templates/link_schema_properties.md.erb +5 -0
- data/lib/prmd/templates/schema.erb +2 -2
- data/lib/prmd/templates/schemata.md.erb +37 -0
- data/lib/prmd/templates/schemata/helper.erb +29 -15
- data/lib/prmd/templates/schemata/link.md.erb +74 -0
- data/lib/prmd/templates/schemata/{link_curl_example.erb → link_curl_example.md.erb} +8 -2
- data/lib/prmd/url_generator.rb +11 -69
- data/lib/prmd/url_generators/generators/default.rb +66 -0
- data/lib/prmd/url_generators/generators/json.rb +30 -0
- data/lib/prmd/version.rb +10 -1
- data/prmd.gemspec +15 -15
- data/test/cli/combine_test.rb +23 -0
- data/test/cli/doc_test.rb +25 -0
- data/test/cli/generate_test.rb +23 -0
- data/test/cli/render_test.rb +25 -0
- data/test/cli/verify_test.rb +21 -0
- data/test/commands/init_test.rb +7 -0
- data/test/commands/render_test.rb +93 -0
- data/test/commands/verify_test.rb +60 -60
- data/test/helpers.rb +61 -6
- data/test/schema_test.rb +17 -11
- data/test/schemata/input/doc-settings.json +4 -0
- metadata +73 -28
- data/lib/prmd/commands/expand.rb +0 -108
- data/lib/prmd/templates/link_schema_properties.erb +0 -16
- data/lib/prmd/templates/schemata.erb +0 -47
- data/lib/prmd/templates/schemata/link.erb +0 -61
@@ -1,16 +0,0 @@
|
|
1
|
-
<table>
|
2
|
-
<tr>
|
3
|
-
<th>Name</th>
|
4
|
-
<th>Type</th>
|
5
|
-
<th>Description</th>
|
6
|
-
<th>Example</th>
|
7
|
-
</tr>
|
8
|
-
<%- extract_attributes(schema, params).each do |(key, type, description, example)| %>
|
9
|
-
<tr>
|
10
|
-
<td><strong><%= key %></strong></td>
|
11
|
-
<td><em><%= type %></em></td>
|
12
|
-
<td><%= description %></td>
|
13
|
-
<td><%= example %></td>
|
14
|
-
</tr>
|
15
|
-
<%- end %>
|
16
|
-
</table>
|
@@ -1,47 +0,0 @@
|
|
1
|
-
<%-
|
2
|
-
return unless schemata.has_key?('links') && !schemata['links'].empty?
|
3
|
-
|
4
|
-
Prmd::Template::render(File.join('schemata', 'helper.erb'), options[:template], {
|
5
|
-
options: options,
|
6
|
-
resource: resource,
|
7
|
-
schema: schema,
|
8
|
-
schemata: schemata
|
9
|
-
})
|
10
|
-
|
11
|
-
title = schemata['title'].split(' - ', 2).last
|
12
|
-
%>
|
13
|
-
## <%= title %>
|
14
|
-
<%= schemata['description'] %>
|
15
|
-
|
16
|
-
<%- if schemata['properties'] %>
|
17
|
-
### Attributes
|
18
|
-
<table>
|
19
|
-
<tr>
|
20
|
-
<th>Name</th>
|
21
|
-
<th>Type</th>
|
22
|
-
<th>Description</th>
|
23
|
-
<th>Example</th>
|
24
|
-
</tr>
|
25
|
-
<%- extract_attributes(schema, schemata['properties']).each do |(key, type, description, example)| %>
|
26
|
-
<tr>
|
27
|
-
<td><strong><%= key %></strong></td>
|
28
|
-
<td><em><%= type %></em></td>
|
29
|
-
<td><%= description %></td>
|
30
|
-
<td><%= example %></td>
|
31
|
-
</tr>
|
32
|
-
<%- end %>
|
33
|
-
</table>
|
34
|
-
|
35
|
-
<%- end %>
|
36
|
-
<%- schemata['links'].each do |link, datum| %>
|
37
|
-
<%=
|
38
|
-
Prmd::Template::render(File.join('schemata', 'link.erb'), options[:template], {
|
39
|
-
options: options,
|
40
|
-
resource: resource,
|
41
|
-
schema: schema,
|
42
|
-
schemata: schemata,
|
43
|
-
link: link,
|
44
|
-
title: title
|
45
|
-
})
|
46
|
-
%>
|
47
|
-
<%- end -%>
|
@@ -1,61 +0,0 @@
|
|
1
|
-
<%-
|
2
|
-
path = build_link_path(schema, link)
|
3
|
-
link_schema_properties_template = Prmd::Template::load('link_schema_properties.erb', options[:template])
|
4
|
-
-%>
|
5
|
-
### <%= title %> <%= link['title'] %>
|
6
|
-
<%= link['description'] %>
|
7
|
-
|
8
|
-
```
|
9
|
-
<%= link['method'] %> <%= path %>
|
10
|
-
```
|
11
|
-
|
12
|
-
<%- if link.has_key?('schema') && link['schema'].has_key?('properties') %>
|
13
|
-
<%-
|
14
|
-
required, optional = link['schema']['properties'].partition do |k, v|
|
15
|
-
(link['schema']['required'] || []).include?(k)
|
16
|
-
end.map { |partition| Hash[partition] }
|
17
|
-
%>
|
18
|
-
<%- unless required.empty? %>
|
19
|
-
#### Required Parameters
|
20
|
-
<%= Erubis::Eruby.new(link_schema_properties_template).result(params: required, schema: schema) %>
|
21
|
-
|
22
|
-
<%- end %>
|
23
|
-
<%- unless optional.empty? %>
|
24
|
-
#### Optional Parameters
|
25
|
-
<%= Erubis::Eruby.new(link_schema_properties_template).result(params: optional, schema: schema) %>
|
26
|
-
<%- end %>
|
27
|
-
<%- end %>
|
28
|
-
|
29
|
-
#### Curl Example
|
30
|
-
<%=
|
31
|
-
Prmd::Template::render(File.join('schemata', 'link_curl_example.erb'), File.dirname(options[:template]), {
|
32
|
-
options: options,
|
33
|
-
resource: resource,
|
34
|
-
schema: schema,
|
35
|
-
schemata: schemata,
|
36
|
-
link: link,
|
37
|
-
path: path
|
38
|
-
})
|
39
|
-
%>
|
40
|
-
|
41
|
-
#### Response Example
|
42
|
-
```
|
43
|
-
HTTP/1.1 <%= case link['rel']
|
44
|
-
when 'create'
|
45
|
-
'201 Created'
|
46
|
-
when 'empty'
|
47
|
-
'202 Accepted'
|
48
|
-
else
|
49
|
-
'200 OK'
|
50
|
-
end %>
|
51
|
-
```
|
52
|
-
```json
|
53
|
-
<%- if link['rel'] == 'empty' %>
|
54
|
-
<%- elsif link.has_key?('targetSchema') && link['targetSchema'].has_key?('properties') %>
|
55
|
-
<%= JSON.pretty_generate(schema.schema_example(link['targetSchema'])) %>
|
56
|
-
<%- elsif link['rel'] == 'instances' %>
|
57
|
-
<%= JSON.pretty_generate([schema.schemata_example(resource)]) %>
|
58
|
-
<%- else %>
|
59
|
-
<%= JSON.pretty_generate(schema.schemata_example(resource)) %>
|
60
|
-
<%- end %>
|
61
|
-
```
|