mojodna-switchboard 0.0.12 → 0.0.13

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.
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env ruby -rubygems
2
+
3
+ require 'switchboard'
4
+
5
+ switchboard = Switchboard::Client.new
6
+ switchboard.plug!(AutoAcceptJack, EchoJack, NotifyJack)
7
+ switchboard.run!
@@ -1,13 +1,4 @@
1
1
  module Switchboard
2
- class Command
3
- OPTIONS = {}
4
- DEFAULT_OPTIONS = {
5
- # :detach => false,
6
- "debug" => false,
7
- "oauth" => false,
8
- "resource" => "switchboard"
9
- }
10
- end
11
2
  module Commands
12
3
  class Default < Switchboard::Command
13
4
  unregister!
@@ -15,7 +15,7 @@ module Switchboard
15
15
  opts.on("--oauth", "Sign requests using OAuth.") { OPTIONS["oauth"] = true }
16
16
  opts.on("--oauth-consumer-key=key", String, "Specifies the OAuth consumer key to use.") { |v| OPTIONS["oauth.consumer_key"] = v }
17
17
  opts.on("--oauth-consumer-secret=secret", String, "Specifies the OAuth consumer secret to use.") { |v| OPTIONS["oauth.consumer_secret"] = v }
18
- opts.on("--oauth-token =oken", String, "Specifies the OAuth token to use.") { |v| OPTIONS["oauth.token"] = v }
18
+ opts.on("--oauth-token=token", String, "Specifies the OAuth token to use.") { |v| OPTIONS["oauth.token"] = v }
19
19
  opts.on("--oauth-token-secret=secret", String, "Specifies the OAuth token secret to use.") { |v| OPTIONS["oauth.token_secret"] = v }
20
20
  end
21
21
  opts
@@ -14,6 +14,14 @@ require 'switchboard/ext/instance_exec'
14
14
  require 'xmpp4r/roster'
15
15
 
16
16
  module Switchboard
17
+ OPTIONS = {}
18
+ DEFAULT_OPTIONS = {
19
+ # :detach => false,
20
+ "debug" => false,
21
+ "oauth" => false,
22
+ "resource" => "switchboard"
23
+ }
24
+
17
25
  class Core
18
26
  include Timeout
19
27
 
@@ -1,5 +1,6 @@
1
1
  require 'jacks/auto_accept'
2
2
  require 'jacks/debug'
3
+ require 'jacks/echo'
3
4
  require 'jacks/notify'
4
5
  require 'jacks/oauth_pubsub'
5
6
  require 'jacks/pubsub'
@@ -0,0 +1,7 @@
1
+ class EchoJack
2
+ def self.connect(switchboard, settings)
3
+ switchboard.on_message do |message|
4
+ stream.send(message.answer)
5
+ end
6
+ end
7
+ end
@@ -16,7 +16,7 @@ module Switchboard
16
16
  end
17
17
 
18
18
  def get(key)
19
- Switchboard::Command::OPTIONS[key] || @config[key] || Switchboard::Command::DEFAULT_OPTIONS[key]
19
+ Switchboard::OPTIONS[key] || @config[key] || Switchboard::DEFAULT_OPTIONS[key]
20
20
  end
21
21
 
22
22
  alias_method :[], :get
@@ -9,3 +9,4 @@ require 'switchboard/component'
9
9
  require 'switchboard/jacks'
10
10
  require 'switchboard/settings'
11
11
  require 'switchboard/version'
12
+
@@ -1,3 +1,3 @@
1
1
  module Switchboard
2
- VERSION = [0, 0, 12]
2
+ VERSION = [0, 0, 13]
3
3
  end
data/switchboard.gemspec CHANGED
@@ -1,13 +1,13 @@
1
1
  # this file is automatically generated
2
2
  Gem::Specification.new do |s|
3
3
  s.name = "switchboard"
4
- s.version = "0.0.12"
4
+ s.version = "0.0.13"
5
5
  s.summary = "XMPP toolkit."
6
6
  s.description = "A toolkit for assembling XMPP clients and interacting with XMPP servers."
7
7
  s.authors = ["Seth Fitzsimmons"]
8
8
  s.email = ["seth@mojodna.net"]
9
9
 
10
- s.files = ["bin/switchboard", "examples/election_results.rb", "lib/switchboard/client.rb", "lib/switchboard/colors.rb", "lib/switchboard/commands/command.rb", "lib/switchboard/commands/config/config.rb", "lib/switchboard/commands/config.rb", "lib/switchboard/commands/default.rb", "lib/switchboard/commands/disco/disco.rb", "lib/switchboard/commands/disco/info.rb", "lib/switchboard/commands/disco/items.rb", "lib/switchboard/commands/disco.rb", "lib/switchboard/commands/help/help.rb", "lib/switchboard/commands/help.rb", "lib/switchboard/commands/last/last.rb", "lib/switchboard/commands/last.rb", "lib/switchboard/commands/pep/location.rb", "lib/switchboard/commands/pep/pep.rb", "lib/switchboard/commands/pep/tune.rb", "lib/switchboard/commands/pep.rb", "lib/switchboard/commands/pubsub/affiliations.rb", "lib/switchboard/commands/pubsub/config.rb", "lib/switchboard/commands/pubsub/create.rb", "lib/switchboard/commands/pubsub/delete.rb", "lib/switchboard/commands/pubsub/info.rb", "lib/switchboard/commands/pubsub/items.rb", "lib/switchboard/commands/pubsub/listen.rb", "lib/switchboard/commands/pubsub/nodes.rb", "lib/switchboard/commands/pubsub/options.rb", "lib/switchboard/commands/pubsub/publish.rb", "lib/switchboard/commands/pubsub/pubsub.rb", "lib/switchboard/commands/pubsub/purge.rb", "lib/switchboard/commands/pubsub/retract.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/register.rb", "lib/switchboard/commands/roster/add.rb", "lib/switchboard/commands/roster/list.rb", "lib/switchboard/commands/roster/online.rb", "lib/switchboard/commands/roster/remove.rb", "lib/switchboard/commands/roster/roster.rb", "lib/switchboard/commands/roster.rb", "lib/switchboard/commands/unregister.rb", "lib/switchboard/commands.rb", "lib/switchboard/component.rb", "lib/switchboard/core.rb", "lib/switchboard/ext/delegate.rb", "lib/switchboard/ext/instance_exec.rb", "lib/switchboard/helpers/oauth_pubsub.rb", "lib/switchboard/helpers/pubsub.rb", "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/settings.rb", "lib/switchboard/switchboard.rb", "lib/switchboard/version.rb", "lib/switchboard.rb", "Rakefile", "README.markdown", "switchboard-0.0.11.gem", "switchboard.gemspec", "switchboard.gemspec.me"]
10
+ s.files = ["bin/switchboard", "examples/echo_bot.rb", "lib/switchboard/client.rb", "lib/switchboard/colors.rb", "lib/switchboard/commands/command.rb", "lib/switchboard/commands/config/config.rb", "lib/switchboard/commands/config.rb", "lib/switchboard/commands/default.rb", "lib/switchboard/commands/disco/disco.rb", "lib/switchboard/commands/disco/info.rb", "lib/switchboard/commands/disco/items.rb", "lib/switchboard/commands/disco.rb", "lib/switchboard/commands/help/help.rb", "lib/switchboard/commands/help.rb", "lib/switchboard/commands/last/last.rb", "lib/switchboard/commands/last.rb", "lib/switchboard/commands/pep/location.rb", "lib/switchboard/commands/pep/pep.rb", "lib/switchboard/commands/pep/tune.rb", "lib/switchboard/commands/pep.rb", "lib/switchboard/commands/pubsub/affiliations.rb", "lib/switchboard/commands/pubsub/config.rb", "lib/switchboard/commands/pubsub/create.rb", "lib/switchboard/commands/pubsub/delete.rb", "lib/switchboard/commands/pubsub/info.rb", "lib/switchboard/commands/pubsub/items.rb", "lib/switchboard/commands/pubsub/listen.rb", "lib/switchboard/commands/pubsub/nodes.rb", "lib/switchboard/commands/pubsub/options.rb", "lib/switchboard/commands/pubsub/publish.rb", "lib/switchboard/commands/pubsub/pubsub.rb", "lib/switchboard/commands/pubsub/purge.rb", "lib/switchboard/commands/pubsub/retract.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/register.rb", "lib/switchboard/commands/roster/add.rb", "lib/switchboard/commands/roster/list.rb", "lib/switchboard/commands/roster/online.rb", "lib/switchboard/commands/roster/remove.rb", "lib/switchboard/commands/roster/roster.rb", "lib/switchboard/commands/roster.rb", "lib/switchboard/commands/unregister.rb", "lib/switchboard/commands.rb", "lib/switchboard/component.rb", "lib/switchboard/core.rb", "lib/switchboard/ext/delegate.rb", "lib/switchboard/ext/instance_exec.rb", "lib/switchboard/helpers/oauth_pubsub.rb", "lib/switchboard/helpers/pubsub.rb", "lib/switchboard/jacks/auto_accept.rb", "lib/switchboard/jacks/debug.rb", "lib/switchboard/jacks/echo.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/settings.rb", "lib/switchboard/switchboard.rb", "lib/switchboard/version.rb", "lib/switchboard.rb", "msg", "Rakefile", "README.markdown", "switchboard-0.0.11.gem", "switchboard.gemspec"]
11
11
  s.executables = ["switchboard"]
12
12
  s.require_paths = ["lib"]
13
13
 
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.12
4
+ version: 0.0.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - Seth Fitzsimmons
@@ -9,11 +9,12 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-02-03 00:00:00 -08:00
12
+ date: 2009-03-29 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: mojodna-xmpp4r
17
+ type: :runtime
17
18
  version_requirement:
18
19
  version_requirements: !ruby/object:Gem::Requirement
19
20
  requirements:
@@ -35,7 +36,7 @@ extra_rdoc_files: []
35
36
 
36
37
  files:
37
38
  - bin/switchboard
38
- - examples/election_results.rb
39
+ - examples/echo_bot.rb
39
40
  - lib/switchboard/client.rb
40
41
  - lib/switchboard/colors.rb
41
42
  - lib/switchboard/commands/command.rb
@@ -88,6 +89,7 @@ files:
88
89
  - lib/switchboard/helpers/pubsub.rb
89
90
  - lib/switchboard/jacks/auto_accept.rb
90
91
  - lib/switchboard/jacks/debug.rb
92
+ - lib/switchboard/jacks/echo.rb
91
93
  - lib/switchboard/jacks/notify.rb
92
94
  - lib/switchboard/jacks/oauth_pubsub.rb
93
95
  - lib/switchboard/jacks/pubsub.rb
@@ -97,11 +99,11 @@ files:
97
99
  - lib/switchboard/switchboard.rb
98
100
  - lib/switchboard/version.rb
99
101
  - lib/switchboard.rb
102
+ - msg
100
103
  - Rakefile
101
104
  - README.markdown
102
105
  - switchboard-0.0.11.gem
103
106
  - switchboard.gemspec
104
- - switchboard.gemspec.me
105
107
  has_rdoc: false
106
108
  homepage:
107
109
  post_install_message:
@@ -1,61 +0,0 @@
1
- #!/usr/bin/env ruby
2
- require 'fire_hydrant'
3
- require 'rexml/document'
4
- require 'open-uri'
5
-
6
- hydrant = FireHydrant.new(YAML.load(File.read("fire_hydrant.yml"))) do
7
- old_votes = load_results
8
-
9
- while(!shutdown?) do
10
- # load the results feed
11
- votes = load_results
12
- diff = nil
13
-
14
- # loop through and compare it to the old results
15
- votes.each do |state, cand|
16
- cand.each do |c, val|
17
- unless old_votes[state][c] == val
18
- diff ||= "Electoral results changed"
19
- diff << "\n#{state} - #{c}: #{old_votes[state][c].inspect} => #{val.inspect}"
20
- end
21
- end
22
- end
23
-
24
- if diff
25
- puts diff
26
- broadcast(diff)
27
- end
28
-
29
- # set this as old_votes
30
- old_votes = votes
31
-
32
- # wait 5 minutes
33
- puts "-----"
34
- sleep 300
35
- end
36
- end
37
-
38
- hydrant.jack!(AutoAcceptJack, NotifyJack)
39
-
40
- def hydrant.load_results(url = "http://d.yimg.com/b/data/us/news/xml/elections/2008a/pres.xml")
41
- doc = REXML::Document.new(open(url))
42
- nodes = doc.elements.collect("//state") { |node| [node.attributes["name"].downcase, node.elements.collect("cand") { |cand| [cand.attributes["name"].downcase, cand.attributes["PopPct"].to_f, cand.attributes["PopVote"].to_i] }] }
43
-
44
- votes = {}
45
- nodes.each do |state, results|
46
- votes[state] = {}
47
- results.each do |cand, pct, vote|
48
- votes[state][cand] = [pct, vote]
49
- end
50
- end
51
-
52
- votes
53
- end
54
-
55
- def hydrant.broadcast(msg)
56
- roster.items.each do |jid, item|
57
- client.send(Jabber::Message.new(jid, msg))
58
- end
59
- end
60
-
61
- hydrant.run!