siri_says 0.0.1
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.
- data/Gemfile +10 -0
- data/Gemfile.lock +26 -0
- data/LICENSE.txt +20 -0
- data/README.markdown +106 -0
- data/Rakefile +23 -0
- data/VERSION +1 -0
- data/examples/campfire.rb +20 -0
- data/examples/echo.rb +10 -0
- data/lib/siri-says.rb +1 -0
- data/lib/siri_says.rb +97 -0
- data/pkg/siri_says-0.0.1.gem +0 -0
- data/siri_says.gemspec +63 -0
- metadata +118 -0
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
GEM
|
2
|
+
remote: http://rubygems.org/
|
3
|
+
specs:
|
4
|
+
active_support (3.0.0)
|
5
|
+
activesupport (= 3.0.0)
|
6
|
+
activesupport (3.0.0)
|
7
|
+
gcal4ruby (0.5.5)
|
8
|
+
gdata4ruby (>= 0.1.5)
|
9
|
+
gdata4ruby (0.1.5)
|
10
|
+
git (1.2.5)
|
11
|
+
i18n (0.6.0)
|
12
|
+
jeweler (1.6.4)
|
13
|
+
bundler (~> 1.0)
|
14
|
+
git (>= 1.2.5)
|
15
|
+
rake
|
16
|
+
rake (0.9.2)
|
17
|
+
|
18
|
+
PLATFORMS
|
19
|
+
ruby
|
20
|
+
|
21
|
+
DEPENDENCIES
|
22
|
+
active_support
|
23
|
+
gcal4ruby
|
24
|
+
i18n
|
25
|
+
jeweler
|
26
|
+
rake (= 0.9.2)
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2011 Tyson Tate
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.markdown
ADDED
@@ -0,0 +1,106 @@
|
|
1
|
+
# Siri Says #
|
2
|
+
|
3
|
+
Siri Says gets that Siri biz-nass all up in your Ruby. Inspired by [Remember the Milk][rtm].
|
4
|
+
|
5
|
+
require "rubygems"
|
6
|
+
require "siri_says"
|
7
|
+
|
8
|
+
siri_says /deploy/ do |message|
|
9
|
+
puts "> Deploying..."
|
10
|
+
end
|
11
|
+
|
12
|
+
SiriSays::Engine.run( google_username, google_password )
|
13
|
+
|
14
|
+
Tell Siri: "Schedule a deploy right now."
|
15
|
+
|
16
|
+
(seconds later)
|
17
|
+
|
18
|
+
> Deploying...
|
19
|
+
|
20
|
+
Boom. [Headshot][headshot].
|
21
|
+
|
22
|
+
## Initial setup ##
|
23
|
+
|
24
|
+
This is a bit of a pain. Suck it up, cowboy.
|
25
|
+
|
26
|
+
### Google Calendar ###
|
27
|
+
|
28
|
+
Add a new "sirisays" calendar.
|
29
|
+
|
30
|
+
### iPhone ###
|
31
|
+
|
32
|
+
Add the calendar:
|
33
|
+
|
34
|
+
1. Settings
|
35
|
+
2. "Mail, Contacts, Calendars"
|
36
|
+
3. "Add Account..."
|
37
|
+
4. "Other"
|
38
|
+
5. "Add CalDAV Account"
|
39
|
+
* Server: google.com
|
40
|
+
* Username: username@gmail.com
|
41
|
+
* Password: ___________
|
42
|
+
* Description: "sirisays"
|
43
|
+
6. "Next"
|
44
|
+
|
45
|
+
Make it the default so that Siri will add events to it:
|
46
|
+
|
47
|
+
1. Settings
|
48
|
+
2. "Mail, Contacts, Calendars"
|
49
|
+
3. "Default Calendar" --> sirisays
|
50
|
+
4. Go to [https://www.google.com/calendar/iphoneselect][iphoneselect] and choose "sirisays" (not sure if this is necessary, actually...)
|
51
|
+
|
52
|
+
## Usage ##
|
53
|
+
|
54
|
+
Write Siri Says plugins (as many as you want) with `siri_says`:
|
55
|
+
|
56
|
+
siri_says /deploy/i do |message|
|
57
|
+
puts "> Deploying..."
|
58
|
+
end
|
59
|
+
|
60
|
+
siri_says /^say/i do |message|
|
61
|
+
puts "> Siri says: #{message.gsub(/^say/i, '')}"
|
62
|
+
end
|
63
|
+
|
64
|
+
Then start SiriSays with your Google Calendar user name and password:
|
65
|
+
|
66
|
+
SiriSays::Engine.run( google_username, google_password )
|
67
|
+
|
68
|
+
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.
|
69
|
+
|
70
|
+
## Sending events ##
|
71
|
+
|
72
|
+
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:
|
73
|
+
|
74
|
+
### Immediate events ###
|
75
|
+
|
76
|
+
To create an immediate event, you can either create an event "now" or "all-day tomorrow":
|
77
|
+
|
78
|
+
* "Schedule a deploy right now"
|
79
|
+
* "Schedule an event right now: deploy"
|
80
|
+
* "Schedule an appointment tomorrow, all-day: deploy"
|
81
|
+
* "New appointment now: deploy"
|
82
|
+
* Etc.
|
83
|
+
|
84
|
+
### Scheduled events ###
|
85
|
+
|
86
|
+
Create events that fire later just like you would any other scheduled event:
|
87
|
+
|
88
|
+
* "New appointment for tomorrow at 4am: deploy"
|
89
|
+
* "Schedule a deploy tomorrow at 4am"
|
90
|
+
* "Schedule an event tomorrow at 4am: deploy"
|
91
|
+
* "Schedule an appointment tomorrow, at 4am: deploy"
|
92
|
+
* Etc.
|
93
|
+
|
94
|
+
## To do ##
|
95
|
+
|
96
|
+
* Remove needless dependency on ActiveSupport. I'm lazy.
|
97
|
+
* Remove dependency on Google Calendar -- allow any CalDAV server.
|
98
|
+
* Add Twilio SMS support. (bo-ring)
|
99
|
+
|
100
|
+
## Note ##
|
101
|
+
|
102
|
+
"Siri Says" isn't affiliated or endorsed by Apple in any way, shape, or form. It's just a dumb hack.
|
103
|
+
|
104
|
+
[rtm]: http://www.rememberthemilk.com/services/siri/
|
105
|
+
[iphoneselect]: https://www.google.com/calendar/iphoneselect
|
106
|
+
[headshot]: http://www.youtube.com/watch?v=olm7xC-gBMY
|
data/Rakefile
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'bundler'
|
3
|
+
|
4
|
+
begin
|
5
|
+
Bundler.setup(:default, :development)
|
6
|
+
rescue Bundler::BundlerError => e
|
7
|
+
$stderr.puts e.message
|
8
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
9
|
+
exit e.status_code
|
10
|
+
end
|
11
|
+
require 'rake'
|
12
|
+
|
13
|
+
require 'jeweler'
|
14
|
+
Jeweler::Tasks.new do |gem|
|
15
|
+
gem.name = "siri_says"
|
16
|
+
gem.homepage = "http://github.com/tysontate/siri_says/"
|
17
|
+
gem.license = "MIT"
|
18
|
+
gem.summary = %Q{Siri as a remote control.}
|
19
|
+
gem.description = %Q{Siri as a remote control. Provides a basic DSL for handling commands from Siri via a ridiculous hack.}
|
20
|
+
gem.email = "tyson@tysontate.com"
|
21
|
+
gem.authors = ["Tyson Tate"]
|
22
|
+
end
|
23
|
+
Jeweler::RubygemsDotOrgTasks.new
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.0.1
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# Echo everything that begins with "Campfire" (or "Camp fire") to a Campfire
|
2
|
+
# room.
|
3
|
+
|
4
|
+
require "rubygems"
|
5
|
+
require "siri-says"
|
6
|
+
require "broach"
|
7
|
+
|
8
|
+
CAMPFIRE_ROOM = "The Hub"
|
9
|
+
|
10
|
+
Broach.settings = {
|
11
|
+
'account' => 'myaccount',
|
12
|
+
'token' => '********************',
|
13
|
+
'use_ssl' => true
|
14
|
+
}
|
15
|
+
|
16
|
+
siri_says /camp\s?fire/ do |msg|
|
17
|
+
Broach.speak( CAMPFIRE_ROOM, msg.sub( /^camp\?fire\s?/, "" ) )
|
18
|
+
end
|
19
|
+
|
20
|
+
SiriSays::Engine.run( "foo@gmail.com", "password" )
|
data/examples/echo.rb
ADDED
data/lib/siri-says.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "siri_says"
|
data/lib/siri_says.rb
ADDED
@@ -0,0 +1,97 @@
|
|
1
|
+
require "rubygems"
|
2
|
+
require "gcal4ruby"
|
3
|
+
require "i18n"
|
4
|
+
require "active_support/core_ext"
|
5
|
+
|
6
|
+
module Kernel
|
7
|
+
def siri_says( regex, &block )
|
8
|
+
SiriSays::Plugins.add( regex, block )
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
module SiriSays
|
13
|
+
class Plugins
|
14
|
+
class << self
|
15
|
+
def add( regex, block )
|
16
|
+
(@plugins ||= []) << {
|
17
|
+
regex: regex,
|
18
|
+
block: block
|
19
|
+
}
|
20
|
+
end
|
21
|
+
|
22
|
+
def handle( message )
|
23
|
+
(@plugins || []).each do |plugin|
|
24
|
+
if message =~ plugin[:regex]
|
25
|
+
plugin[:block].call( message )
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
class Engine
|
33
|
+
class << self
|
34
|
+
def run( username, password, interval=5 )
|
35
|
+
@username = username
|
36
|
+
@password = password
|
37
|
+
@calendar_name = "sirisays"
|
38
|
+
|
39
|
+
while true
|
40
|
+
self.ranges.each do |range|
|
41
|
+
GCal4Ruby::Event.find( self.service, @calendar_name, {
|
42
|
+
"start-min" => range[:start],
|
43
|
+
"start-max" => range[:end]
|
44
|
+
}).each do |event|
|
45
|
+
next if range[:all_day] != event.all_day
|
46
|
+
SiriSays::Plugins.handle( event.title )
|
47
|
+
event.delete
|
48
|
+
end
|
49
|
+
end
|
50
|
+
sleep interval
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
protected
|
55
|
+
|
56
|
+
def ranges
|
57
|
+
[
|
58
|
+
# Sceduled events
|
59
|
+
{ start: scheduled_start, end: scheduled_end, all_day: false },
|
60
|
+
# Immediate events are all-day events
|
61
|
+
{ start: immediate_start, end: immediate_end, all_day: true }
|
62
|
+
]
|
63
|
+
end
|
64
|
+
|
65
|
+
def scheduled_start
|
66
|
+
xmltime( Time.now - 30.minutes )
|
67
|
+
end
|
68
|
+
|
69
|
+
def scheduled_end
|
70
|
+
xmltime( Time.now )
|
71
|
+
end
|
72
|
+
|
73
|
+
def immediate_start
|
74
|
+
xmltime( Date.tomorrow.beginning_of_day - 15.minutes )
|
75
|
+
end
|
76
|
+
|
77
|
+
def immediate_end
|
78
|
+
xmltime( Date.tomorrow.beginning_of_day + 15.minutes )
|
79
|
+
end
|
80
|
+
|
81
|
+
def xmltime( time )
|
82
|
+
time.xmlschema
|
83
|
+
end
|
84
|
+
|
85
|
+
def service
|
86
|
+
return @service if @service
|
87
|
+
begin
|
88
|
+
@service = GCal4Ruby::Service.new
|
89
|
+
@service.authenticate( @username, @password )
|
90
|
+
@service
|
91
|
+
rescue GData4Ruby::HTTPRequestFailed
|
92
|
+
raise "User name or password was incorrect."
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
Binary file
|
data/siri_says.gemspec
ADDED
@@ -0,0 +1,63 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = "siri_says"
|
8
|
+
s.version = "0.0.1"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Tyson Tate"]
|
12
|
+
s.date = "2011-10-21"
|
13
|
+
s.description = "Siri as a remote control. Provides a basic DSL for handling commands from Siri via a ridiculous hack."
|
14
|
+
s.email = "tyson@tysontate.com"
|
15
|
+
s.extra_rdoc_files = [
|
16
|
+
"LICENSE.txt",
|
17
|
+
"README.markdown"
|
18
|
+
]
|
19
|
+
s.files = [
|
20
|
+
"Gemfile",
|
21
|
+
"Gemfile.lock",
|
22
|
+
"LICENSE.txt",
|
23
|
+
"README.markdown",
|
24
|
+
"Rakefile",
|
25
|
+
"VERSION",
|
26
|
+
"examples/campfire.rb",
|
27
|
+
"examples/echo.rb",
|
28
|
+
"lib/siri-says.rb",
|
29
|
+
"lib/siri_says.rb",
|
30
|
+
"pkg/siri_says-0.0.1.gem",
|
31
|
+
"siri_says.gemspec"
|
32
|
+
]
|
33
|
+
s.homepage = "http://github.com/tysontate/siri_says/"
|
34
|
+
s.licenses = ["MIT"]
|
35
|
+
s.require_paths = ["lib"]
|
36
|
+
s.rubygems_version = "1.8.10"
|
37
|
+
s.summary = "Siri as a remote control."
|
38
|
+
|
39
|
+
if s.respond_to? :specification_version then
|
40
|
+
s.specification_version = 3
|
41
|
+
|
42
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
43
|
+
s.add_runtime_dependency(%q<gcal4ruby>, [">= 0"])
|
44
|
+
s.add_runtime_dependency(%q<i18n>, [">= 0"])
|
45
|
+
s.add_runtime_dependency(%q<active_support>, [">= 0"])
|
46
|
+
s.add_development_dependency(%q<rake>, ["= 0.9.2"])
|
47
|
+
s.add_development_dependency(%q<jeweler>, [">= 0"])
|
48
|
+
else
|
49
|
+
s.add_dependency(%q<gcal4ruby>, [">= 0"])
|
50
|
+
s.add_dependency(%q<i18n>, [">= 0"])
|
51
|
+
s.add_dependency(%q<active_support>, [">= 0"])
|
52
|
+
s.add_dependency(%q<rake>, ["= 0.9.2"])
|
53
|
+
s.add_dependency(%q<jeweler>, [">= 0"])
|
54
|
+
end
|
55
|
+
else
|
56
|
+
s.add_dependency(%q<gcal4ruby>, [">= 0"])
|
57
|
+
s.add_dependency(%q<i18n>, [">= 0"])
|
58
|
+
s.add_dependency(%q<active_support>, [">= 0"])
|
59
|
+
s.add_dependency(%q<rake>, ["= 0.9.2"])
|
60
|
+
s.add_dependency(%q<jeweler>, [">= 0"])
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
metadata
ADDED
@@ -0,0 +1,118 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: siri_says
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Tyson Tate
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2011-10-21 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: gcal4ruby
|
16
|
+
requirement: &70210929467480 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *70210929467480
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: i18n
|
27
|
+
requirement: &70210929466320 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ! '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
type: :runtime
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *70210929466320
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: active_support
|
38
|
+
requirement: &70210929464980 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ! '>='
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '0'
|
44
|
+
type: :runtime
|
45
|
+
prerelease: false
|
46
|
+
version_requirements: *70210929464980
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: rake
|
49
|
+
requirement: &70210929463980 !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
51
|
+
requirements:
|
52
|
+
- - =
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 0.9.2
|
55
|
+
type: :development
|
56
|
+
prerelease: false
|
57
|
+
version_requirements: *70210929463980
|
58
|
+
- !ruby/object:Gem::Dependency
|
59
|
+
name: jeweler
|
60
|
+
requirement: &70210929463260 !ruby/object:Gem::Requirement
|
61
|
+
none: false
|
62
|
+
requirements:
|
63
|
+
- - ! '>='
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: '0'
|
66
|
+
type: :development
|
67
|
+
prerelease: false
|
68
|
+
version_requirements: *70210929463260
|
69
|
+
description: Siri as a remote control. Provides a basic DSL for handling commands
|
70
|
+
from Siri via a ridiculous hack.
|
71
|
+
email: tyson@tysontate.com
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files:
|
75
|
+
- LICENSE.txt
|
76
|
+
- README.markdown
|
77
|
+
files:
|
78
|
+
- Gemfile
|
79
|
+
- Gemfile.lock
|
80
|
+
- LICENSE.txt
|
81
|
+
- README.markdown
|
82
|
+
- Rakefile
|
83
|
+
- VERSION
|
84
|
+
- examples/campfire.rb
|
85
|
+
- examples/echo.rb
|
86
|
+
- lib/siri-says.rb
|
87
|
+
- lib/siri_says.rb
|
88
|
+
- pkg/siri_says-0.0.1.gem
|
89
|
+
- siri_says.gemspec
|
90
|
+
homepage: http://github.com/tysontate/siri_says/
|
91
|
+
licenses:
|
92
|
+
- MIT
|
93
|
+
post_install_message:
|
94
|
+
rdoc_options: []
|
95
|
+
require_paths:
|
96
|
+
- lib
|
97
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
98
|
+
none: false
|
99
|
+
requirements:
|
100
|
+
- - ! '>='
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: '0'
|
103
|
+
segments:
|
104
|
+
- 0
|
105
|
+
hash: 3412076788367949800
|
106
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
107
|
+
none: false
|
108
|
+
requirements:
|
109
|
+
- - ! '>='
|
110
|
+
- !ruby/object:Gem::Version
|
111
|
+
version: '0'
|
112
|
+
requirements: []
|
113
|
+
rubyforge_project:
|
114
|
+
rubygems_version: 1.8.10
|
115
|
+
signing_key:
|
116
|
+
specification_version: 3
|
117
|
+
summary: Siri as a remote control.
|
118
|
+
test_files: []
|