beaconpush 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2010 Jakub Kuźma
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.rdoc ADDED
@@ -0,0 +1,51 @@
1
+ = Beaconpush
2
+
3
+ Beaconpush gem provides easy access to the {Beacon push service}[http://beaconpush.com/] from your application.
4
+
5
+ == Usage
6
+
7
+ require "beaconpush"
8
+
9
+ # You may want to put these two lines inside of an initializer in
10
+ # your Rails application
11
+ Beaconpush.key = "ad819983"
12
+ Beaconpush.secret = "..."
13
+
14
+ # Beaconpush is ready to use now!
15
+
16
+ # Fetches the number of online users
17
+ Beaconpush.users_count
18
+ # => 2
19
+
20
+ # Checks if the user is online at the moment
21
+ Beaconpush.user_online?("alice")
22
+ # => false
23
+
24
+ # Sends the given message to the user
25
+ Beaconpush.user_message("bob", "Hello Bob!")
26
+
27
+ # Fetches the list of online users in the given channel
28
+ Beaconpush.channel_users("myfirstchannel")
29
+ # => ["bob"]
30
+
31
+ # Sends the given message to the channel
32
+ Beaconpush.channel_message("myfirstchannel", :message => "Channel message!", :severity => "important")
33
+
34
+ # Forces the user to disconnect
35
+ Beaconpush.user_logout("bob")
36
+
37
+ # You can also use multiple Beacon accounts in a single application
38
+ client1 = Beaconpush::Client.new(:key => "da10749525", :secret => "...")
39
+ client2 = Beaconpush::Client.new(:key => "bb19021573", :secret => "...")
40
+ client1.users_count
41
+ # => 0
42
+ client2.users_count
43
+ # => 4
44
+
45
+ == Installation
46
+
47
+ gem install beaconpush
48
+
49
+ == Copyright
50
+
51
+ Copyright (c) 2010 Jakub Kuźma. Released on the MIT license (see LICENSE[http://github.com/qoobaa/beaconpush/raw/master/LICENSE] for details).
@@ -1,10 +1,10 @@
1
1
  module Beaconpush
2
2
  class Client
3
- attr_accessor :api_key, :secret_key, :version, :host, :port
3
+ attr_accessor :key, :secret, :version, :host, :port
4
4
 
5
5
  def initialize(options)
6
- self.api_key = options.fetch(:api_key, Beaconpush.api_key) || raise(ArgumentError, "No API key given")
7
- self.secret_key = options.fetch(:secret_key, Beaconpush.secret_key) || raise(ArgumentError, "No secret key given")
6
+ self.key = options.fetch(:key, Beaconpush.key) || raise(ArgumentError, "No key given")
7
+ self.secret = options.fetch(:secret, Beaconpush.secret) || raise(ArgumentError, "No secret given")
8
8
  self.version = options.fetch(:version, Beaconpush.version) || raise(ArgumentError, "No API version given")
9
9
  self.host = options.fetch(:host, Beaconpush.host) || raise(ArgumentError, "No Beacon host given")
10
10
  self.port = options.fetch(:port, Beaconpush.port) || raise(ArgumentError, "No Beacon port given")
@@ -44,7 +44,7 @@ module Beaconpush
44
44
  end
45
45
 
46
46
  def request(method, command, body = nil)
47
- path = "/api/#{version}/#{api_key}#{URI.encode(command)}"
47
+ path = "/api/#{version}/#{key}#{URI.encode(command)}"
48
48
 
49
49
  request = Net::HTTPGenericRequest.new(method.to_s.upcase, !!body, method.to_s.upcase != "HEAD", path)
50
50
 
@@ -53,7 +53,7 @@ module Beaconpush
53
53
  request.content_length = body.size
54
54
  end
55
55
 
56
- request["X-Beacon-Secret-Key"] = secret_key
56
+ request["X-Beacon-Secret-Key"] = secret
57
57
 
58
58
  response = http.request(request)
59
59
 
@@ -1,3 +1,3 @@
1
1
  module Beaconpush
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
data/lib/beaconpush.rb CHANGED
@@ -8,7 +8,7 @@ require "beaconpush/response_error"
8
8
  module Beaconpush
9
9
  class << self
10
10
  extend Forwardable
11
- attr_accessor :api_key, :secret_key
11
+ attr_accessor :key, :secret
12
12
  attr_writer :version, :host, :port
13
13
  def_delegators :client, :users_count, :user_online?, :user_logout, :user_message, :channel_message, :channel_users
14
14
 
@@ -25,7 +25,7 @@ module Beaconpush
25
25
  end
26
26
 
27
27
  def client
28
- @client ||= Client.new(:api_key => api_key, :secret_key => secret_key, :version => version, :host => host, :port => port)
28
+ @client ||= Client.new(:key => key, :secret => secret, :version => version, :host => host, :port => port)
29
29
  end
30
30
  end
31
31
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 0
8
- - 1
9
- version: 0.0.1
8
+ - 2
9
+ version: 0.0.2
10
10
  platform: ruby
11
11
  authors:
12
12
  - "Jakub Ku\xC5\xBAma"
@@ -31,6 +31,8 @@ files:
31
31
  - .gitignore
32
32
  - Gemfile
33
33
  - Gemfile.lock
34
+ - LICENSE
35
+ - README.rdoc
34
36
  - Rakefile
35
37
  - beaconpush.gemspec
36
38
  - lib/beaconpush.rb