Class: SpecForge::Documentation::Builder::Compiler
- Inherits:
-
Object
- Object
- SpecForge::Documentation::Builder::Compiler
- Defined in:
- lib/spec_forge/documentation/builder/compiler.rb
Overview
Compiles raw endpoint data into structured documentation format
The Compiler transforms flat endpoint data extracted from test runs into a hierarchical structure organized by URL path and HTTP method. It handles:
- Grouping endpoints by path and HTTP verb
- Sanitizing error responses to exclude invalid request data
- Merging multiple operations with the same status code
- Normalizing parameters, request bodies, and responses
- Type detection for all values
Constant Summary collapse
- UUID_REGEX =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
Regular expression for matching UUID v4 strings
/^[0-9A-F]{8}-[0-9A-F]{4}-4[0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$/i- INTEGER_REGEX =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
Regular expression for matching integer numbers in strings
Matches whole numbers with optional negative sign, used for type detection when analyzing API response data.
/^-?\d+$/- FLOAT_REGEX =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
Regular expression for matching floating point numbers in strings
Matches decimal numbers with optional negative sign, used for type detection when analyzing API response data.
/^-?\d+\.\d+$/
Instance Method Summary collapse
-
#compile ⇒ Hash
Compiles endpoints into a structured documentation format.
-
#initialize(endpoints) ⇒ Compiler
constructor
Creates a new Compiler instance.
Constructor Details
#initialize(endpoints) ⇒ Compiler
Creates a new Compiler instance
60 61 62 |
# File 'lib/spec_forge/documentation/builder/compiler.rb', line 60 def initialize(endpoints) @endpoints = endpoints end |
Instance Method Details
#compile ⇒ Hash
Compiles endpoints into a structured documentation format
Processes all endpoints through grouping, sanitization, merging, and normalization steps to produce a hash structure suitable for documentation generation.
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/spec_forge/documentation/builder/compiler.rb', line 75 def compile # Step one, group the endpoints by their paths and verb # { path: {get: [], post: []}, path_2: {get: []}, ... } grouped = group_endpoints(@endpoints) grouped.each_value do |endpoint| # Operations are those arrays endpoint.transform_values! do |operations| # Step two, clear data from any error (4xx, 5xx) operations operations = sanitize_error_operations(operations) # Step three, merge all of the operations into one single hash operations = merge_operations(operations) # Step four, flatten the operations into one flatten_operations(operations) end end end |