Class: Lbrt::Alert
Defined Under Namespace
Constant Summary collapse
- DEFAULT_CONCURRENCY =
32
Instance Method Summary collapse
- #apply(file) ⇒ Object
- #export(export_options = {}) ⇒ Object
-
#initialize(client, options = {}) ⇒ Alert
constructor
A new instance of Alert.
- #list ⇒ Object
- #peco ⇒ Object
Methods included from Logger::Helper
Constructor Details
#initialize(client, options = {}) ⇒ Alert
6 7 8 9 10 |
# File 'lib/lbrt/alert.rb', line 6 def initialize(client, = {}) @client = client = @driver = Lbrt::Driver.new(@client, ) end |
Instance Method Details
#apply(file) ⇒ Object
53 54 55 |
# File 'lib/lbrt/alert.rb', line 53 def apply(file) walk(file) end |
#export(export_options = {}) ⇒ Object
48 49 50 51 |
# File 'lib/lbrt/alert.rb', line 48 def export( = {}) exported = Lbrt::Alert::Exporter.export(@client, ) Lbrt::Alert::DSL.convert(exported, ) end |
#list ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/lbrt/alert.rb', line 12 def list json = {} alert_by_name = build_alert_by_name alert_by_name.select {|name, alrt| [:status].nil? or [:status] == alrt[:status] }.each {|name, alrt| alert_id = alrt[:id] json[alert_id] = { name: name, url: alert_url(alert_id), status: alrt[:status], } } puts JSON.pretty_generate(json) end |
#peco ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/lbrt/alert.rb', line 31 def peco alert_id_by_name = {} build_alert_by_name.select {|name, alrt| [:status].nil? or [:status] == alrt[:status] }.map {|name, alrt| alert_id_by_name[name] = alrt[:id] } unless alert_id_by_name.empty? result = PecoSelector.select_from(alert_id_by_name) result.each do |alert_id| url = alert_url(alert_id) Lbrt::Utils.open(url) end end end |