Class: AwsDeploy::Notification

Inherits:
Object
  • Object
show all
Defined in:
app/business/aws_deploy/notification.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.send(to = "all") ⇒ Object



7
8
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
# File 'app/business/aws_deploy/notification.rb', line 7

def self.send to="all"
  @errors = []

  if to == "all"

    api_keys = $aws_deploy["pushbullet"]["api_key"]
    keys = api_keys.split(" ")

    keys.each_with_index do |k,i| 
      puts "-" * 100

      puts "#{i} - #{k}"

      puts "-" * 100  
    end

    begin
      _sendn(vals[0], vals[1])
    rescue Exception => e
      @errors << "Problem sending to: #{vals[0]}|#{vals[1]}|#{vals[2]} ... #{e}"
    end

  else


  end

  @errors
end

Instance Method Details

#_sendn(token, device_name) ⇒ Object



42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'app/business/aws_deploy/notification.rb', line 42

def _sendn token, device_name
  push = MyPush.new :token => token

  # find the device...
  iden = ""
  devices = push.devices
  devices["devices"].each do |dev|
    if device_name == dev["extras"]["model"]
      puts "ID: #{dev["iden"]}"
      iden = dev["iden"]
    end
  end

  # send a message..
  push.push :type => MyPush::PUSH_TYPE_NOTE, 
        :title => "[TEST][aws_deploy] #{Rails.application.class.parent_name} #{Rails.env}", 
        :body => "This is a test message sent from aws_deploy", 
        :iden => "#{iden}"

end