Module: TreeHaver::Backends::Psych
- Defined in:
- lib/tree_haver/backends/psych.rb
Overview
Note:
This backend only parses YAML source code
Psych backend using Ruby’s built-in YAML parser
This backend wraps Psych, Ruby’s standard library YAML parser. Psych provides AST access via Psych.parse_stream which returns Psych::Nodes::* objects (Stream, Document, Mapping, Sequence, Scalar, Alias).
Defined Under Namespace
Classes: Language, Node, Parser, Point, Tree
Class Method Summary collapse
- .available? ⇒ Boolean
-
.capabilities ⇒ Hash{Symbol => Object}
Get capabilities supported by this backend.
-
.reset! ⇒ void
private
Reset the load state (primarily for testing).
Class Method Details
.available? ⇒ Boolean
30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/tree_haver/backends/psych.rb', line 30 def available? return @loaded if @load_attempted @load_attempted = true begin require "psych" @loaded = true rescue LoadError @loaded = false end @loaded end |
.capabilities ⇒ Hash{Symbol => Object}
Get capabilities supported by this backend
54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/tree_haver/backends/psych.rb', line 54 def capabilities return {} unless available? { backend: :psych, query: false, # Psych doesn't have tree-sitter-style queries bytes_field: false, # Psych uses line/column, not byte offsets incremental: false, # Psych doesn't support incremental parsing pure_ruby: false, # Psych has native libyaml C extension yaml_only: true, # Psych only parses YAML error_tolerant: false, # Psych raises on syntax errors } end |
.reset! ⇒ void
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
This method returns an undefined value.
Reset the load state (primarily for testing)
46 47 48 49 |
# File 'lib/tree_haver/backends/psych.rb', line 46 def reset! @load_attempted = false @loaded = false end |