Class: Switchboard::Commands::PubSub::Create
- Inherits:
-
Switchboard::Command
- Object
- Switchboard::Command
- Switchboard::Commands::PubSub::Create
- Defined in:
- lib/switchboard/commands/pubsub/create.rb
Constant Summary
Constants inherited from Switchboard::Command
Switchboard::Command::DEFAULT_OPTIONS, Switchboard::Command::OPTIONS
Class Method Summary collapse
Methods inherited from Switchboard::Command
description, help, to_command, to_command_name
Class Method Details
.options(opts) ⇒ Object
7 8 9 10 |
# File 'lib/switchboard/commands/pubsub/create.rb', line 7 def self.(opts) super(opts) opts.on("--collection", "Specifies that a 'collection' node should be created.") { |v| OPTIONS["pubsub.create.node_type"] = "collection" } end |
.run! ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/switchboard/commands/pubsub/create.rb', line 12 def self.run! switchboard = Switchboard::Core.new do defer :node_created do begin if OPTIONS["pubsub.create.node_type"] == "collection" create_collection_node(OPTIONS["pubsub.node"]) else create_node(OPTIONS["pubsub.node"]) end rescue Jabber::ServerError => e puts e end end def node_created(name) if name puts "Node '#{name}' was created." else puts "An auto-named node was created." end end end if OPTIONS["oauth"] switchboard.plug!(OAuthPubSubJack) else switchboard.plug!(PubSubJack) end switchboard.run! end |