Module: IMW::Metadata::HasSummary

Included in:
Resource
Defined in:
lib/imw/metadata/has_summary.rb

Overview

A module for generating a summary & schema of a resource.

The including class should define methods uri, basename, extension.

Instance Method Summary collapse

Instance Method Details

#external_summaryHash

Return information (usually scheme-dependent) on how this resource is situated in the world, i.e. - its URI, its size, how many lines it has, &c.

Modules which override this should chain with super:

# in my_scheme.rb
def external_summary
  super().merge(:user => 'bob', :password => 'smith')
end

Returns:



41
42
43
44
45
46
47
# File 'lib/imw/metadata/has_summary.rb', line 41

def external_summary
  {
    :uri       => uri.to_s,
    :basename  => basename,
    :extension => extension
  }
end

#summaryHash

Return a full summary of this Resource.

The summary will include “external” information about how this resource appears to the world (via its URI), “internal” metadata about this resource (its description, &c.), as well as the structure of this resource’s data (it’s schema’s fields and a snippet).

Will return a Hash, with a :schema key which maps to a well-formed AVRO schema for this resource.

Returns:



21
22
23
24
25
26
27
# File 'lib/imw/metadata/has_summary.rb', line 21

def summary
  return @summary if @summary
  @summary            = external_summary
  @summary[:schema]   = schema                   if respond_to?(:schema)
  @summary[:contents] = resources.map(&:summary) if respond_to?(:resources)
  @summary
end