shove 0.51 → 0.52

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/README.md CHANGED
@@ -20,7 +20,7 @@
20
20
  :cluster => "cluster"
21
21
  )
22
22
 
23
- ##Broadcast messages
23
+ ##Broadcasting
24
24
 
25
25
  # broadcast the "hello" event on the "default" channel with
26
26
  # Hello World! as the data
@@ -30,20 +30,20 @@
30
30
  puts response.message
31
31
  end
32
32
 
33
- ##Direct messages
33
+ ##Send direct messages
34
34
 
35
35
  Shove.direct(userid, "hello", "Hello World!") do |response|
36
36
  # handle response
37
37
  end
38
38
 
39
- ##Authorize a user
39
+ ##Subscription Authorization
40
40
 
41
41
  # authorize user with id userid on channel "default"
42
42
  Shove.authorize(userid, "default") do |response|
43
43
  # handle response
44
44
  end
45
45
 
46
- ##Stream all data from a channel
46
+ ##Channel Streaming
47
47
 
48
48
  # stream all data on channel "default"
49
49
  Shove.stream("default") do |msg|
@@ -56,36 +56,6 @@
56
56
  puts msg[:data] # the payload
57
57
 
58
58
  end
59
-
60
- ##Channel Management
61
- Creating channels is a privileged operation. You can do it from the shove.io management console, or via the management API.
62
- In the case of the ruby gem, you can manage it straight from ruby.
63
-
64
- # Create a channel
65
- options = {
66
- :name => "funchannel", #this is the only required field
67
- :restricted => false, #require authorization for subscription
68
- :broadcastable => true, #allow clients to broadcast to other clients
69
- :presence => true #when users subscribe/unsubscribe all other subscribers are notified
70
- }
71
- Shove.create_channel(options) do |response|
72
- if response.error?
73
- puts "boooo"
74
- puts response.message
75
- end
76
- end
77
-
78
- # Update a channel
79
- Shove.update_channel("funchannel", :presence => false) do |response|
80
- # ...
81
- end
82
-
83
- # Delete channel
84
- # this will unsubscribe all subscribers from this channel
85
- # nearly immediately, so make sure you want to do that.
86
- Shove.delete_channel("funchannel") do |response|
87
- # ...
88
- end
89
59
 
90
60
  ##Block and Non-blocking
91
61
  shover does both. If the shover code happens to run inside of an EM.run block, the HTTP calls
data/lib/shove/client.rb CHANGED
@@ -11,8 +11,7 @@ module Shove
11
11
  @network = opts[:network]
12
12
  @cluster = opts[:cluster] || "a01"
13
13
  @secure = opts[:secure] || false
14
- @host = opts[:host] || "api.#{@cluster}.shove.io"
15
- @web_host = opts[:web_host] || "shove.io"
14
+ @host = opts[:host] || "api-#{@cluster}.shove.io"
16
15
  end
17
16
 
18
17
  # broadcast a message
@@ -44,39 +43,12 @@ module Shove
44
43
  return response
45
44
  end
46
45
  end
47
-
48
- # Channel methods
49
-
50
- # create a channel
51
- # +opts+ the hash containing channel options
52
- # :restricted
53
- # :name
54
- def create_channel opts, &block
55
- Request.new("#{channel_uri}").post({ :channel => opts }, &block)
56
- end
57
-
58
- # delete a channel
59
- # +name+ the name of the channel to delete
60
- def delete_channel name, &block
61
- Request.new("#{channel_uri}/#{name}").delete(&block)
62
- end
63
-
64
- # update the attributes of a channel
65
- # +name+ the name of the channel
66
- # +opts+ the options hash to update
67
- def update_channel name, opts, &block
68
- Request.new("#{channel_uri}/#{name}").put({ :channel => opts }, &block)
69
- end
70
-
46
+
71
47
  protected
72
48
 
73
49
  def uri
74
50
  (@secure ? "https" : "http") + "://#{@host}/#{@network}"
75
51
  end
76
52
 
77
- def channel_uri
78
- (@secure ? "https" : "http") + "://#{@web_host}/api/#{@network}/channels"
79
- end
80
-
81
53
  end
82
54
  end
data/lib/shove.rb CHANGED
@@ -9,10 +9,11 @@ require "yaml"
9
9
  ##
10
10
  # Shove
11
11
  #
12
- # See http://shove.io for an account
12
+ # See http://shove.io for an account and client documentation
13
+ # See https://github.com/shove/shover for gem documentation
13
14
  module Shove
14
15
 
15
- Version = 0.51
16
+ Version = 0.52
16
17
 
17
18
  class << self
18
19
 
@@ -61,29 +62,7 @@ module Shove
61
62
  def validate
62
63
  client.validate
63
64
  end
64
-
65
- # Channel methods
66
-
67
- # create a channel
68
- # +opts+ the hash containing channel options
69
- def create_channel opts, &block
70
- client.create_channel opts, &block
71
- end
72
65
 
73
- # delete a channel
74
- # +name+ the name of the channel to delete
75
- def delete_channel name, &block
76
- client.delete_channel name, &block
77
- end
78
-
79
- # update the attributes of a channel
80
- # +name+ the name of the channel
81
- # +opts+ the options hash to update
82
- def update_channel name, opts, &block
83
- client.update_channel name, opts, &block
84
- end
85
-
86
-
87
66
  # act as a stream client. requires EM
88
67
  # +channel+ the channel to stream
89
68
  def stream channel, &block
@@ -105,9 +84,7 @@ module Shove
105
84
  }
106
85
 
107
86
  http.stream { |msg|
108
-
109
- puts msg
110
-
87
+
111
88
  parts = msg.split "!"
112
89
 
113
90
  case parts[1]
data/shove.gemspec CHANGED
@@ -1,7 +1,7 @@
1
1
  spec = Gem::Specification.new do |s|
2
2
  s.name = "shove"
3
- s.version = "0.51"
4
- s.date = "2011-03-12"
3
+ s.version = "0.52"
4
+ s.date = "2011-03-26"
5
5
  s.summary = "Ruby gem for leveraging shove.io, the web push platform"
6
6
  s.email = "dan@shove.io"
7
7
  s.homepage = "https://github.com/shove/shover"
data/spec/shove_spec.rb CHANGED
@@ -11,8 +11,30 @@ describe Shove do
11
11
  end
12
12
 
13
13
  it "should have config" do
14
- Shove.config["network"].should == "shove"
14
+ Shove.config[:network].should == "deadbeef"
15
15
  end
16
16
 
17
+ it "should be able to authorize with the server" do
18
+ response = Shove.validate
19
+ response.error?.should == false
20
+ end
21
+
22
+ it "should be able to broadcast a message" do
23
+ Shove.broadcast("default", "event", "test") do |response|
24
+ response.error?.should == false
25
+ end
26
+ end
27
+
28
+ it "should be able to broadcast a message with EM" do
29
+ EM.run do
30
+ Shove.broadcast("default", "event", "test") do |response|
31
+ response.error?.should == false
32
+ end
33
+
34
+ EM.add_timer(0.5) do
35
+ EM.stop
36
+ end
37
+ end
38
+ end
17
39
 
18
40
  end
metadata CHANGED
@@ -4,8 +4,8 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 0
7
- - 51
8
- version: "0.51"
7
+ - 52
8
+ version: "0.52"
9
9
  platform: ruby
10
10
  authors:
11
11
  - Dan Simpson
@@ -13,7 +13,7 @@ autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
15
 
16
- date: 2011-03-12 00:00:00 -08:00
16
+ date: 2011-03-26 00:00:00 -07:00
17
17
  default_executable:
18
18
  dependencies:
19
19
  - !ruby/object:Gem::Dependency