Sha256: 903a785ef816a0d794d431d158ae743e3a3cab2d7b4ba04f399d2c871a6766fd

Contents?: true

Size: 824 Bytes

Versions: 1

Compression:

Stored size: 824 Bytes

Contents

module Danger
  # Reads undocumented.json file created by jazzy
  class UndocumentedReader
    def initialize(path)
      load(path)
    end

    def undocumented_symbols
      @data['warnings'].map do |item|
        next unless item_valid? item
        Symbol.new(
          item_file(item),
          item['line'],
          item['symbol'],
          item['symbol_kind'],
          item['warning']
        )
      end
    end

    private

    def load(path)
      @data = JSON.parse(File.read(path))
      @working_path = Pathname.new(@data['source_directory'])
    end

    def item_file(item)
      file = item['file']
      return unless file
      path = Pathname.new(file)
      path.relative_path_from(@working_path).to_s
    end

    def item_valid?(item)
      item['warning'] == 'undocumented'
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
danger-jazzy-1.1.0 lib/jazzy/undocumented_reader.rb