Module: LazyGraph
- Defined in:
- lib/lazy_graph.rb,
lib/lazy_graph/cli.rb,
lib/lazy_graph/node.rb,
lib/lazy_graph/graph.rb,
lib/lazy_graph/logger.rb,
lib/lazy_graph/builder.rb,
lib/lazy_graph/context.rb,
lib/lazy_graph/version.rb,
lib/lazy_graph/rack_app.rb,
lib/lazy_graph/hash_utils.rb,
lib/lazy_graph/builder/dsl.rb,
lib/lazy_graph/environment.rb,
lib/lazy_graph/path_parser.rb,
lib/lazy_graph/rack_server.rb,
lib/lazy_graph/builder_group.rb,
lib/lazy_graph/missing_value.rb,
lib/lazy_graph/stack_pointer.rb,
lib/lazy_graph/node/array_node.rb,
lib/lazy_graph/node/object_node.rb,
lib/lazy_graph/node/symbol_hash.rb,
lib/lazy_graph/path_parser/path.rb,
lib/lazy_graph/node/derived_rules.rb,
lib/lazy_graph/node/node_properties.rb,
lib/lazy_graph/path_parser/path_part.rb,
lib/lazy_graph/path_parser/path_group.rb
Overview
LazyGraph supports a bespoke path structure for querying a LazyGraph. It has some overlap with
-
JSON path (but supports querying a subset of object properties), and
-
GraphQL (but it supports direct references to deeply nested properties without preserving structure)/
Example query paths and outputs
“employees” => [{…whole object…, object…]} “employees” => [{ “id”: “3”, “name”: “John Smith, { ”id“: ”4“, ”name“: ”Jane Smith}]} “employees => [{…whole object…, object…]}” “employees => [{…whole object…, object…]}”
Defined Under Namespace
Modules: Environment, HashUtils, Logger, NodeProperties, PathParser Classes: AbortError, ArrayNode, Builder, BuilderGroup, CLI, Context, Graph, MissingValue, Node, ObjectNode, RackApp, RackServer, StackPointer, ValidationError
Constant Summary collapse
- DIGIT_REGEXP =
/^-?\d+$/
- SAFE_TOKEN_REGEXP =
/^[A-Za-z][A-Za-z0-9]*$/
- PROPERTY_CLASSES =
{}
- UNIQUE_NAME_COUNTER =
Hash.new(0)
- VALIDATION_CACHE =
Represents a lazy graph structure based on JSON schema
{}.compare_by_identity
- METASCHEMA =
JSON.load_file(File.join(__dir__, 'lazy-graph.json'))
- VERSION =
'0.2.0'
- POINTER_POOL =
Module to provide lazy graph functionalities using stack pointers.
[]
Class Attribute Summary collapse
-
.logger ⇒ Object
Returns the value of attribute logger.
Class Method Summary collapse
Class Attribute Details
.logger ⇒ Object
Returns the value of attribute logger.
6 7 8 |
# File 'lib/lazy_graph/logger.rb', line 6 def logger @logger end |
Class Method Details
.fetch_property_class(name, members, namespace: nil) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/lazy_graph/node.rb', line 17 def self.fetch_property_class(name, members, namespace: nil) namespace ||= LazyGraph PROPERTY_CLASSES[members] ||= begin name = name.to_s.capitalize.gsub(/(\.|_)([a-zA-Z])/) do |m| m[1].upcase end.gsub(/[^a-zA-Z]/, '').then { |n| n.length > 0 ? n : 'NodeProps' } index = UNIQUE_NAME_COUNTER[[name, namespace]] += 1 full_name = "#{name}#{index > 1 ? index : ''}" namespace.const_set(full_name, NodeProperties.build(**members)) end end |