Class: Mdq::List

Inherits:
Object
  • Object
show all
Defined in:
lib/mdq/list.rb

Overview

List

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ List

Returns a new instance of List.



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/mdq/list.rb', line 9

def initialize(options)
  db = Mdq::DB.new

  query = options['query']
  models = db.get(query)

  output = JSON.pretty_generate(models.as_json)
  puts output
  if options['output']
    File.open(options['output'], 'w') do |f|
      f.write(output)
    end
  end

  ob = Mdq::OutputBuilder.new

  models.each do |device|
    model = Device.find_by(udid: device.udid)
    udid = model.udid
    is_android = model.android?

    ob.add(db.device_screencap(options[:cap], udid, is_android)) if options[:cap]
    ob.add(db.app_install(options[:install], udid, is_android)) if options[:install]
    ob.add(db.app_uninstall(options[:uninstall], udid, is_android)) if options[:uninstall]
  rescue StandardError
    # none
  end

  ob.print
end