prowl 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (6) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +56 -0
  3. data/lib/prowl.rb +19 -8
  4. data/prowl.gemspec +4 -4
  5. metadata +21 -33
  6. data/README +0 -54
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 8bfa568e0d884adf20b06b97a99e075c2aa6c06e
4
+ data.tar.gz: 10cd71287c45518a2c353617a7395bd9c2306727
5
+ SHA512:
6
+ metadata.gz: 81b5c937ba9cee34330dfbbe915da1967781c9d520872f16bef839a161a5fdfcc4f15f8e5bb6af81dc5d7a9c229129cf6e6eed30126cda947cb17f2feb3e62d2
7
+ data.tar.gz: 9fbca6d04020d30cf1f88e8093222b912d5415d8560d63bcbd6bfa44471546bf384ee9dc9fc59c49c423026c17106a39097eac04fd06c43f1ef8bfce4366680a
@@ -0,0 +1,56 @@
1
+ # Prowl
2
+
3
+ Ruby wrapper for [Prowl](http://www.prowlapp.com/).
4
+
5
+ ## About
6
+
7
+ Prowl rocks! It's a webapp and a iPhone app that works
8
+ together and lets you send push notifications via HTTP
9
+ to any iPhone that has the prowl app installed.
10
+
11
+ ```` ruby
12
+ Prowl.add(
13
+ :apikey => "api key abc123def456",
14
+ :application => "World Saving Project Manager",
15
+ :event => "Canceled",
16
+ :description => "It sucked, so I canceled it. Sorry :("
17
+ )
18
+ ````
19
+
20
+ The user has given you its API key. That lets you
21
+ send push notifications to the users iPhone, through
22
+ the Prowl iPhone app.
23
+
24
+ ## Installation
25
+
26
+ gem install prowl
27
+
28
+ Code available [here](http://github.com/augustl/ruby-prowl/tree).
29
+
30
+ ## Notice
31
+
32
+ `Prowl.send` has been renamed to `Prowl.add`.
33
+
34
+ ## Usage
35
+
36
+ Four required parameters:
37
+
38
+ - *apikey* (String / Array< String >)
39
+ - *application* (String)
40
+ - *event* (String)
41
+ - *description* (String)
42
+
43
+ You can use `Prowl.add`, or create instances of Prowl manually.
44
+
45
+ ```` ruby
46
+ Prowl.add(:apikey => "123abc", :application => "Foo", ...)
47
+ Prowl.verify("apikey")
48
+
49
+ p = Prowl.new(:apikey => "apikey123abc", :application => "FooApp")
50
+ p.valid?
51
+ p.add(:event => "It's valid", ...)
52
+ ````
53
+
54
+ ## Authors
55
+
56
+ - [August Lilleaas](http://august.lilleaas.net/).
@@ -8,13 +8,18 @@ class Prowl
8
8
  class TooManyAPIKeys < RuntimeError; end
9
9
  class PriorityOutOfRange < RuntimeError; end
10
10
 
11
- API_URL = "https://prowl.weks.net:443/publicapi"
11
+ API_URL = "https://api.prowlapp.com/publicapi"
12
12
  MAX_API_KEYS = 5
13
13
  PRIORITY_RANGE = -2..2
14
14
 
15
15
  def initialize(defaults = {})
16
16
  @defaults = defaults
17
17
  end
18
+
19
+ def set_proxy(addr, port)
20
+ @proxy_addr = addr
21
+ @proxy_port = port
22
+ end
18
23
 
19
24
  def add(params = {})
20
25
  perform("add", params)
@@ -62,15 +67,21 @@ class Prowl
62
67
 
63
68
  # If there are multiple API Keys in an array, merge them into a comma-delimited string
64
69
  if params[:apikey].is_a?(Array)
65
- params[:apikey] = params[:apikey].collect{|v| v + ","}.to_s.chop.chop
70
+ params[:apikey] = params[:apikey].join(",")
66
71
  end
67
72
 
68
73
  uri = URI.parse("#{API_URL}/#{action}")
69
- http = Net::HTTP.new(uri.host, uri.port)
70
- http.use_ssl = true
71
- http.verify_mode = OpenSSL::SSL::VERIFY_NONE
72
-
73
- request = Net::HTTP::Get.new(uri.request_uri + "?" + params.map {|k, v| "#{k}=#{CGI.escape(v.to_s)}"}.join("&"))
74
+
75
+ proxy = Net::HTTP::Proxy(@proxy_addr, @proxy_port)
76
+ http = proxy.start(uri.host, :use_ssl => true, :verify_mode => OpenSSL::SSL::VERIFY_NONE)
77
+
78
+ if (action == 'add')
79
+ request = Net::HTTP::Post.new(uri.request_uri)
80
+ request.set_form_data params
81
+ else
82
+ request = Net::HTTP::Get.new(uri.request_uri + "?" + params.map {|k, v| "#{k}=#{CGI.escape(v.to_s)}"}.join("&"))
83
+ end
84
+
74
85
  response = http.request(request)
75
86
  return response.code.to_i
76
87
  end
@@ -82,4 +93,4 @@ if __FILE__ == $0
82
93
 
83
94
  p Prowl.add(:apikey => api_key, :application => "Fishes", :event => "silly", :description => "Awwawaw.", :priority => 1)
84
95
  p Prowl.verify(api_key)
85
- end
96
+ end
@@ -1,9 +1,9 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "prowl"
3
- s.version = "0.1.3"
3
+ s.version = "0.1.4"
4
4
  s.date = "2009-07-08"
5
5
  s.authors = ["August Lilleaas"]
6
- s.email = "augustlilleaas@gmail.com"
6
+ s.email = "august@augustl.com"
7
7
  s.rubyforge_project = "prowl"
8
8
  s.has_rdoc = true
9
9
  s.summary = "Wrapprer for prowl, http://prowl.weks.net/."
@@ -12,7 +12,7 @@ Gem::Specification.new do |s|
12
12
  "lib/prowl.rb",
13
13
  "prowl.gemspec",
14
14
  "Rakefile",
15
- "README",
15
+ "README.md",
16
16
  "test/prowl_test.rb"
17
17
  ]
18
- end
18
+ end
metadata CHANGED
@@ -1,59 +1,47 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: prowl
3
- version: !ruby/object:Gem::Version
4
- version: 0.1.3
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.4
5
5
  platform: ruby
6
- authors:
6
+ authors:
7
7
  - August Lilleaas
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
-
12
- date: 2009-07-08 00:00:00 +02:00
13
- default_executable:
11
+ date: 2009-07-08 00:00:00.000000000 Z
14
12
  dependencies: []
15
-
16
13
  description:
17
- email: augustlilleaas@gmail.com
14
+ email: august@augustl.com
18
15
  executables: []
19
-
20
16
  extensions: []
21
-
22
17
  extra_rdoc_files: []
23
-
24
- files:
18
+ files:
19
+ - README.md
20
+ - Rakefile
25
21
  - lib/prowl.rb
26
22
  - prowl.gemspec
27
- - Rakefile
28
- - README
29
23
  - test/prowl_test.rb
30
- has_rdoc: true
31
24
  homepage: http://prowl.rubyforge.org/
32
25
  licenses: []
33
-
26
+ metadata: {}
34
27
  post_install_message:
35
28
  rdoc_options: []
36
-
37
- require_paths:
29
+ require_paths:
38
30
  - lib
39
- required_ruby_version: !ruby/object:Gem::Requirement
40
- requirements:
31
+ required_ruby_version: !ruby/object:Gem::Requirement
32
+ requirements:
41
33
  - - ">="
42
- - !ruby/object:Gem::Version
43
- version: "0"
44
- version:
45
- required_rubygems_version: !ruby/object:Gem::Requirement
46
- requirements:
34
+ - !ruby/object:Gem::Version
35
+ version: '0'
36
+ required_rubygems_version: !ruby/object:Gem::Requirement
37
+ requirements:
47
38
  - - ">="
48
- - !ruby/object:Gem::Version
49
- version: "0"
50
- version:
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
51
41
  requirements: []
52
-
53
42
  rubyforge_project: prowl
54
- rubygems_version: 1.3.5
43
+ rubygems_version: 2.2.2
55
44
  signing_key:
56
- specification_version: 3
45
+ specification_version: 4
57
46
  summary: Wrapprer for prowl, http://prowl.weks.net/.
58
47
  test_files: []
59
-
data/README DELETED
@@ -1,54 +0,0 @@
1
- --~~ Prowl ~~--
2
-
3
- Ruby wrapper for http://prowl.weks.net/.
4
- Written by August Lilleaas (http://august.lilleaas.net/).
5
-
6
- Note: `send` has been renamed to `add`.
7
-
8
-
9
- --~~ Installation ~~--
10
-
11
- gem install prowl
12
-
13
- or
14
-
15
- gem install augustl-prowl --source=http://gems.github.com/
16
-
17
- Code available here: http://github.com/augustl/ruby-prowl/tree
18
-
19
- --~~ About ~~--
20
-
21
- Prowl rocks! It's a webapp and a iPhone app that works
22
- together and lets you send push notifications via HTTP
23
- to any iPhone that has the prowl app installed.
24
-
25
- Prowl.add(
26
- :apikey => "api key abc123def456",
27
- :application => "World Saving Project Manager",
28
- :event => "Canceled",
29
- :description => "It sucked, so I canceled it. Sorry :("
30
- )
31
-
32
- The user has given you its API key. That lets you
33
- send push notifications to the users iPhone, through
34
- the Prowl iPhone app.
35
-
36
-
37
- --~~ Usage ~~--
38
-
39
- Four required parameters:
40
-
41
- :apikey (string / array of strings)
42
- :application (string)
43
- :event (string)
44
- :description (string)
45
-
46
- You can use Prowl.add, or create instances of Prowl
47
- manually.
48
-
49
- Prowl.add(:apikey => "123abc", :application => "Foo", ...)
50
- Prowl.verify("apikey")
51
-
52
- p = Prowl.new(:apikey => "apikey123abc", :application => "FooApp")
53
- p.valid?
54
- p.add(:event => "It's valid", ...)