lib/imw/tools/summarizer.rb in imw-0.2.16 vs lib/imw/tools/summarizer.rb in imw-0.2.17

- old
+ new

@@ -41,29 +41,28 @@ @total_size ||= resources.map(&:size).inject(0) { |e, sum| sum += e } end # Return a summary of the +inputs+ to this Summarizer. # - # Delegates to the +summary+ method of each constituent - # IMW::Resource in +inputs+. + # Will swallow errors. # # @return [Array<Hash>] def summary - @summary ||= inputs.map do |input| - #input.guess_schema! if input.schema.nil? && input.respond_to?(:guess_schema!) - (input.respond_to?(:summary) ? input.summary : {}) rescue {} - end + @summary ||= summary! rescue [] end - # The metadata employed by this Summarizer. + # Return a summary of the +inputs+ to this summarizer. + # + # Delegates to the +summary+ method of each constituent + # IMW::Resource in +inputs+. # - # It can be set by setting <tt>options[:metadata]</tt>. - # - # @return [IMW::Metadata, nil] - def metadata - @metadata ||= options[:metadata] && IMW::Metadata.load(options[:metadata]) + # @return [Array] + def summary! + inputs.map do |input| + (input.respond_to?(:summary) ? input.summary : {}) + end end - + protected # Set new inputs for this summarizer. # # Summarizer statistics are cached as instance variables so be # careful about changing inputs and then using old statistics...