Sha256: 7c6d278ff19423d8452213d7c22634db3f21922d48d1f6c690a31142fd939a20

Contents?: true

Size: 1.73 KB

Versions: 2

Compression:

Stored size: 1.73 KB

Contents

require 'pushpop'
require 'keen'

module Pushpop

  class Keen < Step

    PLUGIN_NAME = 'keen'

    Pushpop::Job.register_plugin(Keen::PLUGIN_NAME, Keen)

    attr_accessor :_event_collection
    attr_accessor :_analysis_type
    attr_accessor :_timeframe
    attr_accessor :_target_property
    attr_accessor :_group_by
    attr_accessor :_interval
    attr_accessor :_filters
    attr_accessor :_steps
    attr_accessor :_analyses

    def run(last_response=nil, step_responses=nil)
      self.configure(last_response, step_responses)
      ::Keen.send(self._analysis_type, self._event_collection, self.to_analysis_options)
    end

    def configure(last_response=nil, step_responses=nil)
      self.instance_exec(last_response, step_responses, &block)
    end

    def to_analysis_options
      { timeframe: self._timeframe,
        target_property: self._target_property,
        group_by: self._group_by,
        interval: self._interval,
        filters: self._filters,
        analyses: self._analyses,
        steps: self._steps
      }.delete_if { |_, v| v.nil? }
    end

    def event_collection(event_collection)
      self._event_collection = event_collection
    end

    def analysis_type(analysis_type)
      self._analysis_type = analysis_type
    end

    def timeframe(timeframe)
      self._timeframe = timeframe
    end

    def target_property(target_property)
      self._target_property = target_property
    end

    def group_by(group_by)
      self._group_by = group_by
    end

    def interval(interval)
      self._interval = interval
    end

    def filters(filters)
      self._filters = filters
    end

    def steps(steps)
      self._steps = steps
    end

    def analyses(analyses)
      self._analyses = analyses
    end

  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
pushpop-keen-0.1.1 lib/pushpop-keen.rb
pushpop-keen-0.1.0 lib/pushpop-keen.rb