Class: LEWT::Metastat

Inherits:
Extension show all
Defined in:
lib/extensions/metastat/metastat.rb

Overview

The Metastat extension [experimental] handles processing meta-data added to ledger entries. It can compute statistics based of these parsed values

Usage:

Here is an example ‘description’ field entered into a LEWTLedger which can be parsed with Metastat

'description' => 'Adding some features to the system #happiness=10 #average-pay'

Metastat will extract the # tags from the above string and log an indicatior called happinesswhich is equal to 10 and a Boolean switch average-pay will be set to true

These values will be aggregate over the whole ‘extract’ dataset then processed in a few ways.

  1. Create a graph out of the data

  2. Create a summary table out of the data

Instance Attribute Summary collapse

Attributes inherited from Extension

#command_name, #customers, #enterprise, #lewt_settings, #lewt_stash, #options

Instance Method Summary collapse

Methods inherited from Extension

#get_matched_customers, #lewt_extensions

Constructor Details

#initializeMetastat

Sets up this extension and registers its options



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/extensions/metastat/metastat.rb', line 31

def initialize
  options = {
    :tags => {
      :definition => "A comma seperated list of metatags to lookup.",
      :type => String
    },
    :y_series => {
      :definition => "An optional y series to use for a correlation analysis.",
      :type => String
    }
  }
  @boolean_table = Hash.new
  @raw_data = Hash.new
  @dataset = Hash.new
  super({:cmd => 'metastat', :options => options})
end

Instance Attribute Details

#client_graphObject (readonly)

Returns the value of attribute client_graph.



28
29
30
# File 'lib/extensions/metastat/metastat.rb', line 28

def client_graph
  @client_graph
end

#client_tableObject (readonly)

Returns the value of attribute client_table.



28
29
30
# File 'lib/extensions/metastat/metastat.rb', line 28

def client_table
  @client_table
end

Instance Method Details

#process(options, extract_data) ⇒ Object

Handles the process event for this extension

options [Hash]

The options hash passed to this function by the Lewt program.

extract_data [LEWTBook]

The data in LEWTBook format



51
52
53
54
55
56
57
58
59
60
61
# File 'lib/extensions/metastat/metastat.rb', line 51

def process (options, extract_data)
  @options = options
  extract_data.each do |row|
    filter_row_values(row, options)
  end
  @dataset["frequency_table"] = @boolean_table
  if options[:y_series]
    @dataset["correlations"] = compute_correlations @raw_data
  end
  return @dataset
end