Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add config file for loading plugins, and convert all plugins to gems …

…automatically installed by bundler
  • Loading branch information...
commit 7f8a583aa2b8cd14bfb1ac3ea3f666365691852e 1 parent 49fc2ad
@netpro2k netpro2k authored
Showing with 252 additions and 102 deletions.
  1. +13 −2 Gemfile
  2. +0 −3  Gemfile.lock
  3. +13 −10 README.md
  4. +26 −0 config.yaml
  5. +4 −0 plugins/siriproxy-eliza/.gitignore
  6. +4 −0 plugins/siriproxy-eliza/Gemfile
  7. +1 −0  plugins/siriproxy-eliza/Rakefile
  8. +7 −25 plugins/{eliza/eliza.rb → siriproxy-eliza/lib/siriproxy-eliza.rb}
  9. +23 −0 plugins/siriproxy-eliza/siriproxy-eliza.gemspec
  10. +4 −0 plugins/siriproxy-example/.gitignore
  11. +4 −0 plugins/siriproxy-example/Gemfile
  12. +1 −0  plugins/siriproxy-example/Rakefile
  13. +2 −4 plugins/{testproxy/testproxy.rb → siriproxy-example/lib/siriproxy-example.rb}
  14. +23 −0 plugins/siriproxy-example/siriproxy-example.gemspec
  15. +4 −0 plugins/siriproxy-thermostat/.gitignore
  16. +4 −0 plugins/siriproxy-thermostat/Gemfile
  17. +1 −0  plugins/siriproxy-thermostat/Rakefile
  18. +14 −9 plugins/{thermostat/siriThermostat.rb → siriproxy-thermostat/lib/siriproxy-thermostat.rb}
  19. +24 −0 plugins/siriproxy-thermostat/siriproxy-thermostat.gemspec
  20. +4 −0 plugins/siriproxy-twitter/.gitignore
  21. +4 −0 plugins/siriproxy-twitter/Gemfile
  22. +1 −0  plugins/siriproxy-twitter/Rakefile
  23. +11 −20 plugins/{twitter/siriTweet.rb → siriproxy-twitter/lib/siriproxy-twitter.rb}
  24. +22 −0 plugins/siriproxy-twitter/siriproxy-twitter.gemspec
  25. +6 −7 siri_proxy.rb
  26. +4 −0 siri_proxy/plugin.rb
  27. +23 −10 siri_proxy/plugin_manager.rb
  28. +5 −12 start.rb
View
15 Gemfile
@@ -3,6 +3,17 @@ source :gemcutter
gem 'CFPropertyList'
gem 'eventmachine'
gem 'uuidtools'
-gem 'json'
-gem 'libxml-ruby'
+# load plugins
+require 'yaml'
+require 'ostruct'
+config = OpenStruct.new(YAML.load_file('config.yaml'))
+if config.plugins
+ config.plugins.each do |plugin|
+ if plugin.is_a? String
+ gem "siriproxy-#{plugin.downcase}"
+ else
+ gem "siriproxy-#{plugin['name'].downcase}", :path => plugin['path'], :git => plugin['git'], :require => plugin['require']
+ end
+ end
+end
View
3  Gemfile.lock
@@ -5,7 +5,6 @@ GEM
libxml-ruby (>= 1.1.0)
rake (>= 0.7.0)
eventmachine (0.12.10)
- json (1.6.1)
libxml-ruby (2.2.2)
rake (0.9.2.2)
uuidtools (2.1.2)
@@ -16,6 +15,4 @@ PLATFORMS
DEPENDENCIES
CFPropertyList
eventmachine
- json
- libxml-ruby
uuidtools
View
23 README.md
@@ -45,20 +45,23 @@ Set-up Instructions
Currently, setup requires a pretty solid knowledge of certificates and openssl (or some good skills with Google). I'll see about providing automated scripts for generating the CA and relavent cert soon.
-1. Create a root CA using open SSL and have it issue a signed certificate for guzzoni.apple.com. Save the guzzoni private key (no passphrase) and certificate as "server.passless.key" and "server.passless.crt" in the SiriProxy directory. ([http://www.youtube.com/watch?v=_oaNbPOUCaE](http://www.youtube.com/watch?v=_oaNbPOUCaE)
-)
+1. Create a root CA using open SSL and have it issue a signed certificate for guzzoni.apple.com. Save the guzzoni private key (no passphrase) and certificate as "server.passless.key" and "server.passless.crt" in the SiriProxy directory. ([http://www.youtube.com/watch?v=_oaNbPOUCaE](http://www.youtube.com/watch?v=_oaNbPOUCaE))
2. Load the root CA's public certificate on your phone (you can just email it to yourself and click it to do that).
-3. Set up a DNS server on your network to forward requests for guzzoni.apple.com to the computer running the proxy (make sure that computer is not using your DNS server!). I recommend dnsmasq for this purpose. It's easy to get running and can easily handle this sort of behavior. ([http://www.youtube.com/watch?v=a9gO4L0U59s](http://www.youtube.com/watch?v=a9gO4L0U59s)
-)
-4. Install the requisite Ruby gems with bundler:
+3. Set up a DNS server on your network to forward requests for guzzoni.apple.com to the computer running the proxy (make sure that computer is not using your DNS server!). I recommend dnsmasq for this purpose. It's easy to get running and can easily handle this sort of behavior. ([http://www.youtube.com/watch?v=a9gO4L0U59s](http://www.youtube.com/watch?v=a9gO4L0U59s))
+4. Install bundler
- $ bundle install
+`$ gem install bundler`
+
+5. Edit config.yaml and enable some plugins by uncommenting them
+6. Install the requisite Ruby gems with bundler:
+
+`$ bundle install`
-5. Execute start.rb (as root -- since it must listen on TCP/443)
+7. Execute start.rb (as root -- since it must listen on TCP/443)
- $ bundle exec ruby start.rb
+`$ rvmsudo ruby start.rb`
-6. Activate Siri on your phone (connected to the network and using the DNS server with the fake entry), and say, "Test Siri proxy." It should respond, "Siri Proxy is up and running!"
+8. Activate Siri on your phone (connected to the network and using the DNS server with the fake entry), and say, "Test Siri proxy." It should respond, "Siri Proxy is up and running!"
FAQ
---
@@ -156,4 +159,4 @@ This software is provided as-is with no warranty whatsoever. Apple could do thin
I'm a huge fan of Apple and the work that they do. Siri is a very cool feature and I'm pretty excited to explore it and add functionality. Please refrain from using this software for anything malicious.
-Also, this is my first project done in Ruby. Please don't be too critical of my code.
+Also, this is my first project done in Ruby. Please don't be too critical of my code.
View
26 config.yaml
@@ -0,0 +1,26 @@
+port: 443
+plugins:
+ # - name: 'Example'
+ # path: './plugins/siriproxy-example'
+
+ # - name: 'Thermostat'
+ # path: './plugins/siriproxy-thermostat'
+ # host: '192.168.2.71'
+
+ # - name: 'Twitter'
+ # path: './plugins/siriproxy-twitter' # path works just like specifing in gemfile
+ # consumer_key: "YOUR_KEY"
+ # consumer_secret: "YOUR_SECRET"
+ # oauth_token: "YOUR_TOKEN"
+ # oauth_token_secret: "YOUR_TOKEN_SECRET"
+
+ # Note: Eliza should not be run with other plugins
+ # - name: 'Eliza'
+ # path: './plugins/siriproxy-eliza' # path works just like specifing in gemfile
+
+ # Below are not actual plugins, just further example of config options
+
+ # - SimplePlugin # simple syntax for plugins that are in rubygems and have no config
+
+ # - name: 'AnotherPlugin'
+ # git: 'git://github.com/netpro2k/SiriProxy-AnotherPlugin.git' # git works just like specifying in Gemfile
View
4 plugins/siriproxy-eliza/.gitignore
@@ -0,0 +1,4 @@
+*.gem
+.bundle
+Gemfile.lock
+pkg/*
View
4 plugins/siriproxy-eliza/Gemfile
@@ -0,0 +1,4 @@
+source "http://rubygems.org"
+
+# Specify your gem's dependencies in siriproxy-eliza.gemspec
+gemspec
View
1  plugins/siriproxy-eliza/Rakefile
@@ -0,0 +1 @@
+require "bundler/gem_tasks"
View
32 plugins/eliza/eliza.rb → plugins/siriproxy-eliza/lib/siriproxy-eliza.rb
@@ -1,43 +1,24 @@
-require 'tweakSiri'
+require 'siri_proxy'
require 'siriObjectGenerator'
require 'net/http'
-
-#######
-# This is a "hello world" style plugin. It simply intercepts the phrase "text siri proxy" and responds
-# with a message about the proxy being up and running. This is good base code for other plugins.
-#
-# Remember to add other plugins to the "start.rb" file if you create them!
-######
-
-
-class Eliza < SiriProxy::Plugin
+class SiriProxy::Plugin::Eliza < SiriProxy::Plugin
####
# This gets called every time an object is received from the Guzzoni server
def object_from_guzzoni(object, connection)
-
object
end
####
# This gets called every time an object is received from an iPhone
def object_from_client(object, connection)
-
object
end
-
####
# When the server reports an "unkown command", this gets called. It's useful for implementing commands that aren't otherwise covered
def unknown_command(object, connection, command)
- if(command.match(/test siri proxy/i))
- plugin_manager.block_rest_of_session_from_server
-
- return generate_siri_utterance(connection.lastRefId, "Siri Proxy is up and running!")
- end
-
-
object
end
@@ -51,7 +32,9 @@ def speech_recognized(object, connection, phrase)
response = Net::HTTP.post_form(URI.parse("http://www-ai.ijs.si/eliza-cgi-bin/eliza_script"),{'Entry1'=>phrase})
addViews = SiriAddViews.new(false, false, "Reflection")
- addViews.make_root(connection.lastRefId)
+ addViews.make_root(connection.last_ref_id)
+
+ puts response.body.split("</strong>\n").last.split("\n").first
utterance = SiriAssistantUtteranceView.new(response.body.split("</strong>\n").last.split("\n").first)
utterance.listenAfterSpeaking = true
addViews.views << utterance
@@ -64,9 +47,8 @@ def speech_recognized(object, connection, phrase)
##connection.inject_object_to_output_stream()
##requestComplete = SiriRequestCompleted.new
- ##requestComplete.make_root(connection.lastRefId)
+ ##requestComplete.make_root(connection.last_ref_id)
##return requestComplete.to_hash
end
-
-end
+end
View
23 plugins/siriproxy-eliza/siriproxy-eliza.gemspec
@@ -0,0 +1,23 @@
+# -*- encoding: utf-8 -*-
+$:.push File.expand_path("../lib", __FILE__)
+
+Gem::Specification.new do |s|
+ s.name = "siriproxy-eliza"
+ s.version = "0.0.1"
+ s.authors = ["plamoni"]
+ s.email = [""]
+ s.homepage = ""
+ s.summary = %q{Turns Siri into a psychotherapist}
+ s.description = %q{Turns Siri into a psychotherapist}
+
+ s.rubyforge_project = "siriproxy-eliza"
+
+ s.files = `git ls-files`.split("\n")
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
+ s.require_paths = ["lib"]
+
+ # specify any dependencies here; for example:
+ # s.add_development_dependency "rspec"
+ # s.add_runtime_dependency "rest-client"
+end
View
4 plugins/siriproxy-example/.gitignore
@@ -0,0 +1,4 @@
+*.gem
+.bundle
+Gemfile.lock
+pkg/*
View
4 plugins/siriproxy-example/Gemfile
@@ -0,0 +1,4 @@
+source "http://rubygems.org"
+
+# Specify your gem's dependencies in siriproxy-example.gemspec
+gemspec
View
1  plugins/siriproxy-example/Rakefile
@@ -0,0 +1 @@
+require "bundler/gem_tasks"
View
6 plugins/testproxy/testproxy.rb → plugins/siriproxy-example/lib/siriproxy-example.rb
@@ -8,8 +8,7 @@
# Remember to add other plugins to the "start.rb" file if you create them!
######
-
-class TestProxy < SiriProxy::Plugin
+class SiriProxy::Plugin::Example < SiriProxy::Plugin
####
# This gets called every time an object is received from the Guzzoni server
@@ -35,7 +34,6 @@ def unknown_command(object, connection, command)
return generate_siri_utterance(connection.last_ref_id, "Siri Proxy is up and running!")
end
-
object
end
@@ -66,4 +64,4 @@ def speech_recognized(object, connection, phrase)
object
end
-end
+end
View
23 plugins/siriproxy-example/siriproxy-example.gemspec
@@ -0,0 +1,23 @@
+# -*- encoding: utf-8 -*-
+$:.push File.expand_path("../lib", __FILE__)
+
+Gem::Specification.new do |s|
+ s.name = "siriproxy-example"
+ s.version = "0.0.1"
+ s.authors = ["plamoni"]
+ s.email = [""]
+ s.homepage = ""
+ s.summary = %q{An Example Siri Proxy Plugin}
+ s.description = %q{This is a "hello world" style plugin. It simply intercepts the phrase "text siri proxy" and responds with a message about the proxy being up and running. This is good base code for other plugins. }
+
+ s.rubyforge_project = "siriproxy-example"
+
+ s.files = `git ls-files`.split("\n")
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
+ s.require_paths = ["lib"]
+
+ # specify any dependencies here; for example:
+ # s.add_development_dependency "rspec"
+ # s.add_runtime_dependency "rest-client"
+end
View
4 plugins/siriproxy-thermostat/.gitignore
@@ -0,0 +1,4 @@
+*.gem
+.bundle
+Gemfile.lock
+pkg/*
View
4 plugins/siriproxy-thermostat/Gemfile
@@ -0,0 +1,4 @@
+source "http://rubygems.org"
+
+# Specify your gem's dependencies in siriproxy-thermostat.gemspec
+gemspec
View
1  plugins/siriproxy-thermostat/Rakefile
@@ -0,0 +1 @@
+require "bundler/gem_tasks"
View
23 plugins/thermostat/siriThermostat.rb → .../siriproxy-thermostat/lib/siriproxy-thermostat.rb
@@ -1,3 +1,4 @@
+require 'siri_proxy'
require 'siriObjectGenerator'
require 'json'
require 'open-uri'
@@ -8,13 +9,16 @@
# use it if you like. But it's mostly for demonstration purposes. Check out the code and see what all you can do!
#############
-THERMOSTAT_HOST = "192.168.2.71"
+class SiriProxy::Plugin::Thermostat < SiriProxy::Plugin
+ def initialize(pluginConfig)
+ @host = pluginConfig['host']
+
+ end
-class SiriThermostat < SiriProxy::Plugin
def status_of_thermostat(connection)
Thread.new {
- status = JSON.parse(open("http://#{THERMOSTAT_HOST}/tstat").read)
+ status = JSON.parse(open("http://#{@host}/tstat").read)
connection.inject_object_to_output_stream(generate_siri_utterance(connection.last_ref_id, "The temperature is currently #{status["temp"]} degrees."))
connection.inject_object_to_output_stream(generate_siri_utterance(connection.last_ref_id, " The heater and air conditioner are turned off." )) if(status["tmode"] == 0)
@@ -36,7 +40,7 @@ def status_of_thermostat(connection)
return "Checking the status of the thermostat"
end
Thread.new {
- status = JSON.parse(open("http://#{THERMOSTAT_HOST}/tstat").read)
+ status = JSON.parse(open("http://#{@host}/tstat").read)
connection.inject_object_to_output_stream(generate_siri_utterance(connection.last_ref_id, "The temperature is currently #{status["temp"]} degrees."))
connection.inject_object_to_output_stream(generate_siri_utterance(connection.last_ref_id, " The heater and air conditioner are turned off." )) if(status["tmode"] == 0)
@@ -57,10 +61,10 @@ def status_of_thermostat(connection)
def set_thermostat(temp, connection)
Thread.new {
- status = JSON.parse(open("http://#{THERMOSTAT_HOST}/tstat").read)
+ status = JSON.parse(open("http://#{@host}/tstat").read)
if(status["tmode"] == 1) #heat
- status = HTTParty.post("http://#{THERMOSTAT_HOST}/tstat", {:body => "{\"tmode\":1,\"t_heat\":#{temp.to_i}}"})
+ status = HTTParty.post("http://#{@host}/tstat", {:body => "{\"tmode\":1,\"t_heat\":#{temp.to_i}}"})
if(status["success"] == 0)
connection.inject_object_to_output_stream(generate_siri_utterance(connection.last_ref_id, "The heater has been set to #{temp} degrees."))
@@ -68,7 +72,7 @@ def set_thermostat(temp, connection)
connection.inject_object_to_output_stream(generate_siri_utterance(connection.last_ref_id, "Sorry, there was a problem setting the temperature"))
end
elsif(status["tmode"] == 2) #a/c
- res = Net::HTTP.post_form(URI("http://#{THERMOSTAT_HOST}/tstat"), 'tmode' => 2, 't_cool' => temp.to_i)
+ res = Net::HTTP.post_form(URI("http://#{@host}/tstat"), 'tmode' => 2, 't_cool' => temp.to_i)
status = JSON.parse(res.body)
if(status["success"] == 0)
@@ -86,7 +90,7 @@ def set_thermostat(temp, connection)
def temperature(connection)
Thread.new {
- status = JSON.parse(open("http://#{THERMOSTAT_HOST}/tstat").read)
+ status = JSON.parse(open("http://#{@host}/tstat").read)
connection.inject_object_to_output_stream(generate_siri_utterance(connection.last_ref_id, "The current inside temperature is #{status["temp"]} degrees."))
}
@@ -140,4 +144,5 @@ def speech_recognized(object, connection, phrase)
object
end
-end
+end
+
View
24 plugins/siriproxy-thermostat/siriproxy-thermostat.gemspec
@@ -0,0 +1,24 @@
+# -*- encoding: utf-8 -*-
+$:.push File.expand_path("../lib", __FILE__)
+
+Gem::Specification.new do |s|
+ s.name = "siriproxy-thermostat"
+ s.version = "0.0.1"
+ s.authors = ["plamoni"]
+ s.email = [""]
+ s.homepage = ""
+ s.summary = %q{Siri controller for RadioThermostat thermostat units}
+ s.description = %q{This example plugin is more of a demonstration than anything else. If you happen to have a RadioThermostat thermostat, then you can use it if you like. But it's mostly for demonstration purposes. Check out the code and see what all you can do!}
+
+ s.rubyforge_project = "siriproxy-thermostat"
+
+ s.files = `git ls-files`.split("\n")
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
+ s.require_paths = ["lib"]
+
+ # specify any dependencies here; for example:
+ # s.add_development_dependency "rspec"
+ s.add_runtime_dependency "httparty"
+ s.add_runtime_dependency "json"
+end
View
4 plugins/siriproxy-twitter/.gitignore
@@ -0,0 +1,4 @@
+*.gem
+.bundle
+Gemfile.lock
+pkg/*
View
4 plugins/siriproxy-twitter/Gemfile
@@ -0,0 +1,4 @@
+source "http://rubygems.org"
+
+# Specify your gem's dependencies in siriproxy-twitter.gemspec
+gemspec
View
1  plugins/siriproxy-twitter/Rakefile
@@ -0,0 +1 @@
+require "bundler/gem_tasks"
View
31 plugins/twitter/siriTweet.rb → plugins/siriproxy-twitter/lib/siriproxy-twitter.rb
@@ -1,30 +1,21 @@
-require 'rubygems'
+require 'siri_proxy'
require 'siriObjectGenerator'
require 'twitter'
-#######
-# This is a "hello world" style plugin. It simply intercepts the phrase "text siri proxy" and responds
-# with a message about the proxy being up and running. This is good base code for other plugins.
-#
-# Remember to add other plugins to the "start.rb" file if you create them!
-######
+class SiriProxy::Plugin::Twitter < SiriProxy::Plugin
+ VERSION = "0.0.1"
-class SiriTweet < SiriProxy::Plugin
-
- def initialize()
+ def initialize(pluginConfig)
@state = :DEFAULT_STATE
- Twitter.configure do |config|
- config.consumer_key = "YOUR KEY"
- config.consumer_secret = "YOUR SECRET"
- config.oauth_token = "YOUR TOKEN"
- config.oauth_token_secret = "YOUR TOKEN SECRET"
+ ::Twitter.configure do |config|
+ config.consumer_key = pluginConfig['consumer_key']
+ config.consumer_secret = pluginConfig['consumer_secret']
+ config.oauth_token = pluginConfig['oauth_token']
+ config.oauth_token_secret = pluginConfig['oauth_token_secret']
end
- @twitterClient = Twitter::Client.new
-
-# Post a status update
-
+ @twitterClient = ::Twitter::Client.new
end
####
@@ -91,7 +82,7 @@ def speech_recognized(object, connection, phrase)
if phrase.match(/no/i)
plugin_manager.block_rest_of_session_from_server
@state = :DEFAULT_STATE
- generate_siri_utterance(connection.last_ref_id, "Ok I won't send it.")
+ return generate_siri_utterance(connection.last_ref_id, "Ok I won't send it.")
end
plugin_manager.block_rest_of_session_from_server
View
22 plugins/siriproxy-twitter/siriproxy-twitter.gemspec
@@ -0,0 +1,22 @@
+# -*- encoding: utf-8 -*-
+$:.push File.expand_path("../lib", __FILE__)
+
+Gem::Specification.new do |s|
+ s.name = "siriproxy-twitter"
+ s.version = "0.0.1"
+ s.authors = ["netpro2k"]
+ s.email = ["netpro2k@gmail.com"]
+ s.homepage = "http://netpro2k.com"
+ s.summary = %q{Teach Siri how to tweet}
+ s.description = %q{This is a very simple plugin for posting to twitter from siri}
+
+ s.rubyforge_project = "siriproxy-twitter"
+
+ s.files = `git ls-files`.split("\n")
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
+ s.require_paths = ["lib"]
+
+ # specify any dependencies here
+ s.add_runtime_dependency "twitter"
+end
View
13 siri_proxy.rb
@@ -4,7 +4,7 @@
# require 'tweakSiri'
require 'interpretSiri'
-LOG_LEVEL = 6
+LOG_LEVEL = 1
class String
def to_hex(seperator=" ")
@@ -13,19 +13,18 @@ def to_hex(seperator=" ")
end
class SiriProxy
- PORT = 443
- def initialize(pluginClasses=[])
+ def initialize()
EventMachine.run do
begin
- puts "Starting SiriProxy on port #{PORT}.."
- EventMachine::start_server('0.0.0.0', PORT, SiriProxy::Connection::Iphone) { |conn|
+ puts "Starting SiriProxy on port #{APP_CONFIG.port}.."
+ EventMachine::start_server('0.0.0.0', APP_CONFIG.port, SiriProxy::Connection::Iphone) { |conn|
$stderr.puts "start conn #{conn.inspect}"
- conn.plugin_manager = SiriProxy::PluginManager.new(pluginClasses)
+ conn.plugin_manager = SiriProxy::PluginManager.new()
}
rescue RuntimeError => err
if err.message == "no acceptor"
- raise "Cannot start the server on port #{PORT} - are you root, or have another process on this port already?"
+ raise "Cannot start the server on port #{APP_CONFIG.port} - are you root, or have another process on this port already?"
else
raise
end
View
4 siri_proxy/plugin.rb
@@ -1,6 +1,10 @@
class SiriProxy::Plugin
attr_accessor :plugin_manager
+ def initialize(pluginConfig)
+
+ end
+
def object_from_guzzoni(object, connection)
object
View
33 siri_proxy/plugin_manager.rb
@@ -1,20 +1,33 @@
class SiriProxy::PluginManager
attr_accessor :plugins
- def initialize(pluginClasses=[])
- self.plugins = []
-
- puts "Defining plugins: #{pluginClasses.inspect}"
- pluginClasses.each { |pluginClass|
- plugin = pluginClass.new
- plugin.plugin_manager = self
- plugins << plugin
- }
+ def initialize()
+ load_plugins()
@blockNextObjectsFromServer = 0
@blockNextObjectsFromClient = 0
@blockRestOfSessionFromServer = false
end
+
+ def load_plugins()
+ @plugins = []
+ if APP_CONFIG.plugins
+ APP_CONFIG.plugins.each do |pluginConfig|
+ if pluginConfig.is_a? String
+ className = pluginConfig
+ requireName = "siriproxy-#{className.downcase}"
+ else
+ className = pluginConfig['name']
+ requireName = pluginConfig['require'] || "siriproxy-#{className.downcase}"
+ end
+ require requireName
+ plugin = SiriProxy::Plugin.const_get(className).new(pluginConfig)
+ plugin.plugin_manager = self
+ @plugins << plugin
+ end
+ end
+ puts "Plugins laoded: #{@plugins}"
+ end
def object_from_guzzoni(object, connection)
if(@blockRestOfSessionFromServer)
@@ -99,4 +112,4 @@ def block_next_objects_from_client(count=1)
def block_rest_of_session_from_server
@blockRestOfSessionFromServer = true
end
-end
+end
View
17 start.rb
@@ -6,25 +6,18 @@
require 'bundler'
require 'bundler/setup'
+require 'yaml'
+require 'ostruct'
+
require 'siri_proxy'
require 'siri_proxy/connection'
require 'siri_proxy/connection/iphone'
require 'siri_proxy/connection/guzzoni'
-
require 'siri_proxy/plugin'
require 'siri_proxy/plugin_manager'
-require 'plugins/testproxy/testproxy'
-# require 'plugins/thermostat/siriThermostat'
-# require 'plugins/eliza/eliza'
-# require 'plugins/twitter/siriTweet'
-
-
-#Also try Eliza -- though it should really not be run "before" anything else.
-#Also try Twitter -- must first configure keys in siriTweet.rb
-PLUGINS = [TestProxy]
-
-proxy = SiriProxy.new(PLUGINS)
+APP_CONFIG = OpenStruct.new(YAML.load_file('config.yaml'))
+proxy = SiriProxy.new()
#that's it. :-)
Please sign in to comment.
Something went wrong with that request. Please try again.