Permalink
Browse files

Initial commit. Version 0.0.1

  • Loading branch information...
tysonmote committed Oct 21, 2011
1 parent 59912db commit 9ad88e6a18657ee3175a6b9d98aad01404a82679
Showing with 366 additions and 0 deletions.
  1. +10 −0 Gemfile
  2. +26 −0 Gemfile.lock
  3. +20 −0 LICENSE.txt
  4. +106 −0 README.markdown
  5. +23 −0 Rakefile
  6. +1 −0 VERSION
  7. +20 −0 examples/campfire.rb
  8. +10 −0 examples/echo.rb
  9. +1 −0 lib/siri-says.rb
  10. +97 −0 lib/siri_says.rb
  11. BIN pkg/siri_says-0.0.1.gem
  12. +52 −0 siri_says.gemspec
View
10 Gemfile
@@ -0,0 +1,10 @@
+source :rubygems
+
+gem "gcal4ruby"
+gem "i18n"
+gem "active_support"
+
+group :development do
+ gem "rake", "= 0.9.2"
+ gem "jeweler"
+end
View
@@ -0,0 +1,26 @@
+GEM
+ remote: http://rubygems.org/
+ specs:
+ active_support (3.0.0)
+ activesupport (= 3.0.0)
+ activesupport (3.0.0)
+ gcal4ruby (0.5.5)
+ gdata4ruby (>= 0.1.5)
+ gdata4ruby (0.1.5)
+ git (1.2.5)
+ i18n (0.6.0)
+ jeweler (1.6.4)
+ bundler (~> 1.0)
+ git (>= 1.2.5)
+ rake
+ rake (0.9.2)
+
+PLATFORMS
+ ruby
+
+DEPENDENCIES
+ active_support
+ gcal4ruby
+ i18n
+ jeweler
+ rake (= 0.9.2)
View
@@ -0,0 +1,20 @@
+Copyright (c) 2011 Tyson Tate
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
View
@@ -0,0 +1,106 @@
+# Siri Says #
+
+Siri Says gets that Siri all up in your Ruby. Inspired by [Remember the Milk][rtm].
+
+ require "rubygems"
+ require "siri_says"
+
+ siri_says /deploy/ do |message|
+ puts "> Deploying..."
+ end
+
+ SiriSays::Engine.run( google_username, google_password )
+
+Tell Siri: "Schedule a deploy right now."
+
+(seconds later)
+
+ > Deploying...
+
+Boom. [Headshot][headshot].
+
+## Initial setup ##
+
+This is a bit of a pain. Suck it up, cowboy.
+
+### Google Calendar ###
+
+Add a new "sirisays" calendar.
+
+### iPhone ###
+
+Add the calendar:
+
+1. Settings
+2. "Mail, Contacts, Calendars"
+3. "Add Account..."
+4. "Other"
+5. "Add CalDAV Account"
+ * Server: google.com
+ * Username: tysontate@gmail.com
+ * Password: ___________
+ * Description: "sirisays"
+6. "Next"
+
+Make it the default so that Siri will add events to it:
+
+1. Settings
+2. "Mail, Contacts, Calendars"
+3. "Default Calendar" --> sirisays
+4. Go to [https://www.google.com/calendar/iphoneselect][iphoneselect] and choose "sirisays" (not sure if this is necessary, actually...)
+
+## Usage ##
+
+Write Siri Says plugins (as many as you want) with `siri_says`:
+
+ siri_says /deploy/i do |message|
+ puts "> Deploying..."
+ end
+
+ siri_says /^say/i do |message|
+ puts "> Siri says: #{message.gsub(/^say/i, '')}"
+ end
+
+Then start SiriSays with your Google Calendar user name and password:
+
+ SiriSays::Engine.run( google_username, google_password )
+
+When a message is received (i.e. when a calendar event is added), it will be passed to every block whose associated RegEx is a match for the message. The message is the calendar event's title.
+
+## Sending events ##
+
+Google Calendar doesn't recognize Siri's "reminders". To communicate with Siri Says, you'll need to create actual calendar events. Siri Says recognizes "immediate" events and scheduled events:
+
+### Immediate events ###
+
+To create an immediate event, you can either create an event "now" or "all-day tomorrow":
+
+* "Schedule a deploy right now"
+* "Schedule an event right now: deploy"
+* "Schedule an appointment tomorrow, all-day: deploy"
+* "New appointment now: deploy"
+* Etc.
+
+### Scheduled events ###
+
+Create events that fire later just like you would any other scheduled event:
+
+* "New appointment for tomorrow at 4am: deploy"
+* "Schedule a deploy tomorrow at 4am"
+* "Schedule an event tomorrow at 4am: deploy"
+* "Schedule an appointment tomorrow, at 4am: deploy"
+* Etc.
+
+## To do ##
+
+* Remove needless dependency on ActiveSupport. I'm lazy.
+* Remove dependency on Google Calendar -- allow any CalDAV server.
+* Add Twilio SMS support. (bo-ring)
+
+## Note ##
+
+"Siri Says" isn't affiliated or endorsed by Apple in any way, shape, or form. It's just a dumb hack.
+
+[rtm]: http://www.rememberthemilk.com/services/siri/
+[iphoneselect]: https://www.google.com/calendar/iphoneselect
+[headshot]: http://www.youtube.com/watch?v=olm7xC-gBMY
View
@@ -0,0 +1,23 @@
+require 'rubygems'
+require 'bundler'
+
+begin
+ Bundler.setup(:default, :development)
+rescue Bundler::BundlerError => e
+ $stderr.puts e.message
+ $stderr.puts "Run `bundle install` to install missing gems"
+ exit e.status_code
+end
+require 'rake'
+
+require 'jeweler'
+Jeweler::Tasks.new do |gem|
+ gem.name = "siri_says"
+ gem.homepage = "http://github.com/tysontate/siri_says/"
+ gem.license = "MIT"
+ gem.summary = %Q{Siri as a remote control.}
+ gem.description = %Q{Siri as a remote control. Provides a basic DSL for handling commands from Siri via a ridiculous hack.}
+ gem.email = "tyson@tysontate.com"
+ gem.authors = ["Tyson Tate"]
+end
+Jeweler::RubygemsDotOrgTasks.new
View
@@ -0,0 +1 @@
+0.0.1
View
@@ -0,0 +1,20 @@
+# Echo everything that begins with "Campfire" (or "Camp fire") to a Campfire
+# room.
+
+require "rubygems"
+require "siri-says"
+require "broach"
+
+CAMPFIRE_ROOM = "The Hub"
+
+Broach.settings = {
+ 'account' => 'myaccount',
+ 'token' => '********************',
+ 'use_ssl' => true
+}
+
+siri_says /camp\s?fire/ do |msg|
+ Broach.speak( CAMPFIRE_ROOM, msg.sub( /^camp\?fire\s?/, "" ) )
+end
+
+SiriSays::Engine.run( "foo@gmail.com", "password" )
View
@@ -0,0 +1,10 @@
+# Just echo everything to the command line.
+
+require "rubygems"
+require "siri-says"
+
+siri_says /./ do |msg|
+ puts msg
+end
+
+SiriSays::Engine.run( "foo@gmail.com", "password" )
View
@@ -0,0 +1 @@
+require "siri_says"
View
@@ -0,0 +1,97 @@
+require "rubygems"
+require "gcal4ruby"
+require "i18n"
+require "active_support/core_ext"
+
+module Kernel
+ def siri_says( regex, &block )
+ SiriSays::Plugins.add( regex, block )
+ end
+end
+
+module SiriSays
+ class Plugins
+ class << self
+ def add( regex, block )
+ (@plugins ||= []) << {
+ regex: regex,
+ block: block
+ }
+ end
+
+ def handle( message )
+ (@plugins || []).each do |plugin|
+ if message =~ plugin[:regex]
+ plugin[:block].call( message )
+ end
+ end
+ end
+ end
+ end
+
+ class Engine
+ class << self
+ def run( username, password, interval=5 )
+ @username = username
+ @password = password
+ @calendar_name = "sirisays"
+
+ while true
+ self.ranges.each do |range|
+ GCal4Ruby::Event.find( self.service, @calendar_name, {
+ "start-min" => range[:start],
+ "start-max" => range[:end]
+ }).each do |event|
+ next if range[:all_day] != event.all_day
+ SiriSays::Plugins.handle( event.title )
+ event.delete
+ end
+ end
+ sleep interval
+ end
+ end
+
+ protected
+
+ def ranges
+ [
+ # Sceduled events
+ { start: scheduled_start, end: scheduled_end, all_day: false },
+ # Immediate events are all-day events
+ { start: immediate_start, end: immediate_end, all_day: true }
+ ]
+ end
+
+ def scheduled_start
+ xmltime( Time.now - 30.minutes )
+ end
+
+ def scheduled_end
+ xmltime( Time.now )
+ end
+
+ def immediate_start
+ xmltime( Date.tomorrow.beginning_of_day - 15.minutes )
+ end
+
+ def immediate_end
+ xmltime( Date.tomorrow.beginning_of_day + 15.minutes )
+ end
+
+ def xmltime( time )
+ time.xmlschema
+ end
+
+ def service
+ return @service if @service
+ begin
+ @service = GCal4Ruby::Service.new
+ @service.authenticate( @username, @password )
+ @service
+ rescue GData4Ruby::HTTPRequestFailed
+ raise "User name or password was incorrect."
+ end
+ end
+ end
+ end
+end
View
Binary file not shown.
View
@@ -0,0 +1,52 @@
+# Generated by jeweler
+# DO NOT EDIT THIS FILE DIRECTLY
+# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
+# -*- encoding: utf-8 -*-
+
+Gem::Specification.new do |s|
+ s.name = "siri_says"
+ s.version = "0.0.1"
+
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
+ s.authors = ["Tyson Tate"]
+ s.date = "2011-10-21"
+ s.description = "Siri as a remote control. Provides a basic DSL for handling commands from Siri via a ridiculous hack."
+ s.email = "tyson@tysontate.com"
+ s.extra_rdoc_files = [
+ "LICENSE.txt",
+ "README.markdown"
+ ]
+ s.files = [
+ "README.markdown"
+ ]
+ s.homepage = "http://github.com/tysontate/siri_says/"
+ s.licenses = ["MIT"]
+ s.require_paths = ["lib"]
+ s.rubygems_version = "1.8.10"
+ s.summary = "Siri as a remote control."
+
+ if s.respond_to? :specification_version then
+ s.specification_version = 3
+
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
+ s.add_runtime_dependency(%q<gcal4ruby>, [">= 0"])
+ s.add_runtime_dependency(%q<i18n>, [">= 0"])
+ s.add_runtime_dependency(%q<active_support>, [">= 0"])
+ s.add_development_dependency(%q<rake>, ["= 0.9.2"])
+ s.add_development_dependency(%q<jeweler>, [">= 0"])
+ else
+ s.add_dependency(%q<gcal4ruby>, [">= 0"])
+ s.add_dependency(%q<i18n>, [">= 0"])
+ s.add_dependency(%q<active_support>, [">= 0"])
+ s.add_dependency(%q<rake>, ["= 0.9.2"])
+ s.add_dependency(%q<jeweler>, [">= 0"])
+ end
+ else
+ s.add_dependency(%q<gcal4ruby>, [">= 0"])
+ s.add_dependency(%q<i18n>, [">= 0"])
+ s.add_dependency(%q<active_support>, [">= 0"])
+ s.add_dependency(%q<rake>, ["= 0.9.2"])
+ s.add_dependency(%q<jeweler>, [">= 0"])
+ end
+end
+

0 comments on commit 9ad88e6

Please sign in to comment.