apiculture 0.1.2 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 22ff31bb7b740ba2994dadcf1e76b10c5e47d5e4
4
- data.tar.gz: 7a0f4a80554d338542dd0eb9c1ecd39820218066
3
+ metadata.gz: 0bf044e0978c4650b72aa2b337fe9cb000ecd546
4
+ data.tar.gz: 010b7cfb597e96aba2554b32e00b9fd3773e5169
5
5
  SHA512:
6
- metadata.gz: af3e86d8c2b3c1f8a6f42b03f96d4ff904afe5c7874a28d84ecdc41bec3bb0dea2984fa173ac111ba1e32343e7cebc6826af46dca93e17c61e2d94ba307168a3
7
- data.tar.gz: 21674f0cd0a3b0ca724724920184210661b7de00f40d834daf74d95c66371938c7408d56401580ded47955d9ba9e240ee95a4778963a5b3c128d7e9cd0eff819
6
+ metadata.gz: 3b2db79c161620c9f1d8cd22cfb252d7e0ac6013c42de0e87368c819334df7c5b9f8b6a666e0ea380e847d8d0c52dca98afdf94db97e25b3670880f5dc0eff7d
7
+ data.tar.gz: 2b89340ef4473feb21e7c5c49018f5b0bb68748dd8b0d536c5bc0090253bc1d1952db3900839dc40e412a19ba02051cd8889c4a5b0d5afa3fc03a86eeec5816e
@@ -12,6 +12,6 @@ group :development do
12
12
  gem "rspec", "~> 3.1", '< 3.2'
13
13
  gem "rdoc", "~> 6.0"
14
14
  gem "rake", "~> 10"
15
- gem "bundler", "~> 1.0"
16
15
  gem "simplecov", ">= 0"
16
+ gem "bundler"
17
17
  end
@@ -12,6 +12,6 @@ group :development do
12
12
  gem "rspec", "~> 3.1", '< 3.2'
13
13
  gem "rdoc", "~> 6.0"
14
14
  gem "rake", "~> 10"
15
- gem "bundler", "~> 1.0"
16
15
  gem "simplecov", ">= 0"
16
+ gem "bundler"
17
17
  end
@@ -1,4 +1,6 @@
1
1
  require 'builder'
2
+ require 'rdiscount'
3
+
2
4
  # Generates Markdown/HTML documentation about a single API action.
3
5
  #
4
6
  # Formats route parameters and request/QS parameters as a neat HTML
@@ -26,12 +28,15 @@ class Apiculture::MethodDocumentation
26
28
 
27
29
  # Compose an HTML string by converting the result of +to_markdown+
28
30
  def to_html_fragment
29
- require 'rdiscount'
30
- RDiscount.new(to_markdown).to_html
31
+ markdown_string_to_html(to_markdown)
31
32
  end
32
33
 
33
34
  private
34
35
 
36
+ def markdown_string_to_html(str)
37
+ RDiscount.new(str.to_s).to_html
38
+ end
39
+
35
40
  class StringBuf #:nodoc:
36
41
  def initialize; @blocks = []; end
37
42
  def <<(block); @blocks << block.to_s; self; end
@@ -59,7 +64,7 @@ class Apiculture::MethodDocumentation
59
64
  @definition.route_parameters.each do | param |
60
65
  html.tr do
61
66
  html.td { html.tt(':%s' % param.name) }
62
- html.td(param.description)
67
+ html.td { html << markdown_string_to_html(param.description) }
63
68
  end
64
69
  end
65
70
  end
@@ -98,7 +103,7 @@ class Apiculture::MethodDocumentation
98
103
  @definition.responses.each do | resp |
99
104
  html.tr do
100
105
  html.td { html.b(resp.http_status_code) }
101
- html.td resp.description
106
+ html.td { html << markdown_string_to_html(resp.description) }
102
107
  html.td { html.pre { html.code(body_example(resp)) }}
103
108
  end
104
109
  end
@@ -139,7 +144,7 @@ class Apiculture::MethodDocumentation
139
144
  html.td { html.tt(param.name.to_s) }
140
145
  html.td(param.required ? 'Yes' : 'No')
141
146
  html.td(param.matchable.inspect)
142
- html.td(param.description.to_s)
147
+ html.td { html << markdown_string_to_html(param.description) }
143
148
  end
144
149
  end
145
150
  end
@@ -1,3 +1,3 @@
1
1
  module Apiculture
2
- VERSION = '0.1.2'
2
+ VERSION = '0.1.3'
3
3
  end
@@ -10,9 +10,16 @@ describe "Apiculture.api_documentation" do
10
10
  documentation_build_time!
11
11
 
12
12
  desc 'Order a pancake'
13
- required_param :diameter, "Diameter of the pancake", Integer
13
+ required_param :diameter, "Diameter of the pancake. The pancake will be **bold**", Integer
14
14
  param :topping, 'Type of topping', String
15
- responds_with 200, 'When the pancake is created succesfully', {id: 'abdef..c21'}
15
+ pancake_response_info = <<~EOS
16
+ When the pancake has been baked succesfully
17
+ The pancake will have the following properties:
18
+
19
+ * It is going to be round
20
+ * It is going to be delicious
21
+ EOS
22
+ responds_with 200, pancake_response_info, {id: 'abdef..c21'}
16
23
  api_method :post, '/pancakes' do
17
24
  end
18
25
 
@@ -58,7 +65,7 @@ describe "Apiculture.api_documentation" do
58
65
 
59
66
  expect(generated_html).to include('<body')
60
67
  expect(generated_html).to include('Pancake ID to check status on')
61
- expect(generated_html).to include('When the pancake is created succesfully')
68
+ expect(generated_html).to include('When the pancake has been baked succesfully')
62
69
  expect(generated_html).to include('"id": "abdef..c21"')
63
70
  end
64
71
 
@@ -7,7 +7,7 @@ describe Apiculture::MethodDocumentation do
7
7
 
8
8
  definition.description = "This action bakes pancakes"
9
9
  definition.parameters << Apiculture::Parameter.new(:name, 'Pancake name', true, String, :to_s)
10
- definition.parameters << Apiculture::Parameter.new(:thickness, 'Pancake thickness', false, Float, :to_f)
10
+ definition.parameters << Apiculture::Parameter.new(:thickness, 'Pancake **thick**ness', false, Float, :to_f)
11
11
  definition.parameters << Apiculture::Parameter.new(:diameter, 'Pancake diameter', false, Integer, :to_i)
12
12
 
13
13
  definition.route_parameters << Apiculture::RouteParameter.new(:pan_id, 'ID of the pancake frying pan')
@@ -28,9 +28,9 @@ describe Apiculture::MethodDocumentation do
28
28
  expect(generated_html).to include('<h3>URL parameters</h3>')
29
29
  expect(generated_html).to include('ID of the pancake frying pan')
30
30
  expect(generated_html).to include('<h3>Request parameters</h3>')
31
- expect(generated_html).to include('<td>Pancake name</td>')
32
- expect(generated_html).to include('<td>Pancake has been baked</td>')
33
- expect(generated_html).to include('<td>Frying pan too cold</td>')
31
+ expect(generated_html).to include('<p>Pancake name</p>')
32
+ expect(generated_html).to include('<p>Pancake has been baked</p>')
33
+ expect(generated_html).to include('<p>Frying pan too cold</p>')
34
34
  end
35
35
 
36
36
  it 'generates HTML from an ActionDefinition without route params' do
@@ -38,7 +38,7 @@ describe Apiculture::MethodDocumentation do
38
38
 
39
39
  definition.description = "This action bakes pancakes"
40
40
  definition.parameters << Apiculture::Parameter.new(:name, 'Pancake name', true, String, :to_s)
41
- definition.parameters << Apiculture::Parameter.new(:thickness, 'Pancake thickness', false, Float, :to_f)
41
+ definition.parameters << Apiculture::Parameter.new(:thickness, 'Pancake **thick**ness', false, Float, :to_f)
42
42
  definition.parameters << Apiculture::Parameter.new(:diameter, 'Pancake diameter', false, Integer, :to_i)
43
43
 
44
44
  definition.http_verb = 'get'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: apiculture
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Julik Tarkhanov
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2019-02-15 00:00:00.000000000 Z
12
+ date: 2019-02-21 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: mustermann