mojodna-switchboard 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -1,5 +1,6 @@
1
- require 'switchboard'
1
+ require File.join("lib", "switchboard", "version")
2
2
 
3
+ desc "Generate the gemspec"
3
4
  task :gemspec do
4
5
  gemspec =<<-EOF
5
6
  Gem::Specification.new do |s|
@@ -15,6 +16,9 @@ Gem::Specification.new do |s|
15
16
  s.require_paths = ["lib"]
16
17
 
17
18
  s.add_dependency("xmpp4r")
19
+ s.add_dependency("oauth")
20
+ s.add_dependency("rb-appscript")
21
+
18
22
  end
19
23
  EOF
20
24
 
@@ -25,4 +29,4 @@ end
25
29
  puts "gemspec successfully created."
26
30
  end
27
31
 
28
- task :default => :gemspec
32
+ task :default => :gemspec
@@ -2,6 +2,7 @@ require 'switchboard/commands/command'
2
2
  require 'switchboard/commands/config'
3
3
  require 'switchboard/commands/default'
4
4
  require 'switchboard/commands/help'
5
+ require 'switchboard/commands/pep'
5
6
  require 'switchboard/commands/pubsub'
6
7
  require 'switchboard/commands/register'
7
8
  require 'switchboard/commands/roster'
@@ -0,0 +1,2 @@
1
+ require 'switchboard/commands/pep/pep'
2
+ require 'switchboard/commands/pep/tune'
@@ -0,0 +1,7 @@
1
+ module Switchboard
2
+ module Commands
3
+ class PEP < Switchboard::Command
4
+ description "PEP (XEP-0163) manipulation"
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,84 @@
1
+ begin
2
+ require 'appscript'
3
+ rescue LoadError => e
4
+ gem = e.message.split("--").last.strip
5
+ puts "The #{gem} gem is required."
6
+ exit 1
7
+ end
8
+ require 'xmpp4r/tune'
9
+
10
+ module Switchboard
11
+ module Commands
12
+ class PEP
13
+ class Tune < Switchboard::Command
14
+ description "Broadcasting UserTune (XEP-0118)"
15
+
16
+ def self.run!
17
+ switchboard = Switchboard::Core.new do
18
+ @tune_helper = Jabber::UserTune::Helper.new(client, nil)
19
+
20
+ itunes = Appscript.app('iTunes')
21
+ old_track_info = nil
22
+ last_state = :paused
23
+
24
+ while !shutdown?
25
+ track = itunes.current_track.get
26
+ state = itunes.player_state.get
27
+
28
+ if track && state == :playing
29
+
30
+ artist = track.artist.get
31
+ name = track.name.get
32
+ source = track.album.get
33
+ track_info = [artist, name, source]
34
+
35
+ if track_info != old_track_info
36
+ duration = track.duration.get.to_i
37
+ track = track.track_number.get.to_s
38
+
39
+ puts "Now playing: #{name} by #{artist}"
40
+ tune = Jabber::UserTune::Tune.new \
41
+ artist,
42
+ name,
43
+ duration,
44
+ track,
45
+ source
46
+
47
+ begin
48
+ @tune_helper.now_playing(tune)
49
+ rescue Jabber::ServerError => e
50
+ puts e
51
+ end
52
+ end
53
+
54
+ elsif state != last_state
55
+ track_info = nil
56
+ begin
57
+ @tune_helper.stop_playing
58
+ rescue Jabber::ServerError => e
59
+ puts e
60
+ end
61
+ end
62
+
63
+ old_track_info = track_info
64
+ last_state = state
65
+ sleep 1
66
+ end
67
+ end
68
+
69
+ switchboard.on_shutdown do
70
+ begin
71
+ @tune_helper.stop_playing
72
+ rescue Jabber::ServerError => e
73
+ puts e
74
+ end
75
+ end
76
+
77
+ switchboard.plug!(AutoAcceptJack)
78
+
79
+ switchboard.run!
80
+ end
81
+ end
82
+ end
83
+ end
84
+ end
@@ -23,7 +23,7 @@ module Switchboard
23
23
  if items && items.any?
24
24
  puts "Items:"
25
25
  items.each do |id, item|
26
- puts [id, item] * ": "
26
+ puts [id, item].compact * ": "
27
27
  end
28
28
  else
29
29
  puts "No items available for node '#{OPTIONS["pubsub.node"]}'."
@@ -19,7 +19,7 @@ module Switchboard
19
19
 
20
20
  # TODO consider using client.register_info.inspect
21
21
  begin
22
- puts "Registering #{settings["jid"]} with password '#{settings["password"]}'."
22
+ puts "Registering #{settings["jid"]}"
23
23
  iq = client.register(settings["password"])
24
24
  rescue Jabber::ServerError => e
25
25
  puts "Could not register: #{e}"
@@ -4,6 +4,7 @@ begin
4
4
  rescue LoadError => e
5
5
  gem = e.message.split("--").last.strip
6
6
  puts "The #{gem} gem is required."
7
+ exit 1
7
8
  end
8
9
 
9
10
  # allow local library modifications/additions to be loaded
@@ -2,24 +2,28 @@ require 'xmpp4r/pubsub'
2
2
  # TODO this is broken in XMPP4R 0.4.0
3
3
  # require 'xmpp4r/pubsub/helper/nodebrowser'
4
4
 
5
- module PubSubHelper
6
- attr_reader :pubsub
5
+ module Switchboard
6
+ module Helpers
7
+ module PubSubHelper
8
+ attr_reader :pubsub
7
9
 
8
- delegate :create_node, :create_collection_node, :delete_node,
9
- :get_config_from, :get_options_from, :get_items_from, :publish_item_to,
10
- :publish_item_with_id_to, :purge_items_from, :set_config_for,
11
- :subscribe_to, :unsubscribe_from, :to => :pubsub
10
+ delegate :create_node, :create_collection_node, :delete_node,
11
+ :get_config_from, :get_options_from, :get_items_from, :publish_item_to,
12
+ :publish_item_with_id_to, :purge_items_from, :set_config_for,
13
+ :subscribe_to, :unsubscribe_from, :to => :pubsub
12
14
 
13
- def on_pubsub_event(&block)
14
- register_hook(:pubsub_event, &block)
15
- end
15
+ def on_pubsub_event(&block)
16
+ register_hook(:pubsub_event, &block)
17
+ end
16
18
 
17
- def subscriptions(node = nil)
18
- # NOTE: node-specific subscriptions do not appear to work in ejabberd 2.0.2
19
- if node
20
- pubsub.get_subscriptions_from(node)
21
- else
22
- pubsub.get_subscriptions_from_all_nodes
19
+ def subscriptions(node = nil)
20
+ # NOTE: node-specific subscriptions do not appear to work in ejabberd 2.0.2
21
+ if node
22
+ pubsub.get_subscriptions_from(node)
23
+ else
24
+ pubsub.get_subscriptions_from_all_nodes
25
+ end
26
+ end
23
27
  end
24
28
  end
25
29
  end
@@ -6,6 +6,7 @@ module Switchboard
6
6
  @path = path
7
7
 
8
8
  if File.exists?(path)
9
+ set_perms
9
10
  @config = YAML.load(File.read(path))
10
11
  end
11
12
 
@@ -21,6 +22,7 @@ module Switchboard
21
22
  def set!(key, value)
22
23
  set(key, value)
23
24
  write
25
+ set_perms
24
26
  end
25
27
 
26
28
  def set(key, value)
@@ -36,5 +38,10 @@ module Switchboard
36
38
  f << @config.to_yaml
37
39
  end
38
40
  end
41
+
42
+ def set_perms
43
+ File.chmod 0600, @path
44
+ end
45
+
39
46
  end
40
47
  end
@@ -1,3 +1,3 @@
1
1
  module Switchboard
2
- VERSION = [0, 0, 4]
2
+ VERSION = [0, 0, 5]
3
3
  end
data/switchboard.gemspec CHANGED
@@ -1,14 +1,17 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "switchboard"
3
- s.version = "0.0.4"
3
+ s.version = "0.0.5"
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/switchboard", "examples/election_results.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/help/help.rb", "lib/switchboard/commands/help.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/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/remove.rb", "lib/switchboard/commands/roster/roster.rb", "lib/switchboard/commands/roster.rb", "lib/switchboard/commands/unregister.rb", "lib/switchboard/commands.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/oauth/request_proxy/mock_request.rb", "lib/switchboard/settings.rb", "lib/switchboard/switchboard.rb", "lib/switchboard/version.rb", "lib/switchboard/xmpp4r/pubsub/helper/oauth_service_helper.rb", "lib/switchboard.rb", "Rakefile", "README.markdown", "switchboard.gemspec"]
9
+ s.files = ["bin/switchboard", "examples/election_results.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/help/help.rb", "lib/switchboard/commands/help.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/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/remove.rb", "lib/switchboard/commands/roster/roster.rb", "lib/switchboard/commands/roster.rb", "lib/switchboard/commands/unregister.rb", "lib/switchboard/commands.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/oauth/request_proxy/mock_request.rb", "lib/switchboard/settings.rb", "lib/switchboard/switchboard.rb", "lib/switchboard/version.rb", "lib/switchboard/xmpp4r/pubsub/helper/oauth_service_helper.rb", "lib/switchboard.rb", "Rakefile", "README.markdown", "switchboard.gemspec"]
10
10
  s.executables = ["switchboard"]
11
11
  s.require_paths = ["lib"]
12
12
 
13
13
  s.add_dependency("xmpp4r")
14
+ s.add_dependency("oauth")
15
+ s.add_dependency("rb-appscript")
16
+
14
17
  end
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
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Seth Fitzsimmons
@@ -21,6 +21,24 @@ dependencies:
21
21
  - !ruby/object:Gem::Version
22
22
  version: "0"
23
23
  version:
24
+ - !ruby/object:Gem::Dependency
25
+ name: oauth
26
+ version_requirement:
27
+ version_requirements: !ruby/object:Gem::Requirement
28
+ requirements:
29
+ - - ">="
30
+ - !ruby/object:Gem::Version
31
+ version: "0"
32
+ version:
33
+ - !ruby/object:Gem::Dependency
34
+ name: rb-appscript
35
+ version_requirement:
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: "0"
41
+ version:
24
42
  description: A toolkit for assembling XMPP clients and interacting with XMPP servers.
25
43
  email:
26
44
  - seth@mojodna.net
@@ -40,6 +58,9 @@ files:
40
58
  - lib/switchboard/commands/default.rb
41
59
  - lib/switchboard/commands/help/help.rb
42
60
  - lib/switchboard/commands/help.rb
61
+ - lib/switchboard/commands/pep/pep.rb
62
+ - lib/switchboard/commands/pep/tune.rb
63
+ - lib/switchboard/commands/pep.rb
43
64
  - lib/switchboard/commands/pubsub/affiliations.rb
44
65
  - lib/switchboard/commands/pubsub/config.rb
45
66
  - lib/switchboard/commands/pubsub/create.rb