Module: EM::APNS
- Defined in:
- lib/em-apns/error.rb,
lib/em-apns/server.rb,
lib/em-apns/version.rb,
lib/em-apns/connection.rb,
lib/em-apns/server_runner.rb,
lib/em-apns/connection_pool.rb,
lib/em-apns.rb
Defined Under Namespace
Modules: Server Classes: Connection, ConnectionPool, Error, ServerRunner
Constant Summary collapse
- VERSION =
"0.1.1"
Class Attribute Summary collapse
-
.cert ⇒ Object
Returns the value of attribute cert.
-
.env ⇒ Object
Returns the value of attribute env.
-
.host ⇒ Object
Returns the value of attribute host.
-
.key ⇒ Object
Returns the value of attribute key.
- .logger ⇒ Object
-
.pool ⇒ Object
Returns the value of attribute pool.
- .sock ⇒ Object
Class Method Summary collapse
- .config(options) ⇒ Object
- .send_notification(*args) ⇒ Object
- .send_notifications(notifications) ⇒ Object
Class Attribute Details
.cert ⇒ Object
Returns the value of attribute cert.
16 17 18 |
# File 'lib/em-apns.rb', line 16 def cert @cert end |
.env ⇒ Object
Returns the value of attribute env.
16 17 18 |
# File 'lib/em-apns.rb', line 16 def env @env end |
.host ⇒ Object
Returns the value of attribute host.
16 17 18 |
# File 'lib/em-apns.rb', line 16 def host @host end |
.key ⇒ Object
Returns the value of attribute key.
16 17 18 |
# File 'lib/em-apns.rb', line 16 def key @key end |
.logger ⇒ Object
22 23 24 |
# File 'lib/em-apns.rb', line 22 def logger @logger ||= Logger.new(STDOUT) end |
.pool ⇒ Object
Returns the value of attribute pool.
16 17 18 |
# File 'lib/em-apns.rb', line 16 def pool @pool end |
.sock ⇒ Object
18 19 20 |
# File 'lib/em-apns.rb', line 18 def sock @sock ||= (defined?(Rails) && Rails.respond_to?(:root) ? File.join(Rails.root, 'tmp/sockets', "em-apns-#{Rails.env}.sock") : nil) end |
Class Method Details
.config(options) ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/em-apns.rb', line 40 def config raise 'App root folder are not defined' unless [:root] if [:config] configurations = YAML.load_file ['config'] else config_file = File.join([:root],"config/em-apns.yml") configurations = YAML.load_file(config_file) end @env = [:environment] || 'development' @sock = File.join([:root], "tmp/sockets/em-apns-#{@env}.sock") @pool = configurations['pool'] @key = configurations['key'] @cert = configurations['cert'] raise 'No key or certficate file' unless @key && @cert @host = case @env when 'development' "gateway.sandbox.push.apple.com" when 'production' "gateway.push.apple.com" else "localhost" end end |
.send_notification(*args) ⇒ Object
26 27 28 |
# File 'lib/em-apns.rb', line 26 def send_notification(*args) send_notifications([Notification.new(*args)]) end |
.send_notifications(notifications) ⇒ Object
30 31 32 33 34 35 36 37 38 |
# File 'lib/em-apns.rb', line 30 def send_notifications(notifications) UNIXSocket.open(sock) do |socket| notifications.each do |n| socket.puts(n.data) end end rescue => e logger.error(e) end |