Module: Prowler
- Defined in:
- lib/prowler.rb,
lib/prowler/railtie.rb,
lib/prowler/version.rb,
lib/prowler/priority.rb,
lib/prowler/application.rb,
lib/prowler/delayed_job.rb,
lib/prowler/configuration.rb
Defined Under Namespace
Modules: Priority Classes: Application, ConfigurationError, DelayedJob, Railtie
Constant Summary collapse
- VERSION =
"1.2.0"
- SERVICE_URL =
"https://prowlapp.com/publicapi"
- USER_AGENT =
"Prowler/#{VERSION}"
- MULTIPLE_APIKEY_COMMANDS =
%w(add)
Class Attribute Summary collapse
-
.api_key ⇒ Object
Returns the value of attribute api_key.
-
.application ⇒ Object
Returns the value of attribute application.
-
.delayed ⇒ Object
:nodoc:.
-
.open_timeout ⇒ Object
:nodoc:.
-
.provider_key ⇒ Object
Returns the value of attribute provider_key.
-
.read_timeout ⇒ Object
:nodoc:.
-
.root_certificates ⇒ Object
Location of the root certificates file.
-
.send_notifications ⇒ Object
:nodoc:.
-
.verify_certificate ⇒ Object
Returns the value of attribute verify_certificate.
Class Method Summary collapse
-
.configure {|_self| ... } ⇒ Object
Call this method to configure your account details in an initializer.
-
.configured? ⇒ Boolean
Whether the library has been configured.
-
.logger ⇒ Object
Returns the default logger or a logger that prints to STDOUT.
-
.logger=(new_logger) ⇒ Object
Override the default logger.
-
.new(api_key, application, provider_key = nil) ⇒ Object
Create an instance for sending to different accounts within a single Rails application * api_key: Your API key.
-
.notify(event, message, *args) ⇒ Object
Send a notification to your iPhone: * event: The title of notification you want to send.
-
.rails_logger ⇒ Object
:nodoc:.
-
.reset_configuration ⇒ Object
Reset configuration.
-
.verify ⇒ Object
Verify the configured API key is valid.
-
.verify_certificate? ⇒ Boolean
Whether to verify the server’s SSL certificate.
Class Attribute Details
.api_key ⇒ Object
Returns the value of attribute api_key.
3 4 5 |
# File 'lib/prowler/configuration.rb', line 3 def api_key @api_key end |
.application ⇒ Object
Returns the value of attribute application.
4 5 6 |
# File 'lib/prowler/configuration.rb', line 4 def application @application end |
.delayed ⇒ Object
:nodoc:
17 18 19 |
# File 'lib/prowler/configuration.rb', line 17 def delayed @delayed end |
.open_timeout ⇒ Object
:nodoc:
5 6 7 |
# File 'lib/prowler/configuration.rb', line 5 def open_timeout @open_timeout end |
.provider_key ⇒ Object
Returns the value of attribute provider_key.
3 4 5 |
# File 'lib/prowler/configuration.rb', line 3 def provider_key @provider_key end |
.read_timeout ⇒ Object
:nodoc:
5 6 7 |
# File 'lib/prowler/configuration.rb', line 5 def read_timeout @read_timeout end |
.root_certificates ⇒ Object
Location of the root certificates file. Default: #Rails.root/config/cacert.pem
40 41 42 |
# File 'lib/prowler/configuration.rb', line 40 def root_certificates @root_certificates end |
.send_notifications ⇒ Object
:nodoc:
13 14 15 |
# File 'lib/prowler/configuration.rb', line 13 def send_notifications @send_notifications end |
.verify_certificate ⇒ Object
Returns the value of attribute verify_certificate.
6 7 8 |
# File 'lib/prowler/configuration.rb', line 6 def verify_certificate @verify_certificate end |
Class Method Details
.configure {|_self| ... } ⇒ Object
Call this method to configure your account details in an initializer.
9 10 11 |
# File 'lib/prowler/configuration.rb', line 9 def configure yield self end |
.configured? ⇒ Boolean
Whether the library has been configured
29 30 31 |
# File 'lib/prowler/configuration.rb', line 29 def configured? !@application.nil? && !@api_key.nil? end |
.logger ⇒ Object
Returns the default logger or a logger that prints to STDOUT.
51 52 53 |
# File 'lib/prowler/configuration.rb', line 51 def logger @logger ||= rails_logger end |
.logger=(new_logger) ⇒ Object
Override the default logger
56 57 58 |
# File 'lib/prowler/configuration.rb', line 56 def logger=(new_logger) @logger = new_logger end |
.new(api_key, application, provider_key = nil) ⇒ Object
Create an instance for sending to different accounts within a single Rails application
-
api_key: Your API key.
-
application: The name of your application.
-
provider_key: Key to override the rate limit of 1000 requests per hour. (Optional)
90 91 92 |
# File 'lib/prowler.rb', line 90 def new(api_key, application, provider_key = nil) Prowler::Application.new(api_key, application, provider_key) end |
.notify(event, message, *args) ⇒ Object
Send a notification to your iPhone:
-
event: The title of notification you want to send.
-
message: The text of the notification message you want to send.
The following options are supported:
-
:delayed
: Whether to use Delayed::Job to send notifications. (Optional) -
:priority
: The priority of the notification - see Prowler::Priority. (Optional) -
:url
: A custom url for the Prowl application to open. (Optional)
75 76 77 78 |
# File 'lib/prowler.rb', line 75 def notify(event, , *args) app = new(api_key, application, provider_key) app.notify(event, , *args) end |
.rails_logger ⇒ Object
:nodoc:
60 61 62 63 64 65 66 67 68 |
# File 'lib/prowler/configuration.rb', line 60 def rails_logger #:nodoc: if defined?(Rails.logger) Rails.logger elsif defined?(RAILS_DEFAULT_LOGGER) RAILS_DEFAULT_LOGGER else Logger.new(STDERR) end end |
.reset_configuration ⇒ Object
Reset configuration
22 23 24 25 26 |
# File 'lib/prowler/configuration.rb', line 22 def reset_configuration @application = @api_key = @provider_key = nil @delayed = @verify_certificate = @root_certificates = nil @send_notifications = @read_timeout = @open_timeout = nil end |
.verify ⇒ Object
Verify the configured API key is valid
81 82 83 84 |
# File 'lib/prowler.rb', line 81 def verify app = new(api_key, application, provider_key) app.verify end |
.verify_certificate? ⇒ Boolean
Whether to verify the server’s SSL certificate
34 35 36 |
# File 'lib/prowler/configuration.rb', line 34 def verify_certificate? @verify_certificate.nil? ? true : !!@verify_certificate end |