mojodna-switchboard 0.0.12 → 0.0.13
Sign up to get free protection for your applications and to get access to all the features.
- data/examples/echo_bot.rb +7 -0
- data/lib/switchboard/commands/default.rb +0 -9
- data/lib/switchboard/commands/pubsub/pubsub.rb +1 -1
- data/lib/switchboard/core.rb +8 -0
- data/lib/switchboard/jacks.rb +1 -0
- data/lib/switchboard/jacks/echo.rb +7 -0
- data/lib/switchboard/settings.rb +1 -1
- data/lib/switchboard/switchboard.rb +1 -0
- data/lib/switchboard/version.rb +1 -1
- data/switchboard.gemspec +2 -2
- metadata +6 -4
- data/examples/election_results.rb +0 -61
@@ -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
|
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
|
data/lib/switchboard/core.rb
CHANGED
@@ -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
|
|
data/lib/switchboard/jacks.rb
CHANGED
data/lib/switchboard/settings.rb
CHANGED
@@ -16,7 +16,7 @@ module Switchboard
|
|
16
16
|
end
|
17
17
|
|
18
18
|
def get(key)
|
19
|
-
Switchboard::
|
19
|
+
Switchboard::OPTIONS[key] || @config[key] || Switchboard::DEFAULT_OPTIONS[key]
|
20
20
|
end
|
21
21
|
|
22
22
|
alias_method :[], :get
|
data/lib/switchboard/version.rb
CHANGED
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.
|
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/
|
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.
|
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-
|
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/
|
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!
|