grape-doc 0.3.3 → 0.3.4

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: 7d7fdcbcc1ef5e0d881e8faae4051057b755029a
4
- data.tar.gz: 55d0a5e2626df00c3c86827c5302935d00a0631e
3
+ metadata.gz: aaecb438259bbda6c0f52ef2d1e7a027cd686b27
4
+ data.tar.gz: ab25877beee8e7315d34b2fca1f5ca15f2b3743a
5
5
  SHA512:
6
- metadata.gz: f954072f19e1a13a8156dec84c9098808bbd91208427e8aa22984290c3203db7f60558ffe9fc2618363e6c80d4ad145afbc078505707eac7577c377ccf1c5fd2
7
- data.tar.gz: cd3d34ebdac3a4998df27ecfc6bbd765718d8a31127036909fb1e63ba4952ecc0064934500d647b2dbac885d17dfb4b5cdea22e324808ad35fadffe5276ba249
6
+ metadata.gz: fcb4dfccecef9025b1877ab84a12fed26489201d660ac5faf932d8a98eed0a19d01103e6ce48c59153a238bdf728c490c5eeda3d5a6b7787b95680cefbfc401c
7
+ data.tar.gz: 44205c82703e4b7176fc49255c0d50489c0b4387ffe1e07302b1a793f5ab494cecd45e6f221c7b752bb048cca94332f502f140532ba7a760b7fa8f584509bc09
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.3
1
+ 0.3.4
@@ -53,7 +53,7 @@ module GrapeDoc
53
53
  var = case route.route_description
54
54
 
55
55
  when Hash
56
- (route.route_description.find{|k,v| k == 'desc' || k == :desc } || [])[1] || ''
56
+ (route.route_description.find{ |k,v| k == 'desc' || k == :desc } || [])[1] || ''
57
57
 
58
58
  when Array
59
59
  route.route_description
@@ -107,29 +107,24 @@ module GrapeDoc
107
107
  "format type: #{poc_opts['response']['format']}"
108
108
  ]
109
109
 
110
- document.add :h6,'raw body'
110
+ document.add :h6,'raw response body'
111
111
  document.add :raw,poc_opts['response']['raw_body']
112
112
 
113
113
  if JSON.respond_to?(:pretty_generate)
114
114
 
115
115
  document.add :h6,'json formatted body with Class types'
116
- document.add :raw,
117
- JSON.pretty_generate(
118
- ApiDocParts::Parser.typer(poc_opts['response']['body'])
119
- )
120
-
121
- end
116
+ pretty_object = JSON.pretty_generate(
117
+ Parser.typer(poc_opts['response']['body'])
118
+ ) rescue Parser.typer(poc_opts['response']['body'])
122
119
 
120
+ document.add :raw,pretty_object
123
121
 
124
- end
125
122
 
126
- if -> { @poc_data[route_path_var][route.route_method.to_s.upcase] rescue nil }.call
127
- poc_opts = @poc_data[route_path_var][route.route_method.to_s.upcase]
123
+ end
128
124
 
129
125
 
130
126
  end
131
127
 
132
-
133
128
  end
134
129
  end
135
130
  end
@@ -0,0 +1,84 @@
1
+ module GrapeDoc
2
+ module Parser
3
+ class << self
4
+
5
+ def parse(object)
6
+ case object
7
+
8
+ when Array
9
+ object.map{|e|
10
+ case e
11
+ when Array
12
+ e.dup
13
+
14
+ else
15
+ self.format_parse(*e)
16
+
17
+ end
18
+ }
19
+
20
+ else
21
+ # self.format_parse(object)
22
+ object
23
+
24
+ end
25
+ end
26
+
27
+ def format_parse(text,*args)
28
+ text = text.dup.to_s
29
+ args.each do |command|
30
+ case command.to_s.downcase
31
+
32
+ when /^bold/
33
+ text.replace("*#{text}*")
34
+
35
+ when /^italic/
36
+ text.replace("__#{text}__")
37
+
38
+ when /^underlined/
39
+ text.replace("+#{text}+")
40
+
41
+ when /^superscript/
42
+ text.replace("^#{text}^")
43
+
44
+ end
45
+ end;return text
46
+
47
+ end
48
+
49
+ def typer(obj)
50
+ case obj
51
+
52
+ when Array
53
+ obj.map{ |e| typer(e) }
54
+
55
+ when Hash
56
+ obj.reduce({}){|m,o| m.merge!(o[0] => typer(o[1]) ) ;m}
57
+
58
+ when Class,Module
59
+ obj.to_s
60
+
61
+ when String
62
+ if -> { Helpers.constantize(obj) rescue false }.call
63
+ if obj.to_s == 'TEST'
64
+ 'String'
65
+ else
66
+ obj.to_s
67
+ end
68
+
69
+ else
70
+ 'String'
71
+
72
+ end
73
+
74
+ else
75
+ obj.class.to_s
76
+
77
+ end
78
+
79
+ end
80
+
81
+ end
82
+ end
83
+
84
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: grape-doc
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.3
4
+ version: 0.3.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adam Luzsi
@@ -128,12 +128,12 @@ files:
128
128
  - lib/grape/doc/doc_class/header.rb
129
129
  - lib/grape/doc/doc_class/link.rb
130
130
  - lib/grape/doc/doc_class/list.rb
131
- - lib/grape/doc/doc_class/parser.rb
132
131
  - lib/grape/doc/doc_class/raw.rb
133
132
  - lib/grape/doc/doc_class/sidebar.rb
134
133
  - lib/grape/doc/doc_class/table.rb
135
134
  - lib/grape/doc/generator.rb
136
135
  - lib/grape/doc/helper.rb
136
+ - lib/grape/doc/parser.rb
137
137
  - lib/grape/doc/prototype.rb
138
138
  - test/sample.html
139
139
  - test/test_all.rb
@@ -1,74 +0,0 @@
1
- module GrapeDoc
2
- class ApiDocParts
3
-
4
- module Parser
5
- class << self
6
-
7
- def parse(object)
8
- case object
9
-
10
- when Array
11
- object.map{|e|
12
- case e
13
- when Array
14
- e.dup
15
-
16
- else
17
- self.format_parse(*e)
18
-
19
- end
20
- }
21
-
22
- else
23
- # self.format_parse(object)
24
- object
25
-
26
- end
27
- end
28
-
29
- def format_parse(text,*args)
30
- text = text.dup.to_s
31
- args.each do |command|
32
- case command.to_s.downcase
33
-
34
- when /^bold/
35
- text.replace("*#{text}*")
36
-
37
- when /^italic/
38
- text.replace("__#{text}__")
39
-
40
- when /^underlined/
41
- text.replace("+#{text}+")
42
-
43
- when /^superscript/
44
- text.replace("^#{text}^")
45
-
46
- end
47
- end;return text
48
-
49
- end
50
-
51
- def typer(obj)
52
- case obj
53
-
54
- when Array
55
- obj.map{ |e| typer(e) }
56
-
57
- when Hash
58
- obj.reduce({}){|m,o| m.merge!(o[0] => typer(o[1]) ) ;m}
59
-
60
- when Class,Module
61
- obj
62
-
63
- else
64
- obj.class
65
-
66
- end
67
-
68
- end
69
-
70
- end
71
- end
72
-
73
- end
74
- end