redsnow 0.1.6 → 0.2.0

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.
Files changed (101) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +2 -0
  3. data/ext/snowcrash/Makefile +1 -1
  4. data/ext/snowcrash/bin/snowcrash +0 -0
  5. data/ext/snowcrash/configure +9 -9
  6. data/ext/snowcrash/ext/markdown-parser/Makefile +87 -0
  7. data/ext/snowcrash/{sundown → ext/markdown-parser/ext/sundown}/CONTRIBUTING.md +0 -0
  8. data/ext/snowcrash/{sundown → ext/markdown-parser/ext/sundown}/Makefile +2 -1
  9. data/ext/snowcrash/{sundown → ext/markdown-parser/ext/sundown}/Makefile.win +0 -0
  10. data/ext/snowcrash/{sundown → ext/markdown-parser/ext/sundown}/examples/smartypants.c +0 -0
  11. data/ext/snowcrash/{sundown → ext/markdown-parser/ext/sundown}/examples/sundown.c +0 -0
  12. data/ext/snowcrash/{sundown → ext/markdown-parser/ext/sundown}/html/houdini.h +0 -0
  13. data/ext/snowcrash/{sundown → ext/markdown-parser/ext/sundown}/html/houdini_href_e.c +0 -0
  14. data/ext/snowcrash/{sundown → ext/markdown-parser/ext/sundown}/html/houdini_html_e.c +0 -0
  15. data/ext/snowcrash/{sundown → ext/markdown-parser/ext/sundown}/html/html.c +0 -0
  16. data/ext/snowcrash/{sundown → ext/markdown-parser/ext/sundown}/html/html.h +0 -0
  17. data/ext/snowcrash/{sundown → ext/markdown-parser/ext/sundown}/html/html_smartypants.c +0 -0
  18. data/ext/snowcrash/{sundown → ext/markdown-parser/ext/sundown}/html_block_names.txt +0 -0
  19. data/ext/snowcrash/{sundown → ext/markdown-parser/ext/sundown}/src/autolink.c +0 -0
  20. data/ext/snowcrash/{sundown → ext/markdown-parser/ext/sundown}/src/autolink.h +0 -0
  21. data/ext/snowcrash/{sundown → ext/markdown-parser/ext/sundown}/src/buffer.c +0 -0
  22. data/ext/snowcrash/{sundown → ext/markdown-parser/ext/sundown}/src/buffer.h +1 -1
  23. data/ext/snowcrash/{sundown → ext/markdown-parser/ext/sundown}/src/html_blocks.h +0 -0
  24. data/ext/snowcrash/{sundown → ext/markdown-parser/ext/sundown}/src/markdown.c +9 -3
  25. data/ext/snowcrash/{sundown → ext/markdown-parser/ext/sundown}/src/markdown.h +0 -0
  26. data/ext/snowcrash/{sundown → ext/markdown-parser/ext/sundown}/src/src_map.c +11 -7
  27. data/ext/snowcrash/{sundown → ext/markdown-parser/ext/sundown}/src/src_map.h +1 -1
  28. data/ext/snowcrash/{sundown → ext/markdown-parser/ext/sundown}/src/stack.c +0 -0
  29. data/ext/snowcrash/{sundown → ext/markdown-parser/ext/sundown}/src/stack.h +0 -0
  30. data/ext/snowcrash/{sundown → ext/markdown-parser/ext/sundown}/sundown.def +0 -0
  31. data/ext/snowcrash/ext/markdown-parser/msvc/markdown/markdown.vcproj +188 -0
  32. data/ext/snowcrash/ext/markdown-parser/msvc/msvc.sln +38 -0
  33. data/ext/snowcrash/ext/markdown-parser/msvc/sundown/sundown.vcproj +206 -0
  34. data/ext/snowcrash/ext/markdown-parser/src/ByteBuffer.cc +92 -0
  35. data/ext/snowcrash/ext/markdown-parser/src/ByteBuffer.h +82 -0
  36. data/ext/snowcrash/ext/markdown-parser/src/MarkdownNode.cc +152 -0
  37. data/ext/snowcrash/ext/markdown-parser/src/MarkdownNode.h +103 -0
  38. data/ext/snowcrash/ext/markdown-parser/src/MarkdownParser.cc +388 -0
  39. data/ext/snowcrash/{src → ext/markdown-parser/src}/MarkdownParser.h +43 -33
  40. data/ext/snowcrash/snowcrash.gyp +114 -63
  41. data/ext/snowcrash/src/ActionParser.h +334 -398
  42. data/ext/snowcrash/src/AssetParser.h +82 -171
  43. data/ext/snowcrash/src/Blueprint.h +7 -2
  44. data/ext/snowcrash/src/BlueprintParser.h +212 -286
  45. data/ext/snowcrash/src/BlueprintUtility.h +2 -2
  46. data/ext/snowcrash/src/CBlueprint.h +1 -1
  47. data/ext/snowcrash/src/CSourceAnnotation.cc +11 -11
  48. data/ext/snowcrash/src/CSourceAnnotation.h +9 -9
  49. data/ext/snowcrash/src/CodeBlockUtility.h +199 -149
  50. data/ext/snowcrash/src/HeadersParser.h +197 -0
  51. data/ext/snowcrash/src/ParameterParser.h +429 -0
  52. data/ext/snowcrash/src/ParametersParser.h +136 -211
  53. data/ext/snowcrash/src/PayloadParser.h +458 -562
  54. data/ext/snowcrash/src/Platform.h +0 -3
  55. data/ext/snowcrash/src/ResourceGroupParser.h +183 -164
  56. data/ext/snowcrash/src/ResourceParser.h +325 -493
  57. data/ext/snowcrash/src/Section.cc +42 -0
  58. data/ext/snowcrash/src/Section.h +47 -0
  59. data/ext/snowcrash/src/SectionParser.h +229 -0
  60. data/ext/snowcrash/src/SectionParserData.h +81 -0
  61. data/ext/snowcrash/src/SectionProcessor.h +211 -0
  62. data/ext/snowcrash/src/Signature.cc +74 -0
  63. data/ext/snowcrash/src/Signature.h +32 -0
  64. data/ext/snowcrash/src/SourceAnnotation.h +7 -20
  65. data/ext/snowcrash/src/StringUtility.h +30 -10
  66. data/ext/snowcrash/src/SymbolTable.h +7 -7
  67. data/ext/snowcrash/src/UriTemplateParser.cc +10 -10
  68. data/ext/snowcrash/src/UriTemplateParser.h +11 -14
  69. data/ext/snowcrash/src/ValuesParser.h +122 -0
  70. data/ext/snowcrash/src/Version.h +2 -2
  71. data/ext/snowcrash/src/csnowcrash.cc +5 -5
  72. data/ext/snowcrash/src/csnowcrash.h +3 -3
  73. data/ext/snowcrash/src/snowcrash.cc +74 -4
  74. data/ext/snowcrash/src/snowcrash.h +9 -4
  75. data/ext/snowcrash/src/snowcrash/snowcrash.cc +16 -16
  76. data/ext/snowcrash/tools/homebrew/snowcrash.rb +3 -2
  77. data/ext/snowcrash/vcbuild.bat +13 -4
  78. data/lib/redsnow.rb +5 -5
  79. data/lib/redsnow/binding.rb +1 -1
  80. data/lib/redsnow/blueprint.rb +33 -2
  81. data/lib/redsnow/parseresult.rb +7 -4
  82. data/lib/redsnow/version.rb +1 -1
  83. data/test/redsnow_binding_test.rb +6 -6
  84. data/test/redsnow_parseresult_test.rb +1 -1
  85. metadata +62 -42
  86. data/ext/snowcrash/src/BlockUtility.h +0 -186
  87. data/ext/snowcrash/src/BlueprintParserCore.h +0 -190
  88. data/ext/snowcrash/src/BlueprintSection.h +0 -140
  89. data/ext/snowcrash/src/DescriptionSectionUtility.h +0 -156
  90. data/ext/snowcrash/src/HeaderParser.h +0 -289
  91. data/ext/snowcrash/src/ListBlockUtility.h +0 -273
  92. data/ext/snowcrash/src/ListUtility.h +0 -95
  93. data/ext/snowcrash/src/MarkdownBlock.cc +0 -176
  94. data/ext/snowcrash/src/MarkdownBlock.h +0 -93
  95. data/ext/snowcrash/src/MarkdownParser.cc +0 -266
  96. data/ext/snowcrash/src/ParameterDefinitonParser.h +0 -645
  97. data/ext/snowcrash/src/Parser.cc +0 -71
  98. data/ext/snowcrash/src/Parser.h +0 -29
  99. data/ext/snowcrash/src/ParserCore.cc +0 -120
  100. data/ext/snowcrash/src/ParserCore.h +0 -82
  101. data/ext/snowcrash/src/SectionUtility.h +0 -142
@@ -15,8 +15,8 @@
15
15
  #define SNOWCRASH_VERSION_H
16
16
 
17
17
  #define SNOWCRASH_MAJOR_VERSION 0
18
- #define SNOWCRASH_MINOR_VERSION 12
19
- #define SNOWCRASH_PATCH_VERSION 1
18
+ #define SNOWCRASH_MINOR_VERSION 14
19
+ #define SNOWCRASH_PATCH_VERSION 0
20
20
 
21
21
  #define SNOWCRASH_VERSION_IS_RELEASE 1
22
22
 
@@ -5,19 +5,19 @@
5
5
  // Created by Ali Khoramshahi on 13/6/14.
6
6
  // Copyright (c) 2014 Apiary Inc. All rights reserved.
7
7
  //
8
+
8
9
  #include "csnowcrash.h"
9
10
  #include "snowcrash.h"
10
11
 
11
-
12
- int sc_c_parse(const char* source, sc_blueprint_parser_options option, sc_result_t** result, sc_blueprint_t** blueprint)
12
+ int sc_c_parse(const char* source, sc_blueprint_parser_options option, sc_report_t** report, sc_blueprint_t** blueprint)
13
13
  {
14
- snowcrash::Result* t_result = ::new snowcrash::Result;
14
+ snowcrash::Report* t_report = ::new snowcrash::Report;
15
15
  snowcrash::Blueprint* t_blueprint = ::new snowcrash::Blueprint;
16
16
 
17
- int ret = snowcrash::parse(source, option, *t_result, *t_blueprint);
17
+ int ret = snowcrash::parse(source, option, *t_report, *t_blueprint);
18
18
 
19
19
  *blueprint = AS_TYPE(sc_blueprint_t, t_blueprint);
20
- *result = AS_TYPE(sc_result_t, t_result);
20
+ *report = AS_TYPE(sc_report_t, t_report);
21
21
 
22
22
  return ret;
23
23
  }
@@ -22,14 +22,14 @@ extern "C" {
22
22
  *
23
23
  * \param source A textual source data to be parsed.
24
24
  * \param options Parser options. Use 0 for no addtional options.
25
- * \param result returns the pointer to result report.
25
+ * \param report returns the pointer to report.
26
26
  * \param blueprint returns the pointer to blueprint AST.
27
27
  *
28
28
  * \return Error status code. Zero represents success, non-zero a failure.
29
29
  *
30
- * \this function will allocate `result` and `bluepring`, for deallocation `sc_blueprint_free` and `sc_result_free` should be called.
30
+ * \this function will allocate `report` and `blueprint`, for deallocation `sc_blueprint_free` and `sc_report_free` should be called.
31
31
  */
32
- SC_API int sc_c_parse(const char* source, sc_blueprint_parser_options option, sc_result_t** result, sc_blueprint_t** blueprint);
32
+ SC_API int sc_c_parse(const char* source, sc_blueprint_parser_options option, sc_report_t** report, sc_blueprint_t** blueprint);
33
33
 
34
34
  #ifdef __cplusplus
35
35
  }
@@ -7,12 +7,82 @@
7
7
  //
8
8
 
9
9
  #include "snowcrash.h"
10
+ #include "MarkdownParser.h"
11
+ #include "BlueprintParser.h"
12
+
13
+ const int snowcrash::SourceAnnotation::OK = 0;
10
14
 
11
15
  using namespace snowcrash;
12
16
 
13
- int snowcrash::parse(const SourceData& source, BlueprintParserOptions options, Result& result, Blueprint& blueprint)
17
+ /**
18
+ * \brief Check source for unsupported character \t & \r
19
+ * \return True if passed (not found), false otherwise
20
+ */
21
+ static bool CheckSource(const mdp::ByteBuffer& source, Report& report)
14
22
  {
15
- Parser p;
16
- p.parse(source, options, result, blueprint);
17
- return result.error.code;
23
+ std::string::size_type pos = source.find("\t");
24
+
25
+ if (pos != std::string::npos) {
26
+
27
+ mdp::BytesRangeSet rangeSet;
28
+ rangeSet.push_back(mdp::BytesRange(pos, 1));
29
+ report.error = Error("the use of tab(s) '\\t' in source data isn't currently supported, please contact makers",
30
+ BusinessError,
31
+ mdp::BytesRangeSetToCharactersRangeSet(rangeSet, source));
32
+ return false;
33
+ }
34
+
35
+ pos = source.find("\r");
36
+
37
+ if (pos != std::string::npos) {
38
+
39
+ mdp::BytesRangeSet rangeSet;
40
+ rangeSet.push_back(mdp::BytesRange(pos, 1));
41
+ report.error = Error("the use of carriage return(s) '\\r' in source data isn't currently supported, please contact makers",
42
+ BusinessError,
43
+ mdp::BytesRangeSetToCharactersRangeSet(rangeSet, source));
44
+ return false;
45
+ }
46
+
47
+ return true;
48
+ }
49
+
50
+ int snowcrash::parse(const mdp::ByteBuffer& source,
51
+ BlueprintParserOptions options,
52
+ Report& report,
53
+ Blueprint& blueprint)
54
+ {
55
+ try {
56
+
57
+ // Sanity Check
58
+ if (!CheckSource(source, report))
59
+ return report.error.code;
60
+
61
+ // Do nothing if blueprint is empty
62
+ if (source.empty())
63
+ return report.error.code;
64
+
65
+ // Parse Markdown
66
+ mdp::MarkdownParser markdownParser;
67
+ mdp::MarkdownNode markdownAST;
68
+ markdownParser.parse(source, markdownAST);
69
+
70
+ // Build SectionParserData
71
+ SectionParserData pd(options, source, blueprint);
72
+
73
+ // Parse Blueprint
74
+ BlueprintParser::parse(markdownAST.children().begin(), markdownAST.children(), pd, report, blueprint);
75
+ }
76
+ catch (const std::exception& e) {
77
+
78
+ std::stringstream ss;
79
+ ss << "parser exception: '" << e.what() << "'";
80
+ report.error = Error(ss.str(), 1);
81
+ }
82
+ catch (...) {
83
+
84
+ report.error = Error("parser exception has occured", 1);
85
+ }
86
+
87
+ return report.error.code;
18
88
  }
@@ -9,7 +9,9 @@
9
9
  #ifndef SNOWCRASH_H
10
10
  #define SNOWCRASH_H
11
11
 
12
- #include "Parser.h"
12
+ #include "Blueprint.h"
13
+ #include "SourceAnnotation.h"
14
+ #include "SectionParser.h"
13
15
 
14
16
  /**
15
17
  * API Blueprint Parser Interface
@@ -30,12 +32,15 @@ namespace snowcrash {
30
32
  * \brief Parse the source data into a blueprint abstract source tree (AST).
31
33
  *
32
34
  * \param source A textual source data to be parsed.
33
- * \param options Parser options. Use 0 for no addtional options.
34
- * \param result Parsing result report.
35
+ * \param options Parser options. Use 0 for no additional options.
36
+ * \param report Parsing report.
35
37
  * \param blueprint Parsed blueprint AST.
36
38
  * \return Error status code. Zero represents success, non-zero a failure.
37
39
  */
38
- int parse(const SourceData& source, BlueprintParserOptions options, Result& result, Blueprint& blueprint);
40
+ int parse(const mdp::ByteBuffer& source,
41
+ BlueprintParserOptions options,
42
+ Report& report,
43
+ Blueprint& blueprint);
39
44
  }
40
45
 
41
46
  #endif
@@ -46,7 +46,7 @@ void PrintAnnotation(const std::string& prefix, const snowcrash::SourceAnnotatio
46
46
  }
47
47
 
48
48
  if (!annotation.location.empty()) {
49
- for (snowcrash::SourceCharactersBlock::const_iterator it = annotation.location.begin();
49
+ for (mdp::CharactersRangeSet::const_iterator it = annotation.location.begin();
50
50
  it != annotation.location.end();
51
51
  ++it) {
52
52
  std::cerr << ((it == annotation.location.begin()) ? " :" : ";");
@@ -57,20 +57,20 @@ void PrintAnnotation(const std::string& prefix, const snowcrash::SourceAnnotatio
57
57
  std::cerr << std::endl;
58
58
  }
59
59
 
60
- /// \brief Print parser result to stderr.
61
- /// \param result A parser result to print
62
- void PrintResult(const snowcrash::Result& result)
60
+ /// \brief Print parser report to stderr.
61
+ /// \param report A parser report to print
62
+ void PrintReport(const snowcrash::Report& report)
63
63
  {
64
64
  std::cerr << std::endl;
65
-
66
- if (result.error.code == Error::OK) {
65
+
66
+ if (report.error.code == Error::OK) {
67
67
  std::cerr << "OK.\n";
68
68
  }
69
69
  else {
70
- PrintAnnotation("error:", result.error);
70
+ PrintAnnotation("error:", report.error);
71
71
  }
72
-
73
- for (snowcrash::Warnings::const_iterator it = result.warnings.begin(); it != result.warnings.end(); ++it) {
72
+
73
+ for (snowcrash::Warnings::const_iterator it = report.warnings.begin(); it != report.warnings.end(); ++it) {
74
74
  PrintAnnotation("warning:", *it);
75
75
  }
76
76
  }
@@ -129,10 +129,10 @@ int main(int argc, const char *argv[])
129
129
 
130
130
  // Parse
131
131
  snowcrash::BlueprintParserOptions options = 0; // Or snowcrash::RequireBlueprintNameOption
132
- snowcrash::Result result;
132
+ snowcrash::Report report;
133
133
  snowcrash::Blueprint blueprint;
134
- snowcrash::parse(inputStream.str(), options, result, blueprint);
135
-
134
+ snowcrash::parse(inputStream.str(), options, report, blueprint);
135
+
136
136
  // Output
137
137
  if (!argumentParser.exist(ValidateArgument)) {
138
138
 
@@ -163,8 +163,8 @@ int main(int argc, const char *argv[])
163
163
  std::cout << outputStream.rdbuf();
164
164
  }
165
165
  }
166
-
167
- // Result
168
- PrintResult(result);
169
- return result.error.code;
166
+
167
+ // report
168
+ PrintReport(report);
169
+ return report.error.code;
170
170
  }
@@ -2,10 +2,11 @@ require 'formula'
2
2
 
3
3
  class Snowcrash < Formula
4
4
  homepage 'http://apiblueprint.org'
5
- head 'https://github.com/apiaryio/snowcrash.git', :tag => 'v0.12.1'
5
+ head 'https://github.com/apiaryio/snowcrash.git', :tag => 'v0.14.0'
6
6
 
7
7
  def install
8
8
  system "./configure"
9
- system "make", "install"
9
+ system "make", "snowcrash"
10
+ bin.install Dir["bin/snowcrash"]
10
11
  end
11
12
  end
@@ -36,6 +36,7 @@ if /i "%1"=="noprojgen" set noprojgen=1&goto arg-ok
36
36
  if /i "%1"=="nobuild" set nobuild=1&goto arg-ok
37
37
  if /i "%1"=="test" set test=test&goto arg-ok
38
38
  if /i "%1"=="inttest" set inttest=1&goto arg-ok
39
+ if /i "%1"=="MSVC2013" set GYP_MSVS_VERSION=2013&goto arg-ok
39
40
  if /i "%1"=="MSVC2012" set GYP_MSVS_VERSION=2012&goto arg-ok
40
41
  if /i "%1"=="MSVC2010" set GYP_MSVS_VERSION=2010&goto arg-ok
41
42
  if /i "%1"=="MSVC2008" set GYP_MSVS_VERSION=2008&goto arg-ok
@@ -56,7 +57,7 @@ if "%GYP_MSVS_VERSION%"=="" set GYP_MSVS_VERSION=2012
56
57
 
57
58
  @rem Generate the VS project.
58
59
  SETLOCAL
59
- if defined VS100COMNTOOLS call "%VS100COMNTOOLS%\VCVarsQueryRegistry.bat"
60
+ if defined VS120COMNTOOLS call "%VS120COMNTOOLS%\VCVarsQueryRegistry.bat"
60
61
  if defined inttest python configure %debug_arg% --dest-cpu=%target_arch% --include-integration-tests
61
62
  if not defined inttest python configure %debug_arg% --dest-cpu=%target_arch%
62
63
  if errorlevel 1 goto create-msvs-files-failed
@@ -70,10 +71,18 @@ ENDLOCAL
70
71
  :msbuild
71
72
  @rem Skip project generation if requested.
72
73
  if defined nobuild goto exit
74
+ if "%GYP_MSVS_VERSION%"=="2012" goto vc-set-2012
73
75
  if "%GYP_MSVS_VERSION%"=="2010" goto vc-set-2010
74
76
  if "%GYP_MSVS_VERSION%"=="2008" goto vc-set-2008
75
77
 
76
- @rem Look for Visual Studio 2012
78
+ @rem Look for Visual Studio 2013
79
+ if not defined VS120COMNTOOLS goto vc-set-2012
80
+ if not exist "%VS120COMNTOOLS%\..\..\vc\vcvarsall.bat" goto vc-set-2012
81
+ call "%VS120COMNTOOLS%\..\..\vc\vcvarsall.bat"
82
+ if not defined VCINSTALLDIR goto msbuild-not-found
83
+ goto msbuild-found
84
+
85
+ :vc-set-2012
77
86
  if not defined VS110COMNTOOLS goto vc-set-2010
78
87
  if not exist "%VS110COMNTOOLS%\..\..\vc\vcvarsall.bat" goto vc-set-2010
79
88
  call "%VS110COMNTOOLS%\..\..\vc\vcvarsall.bat"
@@ -170,14 +179,14 @@ echo Failed to create vc project files.
170
179
  goto exit
171
180
 
172
181
  :help
173
- echo vcbuild.bat [debug/release] [test] [clean] [noprojgen] [nobuild] [x86/x64] [inttest] [MSVC2008/MSVC2010/MSVC2012]
182
+ echo vcbuild.bat [debug/release] [test] [clean] [noprojgen] [nobuild] [x86/x64] [inttest] [MSVC2012/MSVC2013]
174
183
  echo Examples:
175
184
  echo vcbuild.bat : builds release build
176
185
  echo vcbuild.bat nobuild : generate MSVS project files only
177
186
  echo vcbuild.bat debug : builds debug build
178
187
  echo vcbuild.bat test : builds debug build and runs tests
179
188
  echo vcbuild.bat inttest : include integration tests
180
- echo vcbuild.bat MSVC2012 : indicate target solution's version, could also define as MSVC2008 , MSVC2010 , MSVC2012
189
+ echo vcbuild.bat MSVC2013 : indicate target solution's version, could also define as MSVC2012, MSVC2013
181
190
  goto exit
182
191
 
183
192
  :exit
@@ -14,18 +14,18 @@ module RedSnow
14
14
  # @return [ParseResult]
15
15
  def self.parse(rawBlueprint, options = 0)
16
16
  blueprint = FFI::MemoryPointer.new :pointer
17
- result = FFI::MemoryPointer.new :pointer
18
- ret = RedSnow::Binding.sc_c_parse(rawBlueprint, options, result, blueprint)
17
+ report = FFI::MemoryPointer.new :pointer
18
+ ret = RedSnow::Binding.sc_c_parse(rawBlueprint, options, report, blueprint)
19
19
 
20
20
  blueprint = blueprint.get_pointer(0)
21
- result = result.get_pointer(0)
21
+ report = report.get_pointer(0)
22
22
 
23
- parseResult = ParseResult.new(blueprint, result)
23
+ parseResult = ParseResult.new(blueprint, report)
24
24
 
25
25
  return parseResult
26
26
  ensure
27
27
  RedSnow::Binding.sc_blueprint_free(blueprint)
28
- RedSnow::Binding.sc_result_free(result)
28
+ RedSnow::Binding.sc_report_free(report)
29
29
  end
30
30
 
31
31
  end
@@ -107,7 +107,7 @@ module RedSnow
107
107
  attach_function("sc_transaction_example_name", "sc_transaction_example_name", [ :pointer ], :string)
108
108
  attach_function("sc_transaction_example_description", "sc_transaction_example_description", [ :pointer ], :string)
109
109
 
110
- attach_function("sc_result_free", "sc_result_free", [ :pointer ], :void)
110
+ attach_function("sc_report_free", "sc_report_free", [ :pointer ], :void)
111
111
 
112
112
  attach_function("sc_location_handler", "sc_location_handler", [ :pointer ], :pointer)
113
113
  attach_function("sc_location_size", "sc_location_size", [ :pointer ], :int)
@@ -78,9 +78,11 @@ module RedSnow
78
78
  # @param sc_metadata_collection_handle [FFI::Pointer]
79
79
  def initialize(sc_metadata_collection_handle)
80
80
  sc_metadata_collection_size = RedSnow::Binding.sc_metadata_collection_size(sc_metadata_collection_handle)
81
+
81
82
  if sc_metadata_collection_size > 0
82
83
  metadata_size = sc_metadata_collection_size - 1
83
84
  @collection = Array.new
85
+
84
86
  for index in 0..metadata_size do
85
87
  sc_metadata_handle = RedSnow::Binding.sc_metadata_handle(sc_metadata_collection_handle, index)
86
88
  @collection << Hash[:name => RedSnow::Binding.sc_metadata_key(sc_metadata_handle), :value => RedSnow::Binding.sc_metadata_value(sc_metadata_handle)]
@@ -96,18 +98,20 @@ module RedSnow
96
98
  # HTTP 'Content-Type' header
97
99
  CONTENT_TYPE_HEADER_KEY = :'Content-Type'
98
100
 
99
-
100
101
  # @return [String] the value of 'Content-type' header if present or nil
101
102
  def content_type
102
103
  content_type_header = @collection.detect { |header| header.has_key?(CONTENT_TYPE_HEADER_KEY) }
103
104
  return (content_type_header.nil?) ? nil : content_type_header[CONTENT_TYPE_HEADER_KEY]
104
105
  end
106
+
105
107
  # @param sc_header_collection_handle_payload [FFI::Pointer]
106
108
  def initialize(sc_header_collection_handle_payload)
107
109
  sc_header_collection_size = RedSnow::Binding.sc_header_collection_size(sc_header_collection_handle_payload)
110
+
108
111
  if sc_header_collection_size > 0
109
112
  headers_size = sc_header_collection_size - 1
110
113
  @collection = Array.new
114
+
111
115
  for index in 0..headers_size do
112
116
  sc_header_handle = RedSnow::Binding.sc_header_handle(sc_header_collection_handle_payload, index)
113
117
  @collection << Hash[:name => RedSnow::Binding.sc_header_key(sc_header_handle), :value => RedSnow::Binding.sc_header_value(sc_header_handle)]
@@ -142,10 +146,13 @@ module RedSnow
142
146
  @default_value = RedSnow::Binding.sc_parameter_default_value(sc_parameter_handle)
143
147
  @example_value = RedSnow::Binding.sc_parameter_example_value(sc_parameter_handle)
144
148
  @values = Array.new
149
+
145
150
  sc_value_collection_handle = RedSnow::Binding.sc_value_collection_handle(sc_parameter_handle)
146
151
  sc_value_collection_size = RedSnow::Binding.sc_value_collection_size(sc_value_collection_handle)
152
+
147
153
  if sc_value_collection_size > 0
148
154
  values_size = sc_value_collection_size - 1
155
+
149
156
  for valueIndex in 0..values_size do
150
157
  sc_value_handle = RedSnow::Binding.sc_value_handle(sc_value_collection_handle, valueIndex)
151
158
  value = RedSnow::Binding.sc_value_string(sc_value_handle)
@@ -163,12 +170,15 @@ module RedSnow
163
170
  class Parameters < BlueprintNode
164
171
 
165
172
  attr_accessor :collection
173
+
166
174
  # @param sc_parameter_collection_handle [FFI::Pointer]
167
175
  def initialize(sc_parameter_collection_handle)
168
176
  sc_parameter_collection_size = RedSnow::Binding.sc_parameter_collection_size(sc_parameter_collection_handle)
169
177
  @collection = Array.new
178
+
170
179
  if sc_parameter_collection_size > 0
171
180
  parameters_size = sc_parameter_collection_size - 1
181
+
172
182
  for index in 0..parameters_size do
173
183
  sc_parameter_handle = RedSnow::Binding.sc_parameter_handle(sc_parameter_collection_handle, index)
174
184
  parameter = Parameter.new(sc_parameter_handle)
@@ -193,6 +203,7 @@ module RedSnow
193
203
  attr_accessor :headers
194
204
  attr_accessor :body
195
205
  attr_accessor :schema
206
+
196
207
  # @param sc_payload_handle_resource [FFI::Pointer]
197
208
  def initialize(sc_payload_handle_resource)
198
209
  @name = RedSnow::Binding.sc_payload_name(sc_payload_handle_resource)
@@ -214,6 +225,7 @@ module RedSnow
214
225
 
215
226
  attr_accessor :requests
216
227
  attr_accessor :responses
228
+
217
229
  # @param sc_transaction_example_handle [FFI::Pointer]
218
230
  def initialize(sc_transaction_example_handle)
219
231
  @name = RedSnow::Binding.sc_transaction_example_name(sc_transaction_example_handle)
@@ -222,25 +234,29 @@ module RedSnow
222
234
  @requests = Array.new
223
235
  sc_payload_collection_handle_requests = RedSnow::Binding.sc_payload_collection_handle_requests(sc_transaction_example_handle)
224
236
  sc_payload_collection_size_requests = RedSnow::Binding.sc_payload_collection_size(sc_payload_collection_handle_requests)
237
+
225
238
  if sc_payload_collection_size_requests > 0
226
239
  requests_size = sc_payload_collection_size_requests - 1
240
+
227
241
  for index in 0..requests_size do
228
242
  request = Payload.new(RedSnow::Binding.sc_payload_handle(sc_payload_collection_handle_requests, index))
229
243
  @requests << request
230
244
  end
231
245
  end
246
+
232
247
  # BP Resource Actions Examples Responses
233
248
  @responses = Array.new
234
249
  sc_payload_collection_handle_responses = RedSnow::Binding.sc_payload_collection_handle_responses(sc_transaction_example_handle)
235
250
  sc_payload_collection_size_responses = RedSnow::Binding.sc_payload_collection_size(sc_payload_collection_handle_responses)
251
+
236
252
  if sc_payload_collection_size_responses > 0
237
253
  responses_size = sc_payload_collection_size_responses - 1
254
+
238
255
  for index in 0..responses_size do
239
256
  response = Payload.new(RedSnow::Binding.sc_payload_handle(sc_payload_collection_handle_responses, index))
240
257
  @responses << response
241
258
  end
242
259
  end
243
-
244
260
  end
245
261
 
246
262
  end
@@ -256,6 +272,7 @@ module RedSnow
256
272
  attr_accessor :method
257
273
  attr_accessor :parameters
258
274
  attr_accessor :examples
275
+
259
276
  # @param sc_action_handle [FFI::Pointer]
260
277
  def initialize(sc_action_handle)
261
278
  @name = RedSnow::Binding.sc_action_name(sc_action_handle)
@@ -268,8 +285,10 @@ module RedSnow
268
285
  @examples = Array.new
269
286
  sc_transaction_example_collection_handle = RedSnow::Binding.sc_transaction_example_collection_handle(sc_action_handle)
270
287
  sc_transaction_example_collection_size = RedSnow::Binding.sc_transaction_example_collection_size(sc_transaction_example_collection_handle)
288
+
271
289
  if sc_transaction_example_collection_size > 0
272
290
  examples_size = sc_transaction_example_collection_size - 1
291
+
273
292
  for index in 0..examples_size do
274
293
  example = TransactionExample.new(RedSnow::Binding.sc_transaction_example_handle(sc_transaction_example_collection_handle, index))
275
294
  @examples << example
@@ -292,6 +311,7 @@ module RedSnow
292
311
  attr_accessor :model
293
312
  attr_accessor :parameters
294
313
  attr_accessor :actions
314
+
295
315
  # @param sc_resource_handle [FFI::Pointer]
296
316
  def initialize(sc_resource_handle)
297
317
  @name = RedSnow::Binding.sc_resource_name(sc_resource_handle)
@@ -304,12 +324,15 @@ module RedSnow
304
324
  @actions = Array.new
305
325
  sc_action_collection_handle = RedSnow::Binding.sc_action_collection_handle(sc_resource_handle)
306
326
  sc_action_collection_size = RedSnow::Binding.sc_action_collection_size(sc_action_collection_handle)
327
+
307
328
  if sc_action_collection_size > 0
308
329
  action_size = sc_action_collection_size - 1
330
+
309
331
  for index in 0..action_size do
310
332
  @actions << Action.new(RedSnow::Binding.sc_action_handle(sc_action_collection_handle, index))
311
333
  end
312
334
  end
335
+
313
336
  @parameters = Parameters.new(RedSnow::Binding.sc_parameter_collection_handle_resource(sc_resource_handle))
314
337
  end
315
338
 
@@ -322,6 +345,7 @@ module RedSnow
322
345
  class ResourceGroup < NamedBlueprintNode
323
346
 
324
347
  attr_accessor :resources
348
+
325
349
  # @param sc_resource_groups_handle [FFI::Pointer]
326
350
  def initialize(sc_resource_groups_handle)
327
351
  @name = RedSnow::Binding.sc_resource_groups_name(sc_resource_groups_handle)
@@ -330,8 +354,10 @@ module RedSnow
330
354
  @resources = Array.new
331
355
  sc_resource_collection_handle = RedSnow::Binding.sc_resource_collection_handle(sc_resource_groups_handle)
332
356
  sc_resource_collection_size = RedSnow::Binding.sc_resource_collection_size(sc_resource_collection_handle)
357
+
333
358
  if sc_resource_collection_size > 0
334
359
  resource_size = sc_resource_collection_size - 1
360
+
335
361
  for index in 0..resource_size do
336
362
  sc_resource_handle = RedSnow::Binding.sc_resource_handle(sc_resource_collection_handle, index)
337
363
  @resources << Resource.new(sc_resource_handle)
@@ -351,10 +377,13 @@ module RedSnow
351
377
 
352
378
  attr_accessor :metadata
353
379
  attr_accessor :resource_groups
380
+
354
381
  # Version key
355
382
  VERSION_KEY = :_version
383
+
356
384
  # Supported version of Api Blueprint
357
385
  SUPPORTED_VERSIONS = ["2.0"]
386
+
358
387
  # @param handle [FFI:Pointer]
359
388
  def initialize(handle)
360
389
  # BP name, desc
@@ -369,8 +398,10 @@ module RedSnow
369
398
  sc_resource_groups_collection_handle = RedSnow::Binding.sc_resource_groups_collection_handle(handle)
370
399
  sc_resource_groups_collection_size = RedSnow::Binding.sc_resource_groups_collection_size(sc_resource_groups_collection_handle)
371
400
  @resource_groups = Array.new
401
+
372
402
  if sc_resource_groups_collection_size > 0
373
403
  group_size = sc_resource_groups_collection_size - 1
404
+
374
405
  for index in 0..group_size do
375
406
  sc_resource_groups_handle = RedSnow::Binding.sc_resource_groups_handle(sc_resource_groups_collection_handle, index)
376
407
  @resource_groups << ResourceGroup.new(sc_resource_groups_handle)