Class: Vastlint::Library
- Inherits:
-
Object
- Object
- Vastlint::Library
- Includes:
- Singleton
- Defined in:
- lib/vastlint/library.rb
Class Method Summary collapse
Instance Method Summary collapse
- #path ⇒ Object
- #validate(xml, wrapper_depth:, max_wrapper_depth:, rule_overrides:) ⇒ Object
- #version ⇒ Object
Class Method Details
.resolve_path ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/vastlint/library.rb', line 47 def resolve_path candidates = [ENV["VASTLINT_LIB_PATH"], vendored_path, *development_paths].compact match = candidates.find { |candidate| File.file?(candidate) } return match if match raise LibraryError, <<~MESSAGE.strip unable to find libvastlint for #{platform_label} looked in: #{candidates.map { |candidate| " - #{candidate}" }.join("\n")} set VASTLINT_LIB_PATH or vendor a release library under lib/vastlint/native MESSAGE end |
Instance Method Details
#path ⇒ Object
42 43 44 |
# File 'lib/vastlint/library.rb', line 42 def path self.class.resolve_path end |
#validate(xml, wrapper_depth:, max_wrapper_depth:, rule_overrides:) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/vastlint/library.rb', line 13 def validate(xml, wrapper_depth:, max_wrapper_depth:, rule_overrides:) raw_result = if default_call?(wrapper_depth, max_wrapper_depth, rule_overrides) api.vastlint_validate(xml, xml.bytesize) else api.( xml, xml.bytesize, wrapper_depth, max_wrapper_depth, serialize_rule_overrides(rule_overrides) ) end raise LibraryError, "vastlint returned NULL" if null_pointer?(raw_result) begin json_payload = read_c_string(api.vastlint_result_json(raw_result)) raise LibraryError, "vastlint_result_json returned NULL" if json_payload.nil? || json_payload.empty? json_payload ensure api.vastlint_result_free(raw_result) unless null_pointer?(raw_result) end end |
#version ⇒ Object
38 39 40 |
# File 'lib/vastlint/library.rb', line 38 def version read_c_string(api.vastlint_version()) || raise(LibraryError, "vastlint_version returned NULL") end |