prowler 1.3.0 → 1.3.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gemtest +0 -0
- data/CHANGELOG +5 -0
- data/{INSTALL → README.md} +59 -20
- data/Rakefile +6 -19
- data/lib/prowler/application.rb +7 -5
- data/lib/prowler/configuration.rb +6 -2
- data/lib/prowler/version.rb +1 -1
- data/prowler.gemspec +22 -28
- data/test/prowler_test.rb +38 -0
- metadata +80 -12
- data/README +0 -73
data/.gemtest
ADDED
File without changes
|
data/CHANGELOG
CHANGED
data/{INSTALL → README.md}
RENAMED
@@ -3,68 +3,96 @@ Prowler
|
|
3
3
|
|
4
4
|
This is a plugin/gem for integrating apps with the Prowl iPhone application.
|
5
5
|
|
6
|
-
|
6
|
+
Installation
|
7
|
+
------------
|
7
8
|
|
8
9
|
To install as a plugin from your application root, run:
|
9
10
|
|
10
11
|
Rails 2.x:
|
11
|
-
|
12
|
+
|
13
|
+
``` sh
|
14
|
+
script/plugin install git://github.com/pixeltrix/prowler.git
|
15
|
+
```
|
12
16
|
|
13
17
|
Rails 3.x:
|
14
|
-
|
18
|
+
|
19
|
+
``` sh
|
20
|
+
script/rails plugin install git://github.com/pixeltrix/prowler.git
|
21
|
+
```
|
15
22
|
|
16
23
|
To install as a gem configure your config.gems or Gemfile:
|
17
24
|
|
18
25
|
Rails 2.x:
|
19
|
-
|
26
|
+
|
27
|
+
``` ruby
|
28
|
+
config.gems 'prowler', :version => '~> 1.2'
|
29
|
+
```
|
20
30
|
|
21
31
|
Rails 3.x:
|
22
|
-
|
32
|
+
|
33
|
+
``` ruby
|
34
|
+
gem 'prowler', '~> 1.2'
|
35
|
+
```
|
23
36
|
|
24
37
|
Prowler is not limited to Rails apps - it can be used in any situation
|
25
38
|
where you need to send push notifications to your iPhone.
|
26
39
|
|
27
|
-
|
40
|
+
Configuration
|
41
|
+
-------------
|
28
42
|
|
29
43
|
You should have something like this in config/initializers/prowler.rb.
|
30
44
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
45
|
+
``` ruby
|
46
|
+
Prowler.configure do |config|
|
47
|
+
config.api_key = 'ffffffffffffffffffffffffffffffffffffffff'
|
48
|
+
config.application = 'www.example.com'
|
49
|
+
end
|
50
|
+
```
|
35
51
|
|
36
52
|
You can test that Prowler is working in your production environment by using
|
37
53
|
this rake task (from your application root):
|
38
54
|
|
39
|
-
|
55
|
+
``` sh
|
56
|
+
rake prowler:test
|
57
|
+
```
|
40
58
|
|
41
59
|
If everything is configured properly the task will send a request to
|
42
60
|
prowlapp.com which will be appear on your iPhone after a short delay.
|
43
61
|
|
44
|
-
|
62
|
+
Usage
|
63
|
+
-----
|
45
64
|
|
46
65
|
To use Prowler within your application just call the notify method, e.g.
|
47
66
|
|
48
|
-
|
67
|
+
``` ruby
|
68
|
+
Prowler.notify "Event", "Description"
|
69
|
+
```
|
49
70
|
|
50
71
|
If you need to send to multiple accounts from within a single application you
|
51
72
|
can create an instance of the Prowler class to override the global settings, e.g.
|
52
73
|
|
53
|
-
|
54
|
-
|
74
|
+
``` ruby
|
75
|
+
prowler = Prowler.new(:application => 'application', :api_key => 'apikey')
|
76
|
+
prowler.notify "Event", "Description"
|
77
|
+
```
|
55
78
|
|
56
79
|
If performance is a concern then there is built in support for Delayed::Job.
|
57
80
|
This can done either on a global basis, e.g.
|
58
81
|
|
59
|
-
|
60
|
-
|
61
|
-
|
82
|
+
``` ruby
|
83
|
+
Prowler.configure do |config|
|
84
|
+
config.delayed = true
|
85
|
+
end
|
86
|
+
```
|
62
87
|
|
63
88
|
or on a individual message basis, e.g.
|
64
89
|
|
65
|
-
|
90
|
+
``` ruby
|
91
|
+
Prowler.notify "Event", "Description", :delayed => true
|
92
|
+
```
|
66
93
|
|
67
|
-
|
94
|
+
About
|
95
|
+
-----
|
68
96
|
|
69
97
|
Prowler relies upon the Prowl iPhone application which is advertised as
|
70
98
|
a Growl notification forwarder from your Mac. However they provide an API
|
@@ -72,3 +100,14 @@ which can be called by a generic script which allows you to use the
|
|
72
100
|
application as a general push notification application for your iPhone.
|
73
101
|
|
74
102
|
For more about the Prowl application see: http://prowlapp.com/
|
103
|
+
|
104
|
+
Contributions
|
105
|
+
-------------
|
106
|
+
|
107
|
+
Bug fixes and new feature patches are welcome. Please provide tests and
|
108
|
+
documentation wherever possible - without them it is unlikely your patch
|
109
|
+
will be accepted. If you're fixing a bug then a failing test for the bug
|
110
|
+
is essential. Once you have completed your patch please open a GitHub
|
111
|
+
pull request and I will review it and respond as quickly as possible.
|
112
|
+
|
113
|
+
Copyright (c) 2011 Andrew White, released under the MIT license
|
data/Rakefile
CHANGED
@@ -1,37 +1,24 @@
|
|
1
1
|
require 'rake'
|
2
2
|
require 'rake/testtask'
|
3
3
|
require 'rake/rdoctask'
|
4
|
+
require 'bundler'
|
4
5
|
|
5
|
-
|
6
|
+
Bundler::GemHelper.install_tasks
|
7
|
+
|
8
|
+
desc 'Default: run prowler unit tests.'
|
6
9
|
task :default => :test
|
7
10
|
|
8
|
-
desc 'Test the prowler
|
11
|
+
desc 'Test the prowler gem.'
|
9
12
|
Rake::TestTask.new(:test) do |t|
|
10
13
|
t.libs << 'lib'
|
11
14
|
t.pattern = 'test/**/*_test.rb'
|
12
15
|
t.verbose = true
|
13
16
|
end
|
14
17
|
|
15
|
-
desc 'Generate documentation for the prowler
|
18
|
+
desc 'Generate documentation for the prowler gem.'
|
16
19
|
Rake::RDocTask.new(:rdoc) do |rdoc|
|
17
20
|
rdoc.rdoc_dir = 'rdoc'
|
18
21
|
rdoc.title = 'Prowler'
|
19
22
|
rdoc.options << '--line-numbers' << '--inline-source'
|
20
|
-
rdoc.rdoc_files.include('README')
|
21
23
|
rdoc.rdoc_files.include('lib/**/*.rb')
|
22
24
|
end
|
23
|
-
|
24
|
-
begin
|
25
|
-
require 'jeweler'
|
26
|
-
Jeweler::Tasks.new do |gemspec|
|
27
|
-
gemspec.name = "prowler"
|
28
|
-
gemspec.summary = "Provides access to the Prowl API (http://prowlapp.com)."
|
29
|
-
gemspec.email = "andyw@pixeltrix.co.uk"
|
30
|
-
gemspec.homepage = "http://github.com/pixeltrix/prowler/"
|
31
|
-
gemspec.description = "A plugin/gem that provides access to the Prowl API (http://prowlapp.com). Works with Rails 2 or 3 as well as any other Ruby web frameworks or in your own scripts."
|
32
|
-
gemspec.authors = ["Andrew White"]
|
33
|
-
end
|
34
|
-
Jeweler::GemcutterTasks.new
|
35
|
-
rescue LoadError
|
36
|
-
puts "Jeweler not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
|
37
|
-
end
|
data/lib/prowler/application.rb
CHANGED
@@ -6,15 +6,15 @@ require 'prowler/version'
|
|
6
6
|
|
7
7
|
module Prowler
|
8
8
|
|
9
|
-
SERVICE_URL = "https://prowlapp.com/publicapi"
|
9
|
+
SERVICE_URL = "https://api.prowlapp.com/publicapi"
|
10
10
|
USER_AGENT = "Prowler/#{VERSION}"
|
11
11
|
MULTIPLE_APIKEY_COMMANDS = %w(add)
|
12
|
-
CONFIG_ATTRS = [:application, :provider_key, :api_key]
|
12
|
+
CONFIG_ATTRS = [:application, :provider_key, :api_key, :service_url]
|
13
13
|
|
14
14
|
class ConfigurationError < StandardError; end
|
15
15
|
|
16
16
|
class Application
|
17
|
-
attr_accessor :api_key, :provider_key #:nodoc:
|
17
|
+
attr_accessor :service_url, :api_key, :provider_key #:nodoc:
|
18
18
|
attr_accessor :application, :send_notifications #:nodoc:
|
19
19
|
|
20
20
|
# Create an instance for sending to different accounts within a single Rails application
|
@@ -22,6 +22,7 @@ module Prowler
|
|
22
22
|
# * :application: The name of your application.
|
23
23
|
# * :provider_key: Key to override the rate limit of 1000 requests per hour.
|
24
24
|
# * :api_key: Your API key.
|
25
|
+
# * :service_url: Override the configured service url
|
25
26
|
def initialize(*args)
|
26
27
|
if args.empty?
|
27
28
|
CONFIG_ATTRS.each{ |attr| send("#{attr}=".to_sym, Prowler.send(attr)) }
|
@@ -30,6 +31,7 @@ module Prowler
|
|
30
31
|
send("#{attr}=".to_sym, args[0][attr] || Prowler.send(attr))
|
31
32
|
end
|
32
33
|
else
|
34
|
+
@service_url = Prowler.service_url
|
33
35
|
@api_key, @application, @provider_key = args[0], args[1], args[2]
|
34
36
|
end
|
35
37
|
end
|
@@ -145,13 +147,13 @@ module Prowler
|
|
145
147
|
end
|
146
148
|
|
147
149
|
def perform_get(command, params, klass) #:nodoc:
|
148
|
-
url = URI.parse("#{
|
150
|
+
url = URI.parse("#{service_url}/#{command}?#{params.map{ |k,v| %(#{URI.encode(k.to_s)}=#{URI.encode(v.to_s)}) }.join('&')}")
|
149
151
|
request = Net::HTTP::Get.new("#{url.path}?#{url.query}", headers)
|
150
152
|
perform_request(url, request, klass)
|
151
153
|
end
|
152
154
|
|
153
155
|
def perform_post(command, params, klass) #:nodoc:
|
154
|
-
url = URI.parse("#{
|
156
|
+
url = URI.parse("#{service_url}/#{command}")
|
155
157
|
request = Net::HTTP::Post.new(url.path, headers)
|
156
158
|
request.form_data = params
|
157
159
|
perform_request(url, request, klass)
|
@@ -1,6 +1,6 @@
|
|
1
1
|
module Prowler
|
2
2
|
class << self
|
3
|
-
attr_accessor :api_key, :provider_key
|
3
|
+
attr_accessor :service_url, :api_key, :provider_key
|
4
4
|
attr_accessor :application, :send_notifications
|
5
5
|
attr_accessor :read_timeout, :open_timeout #:nodoc:
|
6
6
|
attr_accessor :delayed, :verify_certificate, :root_certificates
|
@@ -11,6 +11,10 @@ module Prowler
|
|
11
11
|
yield self
|
12
12
|
end
|
13
13
|
|
14
|
+
def service_url #:nodoc:
|
15
|
+
@service_url ||= SERVICE_URL
|
16
|
+
end
|
17
|
+
|
14
18
|
def send_notifications #:nodoc:
|
15
19
|
@send_notifications.nil? ? true : !!@send_notifications
|
16
20
|
end
|
@@ -25,7 +29,7 @@ module Prowler
|
|
25
29
|
|
26
30
|
# Reset configuration
|
27
31
|
def reset_configuration
|
28
|
-
@application = @api_key = @provider_key = nil
|
32
|
+
@service_url = @application = @api_key = @provider_key = nil
|
29
33
|
@delayed = @verify_certificate = @root_certificates = nil
|
30
34
|
@send_notifications = @read_timeout = @open_timeout = nil
|
31
35
|
end
|
data/lib/prowler/version.rb
CHANGED
data/prowler.gemspec
CHANGED
@@ -1,25 +1,26 @@
|
|
1
|
-
# Generated by jeweler
|
2
|
-
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
-
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
1
|
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "prowler/version"
|
5
4
|
|
6
5
|
Gem::Specification.new do |s|
|
7
|
-
s.name
|
8
|
-
s.version
|
6
|
+
s.name = "prowler"
|
7
|
+
s.version = Prowler::VERSION
|
8
|
+
s.platform = Gem::Platform::RUBY
|
9
|
+
s.authors = ["Andrew White"]
|
10
|
+
s.email = ["andyw@pixeltrix.co.uk"]
|
11
|
+
s.homepage = %q{http://github.com/pixeltrix/prowler/}
|
12
|
+
s.summary = %q{Provides access to the Prowl API (http://prowlapp.com).}
|
13
|
+
s.description = <<-EOF
|
14
|
+
A plugin/gem that provides access to the Prowl API (http://prowlapp.com).
|
15
|
+
Works with Rails 2 or 3 as well as any other Ruby web frameworks or in
|
16
|
+
your own scripts.
|
17
|
+
EOF
|
9
18
|
|
10
|
-
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
-
s.authors = ["Andrew White"]
|
12
|
-
s.date = %q{2011-01-31}
|
13
|
-
s.description = %q{A plugin/gem that provides access to the Prowl API (http://prowlapp.com). Works with Rails 2 or 3 as well as any other Ruby web frameworks or in your own scripts.}
|
14
|
-
s.email = %q{andyw@pixeltrix.co.uk}
|
15
|
-
s.extra_rdoc_files = [
|
16
|
-
"README"
|
17
|
-
]
|
18
19
|
s.files = [
|
20
|
+
".gemtest",
|
19
21
|
"CHANGELOG",
|
20
|
-
"INSTALL",
|
21
22
|
"MIT-LICENSE",
|
22
|
-
"README",
|
23
|
+
"README.md",
|
23
24
|
"Rakefile",
|
24
25
|
"VERSION",
|
25
26
|
"init.rb",
|
@@ -38,21 +39,14 @@ Gem::Specification.new do |s|
|
|
38
39
|
"test/config/cacert.pem",
|
39
40
|
"test/prowler_test.rb"
|
40
41
|
]
|
41
|
-
|
42
|
+
|
43
|
+
s.test_files = ["test/prowler_test.rb"]
|
42
44
|
s.require_paths = ["lib"]
|
43
|
-
s.rubygems_version = %q{1.4.2}
|
44
|
-
s.summary = %q{Provides access to the Prowl API (http://prowlapp.com).}
|
45
|
-
s.test_files = [
|
46
|
-
"test/prowler_test.rb"
|
47
|
-
]
|
48
45
|
|
49
|
-
|
50
|
-
|
46
|
+
s.add_development_dependency "bundler", "~> 1.0.10"
|
47
|
+
s.add_development_dependency "mocha", "~> 0.9.12"
|
48
|
+
s.add_development_dependency "shoulda", "~> 2.11.3"
|
49
|
+
s.add_development_dependency "webmock", "~> 1.6.2"
|
51
50
|
|
52
|
-
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
53
|
-
else
|
54
|
-
end
|
55
|
-
else
|
56
|
-
end
|
57
51
|
end
|
58
52
|
|
data/test/prowler_test.rb
CHANGED
@@ -24,11 +24,13 @@ class ProwlerTest < Test::Unit::TestCase
|
|
24
24
|
|
25
25
|
should "be done with a block" do
|
26
26
|
Prowler.configure do |config|
|
27
|
+
config.service_url = "test.host"
|
27
28
|
config.api_key = "apikey"
|
28
29
|
config.application = "application"
|
29
30
|
config.provider_key = "providerkey"
|
30
31
|
end
|
31
32
|
|
33
|
+
assert_equal "test.host", Prowler.service_url
|
32
34
|
assert_equal "apikey", Prowler.api_key
|
33
35
|
assert_equal "application", Prowler.application
|
34
36
|
assert_equal "providerkey", Prowler.provider_key
|
@@ -513,6 +515,11 @@ class ProwlerTest < Test::Unit::TestCase
|
|
513
515
|
assert_equal "application2", prowler.application
|
514
516
|
assert_equal "providerkey2", prowler.provider_key
|
515
517
|
end
|
518
|
+
|
519
|
+
should "configure default service url" do
|
520
|
+
prowler = Prowler.new("apikey", "application")
|
521
|
+
assert_equal Prowler::SERVICE_URL, prowler.service_url
|
522
|
+
end
|
516
523
|
end
|
517
524
|
|
518
525
|
context "Sending a notification" do
|
@@ -553,4 +560,35 @@ class ProwlerTest < Test::Unit::TestCase
|
|
553
560
|
end
|
554
561
|
end
|
555
562
|
end
|
563
|
+
|
564
|
+
context "When using a custom service url" do
|
565
|
+
setup do
|
566
|
+
Prowler.reset_configuration
|
567
|
+
Prowler.configure do |config|
|
568
|
+
config.service_url = "https://test.host/publicapi"
|
569
|
+
config.api_key = "apikey"
|
570
|
+
config.application = "Application Name"
|
571
|
+
end
|
572
|
+
end
|
573
|
+
|
574
|
+
should "send notifications to the custom service url" do
|
575
|
+
stub_request(:post, "https://test.host/publicapi/add")
|
576
|
+
|
577
|
+
Prowler.notify "Event Name", "Message Text"
|
578
|
+
|
579
|
+
assert_requested :post, "https://test.host/publicapi/add", :body => {
|
580
|
+
:application => "Application Name",
|
581
|
+
:apikey => "apikey",
|
582
|
+
:event => "Event Name",
|
583
|
+
:description => "Message Text",
|
584
|
+
:priority => Prowler::Priority::NORMAL.to_s
|
585
|
+
}
|
586
|
+
end
|
587
|
+
|
588
|
+
should "verify the API key with the custom url" do
|
589
|
+
stub_request :get, "https://test.host/publicapi/verify?apikey=apikey"
|
590
|
+
Prowler.verify
|
591
|
+
assert_requested :get, "https://test.host/publicapi/verify?apikey=apikey"
|
592
|
+
end
|
593
|
+
end
|
556
594
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: prowler
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 25
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 3
|
9
|
-
-
|
10
|
-
version: 1.3.
|
9
|
+
- 1
|
10
|
+
version: 1.3.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Andrew White
|
@@ -15,23 +15,91 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-
|
18
|
+
date: 2011-04-20 00:00:00 +01:00
|
19
19
|
default_executable:
|
20
|
-
dependencies:
|
20
|
+
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
22
|
+
name: bundler
|
23
|
+
prerelease: false
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
hash: 3
|
30
|
+
segments:
|
31
|
+
- 1
|
32
|
+
- 0
|
33
|
+
- 10
|
34
|
+
version: 1.0.10
|
35
|
+
type: :development
|
36
|
+
version_requirements: *id001
|
37
|
+
- !ruby/object:Gem::Dependency
|
38
|
+
name: mocha
|
39
|
+
prerelease: false
|
40
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ~>
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
hash: 35
|
46
|
+
segments:
|
47
|
+
- 0
|
48
|
+
- 9
|
49
|
+
- 12
|
50
|
+
version: 0.9.12
|
51
|
+
type: :development
|
52
|
+
version_requirements: *id002
|
53
|
+
- !ruby/object:Gem::Dependency
|
54
|
+
name: shoulda
|
55
|
+
prerelease: false
|
56
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
hash: 37
|
62
|
+
segments:
|
63
|
+
- 2
|
64
|
+
- 11
|
65
|
+
- 3
|
66
|
+
version: 2.11.3
|
67
|
+
type: :development
|
68
|
+
version_requirements: *id003
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: webmock
|
71
|
+
prerelease: false
|
72
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ~>
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
hash: 11
|
78
|
+
segments:
|
79
|
+
- 1
|
80
|
+
- 6
|
81
|
+
- 2
|
82
|
+
version: 1.6.2
|
83
|
+
type: :development
|
84
|
+
version_requirements: *id004
|
85
|
+
description: |
|
86
|
+
A plugin/gem that provides access to the Prowl API (http://prowlapp.com).
|
87
|
+
Works with Rails 2 or 3 as well as any other Ruby web frameworks or in
|
88
|
+
your own scripts.
|
21
89
|
|
22
|
-
|
23
|
-
|
90
|
+
email:
|
91
|
+
- andyw@pixeltrix.co.uk
|
24
92
|
executables: []
|
25
93
|
|
26
94
|
extensions: []
|
27
95
|
|
28
|
-
extra_rdoc_files:
|
29
|
-
|
96
|
+
extra_rdoc_files: []
|
97
|
+
|
30
98
|
files:
|
99
|
+
- .gemtest
|
31
100
|
- CHANGELOG
|
32
|
-
- INSTALL
|
33
101
|
- MIT-LICENSE
|
34
|
-
- README
|
102
|
+
- README.md
|
35
103
|
- Rakefile
|
36
104
|
- VERSION
|
37
105
|
- init.rb
|
@@ -79,7 +147,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
79
147
|
requirements: []
|
80
148
|
|
81
149
|
rubyforge_project:
|
82
|
-
rubygems_version: 1.
|
150
|
+
rubygems_version: 1.6.2
|
83
151
|
signing_key:
|
84
152
|
specification_version: 3
|
85
153
|
summary: Provides access to the Prowl API (http://prowlapp.com).
|
data/README
DELETED
@@ -1,73 +0,0 @@
|
|
1
|
-
== Prowler
|
2
|
-
|
3
|
-
This is a plugin/gem for integrating apps with the Prowl iPhone application.
|
4
|
-
|
5
|
-
INSTALLATION
|
6
|
-
|
7
|
-
To install as a plugin from your application root, run:
|
8
|
-
|
9
|
-
Rails 2.x:
|
10
|
-
script/plugin install git://github.com/pixeltrix/prowler.git
|
11
|
-
|
12
|
-
Rails 3.x:
|
13
|
-
script/rails plugin install git://github.com/pixeltrix/prowler.git
|
14
|
-
|
15
|
-
To install as a gem configure your config.gems or Gemfile:
|
16
|
-
|
17
|
-
Rails 2.x:
|
18
|
-
config.gems 'prowler', :version => '~> 1.2'
|
19
|
-
|
20
|
-
Rails 3.x:
|
21
|
-
gem 'prowler', '~> 1.2'
|
22
|
-
|
23
|
-
Prowler is not limited to Rails apps - it can be used in any situation
|
24
|
-
where you need to send push notifications to your iPhone.
|
25
|
-
|
26
|
-
CONFIGURATION
|
27
|
-
|
28
|
-
You should have something like this in config/initializers/prowler.rb.
|
29
|
-
|
30
|
-
Prowler.configure do |config|
|
31
|
-
config.api_key = 'ffffffffffffffffffffffffffffffffffffffff'
|
32
|
-
config.application = 'www.example.com'
|
33
|
-
end
|
34
|
-
|
35
|
-
You can test that Prowler is working in your production environment by using
|
36
|
-
this rake task (from your application root):
|
37
|
-
|
38
|
-
rake prowler:test
|
39
|
-
|
40
|
-
If everything is configured properly the task will send a request to
|
41
|
-
prowlapp.com which will be appear on your iPhone after a short delay.
|
42
|
-
|
43
|
-
USAGE
|
44
|
-
|
45
|
-
To use Prowler within your application just call the notify method, e.g.
|
46
|
-
|
47
|
-
Prowler.notify "Event", "Description"
|
48
|
-
|
49
|
-
If you need to send to multiple accounts from within a single application you
|
50
|
-
can create an instance of the Prowler class to override the global settings, e.g.
|
51
|
-
|
52
|
-
prowler = Prowler.new(:application => 'application', :api_key => 'apikey')
|
53
|
-
prowler.notify "Event", "Description"
|
54
|
-
|
55
|
-
If performance is a concern then there is built in support for Delayed::Job.
|
56
|
-
This can done either on a global basis, e.g.
|
57
|
-
|
58
|
-
Prowler.configure do |config|
|
59
|
-
config.delayed = true
|
60
|
-
end
|
61
|
-
|
62
|
-
or on a individual message basis, e.g.
|
63
|
-
|
64
|
-
Prowler.notify "Event", "Description", :delayed => true
|
65
|
-
|
66
|
-
ABOUT
|
67
|
-
|
68
|
-
Prowler relies upon the Prowl iPhone application which is advertised as
|
69
|
-
a Growl notification forwarder from your Mac. However they provide an API
|
70
|
-
which can be called by a generic script which allows you to use the
|
71
|
-
application as a general push notification application for your iPhone.
|
72
|
-
|
73
|
-
For more about the Prowl application see: http://prowlapp.com/
|