mojodna-switchboard 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/README.markdown CHANGED
@@ -7,19 +7,12 @@ command-line tools for interacting with XMPP servers.
7
7
 
8
8
  Install it:
9
9
 
10
- $ gem install mojodna-switchboard -s http://gems.github.com
10
+ $ sudo gem install mojodna-switchboard -s http://gems.github.com
11
11
 
12
12
  Configure it:
13
13
 
14
14
  $ switchboard config jid jid@example.com
15
15
  $ switchboard config password pa55word
16
- $ switchboard config oauth.consumer_key asdf
17
- $ switchboard config oauth.consumer_secret qwerty
18
- $ switchboard config oauth.token asdf
19
- $ switchboard config oauth.token_secret qwerty
20
- $ switchboard config oauth.general_token asdf
21
- $ switchboard config oauth.general_token_secret qwerty
22
- $ switchboard config pubsub.server fireeagle.com
23
16
 
24
17
  _Settings will be stored in `$HOME/.switchboardrc`_
25
18
 
@@ -28,4 +21,4 @@ Run it:
28
21
  $ switchboard <command> <args>
29
22
  $ switchboard roster list
30
23
  $ switchboard roster add fireeagle.com
31
- $ ...
24
+ $ ...
@@ -91,7 +91,11 @@ module Switchboard
91
91
  jacks.each do |jack|
92
92
  puts "Connecting jack: #{jack}" if debug?
93
93
  @jacks << jack
94
- jack.connect(self)
94
+ if jack.connect(self, settings) == false
95
+ puts "A jack was unable to connect. Shutting down..."
96
+ shutdown(false)
97
+ exit 1
98
+ end
95
99
  end
96
100
  end
97
101
 
@@ -1,5 +1,6 @@
1
1
  require 'jacks/auto_accept'
2
+ require 'jacks/debug'
2
3
  require 'jacks/notify'
4
+ require 'jacks/oauth_pubsub'
5
+ require 'jacks/pubsub'
3
6
  require 'jacks/roster_debug'
4
- require 'jacks/debug'
5
- require 'jacks/oauth_pubsub'
@@ -1,5 +1,5 @@
1
1
  class AutoAcceptJack
2
- def self.connect(switchboard)
2
+ def self.connect(switchboard, settings)
3
3
  # complain if subscription requests were denied
4
4
  switchboard.on_roster_subscription do |item, subscription|
5
5
  unless subscription.type == :subscribed
@@ -1,7 +1,7 @@
1
1
  require 'switchboard/colors'
2
2
 
3
3
  class DebugJack
4
- def self.connect(switchboard)
4
+ def self.connect(switchboard, settings)
5
5
  switchboard.on_presence do |presence|
6
6
  puts "<< #{presence.to_s}".green
7
7
  end
@@ -1,5 +1,5 @@
1
1
  class NotifyJack
2
- def self.connect(switchboard)
2
+ def self.connect(switchboard, settings)
3
3
  switchboard.on_roster_loaded do
4
4
  roster.items.each do |jid, item|
5
5
  presence(nil, jid)
@@ -12,7 +12,13 @@ require 'xmpp4r/pubsub'
12
12
  require 'xmpp4r/pubsub/helper/oauth_service_helper'
13
13
 
14
14
  class OAuthPubSubJack
15
- def self.connect(switchboard)
15
+ def self.connect(switchboard, settings)
16
+ # TODO generalize this pattern for required settings
17
+ unless settings["pubsub.server"]
18
+ puts "A pubsub server must be specified."
19
+ return false
20
+ end
21
+
16
22
  switchboard.on_startup do
17
23
  @pubsub = Jabber::PubSub::OAuthServiceHelper.new(client, settings["pubsub.server"])
18
24
 
@@ -0,0 +1,40 @@
1
+ require 'xmpp4r/pubsub'
2
+
3
+ class PubSubJack
4
+ def self.connect(switchboard, settings)
5
+ # TODO generalize this pattern for required settings
6
+ unless settings["pubsub.server"]
7
+ puts "A pubsub server must be specified."
8
+ return false
9
+ end
10
+
11
+ switchboard.on_startup do
12
+ @pubsub = Jabber::PubSub::ServiceHelper.new(client, settings["pubsub.server"])
13
+
14
+ @pubsub.add_event_callback do |event|
15
+ on(:pubsub_event, event)
16
+ end
17
+ end
18
+
19
+ # TODO add the ability to define accessors
20
+ def switchboard.general_token
21
+ @general_token
22
+ end
23
+
24
+ def switchboard.oauth_consumer
25
+ @oauth_consumer
26
+ end
27
+
28
+ def switchboard.oauth_token
29
+ @oauth_token
30
+ end
31
+
32
+ def switchboard.pubsub
33
+ @pubsub
34
+ end
35
+
36
+ def switchboard.on_pubsub_event(&block)
37
+ register_hook(:pubsub_event, &block)
38
+ end
39
+ end
40
+ end
@@ -1,5 +1,5 @@
1
1
  class RosterDebugJack
2
- def self.connect(switchboard)
2
+ def self.connect(switchboard, settings)
3
3
  switchboard.on_roster_presence do |item, old_presence, new_presence|
4
4
  puts "[presence] << #{item.inspect}: #{old_presence.to_s}, #{new_presence.to_s}"
5
5
  end
@@ -1,3 +1,3 @@
1
1
  module Switchboard
2
- VERSION = [0, 0, 1]
2
+ VERSION = [0, 0, 2]
3
3
  end
data/switchboard.gemspec CHANGED
@@ -1,12 +1,12 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "switchboard"
3
- s.version = "0.0.1"
3
+ s.version = "0.0.2"
4
4
  s.summary = "XMPP toolkit"
5
5
  s.description = "A toolkit for assembling XMPP clients and interacting with XMPP servers."
6
6
  s.authors = ["Seth Fitzsimmons"]
7
7
  s.email = ["seth@mojodna.net"]
8
8
 
9
- s.files = ["bin", "bin/switchboard", "examples/election_results.rb", "github-test.rb", "lib", "lib/switchboard", "lib/switchboard/colors.rb", "lib/switchboard/commands", "lib/switchboard/commands/command.rb", "lib/switchboard/commands/config", "lib/switchboard/commands/config/config.rb", "lib/switchboard/commands/config.rb", "lib/switchboard/commands/default.rb", "lib/switchboard/commands/help", "lib/switchboard/commands/help/help.rb", "lib/switchboard/commands/help.rb", "lib/switchboard/commands/pubsub", "lib/switchboard/commands/pubsub/pubsub.rb", "lib/switchboard/commands/pubsub/subscribe.rb", "lib/switchboard/commands/pubsub/subscriptions.rb", "lib/switchboard/commands/pubsub/unsubscribe.rb", "lib/switchboard/commands/pubsub.rb", "lib/switchboard/commands/roster", "lib/switchboard/commands/roster/add.rb", "lib/switchboard/commands/roster/list.rb", "lib/switchboard/commands/roster/remove.rb", "lib/switchboard/commands/roster/roster.rb", "lib/switchboard/commands/roster.rb", "lib/switchboard/commands.rb", "lib/switchboard/core.rb", "lib/switchboard/instance_exec.rb", "lib/switchboard/jacks", "lib/switchboard/jacks/auto_accept.rb", "lib/switchboard/jacks/debug.rb", "lib/switchboard/jacks/notify.rb", "lib/switchboard/jacks/oauth_pubsub.rb", "lib/switchboard/jacks/roster_debug.rb", "lib/switchboard/jacks.rb", "lib/switchboard/oauth", "lib/switchboard/oauth/request_proxy", "lib/switchboard/oauth/request_proxy/mock_request.rb", "lib/switchboard/settings.rb", "lib/switchboard/switchboard.rb", "lib/switchboard/version.rb", "lib/switchboard/xmpp4r", "lib/switchboard/xmpp4r/pubsub", "lib/switchboard/xmpp4r/pubsub/helper", "lib/switchboard/xmpp4r/pubsub/helper/oauth_service_helper.rb", "lib/switchboard.rb", "README.markdown", "switchboard-0.0.1.gem", "switchboard.gemspec"]
9
+ s.files = ["bin", "bin/switchboard", "examples/election_results.rb", "github-test.rb", "lib", "lib/switchboard", "lib/switchboard/colors.rb", "lib/switchboard/commands", "lib/switchboard/commands/command.rb", "lib/switchboard/commands/config", "lib/switchboard/commands/config/config.rb", "lib/switchboard/commands/config.rb", "lib/switchboard/commands/default.rb", "lib/switchboard/commands/help", "lib/switchboard/commands/help/help.rb", "lib/switchboard/commands/help.rb", "lib/switchboard/commands/pubsub", "lib/switchboard/commands/pubsub/pubsub.rb", "lib/switchboard/commands/pubsub/subscribe.rb", "lib/switchboard/commands/pubsub/subscriptions.rb", "lib/switchboard/commands/pubsub/unsubscribe.rb", "lib/switchboard/commands/pubsub.rb", "lib/switchboard/commands/roster", "lib/switchboard/commands/roster/add.rb", "lib/switchboard/commands/roster/list.rb", "lib/switchboard/commands/roster/remove.rb", "lib/switchboard/commands/roster/roster.rb", "lib/switchboard/commands/roster.rb", "lib/switchboard/commands.rb", "lib/switchboard/core.rb", "lib/switchboard/instance_exec.rb", "lib/switchboard/jacks", "lib/switchboard/jacks/auto_accept.rb", "lib/switchboard/jacks/debug.rb", "lib/switchboard/jacks/notify.rb", "lib/switchboard/jacks/oauth_pubsub.rb", "lib/switchboard/jacks/pubsub.rb", "lib/switchboard/jacks/roster_debug.rb", "lib/switchboard/jacks.rb", "lib/switchboard/oauth", "lib/switchboard/oauth/request_proxy", "lib/switchboard/oauth/request_proxy/mock_request.rb", "lib/switchboard/settings.rb", "lib/switchboard/switchboard.rb", "lib/switchboard/version.rb", "lib/switchboard/xmpp4r", "lib/switchboard/xmpp4r/pubsub", "lib/switchboard/xmpp4r/pubsub/helper", "lib/switchboard/xmpp4r/pubsub/helper/oauth_service_helper.rb", "lib/switchboard.rb", "README.markdown", "switchboard-0.0.1.gem", "switchboard.gemspec"]
10
10
  s.executables = ["switchboard"]
11
11
  s.require_paths = ["lib"]
12
12
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mojodna-switchboard
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Seth Fitzsimmons
@@ -67,6 +67,7 @@ files:
67
67
  - lib/switchboard/jacks/debug.rb
68
68
  - lib/switchboard/jacks/notify.rb
69
69
  - lib/switchboard/jacks/oauth_pubsub.rb
70
+ - lib/switchboard/jacks/pubsub.rb
70
71
  - lib/switchboard/jacks/roster_debug.rb
71
72
  - lib/switchboard/jacks.rb
72
73
  - lib/switchboard/oauth