shove 1.0.7 → 1.0.8
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/Gemfile +1 -2
- data/README.markdown +57 -91
- data/Rakefile +0 -23
- data/lib/shove.rb +3 -70
- data/lib/shove/app.rb +40 -33
- data/lib/shove/client/channel.rb +4 -0
- data/lib/shove/client/connection.rb +32 -14
- data/lib/shove/http/request.rb +2 -2
- data/lib/shove/protocol.rb +3 -1
- data/shove.gemspec +1 -3
- data/spec/cassettes/should_be_able_to_authorize_with_the_server.yml +10 -6
- data/spec/cassettes/should_deny_a_connection.yml +10 -6
- data/spec/cassettes/should_deny_a_control_to_a_client.yml +10 -6
- data/spec/cassettes/should_deny_a_publishing_to_a_client.yml +10 -6
- data/spec/cassettes/should_deny_a_subscriptions_to_a_client.yml +10 -6
- data/spec/cassettes/should_deny_publishing_on_a_channel_context.yml +10 -6
- data/spec/cassettes/should_deny_subscriptions_on_a_channel_context.yml +10 -6
- data/spec/cassettes/should_get_a_set_of_nodes_for_the_network.yml +11 -7
- data/spec/cassettes/should_grant_a_connection.yml +10 -6
- data/spec/cassettes/should_grant_a_control_to_a_client.yml +11 -7
- data/spec/cassettes/should_grant_a_publishing_to_a_client.yml +10 -6
- data/spec/cassettes/should_grant_a_subscriptions_to_a_client.yml +10 -6
- data/spec/cassettes/should_grant_publishing_on_a_channel_context.yml +10 -6
- data/spec/cassettes/should_grant_subscriptions_on_a_channel_context.yml +10 -6
- data/spec/cassettes/should_publish_on_a_channel_context.yml +10 -6
- data/spec/cassettes/should_publish_to_a_client.yml +10 -6
- data/spec/helper.rb +0 -2
- data/spec/shove_client_spec.rb +39 -30
- data/spec/shove_http_spec.rb +27 -31
- metadata +20 -40
- data/bin/shove +0 -169
- data/lib/shove/app_directory.rb +0 -103
- data/spec/app_directory_spec.rb +0 -66
- data/spec/cassettes/should_authorize_on_a_channel.yml +0 -26
- data/spec/cassettes/should_authorize_oneself.yml +0 -24
- data/spec/cassettes/should_cancel_a_binding.yml +0 -24
- data/spec/cassettes/should_configure_the_default.yml +0 -24
- data/spec/cassettes/should_configure_the_from_the_previous_test.yml +0 -24
- data/spec/cassettes/should_create_a_channel_context.yml +0 -24
- data/spec/cassettes/should_get_a_subscribe_granted_event.yml +0 -24
- data/spec/cassettes/should_publish.yml +0 -24
- data/spec/cassettes/should_receive_an_unsubscribe_event.yml +0 -24
- data/spec/cassettes/should_receive_messages_on_a_channel.yml +0 -24
- data/spec/cassettes/should_send_a_connect_op.yml +0 -24
- data/spec/cassettes/should_send_a_connect_op_with_an_id.yml +0 -24
- data/spec/cassettes/should_spawn_a_client.yml +0 -24
- data/spec/cassettes/should_subscribe_to_a_channel.yml +0 -24
- data/spec/cassettes/should_trigger_a_connect_denied_event.yml +0 -24
- data/spec/cassettes/should_trigger_a_connect_event.yml +0 -24
- data/spec/cassettes/should_trigger_a_disconnect_event.yml +0 -24
- data/spec/cassettes/should_trigger_an_error_event.yml +0 -24
- data/spec/cassettes/should_unsubscribe_from_a_channel.yml +0 -24
- data/spec/cassettes/should_update_the_default_app.yml +0 -24
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: shove
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.8
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ date: 2012-02-08 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: em-http-request
|
16
|
-
requirement:
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,15 @@ dependencies:
|
|
21
21
|
version: 1.0.0
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements:
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 1.0.0
|
25
30
|
- !ruby/object:Gem::Dependency
|
26
31
|
name: em-ws-client
|
27
|
-
requirement:
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
28
33
|
none: false
|
29
34
|
requirements:
|
30
35
|
- - ! '>='
|
@@ -32,10 +37,15 @@ dependencies:
|
|
32
37
|
version: 0.2.0
|
33
38
|
type: :runtime
|
34
39
|
prerelease: false
|
35
|
-
version_requirements:
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: 0.2.0
|
36
46
|
- !ruby/object:Gem::Dependency
|
37
47
|
name: yajl-ruby
|
38
|
-
requirement:
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
39
49
|
none: false
|
40
50
|
requirements:
|
41
51
|
- - ! '>='
|
@@ -43,22 +53,15 @@ dependencies:
|
|
43
53
|
version: 1.1.0
|
44
54
|
type: :runtime
|
45
55
|
prerelease: false
|
46
|
-
version_requirements:
|
47
|
-
- !ruby/object:Gem::Dependency
|
48
|
-
name: confstruct
|
49
|
-
requirement: &21819840 !ruby/object:Gem::Requirement
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
50
57
|
none: false
|
51
58
|
requirements:
|
52
59
|
- - ! '>='
|
53
60
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
55
|
-
type: :runtime
|
56
|
-
prerelease: false
|
57
|
-
version_requirements: *21819840
|
61
|
+
version: 1.1.0
|
58
62
|
description: Client side implementation for the shove.io API. See http://shove.io/documentation
|
59
63
|
email: dan@shove.io
|
60
|
-
executables:
|
61
|
-
- shove
|
64
|
+
executables: []
|
62
65
|
extensions: []
|
63
66
|
extra_rdoc_files: []
|
64
67
|
files:
|
@@ -67,10 +70,8 @@ files:
|
|
67
70
|
- Gemfile.lock
|
68
71
|
- README.markdown
|
69
72
|
- Rakefile
|
70
|
-
- bin/shove
|
71
73
|
- lib/shove.rb
|
72
74
|
- lib/shove/app.rb
|
73
|
-
- lib/shove/app_directory.rb
|
74
75
|
- lib/shove/client/callback.rb
|
75
76
|
- lib/shove/client/channel.rb
|
76
77
|
- lib/shove/client/connection.rb
|
@@ -80,14 +81,7 @@ files:
|
|
80
81
|
- lib/shove/http/response.rb
|
81
82
|
- lib/shove/protocol.rb
|
82
83
|
- shove.gemspec
|
83
|
-
- spec/app_directory_spec.rb
|
84
|
-
- spec/cassettes/should_authorize_on_a_channel.yml
|
85
|
-
- spec/cassettes/should_authorize_oneself.yml
|
86
84
|
- spec/cassettes/should_be_able_to_authorize_with_the_server.yml
|
87
|
-
- spec/cassettes/should_cancel_a_binding.yml
|
88
|
-
- spec/cassettes/should_configure_the_default.yml
|
89
|
-
- spec/cassettes/should_configure_the_from_the_previous_test.yml
|
90
|
-
- spec/cassettes/should_create_a_channel_context.yml
|
91
85
|
- spec/cassettes/should_deny_a_connection.yml
|
92
86
|
- spec/cassettes/should_deny_a_control_to_a_client.yml
|
93
87
|
- spec/cassettes/should_deny_a_publishing_to_a_client.yml
|
@@ -95,28 +89,14 @@ files:
|
|
95
89
|
- spec/cassettes/should_deny_publishing_on_a_channel_context.yml
|
96
90
|
- spec/cassettes/should_deny_subscriptions_on_a_channel_context.yml
|
97
91
|
- spec/cassettes/should_get_a_set_of_nodes_for_the_network.yml
|
98
|
-
- spec/cassettes/should_get_a_subscribe_granted_event.yml
|
99
92
|
- spec/cassettes/should_grant_a_connection.yml
|
100
93
|
- spec/cassettes/should_grant_a_control_to_a_client.yml
|
101
94
|
- spec/cassettes/should_grant_a_publishing_to_a_client.yml
|
102
95
|
- spec/cassettes/should_grant_a_subscriptions_to_a_client.yml
|
103
96
|
- spec/cassettes/should_grant_publishing_on_a_channel_context.yml
|
104
97
|
- spec/cassettes/should_grant_subscriptions_on_a_channel_context.yml
|
105
|
-
- spec/cassettes/should_publish.yml
|
106
98
|
- spec/cassettes/should_publish_on_a_channel_context.yml
|
107
99
|
- spec/cassettes/should_publish_to_a_client.yml
|
108
|
-
- spec/cassettes/should_receive_an_unsubscribe_event.yml
|
109
|
-
- spec/cassettes/should_receive_messages_on_a_channel.yml
|
110
|
-
- spec/cassettes/should_send_a_connect_op.yml
|
111
|
-
- spec/cassettes/should_send_a_connect_op_with_an_id.yml
|
112
|
-
- spec/cassettes/should_spawn_a_client.yml
|
113
|
-
- spec/cassettes/should_subscribe_to_a_channel.yml
|
114
|
-
- spec/cassettes/should_trigger_a_connect_denied_event.yml
|
115
|
-
- spec/cassettes/should_trigger_a_connect_event.yml
|
116
|
-
- spec/cassettes/should_trigger_a_disconnect_event.yml
|
117
|
-
- spec/cassettes/should_trigger_an_error_event.yml
|
118
|
-
- spec/cassettes/should_unsubscribe_from_a_channel.yml
|
119
|
-
- spec/cassettes/should_update_the_default_app.yml
|
120
100
|
- spec/helper.rb
|
121
101
|
- spec/shove_client_spec.rb
|
122
102
|
- spec/shove_http_spec.rb
|
@@ -140,7 +120,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
140
120
|
version: '0'
|
141
121
|
requirements: []
|
142
122
|
rubyforge_project:
|
143
|
-
rubygems_version: 1.8.
|
123
|
+
rubygems_version: 1.8.23
|
144
124
|
signing_key:
|
145
125
|
specification_version: 3
|
146
126
|
summary: Ruby gem for leveraging shove.io, the web push platform
|
data/bin/shove
DELETED
@@ -1,169 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
$:.unshift File.dirname(__FILE__) + "/../lib"
|
4
|
-
|
5
|
-
require "optparse"
|
6
|
-
require "shove"
|
7
|
-
|
8
|
-
action = ARGV[0]
|
9
|
-
channel = nil
|
10
|
-
client = nil
|
11
|
-
message = nil
|
12
|
-
app = nil
|
13
|
-
app_dir = Shove::AppDirectory.new
|
14
|
-
|
15
|
-
OptionParser.new do |o|
|
16
|
-
|
17
|
-
o.banner = "Usage: shove "
|
18
|
-
|
19
|
-
o.on("-h", "--help") do
|
20
|
-
action = "help"
|
21
|
-
end
|
22
|
-
|
23
|
-
o.on("-v", "--version") do
|
24
|
-
action = "version"
|
25
|
-
end
|
26
|
-
|
27
|
-
o.on("-l", "--list") do
|
28
|
-
action = "apps"
|
29
|
-
end
|
30
|
-
|
31
|
-
o.on("-a", "--app app", "the app to work with") do |arg|
|
32
|
-
app = arg
|
33
|
-
end
|
34
|
-
|
35
|
-
o.on("-c", "--channel channel", "the channel to operate on") do |arg|
|
36
|
-
channel = arg
|
37
|
-
end
|
38
|
-
|
39
|
-
o.on("-u", "--client client", "the client to operate on") do |arg|
|
40
|
-
client = arg
|
41
|
-
end
|
42
|
-
|
43
|
-
o.on("-m", "--message message", "the message to publish") do |arg|
|
44
|
-
message = arg
|
45
|
-
end
|
46
|
-
|
47
|
-
o.parse!(ARGV)
|
48
|
-
end
|
49
|
-
|
50
|
-
begin
|
51
|
-
|
52
|
-
case action
|
53
|
-
when "version"
|
54
|
-
puts "shove version #{Shove::Version}"
|
55
|
-
when "apps"
|
56
|
-
|
57
|
-
apps = app_dir.apps
|
58
|
-
|
59
|
-
if apps.empty?
|
60
|
-
puts "No apps found. Run: shove apps:add"
|
61
|
-
else
|
62
|
-
puts "App Id\t\tApp Key"
|
63
|
-
puts "-----------------------"
|
64
|
-
apps.each_pair do |id,key|
|
65
|
-
puts "#{id}\t\t#{key}"
|
66
|
-
end
|
67
|
-
end
|
68
|
-
|
69
|
-
when "apps:add"
|
70
|
-
app_dir.get_config app
|
71
|
-
when "apps:default"
|
72
|
-
app_dir.default = app
|
73
|
-
when "hosts"
|
74
|
-
Shove.configure(app_dir.get_config(app))
|
75
|
-
|
76
|
-
Shove.hosts.each do |host|
|
77
|
-
puts host
|
78
|
-
end
|
79
|
-
|
80
|
-
when "publish"
|
81
|
-
|
82
|
-
Shove.configure(app_dir.get_config(app))
|
83
|
-
|
84
|
-
errors = []
|
85
|
-
errors << "channel not defined" unless channel
|
86
|
-
errors << "message not defined" unless message
|
87
|
-
|
88
|
-
if errors.empty?
|
89
|
-
Shove.channel(channel).publish(message) do |r|
|
90
|
-
if r.error?
|
91
|
-
puts "Error: #{r.message}"
|
92
|
-
else
|
93
|
-
puts "Published"
|
94
|
-
end
|
95
|
-
end
|
96
|
-
else
|
97
|
-
puts "Errors: #{errors.join(",")}"
|
98
|
-
end
|
99
|
-
|
100
|
-
when "watch"
|
101
|
-
|
102
|
-
Shove.configure(app_dir.get_config(app))
|
103
|
-
|
104
|
-
if channel
|
105
|
-
|
106
|
-
EM.run do
|
107
|
-
client = Shove.connect
|
108
|
-
client.authorize(app_dir.key(app))
|
109
|
-
|
110
|
-
client.on("connect") do |error|
|
111
|
-
puts "Connected"
|
112
|
-
end
|
113
|
-
|
114
|
-
client.on("error") do |error|
|
115
|
-
puts "Watch Error #{error}"
|
116
|
-
EM.stop
|
117
|
-
end
|
118
|
-
|
119
|
-
channel = client.channel(channel)
|
120
|
-
|
121
|
-
channel.on("subscribe_denied") do
|
122
|
-
puts "Subscribe Denied"
|
123
|
-
end
|
124
|
-
|
125
|
-
channel.on("subscribe") do
|
126
|
-
puts "Subscribed"
|
127
|
-
end
|
128
|
-
|
129
|
-
channel.on("message") do |msg|
|
130
|
-
puts "#{Time.now}: #{msg}"
|
131
|
-
end
|
132
|
-
|
133
|
-
end
|
134
|
-
|
135
|
-
else
|
136
|
-
puts "You must provide the channel with: -c channel_name"
|
137
|
-
end
|
138
|
-
|
139
|
-
else
|
140
|
-
puts File.read(__FILE__).split("__END__").last
|
141
|
-
end
|
142
|
-
|
143
|
-
|
144
|
-
rescue Exception => ex
|
145
|
-
|
146
|
-
puts ex.message
|
147
|
-
puts ex.backtrace
|
148
|
-
|
149
|
-
abort File.read(__FILE__).split("__END__").last
|
150
|
-
end
|
151
|
-
|
152
|
-
__END__
|
153
|
-
Usage: shove action [options]
|
154
|
-
|
155
|
-
|
156
|
-
Options
|
157
|
-
-h, --help
|
158
|
-
Show this message
|
159
|
-
|
160
|
-
Actions
|
161
|
-
publish publish a message to the app
|
162
|
-
example: shove publish -c chan -m "Hello"
|
163
|
-
|
164
|
-
hosts List available hosts for your app
|
165
|
-
watch Watch the messages on a given channel
|
166
|
-
|
167
|
-
apps List known apps
|
168
|
-
apps:default Use a particular app
|
169
|
-
apps:add Add a new app
|
data/lib/shove/app_directory.rb
DELETED
@@ -1,103 +0,0 @@
|
|
1
|
-
module Shove
|
2
|
-
|
3
|
-
# Used for storing and accessing shove credentials
|
4
|
-
# from the command line utility
|
5
|
-
class AppDirectory
|
6
|
-
|
7
|
-
attr_accessor :apps, :app
|
8
|
-
|
9
|
-
def initialize io=STDIN, path=File.expand_path("~/.shove.yml")
|
10
|
-
@io = io
|
11
|
-
@path = path
|
12
|
-
@app = nil
|
13
|
-
@apps = {}
|
14
|
-
load!
|
15
|
-
end
|
16
|
-
|
17
|
-
def put app_id, app_key
|
18
|
-
@apps[app_id] = app_key
|
19
|
-
@app = app_id if @app.nil?
|
20
|
-
save
|
21
|
-
end
|
22
|
-
|
23
|
-
def key app_id
|
24
|
-
get_config(app_id)[:app_key]
|
25
|
-
end
|
26
|
-
|
27
|
-
def default= app_id
|
28
|
-
unless app_id.nil?
|
29
|
-
@app = app_id
|
30
|
-
save
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
def default
|
35
|
-
@app ? get_config(@app) : get_config
|
36
|
-
end
|
37
|
-
|
38
|
-
def get_config app_id=nil
|
39
|
-
config = ENV["SHOVE_ENV"] == "development" ? {
|
40
|
-
:api_url => "http://api.shove.dev:8080",
|
41
|
-
:ws_url => "ws://shove.dev:9000"
|
42
|
-
} : {}
|
43
|
-
|
44
|
-
if !@app.nil? && app_id.nil?
|
45
|
-
config[:app_id] = @app
|
46
|
-
config[:app_key] = key(@app)
|
47
|
-
elsif app_id.nil? || !@apps.key?(app_id)
|
48
|
-
|
49
|
-
puts "We need some information to continue"
|
50
|
-
|
51
|
-
if app_id.nil?
|
52
|
-
config[:app_id] = getinput "Enter App Id"
|
53
|
-
else
|
54
|
-
config[:app_id] = app_id
|
55
|
-
end
|
56
|
-
|
57
|
-
loop do
|
58
|
-
config[:app_key] = getinput "Enter App Key"
|
59
|
-
|
60
|
-
Shove.configure config
|
61
|
-
if Shove.valid?
|
62
|
-
puts "App Settings accepted. Moving on..."
|
63
|
-
break
|
64
|
-
else
|
65
|
-
puts "App Settings invalid, please try again"
|
66
|
-
end
|
67
|
-
end
|
68
|
-
|
69
|
-
put config[:app_id], config[:app_key]
|
70
|
-
else
|
71
|
-
config[:app_id] = app_id
|
72
|
-
config[:app_key] = @apps[app_id]
|
73
|
-
end
|
74
|
-
|
75
|
-
config
|
76
|
-
end
|
77
|
-
|
78
|
-
private
|
79
|
-
|
80
|
-
def save
|
81
|
-
File.open(@path, "w") do |f|
|
82
|
-
f << {
|
83
|
-
"app" => @app,
|
84
|
-
"apps" => @apps
|
85
|
-
}.to_yaml
|
86
|
-
end
|
87
|
-
end
|
88
|
-
|
89
|
-
def getinput text
|
90
|
-
print "#{text}: "
|
91
|
-
@io.gets.strip
|
92
|
-
end
|
93
|
-
|
94
|
-
def load!
|
95
|
-
if FileTest.exist?(@path)
|
96
|
-
tmp = YAML.load_file(@path)
|
97
|
-
@app = tmp["app"]
|
98
|
-
@apps = tmp["apps"]
|
99
|
-
end
|
100
|
-
end
|
101
|
-
|
102
|
-
end
|
103
|
-
end
|
data/spec/app_directory_spec.rb
DELETED
@@ -1,66 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + "/helper"
|
2
|
-
|
3
|
-
module Shove
|
4
|
-
|
5
|
-
# Mock standard in (for CLI app)
|
6
|
-
class MockStdin
|
7
|
-
|
8
|
-
def initialize *msgs
|
9
|
-
@msgs = msgs
|
10
|
-
end
|
11
|
-
|
12
|
-
def gets
|
13
|
-
"#{@msgs.shift}\r\n"
|
14
|
-
end
|
15
|
-
|
16
|
-
end
|
17
|
-
|
18
|
-
describe AppDirectory do
|
19
|
-
|
20
|
-
before do |context|
|
21
|
-
VCR.insert_cassette context.example.metadata[:description_args].first
|
22
|
-
end
|
23
|
-
|
24
|
-
after do |context|
|
25
|
-
VCR.eject_cassette
|
26
|
-
end
|
27
|
-
|
28
|
-
it "should configure the default" do
|
29
|
-
system "rm /tmp/shove.yml"
|
30
|
-
dir = AppDirectory.new(MockStdin.new("test","test"), "/tmp/shove.yml")
|
31
|
-
config = dir.default
|
32
|
-
config[:app_id].should == "test"
|
33
|
-
config[:app_key].should == "test"
|
34
|
-
FileTest.exist?("/tmp/shove.yml").should == true
|
35
|
-
end
|
36
|
-
|
37
|
-
it "should configure the from the previous test" do
|
38
|
-
dir = AppDirectory.new(MockStdin.new, "/tmp/shove.yml")
|
39
|
-
config = dir.get_config "test"
|
40
|
-
config[:app_id].should == "test"
|
41
|
-
config[:app_key].should == "test"
|
42
|
-
end
|
43
|
-
|
44
|
-
it "should save an app" do
|
45
|
-
dir = AppDirectory.new(MockStdin.new, "/tmp/shove.yml")
|
46
|
-
dir.put "id1", "key1"
|
47
|
-
dir.put "id2", "key2"
|
48
|
-
dir.put "id3", "key3"
|
49
|
-
dir.apps.size.should == 4
|
50
|
-
end
|
51
|
-
|
52
|
-
it "should update an app" do
|
53
|
-
dir = AppDirectory.new(MockStdin.new, "/tmp/shove.yml")
|
54
|
-
dir.put "id2", "key9"
|
55
|
-
dir.key("id2").should == "key9"
|
56
|
-
end
|
57
|
-
|
58
|
-
it "should update the default app" do
|
59
|
-
dir = AppDirectory.new(MockStdin.new, "/tmp/shove.yml")
|
60
|
-
dir.default = "id2"
|
61
|
-
dir.app.should == "id2"
|
62
|
-
dir.default()[:app_key].should == "key9"
|
63
|
-
end
|
64
|
-
|
65
|
-
end
|
66
|
-
end
|