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

Class Method Summary collapse

Class Attribute Details

.api_keyObject

Returns the value of attribute api_key.



3
4
5
# File 'lib/prowler/configuration.rb', line 3

def api_key
  @api_key
end

.applicationObject

Returns the value of attribute application.



4
5
6
# File 'lib/prowler/configuration.rb', line 4

def application
  @application
end

.delayedObject

:nodoc:



17
18
19
# File 'lib/prowler/configuration.rb', line 17

def delayed
  @delayed
end

.open_timeoutObject

:nodoc:



5
6
7
# File 'lib/prowler/configuration.rb', line 5

def open_timeout
  @open_timeout
end

.provider_keyObject

Returns the value of attribute provider_key.



3
4
5
# File 'lib/prowler/configuration.rb', line 3

def provider_key
  @provider_key
end

.read_timeoutObject

:nodoc:



5
6
7
# File 'lib/prowler/configuration.rb', line 5

def read_timeout
  @read_timeout
end

.root_certificatesObject

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_notificationsObject

:nodoc:



13
14
15
# File 'lib/prowler/configuration.rb', line 13

def send_notifications
  @send_notifications
end

.verify_certificateObject

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.

Yields:

  • (_self)

Yield Parameters:

  • _self (Prowler)

    the object that the method was called on



9
10
11
# File 'lib/prowler/configuration.rb', line 9

def configure
  yield self
end

.configured?Boolean

Whether the library has been configured

Returns:

  • (Boolean)


29
30
31
# File 'lib/prowler/configuration.rb', line 29

def configured?
  !@application.nil? && !@api_key.nil?
end

.loggerObject

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, message, *args)
  app = new(api_key, application, provider_key)
  app.notify(event, message, *args)
end

.rails_loggerObject

: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_configurationObject

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

.verifyObject

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

Returns:

  • (Boolean)


34
35
36
# File 'lib/prowler/configuration.rb', line 34

def verify_certificate?
  @verify_certificate.nil? ? true : !!@verify_certificate
end