class XcMetricsAggregator::ProductsService

Attributes

products[R]

Public Class Methods

new() click to toggle source
# File lib/xc_metrics_aggregator/product.rb, line 49
def initialize
    @products = Dir.glob(PRODUCT_PATH + "/*").map { |dir_path| Product.new dir_path }     
end

Public Instance Methods

each_product(bundle_ids=[]) { |product| ... } click to toggle source
# File lib/xc_metrics_aggregator/product.rb, line 71
def each_product(bundle_ids=[])
  targets(bundle_ids).each do |product|
    yield product
  end
end
structure(available_path) click to toggle source
# File lib/xc_metrics_aggregator/product.rb, line 77
def structure(available_path)
  structure = XcMetricsAggregator::TableStructure.new
  structure.title = "available app list"
  structure.headings = headings(available_path)
  structure.rows = rows(available_path)
  structure
end
target(bundle_id) click to toggle source
# File lib/xc_metrics_aggregator/product.rb, line 63
def target(bundle_id)
  if bundle_id.nil?
    raise StandardError.new("needs bundle id")
  end

  products.select { |product| bundle_id == product.bundle_id.to_s }.first
end
targets(bundle_ids=[]) click to toggle source
# File lib/xc_metrics_aggregator/product.rb, line 53
def targets(bundle_ids=[])
  if bundle_ids.empty?
    products
  else
    products.select do |product|
       bundle_ids.include? product.bundle_id.to_s
    end
  end
end

Private Instance Methods

headings(available_path) click to toggle source
# File lib/xc_metrics_aggregator/product.rb, line 86
def headings(available_path)
  if available_path
    ['bundle id', 'status', 'raw data path']
  else 
    ['bundle id', 'status']
  end
  
end
rows(available_path) click to toggle source
# File lib/xc_metrics_aggregator/product.rb, line 95
def rows(available_path)
  rows = []
  products.each do |product|
    status = 
      if product.has_metrics?
        "has metrics"
      else
        "fail to get metrics"
      end
    if available_path
      rows << [product.bundle_id, status, product.metrics_file.to_s]
    else 
      rows << [product.bundle_id, status]
    end
  end
  return rows
end