Sha256: dae01a89df7d00572f094ba0ce1a0601a75d2bdf7dcd78856c417b1fd7e9f264
Contents?: true
Size: 1.19 KB
Versions: 11
Compression:
Stored size: 1.19 KB
Contents
module Garb class ReportResponse # include Enumerable def initialize(response_body) @xml = response_body end def parse entries = Entry.parse(@xml) @results = entries.collect do |entry| hash = {} entry.metrics.each do |m| name = m.name.sub(/^ga\:/,'').underscore hash.merge!({name => m.value}) end entry.dimensions.each do |d| name = d.name.sub(/^ga\:/,'').underscore hash.merge!({name => d.value}) end OpenStruct.new(hash) end end def results @results || parse end class Metric include HappyMapper tag 'metric' namespace 'http://schemas.google.com/analytics/2009' attribute :name, String attribute :value, String end class Dimension include HappyMapper tag 'dimension' namespace 'http://schemas.google.com/analytics/2009' attribute :name, String attribute :value, String end class Entry include HappyMapper tag 'entry' has_many :metrics, Metric has_many :dimensions, Dimension end end end
Version data entries
11 entries across 11 versions & 3 rubygems