Sha256: 2ba65fdd17310d49fa60bcdd53151c1f112983f6b66123ea9cce019d34c86a84
Contents?: true
Size: 1.12 KB
Versions: 15
Compression:
Stored size: 1.12 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\:/,'').underscored hash.merge!({name => m.value}) end entry.dimensions.each do |d| name = d.name.sub(/^ga\:/,'').underscored hash.merge!({name => d.value}) end OpenStruct.new(hash) end end def results @results || parse end class Metric include HappyMapper tag 'metric' namespace 'dxp' attribute :name, String attribute :value, String end class Dimension include HappyMapper tag 'dimension' namespace 'dxp' 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
15 entries across 15 versions & 4 rubygems