lounge_lizard 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (348) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +11 -0
  3. data/.gitmodules +3 -0
  4. data/.rspec +2 -0
  5. data/CODE_OF_CONDUCT.md +74 -0
  6. data/Gemfile +4 -0
  7. data/Guardfile +33 -0
  8. data/LICENSE.txt +21 -0
  9. data/README.md +50 -0
  10. data/Rakefile +43 -0
  11. data/bin/console +14 -0
  12. data/bin/setup +8 -0
  13. data/circle.yml +14 -0
  14. data/ext/drafter/CHANGELOG.md +278 -0
  15. data/ext/drafter/Dockerfile +17 -0
  16. data/ext/drafter/Makefile +62 -0
  17. data/ext/drafter/appveyor.yml +17 -0
  18. data/ext/drafter/bin/drafter +0 -0
  19. data/ext/drafter/build/Makefile +387 -0
  20. data/ext/drafter/build/drafter.Makefile +6 -0
  21. data/ext/drafter/build/drafter.target.mk +159 -0
  22. data/ext/drafter/build/ext/snowcrash/libmarkdownparser.target.mk +141 -0
  23. data/ext/drafter/build/ext/snowcrash/libsnowcrash.target.mk +154 -0
  24. data/ext/drafter/build/ext/snowcrash/libsundown.target.mk +149 -0
  25. data/ext/drafter/build/ext/snowcrash/perf-libsnowcrash.target.mk +147 -0
  26. data/ext/drafter/build/ext/snowcrash/snowcrash.Makefile +6 -0
  27. data/ext/drafter/build/gyp-mac-tool +606 -0
  28. data/ext/drafter/build/libdrafter.target.mk +186 -0
  29. data/ext/drafter/build/libsos.target.mk +137 -0
  30. data/ext/drafter/build/out/Release/drafter +0 -0
  31. data/ext/drafter/build/out/Release/libdrafter.dylib +0 -0
  32. data/ext/drafter/build/out/Release/libmarkdownparser.a +0 -0
  33. data/ext/drafter/build/out/Release/libsnowcrash.a +0 -0
  34. data/ext/drafter/build/out/Release/libsos.a +0 -0
  35. data/ext/drafter/build/out/Release/libsundown.a +0 -0
  36. data/ext/drafter/build/out/Release/obj.target/drafter/src/config.o +0 -0
  37. data/ext/drafter/build/out/Release/obj.target/drafter/src/main.o +0 -0
  38. data/ext/drafter/build/out/Release/obj.target/drafter/src/reporting.o +0 -0
  39. data/ext/drafter/build/out/Release/obj.target/libdrafter/src/ConversionContext.o +0 -0
  40. data/ext/drafter/build/out/Release/obj.target/libdrafter/src/NamedTypesRegistry.o +0 -0
  41. data/ext/drafter/build/out/Release/obj.target/libdrafter/src/RefractAPI.o +0 -0
  42. data/ext/drafter/build/out/Release/obj.target/libdrafter/src/RefractDataStructure.o +0 -0
  43. data/ext/drafter/build/out/Release/obj.target/libdrafter/src/RefractElementFactory.o +0 -0
  44. data/ext/drafter/build/out/Release/obj.target/libdrafter/src/RefractSourceMap.o +0 -0
  45. data/ext/drafter/build/out/Release/obj.target/libdrafter/src/Render.o +0 -0
  46. data/ext/drafter/build/out/Release/obj.target/libdrafter/src/Serialize.o +0 -0
  47. data/ext/drafter/build/out/Release/obj.target/libdrafter/src/SerializeAST.o +0 -0
  48. data/ext/drafter/build/out/Release/obj.target/libdrafter/src/SerializeResult.o +0 -0
  49. data/ext/drafter/build/out/Release/obj.target/libdrafter/src/SerializeSourcemap.o +0 -0
  50. data/ext/drafter/build/out/Release/obj.target/libdrafter/src/drafter.o +0 -0
  51. data/ext/drafter/build/out/Release/obj.target/libdrafter/src/drafter_private.o +0 -0
  52. data/ext/drafter/build/out/Release/obj.target/libdrafter/src/refract/ComparableVisitor.o +0 -0
  53. data/ext/drafter/build/out/Release/obj.target/libdrafter/src/refract/Element.o +0 -0
  54. data/ext/drafter/build/out/Release/obj.target/libdrafter/src/refract/ExpandVisitor.o +0 -0
  55. data/ext/drafter/build/out/Release/obj.target/libdrafter/src/refract/IsExpandableVisitor.o +0 -0
  56. data/ext/drafter/build/out/Release/obj.target/libdrafter/src/refract/JSONSchemaVisitor.o +0 -0
  57. data/ext/drafter/build/out/Release/obj.target/libdrafter/src/refract/PrintVisitor.o +0 -0
  58. data/ext/drafter/build/out/Release/obj.target/libdrafter/src/refract/Query.o +0 -0
  59. data/ext/drafter/build/out/Release/obj.target/libdrafter/src/refract/Registry.o +0 -0
  60. data/ext/drafter/build/out/Release/obj.target/libdrafter/src/refract/RenderJSONVisitor.o +0 -0
  61. data/ext/drafter/build/out/Release/obj.target/libdrafter/src/refract/SerializeCompactVisitor.o +0 -0
  62. data/ext/drafter/build/out/Release/obj.target/libdrafter/src/refract/SerializeVisitor.o +0 -0
  63. data/ext/drafter/build/out/Release/obj.target/libdrafter/src/refract/TypeQueryVisitor.o +0 -0
  64. data/ext/drafter/build/out/Release/obj.target/libdrafter/src/refract/VisitorUtils.o +0 -0
  65. data/ext/drafter/build/out/Release/obj.target/libmarkdownparser/ext/snowcrash/ext/markdown-parser/src/ByteBuffer.o +0 -0
  66. data/ext/drafter/build/out/Release/obj.target/libmarkdownparser/ext/snowcrash/ext/markdown-parser/src/MarkdownNode.o +0 -0
  67. data/ext/drafter/build/out/Release/obj.target/libmarkdownparser/ext/snowcrash/ext/markdown-parser/src/MarkdownParser.o +0 -0
  68. data/ext/drafter/build/out/Release/obj.target/libsnowcrash/ext/snowcrash/src/Blueprint.o +0 -0
  69. data/ext/drafter/build/out/Release/obj.target/libsnowcrash/ext/snowcrash/src/BlueprintSourcemap.o +0 -0
  70. data/ext/drafter/build/out/Release/obj.target/libsnowcrash/ext/snowcrash/src/HTTP.o +0 -0
  71. data/ext/drafter/build/out/Release/obj.target/libsnowcrash/ext/snowcrash/src/HeadersParser.o +0 -0
  72. data/ext/drafter/build/out/Release/obj.target/libsnowcrash/ext/snowcrash/src/MSON.o +0 -0
  73. data/ext/drafter/build/out/Release/obj.target/libsnowcrash/ext/snowcrash/src/MSONOneOfParser.o +0 -0
  74. data/ext/drafter/build/out/Release/obj.target/libsnowcrash/ext/snowcrash/src/MSONSourcemap.o +0 -0
  75. data/ext/drafter/build/out/Release/obj.target/libsnowcrash/ext/snowcrash/src/MSONTypeSectionParser.o +0 -0
  76. data/ext/drafter/build/out/Release/obj.target/libsnowcrash/ext/snowcrash/src/MSONValueMemberParser.o +0 -0
  77. data/ext/drafter/build/out/Release/obj.target/libsnowcrash/ext/snowcrash/src/Section.o +0 -0
  78. data/ext/drafter/build/out/Release/obj.target/libsnowcrash/ext/snowcrash/src/Signature.o +0 -0
  79. data/ext/drafter/build/out/Release/obj.target/libsnowcrash/ext/snowcrash/src/UriTemplateParser.o +0 -0
  80. data/ext/drafter/build/out/Release/obj.target/libsnowcrash/ext/snowcrash/src/posix/RegexMatch.o +0 -0
  81. data/ext/drafter/build/out/Release/obj.target/libsnowcrash/ext/snowcrash/src/snowcrash.o +0 -0
  82. data/ext/drafter/build/out/Release/obj.target/libsos/ext/sos/src/sos.o +0 -0
  83. data/ext/drafter/build/out/Release/obj.target/libsundown/ext/snowcrash/ext/markdown-parser/ext/sundown/html/houdini_href_e.o +0 -0
  84. data/ext/drafter/build/out/Release/obj.target/libsundown/ext/snowcrash/ext/markdown-parser/ext/sundown/html/houdini_html_e.o +0 -0
  85. data/ext/drafter/build/out/Release/obj.target/libsundown/ext/snowcrash/ext/markdown-parser/ext/sundown/html/html.o +0 -0
  86. data/ext/drafter/build/out/Release/obj.target/libsundown/ext/snowcrash/ext/markdown-parser/ext/sundown/html/html_smartypants.o +0 -0
  87. data/ext/drafter/build/out/Release/obj.target/libsundown/ext/snowcrash/ext/markdown-parser/ext/sundown/src/autolink.o +0 -0
  88. data/ext/drafter/build/out/Release/obj.target/libsundown/ext/snowcrash/ext/markdown-parser/ext/sundown/src/buffer.o +0 -0
  89. data/ext/drafter/build/out/Release/obj.target/libsundown/ext/snowcrash/ext/markdown-parser/ext/sundown/src/markdown.o +0 -0
  90. data/ext/drafter/build/out/Release/obj.target/libsundown/ext/snowcrash/ext/markdown-parser/ext/sundown/src/src_map.o +0 -0
  91. data/ext/drafter/build/out/Release/obj.target/libsundown/ext/snowcrash/ext/markdown-parser/ext/sundown/src/stack.o +0 -0
  92. data/ext/drafter/circle.yml +32 -0
  93. data/ext/drafter/config.gypi +10 -0
  94. data/ext/drafter/config.mk +5 -0
  95. data/ext/drafter/configure +224 -0
  96. data/ext/drafter/drafter.gyp +189 -0
  97. data/ext/drafter/drafter.xcworkspace/contents.xcworkspacedata +13 -0
  98. data/ext/drafter/ext/snowcrash/Makefile +58 -0
  99. data/ext/drafter/ext/snowcrash/appveyor.yml +7 -0
  100. data/ext/drafter/ext/snowcrash/common.gypi +165 -0
  101. data/ext/drafter/ext/snowcrash/configure +197 -0
  102. data/ext/drafter/ext/snowcrash/ext/markdown-parser/Makefile +90 -0
  103. data/ext/drafter/ext/snowcrash/ext/markdown-parser/ext/sundown/CONTRIBUTING.md +10 -0
  104. data/ext/drafter/ext/snowcrash/ext/markdown-parser/ext/sundown/Makefile +84 -0
  105. data/ext/drafter/ext/snowcrash/ext/markdown-parser/ext/sundown/Makefile.win +33 -0
  106. data/ext/drafter/ext/snowcrash/ext/markdown-parser/ext/sundown/examples/smartypants.c +72 -0
  107. data/ext/drafter/ext/snowcrash/ext/markdown-parser/ext/sundown/examples/sundown.c +80 -0
  108. data/ext/drafter/ext/snowcrash/ext/markdown-parser/ext/sundown/html/houdini.h +37 -0
  109. data/ext/drafter/ext/snowcrash/ext/markdown-parser/ext/sundown/html/houdini_href_e.c +108 -0
  110. data/ext/drafter/ext/snowcrash/ext/markdown-parser/ext/sundown/html/houdini_html_e.c +84 -0
  111. data/ext/drafter/ext/snowcrash/ext/markdown-parser/ext/sundown/html/html.c +647 -0
  112. data/ext/drafter/ext/snowcrash/ext/markdown-parser/ext/sundown/html/html.h +77 -0
  113. data/ext/drafter/ext/snowcrash/ext/markdown-parser/ext/sundown/html/html_smartypants.c +389 -0
  114. data/ext/drafter/ext/snowcrash/ext/markdown-parser/ext/sundown/html_block_names.txt +25 -0
  115. data/ext/drafter/ext/snowcrash/ext/markdown-parser/ext/sundown/src/autolink.c +297 -0
  116. data/ext/drafter/ext/snowcrash/ext/markdown-parser/ext/sundown/src/autolink.h +51 -0
  117. data/ext/drafter/ext/snowcrash/ext/markdown-parser/ext/sundown/src/buffer.c +225 -0
  118. data/ext/drafter/ext/snowcrash/ext/markdown-parser/ext/sundown/src/buffer.h +96 -0
  119. data/ext/drafter/ext/snowcrash/ext/markdown-parser/ext/sundown/src/html_blocks.h +206 -0
  120. data/ext/drafter/ext/snowcrash/ext/markdown-parser/ext/sundown/src/markdown.c +2726 -0
  121. data/ext/drafter/ext/snowcrash/ext/markdown-parser/ext/sundown/src/markdown.h +147 -0
  122. data/ext/drafter/ext/snowcrash/ext/markdown-parser/ext/sundown/src/src_map.c +204 -0
  123. data/ext/drafter/ext/snowcrash/ext/markdown-parser/ext/sundown/src/src_map.h +58 -0
  124. data/ext/drafter/ext/snowcrash/ext/markdown-parser/ext/sundown/src/stack.c +81 -0
  125. data/ext/drafter/ext/snowcrash/ext/markdown-parser/ext/sundown/src/stack.h +29 -0
  126. data/ext/drafter/ext/snowcrash/ext/markdown-parser/ext/sundown/sundown.def +20 -0
  127. data/ext/drafter/ext/snowcrash/ext/markdown-parser/msvc/markdown/markdown.vcproj +188 -0
  128. data/ext/drafter/ext/snowcrash/ext/markdown-parser/msvc/msvc.sln +38 -0
  129. data/ext/drafter/ext/snowcrash/ext/markdown-parser/msvc/sundown/sundown.vcproj +206 -0
  130. data/ext/drafter/ext/snowcrash/ext/markdown-parser/src/ByteBuffer.cc +160 -0
  131. data/ext/drafter/ext/snowcrash/ext/markdown-parser/src/ByteBuffer.h +90 -0
  132. data/ext/drafter/ext/snowcrash/ext/markdown-parser/src/MarkdownNode.cc +152 -0
  133. data/ext/drafter/ext/snowcrash/ext/markdown-parser/src/MarkdownNode.h +103 -0
  134. data/ext/drafter/ext/snowcrash/ext/markdown-parser/src/MarkdownParser.cc +388 -0
  135. data/ext/drafter/ext/snowcrash/ext/markdown-parser/src/MarkdownParser.h +106 -0
  136. data/ext/drafter/ext/snowcrash/snowcrash.gyp +196 -0
  137. data/ext/drafter/ext/snowcrash/src/ActionParser.h +560 -0
  138. data/ext/drafter/ext/snowcrash/src/AssetParser.h +123 -0
  139. data/ext/drafter/ext/snowcrash/src/AttributesParser.h +123 -0
  140. data/ext/drafter/ext/snowcrash/src/Blueprint.cc +90 -0
  141. data/ext/drafter/ext/snowcrash/src/Blueprint.h +489 -0
  142. data/ext/drafter/ext/snowcrash/src/BlueprintParser.h +845 -0
  143. data/ext/drafter/ext/snowcrash/src/BlueprintSourcemap.cc +81 -0
  144. data/ext/drafter/ext/snowcrash/src/BlueprintSourcemap.h +345 -0
  145. data/ext/drafter/ext/snowcrash/src/BlueprintUtility.h +111 -0
  146. data/ext/drafter/ext/snowcrash/src/CodeBlockUtility.h +276 -0
  147. data/ext/drafter/ext/snowcrash/src/DataStructureGroupParser.h +157 -0
  148. data/ext/drafter/ext/snowcrash/src/HTTP.cc +49 -0
  149. data/ext/drafter/ext/snowcrash/src/HTTP.h +108 -0
  150. data/ext/drafter/ext/snowcrash/src/HeadersParser.cc +117 -0
  151. data/ext/drafter/ext/snowcrash/src/HeadersParser.h +377 -0
  152. data/ext/drafter/ext/snowcrash/src/MSON.cc +272 -0
  153. data/ext/drafter/ext/snowcrash/src/MSON.h +405 -0
  154. data/ext/drafter/ext/snowcrash/src/MSONMixinParser.h +103 -0
  155. data/ext/drafter/ext/snowcrash/src/MSONNamedTypeParser.h +135 -0
  156. data/ext/drafter/ext/snowcrash/src/MSONOneOfParser.cc +132 -0
  157. data/ext/drafter/ext/snowcrash/src/MSONOneOfParser.h +80 -0
  158. data/ext/drafter/ext/snowcrash/src/MSONParameterParser.h +166 -0
  159. data/ext/drafter/ext/snowcrash/src/MSONPropertyMemberParser.h +106 -0
  160. data/ext/drafter/ext/snowcrash/src/MSONSourcemap.cc +141 -0
  161. data/ext/drafter/ext/snowcrash/src/MSONSourcemap.h +181 -0
  162. data/ext/drafter/ext/snowcrash/src/MSONTypeSectionParser.cc +209 -0
  163. data/ext/drafter/ext/snowcrash/src/MSONTypeSectionParser.h +213 -0
  164. data/ext/drafter/ext/snowcrash/src/MSONUtility.h +506 -0
  165. data/ext/drafter/ext/snowcrash/src/MSONValueMemberParser.cc +214 -0
  166. data/ext/drafter/ext/snowcrash/src/MSONValueMemberParser.h +390 -0
  167. data/ext/drafter/ext/snowcrash/src/ModelTable.h +87 -0
  168. data/ext/drafter/ext/snowcrash/src/ParameterParser.h +516 -0
  169. data/ext/drafter/ext/snowcrash/src/ParametersParser.h +222 -0
  170. data/ext/drafter/ext/snowcrash/src/PayloadParser.h +733 -0
  171. data/ext/drafter/ext/snowcrash/src/Platform.h +33 -0
  172. data/ext/drafter/ext/snowcrash/src/RegexMatch.h +32 -0
  173. data/ext/drafter/ext/snowcrash/src/RelationParser.h +87 -0
  174. data/ext/drafter/ext/snowcrash/src/ResourceGroupParser.h +297 -0
  175. data/ext/drafter/ext/snowcrash/src/ResourceParser.h +536 -0
  176. data/ext/drafter/ext/snowcrash/src/Section.cc +48 -0
  177. data/ext/drafter/ext/snowcrash/src/Section.h +60 -0
  178. data/ext/drafter/ext/snowcrash/src/SectionParser.h +246 -0
  179. data/ext/drafter/ext/snowcrash/src/SectionParserData.h +109 -0
  180. data/ext/drafter/ext/snowcrash/src/SectionProcessor.h +299 -0
  181. data/ext/drafter/ext/snowcrash/src/Signature.cc +75 -0
  182. data/ext/drafter/ext/snowcrash/src/Signature.h +103 -0
  183. data/ext/drafter/ext/snowcrash/src/SignatureSectionProcessor.h +442 -0
  184. data/ext/drafter/ext/snowcrash/src/SourceAnnotation.h +166 -0
  185. data/ext/drafter/ext/snowcrash/src/StringUtility.h +323 -0
  186. data/ext/drafter/ext/snowcrash/src/UriTemplateParser.cc +195 -0
  187. data/ext/drafter/ext/snowcrash/src/UriTemplateParser.h +240 -0
  188. data/ext/drafter/ext/snowcrash/src/ValuesParser.h +111 -0
  189. data/ext/drafter/ext/snowcrash/src/posix/RegexMatch.cc +99 -0
  190. data/ext/drafter/ext/snowcrash/src/snowcrash.cc +90 -0
  191. data/ext/drafter/ext/snowcrash/src/snowcrash.h +44 -0
  192. data/ext/drafter/ext/snowcrash/src/win/RegexMatch.cc +78 -0
  193. data/ext/drafter/ext/snowcrash/tools/gyp/AUTHORS +12 -0
  194. data/ext/drafter/ext/snowcrash/tools/gyp/DEPS +23 -0
  195. data/ext/drafter/ext/snowcrash/tools/gyp/OWNERS +1 -0
  196. data/ext/drafter/ext/snowcrash/tools/gyp/PRESUBMIT.py +137 -0
  197. data/ext/drafter/ext/snowcrash/tools/gyp/buildbot/buildbot_run.py +136 -0
  198. data/ext/drafter/ext/snowcrash/tools/gyp/buildbot/commit_queue/OWNERS +6 -0
  199. data/ext/drafter/ext/snowcrash/tools/gyp/buildbot/commit_queue/cq_config.json +15 -0
  200. data/ext/drafter/ext/snowcrash/tools/gyp/codereview.settings +10 -0
  201. data/ext/drafter/ext/snowcrash/tools/gyp/data/win/large-pdb-shim.cc +12 -0
  202. data/ext/drafter/ext/snowcrash/tools/gyp/gyp +8 -0
  203. data/ext/drafter/ext/snowcrash/tools/gyp/gyp.bat +5 -0
  204. data/ext/drafter/ext/snowcrash/tools/gyp/gyp_main.py +16 -0
  205. data/ext/drafter/ext/snowcrash/tools/gyp/pylib/gyp/MSVSNew.py +340 -0
  206. data/ext/drafter/ext/snowcrash/tools/gyp/pylib/gyp/MSVSProject.py +208 -0
  207. data/ext/drafter/ext/snowcrash/tools/gyp/pylib/gyp/MSVSSettings.py +1096 -0
  208. data/ext/drafter/ext/snowcrash/tools/gyp/pylib/gyp/MSVSToolFile.py +58 -0
  209. data/ext/drafter/ext/snowcrash/tools/gyp/pylib/gyp/MSVSUserFile.py +147 -0
  210. data/ext/drafter/ext/snowcrash/tools/gyp/pylib/gyp/MSVSUtil.py +270 -0
  211. data/ext/drafter/ext/snowcrash/tools/gyp/pylib/gyp/MSVSUtil.pyc +0 -0
  212. data/ext/drafter/ext/snowcrash/tools/gyp/pylib/gyp/MSVSVersion.py +445 -0
  213. data/ext/drafter/ext/snowcrash/tools/gyp/pylib/gyp/MSVSVersion.pyc +0 -0
  214. data/ext/drafter/ext/snowcrash/tools/gyp/pylib/gyp/__init__.py +548 -0
  215. data/ext/drafter/ext/snowcrash/tools/gyp/pylib/gyp/__init__.pyc +0 -0
  216. data/ext/drafter/ext/snowcrash/tools/gyp/pylib/gyp/common.py +608 -0
  217. data/ext/drafter/ext/snowcrash/tools/gyp/pylib/gyp/common.pyc +0 -0
  218. data/ext/drafter/ext/snowcrash/tools/gyp/pylib/gyp/easy_xml.py +157 -0
  219. data/ext/drafter/ext/snowcrash/tools/gyp/pylib/gyp/flock_tool.py +54 -0
  220. data/ext/drafter/ext/snowcrash/tools/gyp/pylib/gyp/generator/__init__.py +0 -0
  221. data/ext/drafter/ext/snowcrash/tools/gyp/pylib/gyp/generator/__init__.pyc +0 -0
  222. data/ext/drafter/ext/snowcrash/tools/gyp/pylib/gyp/generator/analyzer.py +741 -0
  223. data/ext/drafter/ext/snowcrash/tools/gyp/pylib/gyp/generator/android.py +1069 -0
  224. data/ext/drafter/ext/snowcrash/tools/gyp/pylib/gyp/generator/cmake.py +1248 -0
  225. data/ext/drafter/ext/snowcrash/tools/gyp/pylib/gyp/generator/dump_dependency_json.py +99 -0
  226. data/ext/drafter/ext/snowcrash/tools/gyp/pylib/gyp/generator/eclipse.py +425 -0
  227. data/ext/drafter/ext/snowcrash/tools/gyp/pylib/gyp/generator/gypd.py +94 -0
  228. data/ext/drafter/ext/snowcrash/tools/gyp/pylib/gyp/generator/gypsh.py +56 -0
  229. data/ext/drafter/ext/snowcrash/tools/gyp/pylib/gyp/generator/make.py +2218 -0
  230. data/ext/drafter/ext/snowcrash/tools/gyp/pylib/gyp/generator/make.pyc +0 -0
  231. data/ext/drafter/ext/snowcrash/tools/gyp/pylib/gyp/generator/msvs.py +3467 -0
  232. data/ext/drafter/ext/snowcrash/tools/gyp/pylib/gyp/generator/ninja.py +2427 -0
  233. data/ext/drafter/ext/snowcrash/tools/gyp/pylib/gyp/generator/ninja.pyc +0 -0
  234. data/ext/drafter/ext/snowcrash/tools/gyp/pylib/gyp/generator/xcode.py +1300 -0
  235. data/ext/drafter/ext/snowcrash/tools/gyp/pylib/gyp/generator/xcode.pyc +0 -0
  236. data/ext/drafter/ext/snowcrash/tools/gyp/pylib/gyp/input.py +2899 -0
  237. data/ext/drafter/ext/snowcrash/tools/gyp/pylib/gyp/input.pyc +0 -0
  238. data/ext/drafter/ext/snowcrash/tools/gyp/pylib/gyp/mac_tool.py +605 -0
  239. data/ext/drafter/ext/snowcrash/tools/gyp/pylib/gyp/msvs_emulation.py +1093 -0
  240. data/ext/drafter/ext/snowcrash/tools/gyp/pylib/gyp/msvs_emulation.pyc +0 -0
  241. data/ext/drafter/ext/snowcrash/tools/gyp/pylib/gyp/ninja_syntax.py +160 -0
  242. data/ext/drafter/ext/snowcrash/tools/gyp/pylib/gyp/ninja_syntax.pyc +0 -0
  243. data/ext/drafter/ext/snowcrash/tools/gyp/pylib/gyp/ordered_dict.py +289 -0
  244. data/ext/drafter/ext/snowcrash/tools/gyp/pylib/gyp/simple_copy.py +46 -0
  245. data/ext/drafter/ext/snowcrash/tools/gyp/pylib/gyp/simple_copy.pyc +0 -0
  246. data/ext/drafter/ext/snowcrash/tools/gyp/pylib/gyp/win_tool.py +314 -0
  247. data/ext/drafter/ext/snowcrash/tools/gyp/pylib/gyp/xcode_emulation.py +1664 -0
  248. data/ext/drafter/ext/snowcrash/tools/gyp/pylib/gyp/xcode_emulation.pyc +0 -0
  249. data/ext/drafter/ext/snowcrash/tools/gyp/pylib/gyp/xcode_ninja.py +276 -0
  250. data/ext/drafter/ext/snowcrash/tools/gyp/pylib/gyp/xcode_ninja.pyc +0 -0
  251. data/ext/drafter/ext/snowcrash/tools/gyp/pylib/gyp/xcodeproj_file.py +2927 -0
  252. data/ext/drafter/ext/snowcrash/tools/gyp/pylib/gyp/xcodeproj_file.pyc +0 -0
  253. data/ext/drafter/ext/snowcrash/tools/gyp/pylib/gyp/xml_fix.py +69 -0
  254. data/ext/drafter/ext/snowcrash/tools/gyp/pylintrc +307 -0
  255. data/ext/drafter/ext/snowcrash/tools/gyp/samples/samples +81 -0
  256. data/ext/drafter/ext/snowcrash/tools/gyp/samples/samples.bat +5 -0
  257. data/ext/drafter/ext/snowcrash/tools/gyp/setup.py +19 -0
  258. data/ext/drafter/ext/snowcrash/tools/gyp/tools/Xcode/Specifications/gyp.pbfilespec +27 -0
  259. data/ext/drafter/ext/snowcrash/tools/gyp/tools/Xcode/Specifications/gyp.xclangspec +226 -0
  260. data/ext/drafter/ext/snowcrash/tools/gyp/tools/emacs/gyp.el +275 -0
  261. data/ext/drafter/ext/snowcrash/tools/gyp/tools/graphviz.py +100 -0
  262. data/ext/drafter/ext/snowcrash/tools/gyp/tools/pretty_gyp.py +155 -0
  263. data/ext/drafter/ext/snowcrash/tools/gyp/tools/pretty_sln.py +169 -0
  264. data/ext/drafter/ext/snowcrash/tools/gyp/tools/pretty_vcproj.py +329 -0
  265. data/ext/drafter/ext/snowcrash/vcbuild.bat +139 -0
  266. data/ext/drafter/ext/sos/Makefile +62 -0
  267. data/ext/drafter/ext/sos/src/sos.cc +235 -0
  268. data/ext/drafter/ext/sos/src/sos.h +188 -0
  269. data/ext/drafter/ext/sos/src/sosJSON.h +121 -0
  270. data/ext/drafter/ext/sos/src/sosYAML.h +105 -0
  271. data/ext/drafter/src/ConversionContext.cc +39 -0
  272. data/ext/drafter/src/ConversionContext.h +34 -0
  273. data/ext/drafter/src/NamedTypesRegistry.cc +405 -0
  274. data/ext/drafter/src/NamedTypesRegistry.h +28 -0
  275. data/ext/drafter/src/NodeInfo.h +143 -0
  276. data/ext/drafter/src/RefractAPI.cc +579 -0
  277. data/ext/drafter/src/RefractAPI.h +28 -0
  278. data/ext/drafter/src/RefractDataStructure.cc +1199 -0
  279. data/ext/drafter/src/RefractDataStructure.h +26 -0
  280. data/ext/drafter/src/RefractElementFactory.cc +107 -0
  281. data/ext/drafter/src/RefractElementFactory.h +67 -0
  282. data/ext/drafter/src/RefractSourceMap.cc +29 -0
  283. data/ext/drafter/src/RefractSourceMap.h +57 -0
  284. data/ext/drafter/src/Render.cc +157 -0
  285. data/ext/drafter/src/Render.h +40 -0
  286. data/ext/drafter/src/Serialize.cc +160 -0
  287. data/ext/drafter/src/Serialize.h +289 -0
  288. data/ext/drafter/src/SerializeAST.cc +507 -0
  289. data/ext/drafter/src/SerializeAST.h +29 -0
  290. data/ext/drafter/src/SerializeResult.cc +170 -0
  291. data/ext/drafter/src/SerializeResult.h +34 -0
  292. data/ext/drafter/src/SerializeSourcemap.cc +331 -0
  293. data/ext/drafter/src/SerializeSourcemap.h +21 -0
  294. data/ext/drafter/src/Version.h +40 -0
  295. data/ext/drafter/src/config.cc +91 -0
  296. data/ext/drafter/src/config.h +38 -0
  297. data/ext/drafter/src/drafter.cc +137 -0
  298. data/ext/drafter/src/drafter.h +102 -0
  299. data/ext/drafter/src/drafter_private.cc +85 -0
  300. data/ext/drafter/src/drafter_private.h +34 -0
  301. data/ext/drafter/src/main.cc +137 -0
  302. data/ext/drafter/src/refract/AppendDecorator.h +58 -0
  303. data/ext/drafter/src/refract/Build.h +67 -0
  304. data/ext/drafter/src/refract/ComparableVisitor.cc +43 -0
  305. data/ext/drafter/src/refract/ComparableVisitor.h +62 -0
  306. data/ext/drafter/src/refract/Element.cc +409 -0
  307. data/ext/drafter/src/refract/Element.h +656 -0
  308. data/ext/drafter/src/refract/ElementFwd.h +37 -0
  309. data/ext/drafter/src/refract/ElementInserter.h +59 -0
  310. data/ext/drafter/src/refract/Exception.h +31 -0
  311. data/ext/drafter/src/refract/ExpandVisitor.cc +359 -0
  312. data/ext/drafter/src/refract/ExpandVisitor.h +58 -0
  313. data/ext/drafter/src/refract/FilterVisitor.h +52 -0
  314. data/ext/drafter/src/refract/IsExpandableVisitor.cc +140 -0
  315. data/ext/drafter/src/refract/IsExpandableVisitor.h +31 -0
  316. data/ext/drafter/src/refract/Iterate.h +160 -0
  317. data/ext/drafter/src/refract/JSONSchemaVisitor.cc +675 -0
  318. data/ext/drafter/src/refract/JSONSchemaVisitor.h +73 -0
  319. data/ext/drafter/src/refract/PrintVisitor.cc +164 -0
  320. data/ext/drafter/src/refract/PrintVisitor.h +50 -0
  321. data/ext/drafter/src/refract/Query.cc +13 -0
  322. data/ext/drafter/src/refract/Query.h +38 -0
  323. data/ext/drafter/src/refract/Registry.cc +114 -0
  324. data/ext/drafter/src/refract/Registry.h +43 -0
  325. data/ext/drafter/src/refract/RenderJSONVisitor.cc +255 -0
  326. data/ext/drafter/src/refract/RenderJSONVisitor.h +51 -0
  327. data/ext/drafter/src/refract/SerializeCompactVisitor.cc +167 -0
  328. data/ext/drafter/src/refract/SerializeCompactVisitor.h +56 -0
  329. data/ext/drafter/src/refract/SerializeVisitor.cc +214 -0
  330. data/ext/drafter/src/refract/SerializeVisitor.h +55 -0
  331. data/ext/drafter/src/refract/TypeQueryVisitor.cc +46 -0
  332. data/ext/drafter/src/refract/TypeQueryVisitor.h +110 -0
  333. data/ext/drafter/src/refract/Visitor.h +126 -0
  334. data/ext/drafter/src/refract/VisitorUtils.cc +63 -0
  335. data/ext/drafter/src/refract/VisitorUtils.h +231 -0
  336. data/ext/drafter/src/reporting.cc +263 -0
  337. data/ext/drafter/src/reporting.h +39 -0
  338. data/ext/drafter/src/stream.h +148 -0
  339. data/ext/drafter/tools/homebrew/drafter.rb +18 -0
  340. data/ext/drafter/tools/make-tarball.sh +39 -0
  341. data/ext/drafter/tools/refract-filter.py +96 -0
  342. data/ext/drafter/tools/release.sh +17 -0
  343. data/ext/drafter/vcbuild.bat +203 -0
  344. data/lib/lounge_lizard/binding.rb +29 -0
  345. data/lib/lounge_lizard/version.rb +3 -0
  346. data/lib/lounge_lizard.rb +18 -0
  347. data/lounge_lizard.gemspec +37 -0
  348. metadata +547 -0
@@ -0,0 +1,579 @@
1
+ //
2
+ // RefractAPI.cc
3
+ // drafter
4
+ //
5
+ // Created by Jiri Kratochvil on 31/07/15.
6
+ // Copyright (c) 2015 Apiary Inc. All rights reserved.
7
+ //
8
+
9
+
10
+ #include "SourceAnnotation.h"
11
+ #include "RefractDataStructure.h"
12
+ #include "RefractAPI.h"
13
+ #include "Render.h"
14
+
15
+ #include "RefractSourceMap.h"
16
+
17
+ #include <iterator>
18
+ #include <set>
19
+
20
+ #include "NamedTypesRegistry.h"
21
+ #include "ConversionContext.h"
22
+
23
+ namespace drafter {
24
+
25
+ // Forward Declarations
26
+ using refract::RefractElements;
27
+ refract::IElement* ElementToRefract(const NodeInfo<snowcrash::Element>& element, ConversionContext& context);
28
+
29
+ namespace {
30
+
31
+ template <typename T>
32
+ bool IsNull(const T* ptr)
33
+ {
34
+ return ptr == NULL;
35
+ }
36
+
37
+ void RemoveEmptyElements(RefractElements& elements)
38
+ {
39
+ elements.erase(std::remove_if(elements.begin(), elements.end(), IsNull<refract::IElement>), elements.end());
40
+ }
41
+
42
+ template <typename T, typename Functor>
43
+ struct ContextBinder {
44
+
45
+ const Functor& functor;
46
+ ConversionContext& context;
47
+
48
+ ContextBinder(const Functor& functor, ConversionContext& context) : functor(functor), context(context) {}
49
+
50
+ refract::IElement* operator()(const NodeInfo<T>& nodeInfo) const {
51
+ return functor(nodeInfo, context);
52
+ }
53
+ };
54
+
55
+ template <typename T, typename Functor>
56
+ void NodeInfoToElements(const NodeInfo<T>& nodeInfo, const Functor& transformFunctor, RefractElements& content, ConversionContext& context)
57
+ {
58
+ NodeInfoCollection<T> nodeInfoCollection(nodeInfo);
59
+
60
+ std::transform(nodeInfoCollection.begin(), nodeInfoCollection.end(),
61
+ std::back_inserter(content),
62
+ ContextBinder<typename T::value_type, Functor>(transformFunctor, context));
63
+ }
64
+
65
+ template<typename T, typename C, typename F>
66
+ T* CollectionToRefract(const NodeInfo<C>& collection, ConversionContext& context, const F& transformFunctor, const std::string& key = std::string(), const refract::IElement::renderFlags renderType = refract::IElement::rCompact)
67
+ {
68
+ T* element = new T;
69
+ RefractElements content;
70
+
71
+ if (!key.empty()) {
72
+ element->element(key);
73
+ }
74
+
75
+ NodeInfoToElements(collection, transformFunctor, content, context);
76
+
77
+ RemoveEmptyElements(content);
78
+
79
+ element->set(content);
80
+
81
+ element->renderType(renderType);
82
+
83
+ return element;
84
+ }
85
+ }
86
+
87
+ refract::IElement* DataStructureToRefract(const NodeInfo<snowcrash::DataStructure>& dataStructure, ConversionContext& context)
88
+ {
89
+ // TODO: Check for already expanded MSON in context.registry and use it if possible.
90
+ // We aren't doing it yet because APIB AST with MSON Refract will start getting sourcemaps
91
+ // which is a breaking change. Once we remove APIB AST code, we can move forward with this.
92
+ refract::IElement* msonElement = MSONToRefract(dataStructure, context);
93
+
94
+ if (context.options.expandMSON) {
95
+ refract::IElement* msonExpanded = ExpandRefract(msonElement, context);
96
+ msonElement = msonExpanded;
97
+ }
98
+
99
+ if (!msonElement) {
100
+ return NULL;
101
+ }
102
+
103
+ refract::ObjectElement* element = new refract::ObjectElement;
104
+ element->element(SerializeKey::DataStructure);
105
+ element->push_back(msonElement);
106
+
107
+ return element;
108
+ }
109
+
110
+ refract::IElement* MetadataToRefract(const NodeInfo<snowcrash::Metadata>& metadata, ConversionContext& context)
111
+ {
112
+ refract::MemberElement* element = new refract::MemberElement;
113
+
114
+ refract::ArrayElement* classes = CreateArrayElement(SerializeKey::User);
115
+ classes->renderType(refract::IElement::rCompact);
116
+
117
+ element->meta[SerializeKey::Classes] = classes;
118
+ element->set(refract::IElement::Create(metadata.node->first), refract::IElement::Create(metadata.node->second));
119
+ element->renderType(refract::IElement::rFull);
120
+
121
+ AttachSourceMap(element, metadata);
122
+
123
+ return element;
124
+ }
125
+
126
+ refract::IElement* CopyToRefract(const NodeInfo<std::string>& copy)
127
+ {
128
+ if (copy.node->empty()) {
129
+ return NULL;
130
+ }
131
+
132
+ refract::IElement* element = PrimitiveToRefract(copy);
133
+ element->element(SerializeKey::Copy);
134
+
135
+ return element;
136
+ }
137
+
138
+ template<typename T>
139
+ refract::IElement* ParameterValuesToRefract(const NodeInfo<snowcrash::Parameter>& parameter, ConversionContext& context)
140
+ {
141
+ refract::ArrayElement* element = CollectionToRefract<refract::ArrayElement>(MAKE_NODE_INFO(parameter, values),
142
+ context,
143
+ LiteralToRefract<T>,
144
+ SerializeKey::Enum,
145
+ refract::IElement::rDefault);
146
+
147
+ // Add sample value
148
+ if (!parameter.node->exampleValue.empty()) {
149
+ refract::ArrayElement* samples = new refract::ArrayElement;
150
+ samples->push_back(CreateArrayElement(LiteralToRefract<T>(MAKE_NODE_INFO(parameter, exampleValue), context), true));
151
+ element->attributes[SerializeKey::Samples] = samples;
152
+ }
153
+
154
+ // Add default value
155
+ if (!parameter.node->defaultValue.empty()) {
156
+ element->attributes[SerializeKey::Default] = CreateArrayElement(LiteralToRefract<T>(MAKE_NODE_INFO(parameter, defaultValue), context), true);
157
+ }
158
+
159
+ return element;
160
+ }
161
+
162
+ template<typename T>
163
+ refract::IElement* ExtractParameter(const NodeInfo<snowcrash::Parameter>& parameter, ConversionContext& context)
164
+ {
165
+ refract::IElement* element = NULL;
166
+
167
+ if (parameter.node->values.empty()) {
168
+ if (parameter.node->exampleValue.empty()) {
169
+ typedef typename refract::ElementTypeSelector<T>::ElementType ElementType;
170
+ element = new ElementType;
171
+ }
172
+ else {
173
+ element = LiteralToRefract<T>(MAKE_NODE_INFO(parameter, exampleValue), context);
174
+ }
175
+
176
+ if (!parameter.node->defaultValue.empty()) {
177
+ element->attributes[SerializeKey::Default] = PrimitiveToRefract(MAKE_NODE_INFO(parameter, defaultValue));
178
+ }
179
+ }
180
+ else {
181
+ element = ParameterValuesToRefract<T>(parameter, context);
182
+ }
183
+
184
+ return element;
185
+ }
186
+
187
+ refract::IElement* ParameterToRefract(const NodeInfo<snowcrash::Parameter>& parameter, ConversionContext& context)
188
+ {
189
+ refract::MemberElement* element = new refract::MemberElement;
190
+ refract::IElement *value = NULL;
191
+
192
+ // Parameter type, exampleValue, defaultValue, values
193
+ if (parameter.node->type == "boolean") {
194
+ value = ExtractParameter<bool>(parameter, context);
195
+ }
196
+ else if (parameter.node->type == "number") {
197
+ value = ExtractParameter<double>(parameter, context);
198
+ }
199
+ else {
200
+ value = ExtractParameter<std::string>(parameter, context);
201
+ }
202
+
203
+ element->set(PrimitiveToRefract(MAKE_NODE_INFO(parameter, name)), value);
204
+
205
+ // Description
206
+ if (!parameter.node->description.empty()) {
207
+ element->meta[SerializeKey::Description] = PrimitiveToRefract(MAKE_NODE_INFO(parameter, description));
208
+ }
209
+
210
+ // Parameter use
211
+ std::string use = SerializeKey::Required;
212
+
213
+ if (parameter.node->use == snowcrash::OptionalParameterUse) {
214
+ use = SerializeKey::Optional;
215
+ }
216
+
217
+ refract::ArrayElement* typeAttributes = new refract::ArrayElement;
218
+
219
+ typeAttributes->push_back(refract::IElement::Create(use));
220
+ element->attributes[SerializeKey::TypeAttributes] = typeAttributes;
221
+
222
+ return element;
223
+ }
224
+
225
+ refract::IElement* ParametersToRefract(const NodeInfo<snowcrash::Parameters>& parameters, ConversionContext& context)
226
+ {
227
+ return CollectionToRefract<refract::ObjectElement>(parameters, context, ParameterToRefract, SerializeKey::HrefVariables, refract::IElement::rFull);
228
+ }
229
+
230
+ refract::IElement* HeaderToRefract(const NodeInfo<snowcrash::Header>& header, ConversionContext& context)
231
+ {
232
+ refract::MemberElement* element = new refract::MemberElement;
233
+
234
+ element->set(refract::IElement::Create(header.node->first), refract::IElement::Create(header.node->second));
235
+
236
+ AttachSourceMap(element, header);
237
+
238
+ return element;
239
+ }
240
+
241
+ refract::IElement* AssetToRefract(const NodeInfo<snowcrash::Asset>& asset, const std::string& contentType, const std::string& metaClass)
242
+ {
243
+ if (asset.node->empty()) {
244
+ return NULL;
245
+ }
246
+
247
+ refract::IElement* element = PrimitiveToRefract(asset);
248
+
249
+ element->element(SerializeKey::Asset);
250
+ element->meta[SerializeKey::Classes] = CreateArrayElement(metaClass);
251
+
252
+ if (!contentType.empty()) {
253
+ // FIXME: "contentType" has no sourceMap?
254
+ element->attributes[SerializeKey::ContentType] = refract::IElement::Create(contentType);
255
+ }
256
+
257
+ return element;
258
+ }
259
+
260
+ refract::IElement* PayloadToRefract(const NodeInfo<snowcrash::Payload>& payload, const NodeInfo<snowcrash::Action>& action, ConversionContext& context)
261
+ {
262
+ refract::ArrayElement* element = new refract::ArrayElement;
263
+ RefractElements content;
264
+
265
+ // Use HTTP method to recognize if request or response
266
+ if (action.isNull() || action.node->method.empty()) {
267
+ element->element(SerializeKey::HTTPResponse);
268
+
269
+ // FIXME: tests pass without commented out part of condition
270
+ // delivery test to see this part is required else remove it
271
+ // related discussion: https://github.com/apiaryio/drafter/pull/148/files#r42275194
272
+ if (!payload.isNull() /* && !payload.node->name.empty() */) {
273
+ element->attributes[SerializeKey::StatusCode] = PrimitiveToRefract(MAKE_NODE_INFO(payload, name));
274
+ }
275
+ }
276
+ else {
277
+ element->element(SerializeKey::HTTPRequest);
278
+ element->attributes[SerializeKey::Method] = PrimitiveToRefract(MAKE_NODE_INFO(action, method));
279
+
280
+ if (!payload.isNull() && !payload.node->name.empty()) {
281
+ element->meta[SerializeKey::Title] = PrimitiveToRefract(MAKE_NODE_INFO(payload, name));
282
+ }
283
+ }
284
+
285
+ AttachSourceMap(element, payload);
286
+
287
+ // If no payload, return immediately
288
+ if (payload.isNull()) {
289
+ element->set(content);
290
+ return element;
291
+ }
292
+
293
+ if (!payload.node->parameters.empty()) {
294
+ element->attributes[SerializeKey::HrefVariables] = ParametersToRefract(MAKE_NODE_INFO(payload, parameters), context);
295
+ }
296
+
297
+ if (!payload.node->headers.empty()) {
298
+ element->attributes[SerializeKey::Headers] = CollectionToRefract<refract::ArrayElement>(MAKE_NODE_INFO(payload, headers),
299
+ context,
300
+ HeaderToRefract,
301
+ SerializeKey::HTTPHeaders,
302
+ refract::IElement::rFull);
303
+ }
304
+
305
+ content.push_back(CopyToRefract(MAKE_NODE_INFO(payload, description)));
306
+ content.push_back(DataStructureToRefract(MAKE_NODE_INFO(payload, attributes), context));
307
+
308
+ // FIXME: This whole rendering should be done after converting to refract. Currently, both
309
+ // the renders will do MSONToRefract individually on the same thing. So, basically, the attributes
310
+ // in a payload gets converted to refract 3 times which is something we should fix.
311
+ try {
312
+ // Render using boutique
313
+ NodeInfoByValue<snowcrash::Asset> payloadBody = renderPayloadBody(payload, action, context);
314
+ NodeInfoByValue<snowcrash::Asset> payloadSchema = renderPayloadSchema(payload, action, context);
315
+
316
+ // Get content type
317
+ std::string contentType = getContentTypeFromHeaders(payload.node->headers);
318
+ std::string schemaContentType = snowcrash::RegexMatch(contentType, JSONRegex) ? JSONSchemaContentType : contentType;
319
+
320
+ // Push Body Asset
321
+ content.push_back(AssetToRefract(NodeInfo<snowcrash::Asset>(payloadBody), contentType, SerializeKey::MessageBody));
322
+
323
+ // Render only if Body is JSON or Schema is defined
324
+ if (!payloadSchema.first.empty()) {
325
+ content.push_back(AssetToRefract(NodeInfo<snowcrash::Asset>(payloadSchema), schemaContentType, SerializeKey::MessageBodySchema));
326
+ }
327
+ }
328
+
329
+ // what to do?
330
+ // we are not able to generate JSON and/or JSON Schema
331
+ // this is not fatal, rethrow will finish conversion
332
+
333
+ // ideal solution is add warning into collection
334
+ // but there is no way how to do it
335
+ // in current time we solve it by rethrow
336
+ catch (snowcrash::Error& e) {
337
+ context.warn(
338
+ snowcrash::Warning("unable to render JSON/JSONSchema. " + e.message,
339
+ snowcrash::ApplicationError,
340
+ payload.sourceMap->sourceMap));
341
+ }
342
+ catch (refract::LogicError& e) {
343
+ context.warn(
344
+ snowcrash::Warning(std::string(
345
+ "unable to render JSON/JSONSchema. ").append(
346
+ e.what()),
347
+ snowcrash::ApplicationError,
348
+ payload.sourceMap->sourceMap));
349
+ }
350
+
351
+ RemoveEmptyElements(content);
352
+ element->set(content);
353
+
354
+ return element;
355
+ }
356
+
357
+ refract::IElement* TransactionToRefract(const NodeInfo<snowcrash::TransactionExample>& transaction,
358
+ const NodeInfo<snowcrash::Action>& action,
359
+ const NodeInfo<snowcrash::Request>& request,
360
+ const NodeInfo<snowcrash::Response>& response,
361
+ ConversionContext& context)
362
+ {
363
+ refract::ArrayElement* element = new refract::ArrayElement;
364
+ RefractElements content;
365
+
366
+ element->element(SerializeKey::HTTPTransaction);
367
+ content.push_back(CopyToRefract(MAKE_NODE_INFO(transaction, description)));
368
+
369
+ content.push_back(PayloadToRefract(request, action, context));
370
+ content.push_back(PayloadToRefract(response, NodeInfo<snowcrash::Action>(), context));
371
+
372
+ RemoveEmptyElements(content);
373
+ element->set(content);
374
+
375
+ return element;
376
+ }
377
+
378
+ refract::IElement* ActionToRefract(const NodeInfo<snowcrash::Action>& action, ConversionContext& context)
379
+ {
380
+ refract::ArrayElement* element = new refract::ArrayElement;
381
+ RefractElements content;
382
+
383
+ element->element(SerializeKey::Transition);
384
+ element->meta[SerializeKey::Title] = PrimitiveToRefract(MAKE_NODE_INFO(action, name));
385
+
386
+ if (!action.node->relation.str.empty()) {
387
+ // We can't use PrimitiveToRefract() because `action.node->relation` here is a struct Relation
388
+ refract::StringElement* relation = refract::IElement::Create(action.node->relation.str);
389
+ AttachSourceMap(relation, MAKE_NODE_INFO(action, relation));
390
+
391
+ element->attributes[SerializeKey::Relation] = relation;
392
+ }
393
+
394
+ if (!action.node->uriTemplate.empty()) {
395
+ element->attributes[SerializeKey::Href] = PrimitiveToRefract(MAKE_NODE_INFO(action, uriTemplate));
396
+ }
397
+
398
+ if (!action.node->parameters.empty()) {
399
+ element->attributes[SerializeKey::HrefVariables] = ParametersToRefract(MAKE_NODE_INFO(action, parameters), context);
400
+ }
401
+
402
+ if (!action.node->attributes.empty()) {
403
+ refract::IElement* dataStructure = DataStructureToRefract(MAKE_NODE_INFO(action, attributes), context);
404
+ dataStructure->renderType(refract::IElement::rFull);
405
+ element->attributes[SerializeKey::Data] = dataStructure;
406
+ }
407
+
408
+ content.push_back(CopyToRefract(MAKE_NODE_INFO(action, description)));
409
+
410
+ typedef NodeInfoCollection<snowcrash::TransactionExamples> ExamplesType;
411
+ ExamplesType examples(MAKE_NODE_INFO(action, examples));
412
+
413
+ for (ExamplesType::const_iterator it = examples.begin();
414
+ it != examples.end();
415
+ ++it) {
416
+
417
+ // When there are only responses
418
+ if (it->node->requests.empty() && !it->node->responses.empty()) {
419
+
420
+ typedef NodeInfoCollection<snowcrash::Responses> ResponsesType;
421
+ ResponsesType responses(it->node->responses, it->sourceMap->responses);
422
+
423
+ for (ResponsesType::const_iterator resIt = responses.begin();
424
+ resIt != responses.end();
425
+ ++resIt) {
426
+
427
+ content.push_back(TransactionToRefract(*it, action, NodeInfo<snowcrash::Request>(), *resIt, context));
428
+ }
429
+ }
430
+
431
+ // When there are only requests or both responses and requests
432
+ typedef NodeInfoCollection<snowcrash::Requests> RequestsType;
433
+ RequestsType requests(it->node->requests, it->sourceMap->requests);
434
+
435
+ for (RequestsType::const_iterator reqIt = requests.begin();
436
+ reqIt != requests.end();
437
+ ++reqIt) {
438
+
439
+ if (it->node->responses.empty()) {
440
+ content.push_back(TransactionToRefract(*it, action, *reqIt, NodeInfo<snowcrash::Response>(), context));
441
+ }
442
+
443
+ typedef NodeInfoCollection<snowcrash::Responses> ResponsesType;
444
+ ResponsesType responses(it->node->responses, it->sourceMap->responses);
445
+
446
+ for (ResponsesType::const_iterator resIt = responses.begin();
447
+ resIt != responses.end();
448
+ ++resIt) {
449
+
450
+ content.push_back(TransactionToRefract(*it, action, *reqIt, *resIt, context));
451
+ }
452
+ }
453
+ }
454
+
455
+ RemoveEmptyElements(content);
456
+ element->set(content);
457
+
458
+ return element;
459
+ }
460
+
461
+ refract::IElement* ResourceToRefract(const NodeInfo<snowcrash::Resource>& resource, ConversionContext& context)
462
+ {
463
+ refract::ArrayElement* element = new refract::ArrayElement;
464
+ RefractElements content;
465
+
466
+ element->element(SerializeKey::Resource);
467
+
468
+ element->meta[SerializeKey::Title] = PrimitiveToRefract(MAKE_NODE_INFO(resource, name));
469
+
470
+ element->attributes[SerializeKey::Href] = PrimitiveToRefract(MAKE_NODE_INFO(resource, uriTemplate));
471
+
472
+ if (!resource.node->parameters.empty()) {
473
+ element->attributes[SerializeKey::HrefVariables] = ParametersToRefract(MAKE_NODE_INFO(resource, parameters), context);
474
+ }
475
+
476
+ content.push_back(CopyToRefract(MAKE_NODE_INFO(resource, description)));
477
+ content.push_back(DataStructureToRefract(MAKE_NODE_INFO(resource, attributes), context));
478
+ NodeInfoToElements(MAKE_NODE_INFO(resource, actions), ActionToRefract, content, context);
479
+
480
+ RemoveEmptyElements(content);
481
+
482
+ element->set(content);
483
+
484
+ return element;
485
+ }
486
+
487
+ const snowcrash::SourceMap<snowcrash::Elements>* GetElementChildrenSourceMap(const NodeInfo<snowcrash::Element>& element)
488
+ {
489
+ return element.sourceMap->content.elements().collection.empty()
490
+ ? NodeInfo<snowcrash::Elements>::NullSourceMap()
491
+ : &element.sourceMap->content.elements();
492
+ }
493
+
494
+ refract::IElement* CategoryToRefract(const NodeInfo<snowcrash::Element>& element, ConversionContext& context)
495
+ {
496
+ refract::ArrayElement* category = new refract::ArrayElement;
497
+ RefractElements content;
498
+
499
+ category->element(SerializeKey::Category);
500
+
501
+ if (element.node->category == snowcrash::Element::ResourceGroupCategory) {
502
+ category->meta[SerializeKey::Classes] = CreateArrayElement(SerializeKey::ResourceGroup);
503
+ category->meta[SerializeKey::Title] = PrimitiveToRefract(MAKE_NODE_INFO(element, attributes.name));
504
+ }
505
+ else if (element.node->category == snowcrash::Element::DataStructureGroupCategory) {
506
+ category->meta[SerializeKey::Classes] = CreateArrayElement(SerializeKey::DataStructures);
507
+ }
508
+
509
+ if (!element.node->content.elements().empty()) {
510
+ const NodeInfo<snowcrash::Elements> elementsNodeInfo = MakeNodeInfo(&element.node->content.elements(), GetElementChildrenSourceMap(element));
511
+
512
+ NodeInfoToElements(elementsNodeInfo, ElementToRefract, content, context);
513
+ }
514
+
515
+ RemoveEmptyElements(content);
516
+ category->set(content);
517
+
518
+ return category;
519
+ }
520
+
521
+ refract::IElement* ElementToRefract(const NodeInfo<snowcrash::Element>& element, ConversionContext& context)
522
+ {
523
+ switch (element.node->element) {
524
+ case snowcrash::Element::ResourceElement:
525
+ return ResourceToRefract(MAKE_NODE_INFO(element, content.resource), context);
526
+ case snowcrash::Element::DataStructureElement:
527
+ return DataStructureToRefract(MAKE_NODE_INFO(element, content.dataStructure), context);
528
+ case snowcrash::Element::CopyElement:
529
+ return CopyToRefract(MAKE_NODE_INFO(element, content.copy));
530
+ case snowcrash::Element::CategoryElement:
531
+ return CategoryToRefract(element, context);
532
+ default:
533
+ // we are not able to get sourcemap info there
534
+ // It is strongly dependent on type of element.
535
+ // For unknown type of Element we are not able to locate SourceMap
536
+ // with adequate effort we do not provide it to upper level
537
+ throw snowcrash::Error("unknown type of api description element", snowcrash::ApplicationError);
538
+ }
539
+ }
540
+
541
+ refract::IElement* BlueprintToRefract(const NodeInfo<snowcrash::Blueprint>& blueprint, ConversionContext& context)
542
+ {
543
+ refract::ArrayElement* ast = new refract::ArrayElement;
544
+ RefractElements content;
545
+
546
+ ast->element(SerializeKey::Category);
547
+
548
+ ast->meta[SerializeKey::Classes] = CreateArrayElement(SerializeKey::API);
549
+ ast->meta[SerializeKey::Title] = PrimitiveToRefract(MAKE_NODE_INFO(blueprint, name));
550
+
551
+ content.push_back(CopyToRefract(MAKE_NODE_INFO(blueprint, description)));
552
+
553
+ if (!blueprint.node->metadata.empty()) {
554
+ ast->attributes[SerializeKey::Meta] = CollectionToRefract<refract::ArrayElement>(MAKE_NODE_INFO(blueprint, metadata), context, MetadataToRefract);
555
+ }
556
+
557
+ NodeInfoToElements(MAKE_NODE_INFO(blueprint, content.elements()), ElementToRefract, content, context);
558
+
559
+ RemoveEmptyElements(content);
560
+ ast->set(content);
561
+
562
+ return ast;
563
+ }
564
+
565
+ refract::IElement* AnnotationToRefract(const snowcrash::SourceAnnotation& annotation, const std::string& key)
566
+ {
567
+ refract::IElement* element = refract::IElement::Create(annotation.message);
568
+
569
+ element->element(SerializeKey::Annotation);
570
+
571
+ element->meta[SerializeKey::Classes] = CreateArrayElement(key);
572
+
573
+ element->attributes[SerializeKey::AnnotationCode] = refract::IElement::Create(annotation.code);
574
+ element->attributes[SerializeKey::SourceMap] = SourceMapToRefract(annotation.location);
575
+
576
+ return element;
577
+ }
578
+
579
+ } // namespace drafter
@@ -0,0 +1,28 @@
1
+ //
2
+ // RefractAPI.h
3
+ // drafter
4
+ //
5
+ // Created by Jiri Kratochvil on 31/07/15.
6
+ // Copyright (c) 2015 Apiary Inc. All rights reserved.
7
+ //
8
+
9
+ #ifndef DRAFTER_REFRACTAST_H
10
+ #define DRAFTER_REFRACTAST_H
11
+
12
+ #include "Serialize.h"
13
+
14
+ namespace snowcrash {
15
+ struct SourceAnnotation;
16
+ }
17
+
18
+ namespace drafter {
19
+
20
+ class ConversionContext;
21
+
22
+ refract::IElement* AnnotationToRefract(const snowcrash::SourceAnnotation& annotation, const std::string& key);
23
+
24
+ refract::IElement* DataStructureToRefract(const NodeInfo<snowcrash::DataStructure>& dataStructure, ConversionContext& context);
25
+ refract::IElement* BlueprintToRefract(const NodeInfo<snowcrash::Blueprint>& blueprint, ConversionContext& context);
26
+ }
27
+
28
+ #endif // #ifndef DRAFTER_REFRACTAST_H