Sha256: abb18afcbcb8cdca06065336309681b4beae78a55a90a692a74dbd84bacef390
Contents?: true
Size: 1.05 KB
Versions: 2
Compression:
Stored size: 1.05 KB
Contents
# frozen_string_literal: true require 'puppet-strings/yard/parsers/json/task_statement' # Implementas a JSON parser. class PuppetStrings::Yard::Parsers::JSON::Parser < YARD::Parser::Base attr_reader :file, :source # Initializes the parser. # @param [String] source The source being parsed. # @param [String] filename The file name of the file being parsed. # @return [void] def initialize(source, filename) # rubocop:disable Lint/MissingSuper @file = filename @source = source @statements = [] end def enumerator @statements end # Parses the source # @return [void] def parse begin json = JSON.parse(source) # TODO: this should compare json to a Task metadata json-schema or perform some other hueristics # to determine what type of statement it represents @statements.push(PuppetStrings::Yard::Parsers::JSON::TaskStatement.new(json, @source, @file)) unless json.empty? rescue log.error "Failed to parse #{@file}: " @statements = [] end @statements.freeze self end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
puppet-strings-3.0.1 | lib/puppet-strings/yard/parsers/json/parser.rb |
puppet-strings-3.0.0 | lib/puppet-strings/yard/parsers/json/parser.rb |