Module: Prowler
- Defined in:
- lib/prowler.rb,
lib/prowler/railtie.rb,
lib/prowler/version.rb,
lib/prowler/priority.rb,
lib/prowler/response.rb,
lib/prowler/application.rb,
lib/prowler/delayed_job.rb,
lib/prowler/configuration.rb
Defined Under Namespace
Modules: Priority Classes: ApiKey, Application, ConfigurationError, DelayedJob, Error, Railtie, Success, Token
Constant Summary collapse
- VERSION =
"1.3.1"
- SERVICE_URL =
"https://api.prowlapp.com/publicapi"
- USER_AGENT =
"Prowler/#{VERSION}"
- MULTIPLE_APIKEY_COMMANDS =
%w(add)
- CONFIG_ATTRS =
[:application, :provider_key, :api_key, :service_url]
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.
-
.raise_errors ⇒ Object
:nodoc:.
-
.read_timeout ⇒ Object
:nodoc:.
-
.root_certificates ⇒ Object
Location of the root certificates file.
-
.send_notifications ⇒ Object
:nodoc:.
-
.service_url ⇒ 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(*args) ⇒ Object
Create an instance for sending to different accounts within a single Rails application Pass any of the following options to override the global configuration: * :application: The name of your application.
-
.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.
-
.retrieve_api_key(token) ⇒ Object
Retrieve an API key for a user using the token provided by retrieve_token.
-
.retrieve_token ⇒ Object
Retrieve a registration token and confirmation url for the initial phase of fetching an API key for a user.
-
.verify(api_key = nil) ⇒ Object
Verify the configured API key is valid * api_key: API key to be verified - uses the first configured key(s) if not provided.
-
.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:
22 23 24 |
# File 'lib/prowler/configuration.rb', line 22 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 |
.raise_errors ⇒ Object
:nodoc:
26 27 28 |
# File 'lib/prowler/configuration.rb', line 26 def raise_errors @raise_errors 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
49 50 51 |
# File 'lib/prowler/configuration.rb', line 49 def root_certificates @root_certificates end |
.send_notifications ⇒ Object
:nodoc:
18 19 20 |
# File 'lib/prowler/configuration.rb', line 18 def send_notifications @send_notifications end |
.service_url ⇒ Object
:nodoc:
14 15 16 |
# File 'lib/prowler/configuration.rb', line 14 def service_url @service_url 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.
10 11 12 |
# File 'lib/prowler/configuration.rb', line 10 def configure yield self end |
.configured? ⇒ Boolean
Whether the library has been configured
38 39 40 |
# File 'lib/prowler/configuration.rb', line 38 def configured? !@application.nil? && !@api_key.nil? end |
.logger ⇒ Object
Returns the default logger or a logger that prints to STDOUT.
60 61 62 |
# File 'lib/prowler/configuration.rb', line 60 def logger @logger ||= rails_logger end |
.logger=(new_logger) ⇒ Object
Override the default logger
65 66 67 |
# File 'lib/prowler/configuration.rb', line 65 def logger=(new_logger) @logger = new_logger end |
.new(*args) ⇒ Object
Create an instance for sending to different accounts within a single Rails application Pass any of the following options to override the global configuration:
-
:application: The name of your application.
-
:provider_key: Key to override the rate limit of 1000 requests per hour.
-
:api_key: Your API key.
110 111 112 |
# File 'lib/prowler.rb', line 110 def new(*args) Prowler::Application.new(*args) 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.
-
api_key: One or more API keys to be notified - uses the configured key(s) if not provided.
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)
77 78 79 |
# File 'lib/prowler.rb', line 77 def notify(event, , *args) new.notify(event, , *args) end |
.rails_logger ⇒ Object
:nodoc:
69 70 71 72 73 74 75 76 77 |
# File 'lib/prowler/configuration.rb', line 69 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
31 32 33 34 35 |
# File 'lib/prowler/configuration.rb', line 31 def reset_configuration @service_url = @application = @api_key = @provider_key = nil @delayed = @verify_certificate = @root_certificates = nil @send_notifications = @read_timeout = @open_timeout = nil end |
.retrieve_api_key(token) ⇒ Object
Retrieve an API key for a user using the token provided by retrieve_token. This API command requires the provider_key to be configured.
-
token: Token returned by retrieve_token command.
Returns either Prowler::ApiKey object if successful or nil if an error occurs.
101 102 103 |
# File 'lib/prowler.rb', line 101 def retrieve_api_key(token) new.retrieve_api_key(token) end |
.retrieve_token ⇒ Object
Retrieve a registration token and confirmation url for the initial phase of fetching an API key for a user. The token is valid for 24 hours. This API command requires the provider_key to be configured.
Returns either Prowler::Token object if successful or nil if an error occurs.
92 93 94 |
# File 'lib/prowler.rb', line 92 def retrieve_token new.retrieve_token end |
.verify(api_key = nil) ⇒ Object
Verify the configured API key is valid
-
api_key: API key to be verified - uses the first configured key(s) if not provided.
83 84 85 |
# File 'lib/prowler.rb', line 83 def verify(api_key = nil) new.verify(api_key) end |
.verify_certificate? ⇒ Boolean
Whether to verify the server’s SSL certificate
43 44 45 |
# File 'lib/prowler/configuration.rb', line 43 def verify_certificate? @verify_certificate.nil? ? true : !!@verify_certificate end |