raddocs 1.0.1 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ffbd193e9c8f8b0bf7fd8e25fdee03e5b3f421c7
4
- data.tar.gz: 02f48976120eeaedd38ad8698f7c0a26fec12d2c
3
+ metadata.gz: 5043b44d22752b964fc9a570ef8a2788e052b40c
4
+ data.tar.gz: 311bb2c3b45d3707d2da468e65fe685f68c5b438
5
5
  SHA512:
6
- metadata.gz: 57e35b21e0e6a3f928c5e0d7325ea81225340e27fc62269fa0c77f698529917f231b6e451580273a7e14256de48c069a34e550866b31b2b87e63c2bcb6b04aab
7
- data.tar.gz: ebaf4933fcedc78144fe7aec56b71e581428b7c508f0d6b8c7504c9fd5df8987bfb5dd402126f9822318f1ebb7e64332ea6f6e70ea0da14aeb33a4361284142f
6
+ metadata.gz: b17b829952b94d6730582268d63c3b1fa72d26fe4f08c40b54cb54a75db48b4cff2439b9f2167c3a1e03c5148c1e4410ba84ba173d22aea80749ec97cbc37bcf
7
+ data.tar.gz: 3c9f051091ae8ee325b8d985ea236510cbe1f3d675d3bee556aa1cfe3d9f532198a54c898eb8d029c06584a85bb8a1e0a86a83562e500ae05866fa5a0bf53ae0
@@ -8,19 +8,23 @@ module Raddocs
8
8
  # @return [Array] array of {Raddocs::Resource Resources}
9
9
  def resources
10
10
  @attrs.fetch("resources", {}).map do |resource|
11
- Resource.new(resource["name"], resource["examples"])
11
+ Resource.new(resource["name"], resource["explanation"], resource["examples"])
12
12
  end
13
13
  end
14
14
  end
15
15
 
16
16
  # Group of examples related to a specific resource, eg "Orders"
17
- class Resource < Struct.new(:name, :examples)
17
+ class Resource < Struct.new(:name, :explanation, :examples)
18
18
  # @return [Array] array of {Raddocs::IndexExample IndexExamples}
19
19
  def examples
20
20
  @examples ||= super.map do |example|
21
21
  IndexExample.new(example)
22
22
  end
23
23
  end
24
+
25
+ def explanation?
26
+ !explanation.nil?
27
+ end
24
28
  end
25
29
 
26
30
  # Example model for the index page
@@ -42,17 +46,18 @@ module Raddocs
42
46
 
43
47
  # Example page model
44
48
  class Example
45
- attr_reader :resource, :description, :explanation, :parameters, :response_fields,
49
+ attr_reader :resource, :resource_explanation, :description, :explanation, :parameters, :response_fields,
46
50
  :requests
47
51
 
48
52
  def initialize(file)
49
53
  @attrs = JSON.parse(File.read(file))
50
-
54
+ @resource_explanation = @attrs.fetch("resource_explanation", nil)
51
55
  @resource = @attrs.fetch("resource")
56
+
52
57
  @description = @attrs.fetch("description")
53
58
  @explanation = @attrs.fetch("explanation", nil)
54
59
  @parameters = Parameters.new(@attrs.fetch("parameters"))
55
- @response_fields = ResponseFields.new(@attrs.fetch("response_fields"))
60
+ @response_fields = ResponseFields.new(@attrs.fetch("response_fields", []))
56
61
  @requests = @attrs.fetch("requests").map { |request| Request.new(request) }
57
62
  end
58
63
 
@@ -60,6 +65,10 @@ module Raddocs
60
65
  def explanation?
61
66
  !explanation.nil?
62
67
  end
68
+
69
+ def resource_explanation?
70
+ !resource_explanation.nil?
71
+ end
63
72
  end
64
73
 
65
74
  # Guide page model
@@ -33,6 +33,9 @@
33
33
  = link_to "&laquo; Back to Index", "/"
34
34
 
35
35
  %h1== #{example.resource} API
36
+ - if example.resource_explanation?
37
+ %p.explanation
38
+ = example.resource_explanation
36
39
  .article
37
40
  %h2= example.description
38
41
 
data/lib/views/guide.erb CHANGED
@@ -6,12 +6,12 @@
6
6
  <link rel="stylesheet" href="<%= file %>" />
7
7
  <% end %>
8
8
 
9
- <script src="#{url_location}/js/jquery-1-7-2.js"></script>
10
- <script src="#{url_location}/js/codemirror.js"></script>
11
- <script src="#{url_location}/js/mode/css/css.js"></script>
12
- <script src="#{url_location}/js/mode/htmlmixed/htmlmixed.js"></script>
13
- <script src="#{url_location}/js/mode/javascript/javascript.js"></script>
14
- <script src="#{url_location}/js/mode/xml/xml.js"></script>
9
+ <script src="<%= url_location %>/js/jquery-1-7-2.js"></script>
10
+ <script src="<%= url_location %>/js/codemirror.js"></script>
11
+ <script src="<%= url_location %>/js/mode/css/css.js"></script>
12
+ <script src="<%= url_location %>/js/mode/htmlmixed/htmlmixed.js"></script>
13
+ <script src="<%= url_location %>/js/mode/javascript/javascript.js"></script>
14
+ <script src="<%= url_location %>/js/mode/xml/xml.js"></script>
15
15
 
16
16
  <style>
17
17
  td.required .name:after {
data/lib/views/index.haml CHANGED
@@ -9,6 +9,9 @@
9
9
  - index.resources.each do |resource|
10
10
  .resource
11
11
  %h2= resource.name
12
+ - if resource.explanation?
13
+ %p.explanation
14
+ = resource.explanation
12
15
  %ul.examples
13
16
  - resource.examples.each do |example|
14
17
  %li.example
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: raddocs
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eric Oestrich
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-05-03 00:00:00.000000000 Z
11
+ date: 2017-05-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sinatra
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '1.3'
19
+ version: '2.0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '1.3'
26
+ version: '2.0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: haml
29
29
  requirement: !ruby/object:Gem::Requirement