siriproxy-sancho 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/.gitignore +18 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +34 -0
- data/LICENSE.txt +22 -0
- data/README.md +29 -0
- data/Rakefile +1 -0
- data/lib/siriproxy-sancho.rb +55 -0
- data/lib/siriproxy-sancho/version.rb +5 -0
- data/siriproxy-sancho.gemspec +23 -0
- metadata +103 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
siriproxy-sancho (0.0.1)
|
5
|
+
em-http-request
|
6
|
+
eventmachine
|
7
|
+
uuid
|
8
|
+
|
9
|
+
GEM
|
10
|
+
remote: https://rubygems.org/
|
11
|
+
specs:
|
12
|
+
addressable (2.3.2)
|
13
|
+
cookiejar (0.3.0)
|
14
|
+
em-http-request (1.0.3)
|
15
|
+
addressable (>= 2.2.3)
|
16
|
+
cookiejar
|
17
|
+
em-socksify
|
18
|
+
eventmachine (>= 1.0.0.beta.4)
|
19
|
+
http_parser.rb (>= 0.5.3)
|
20
|
+
em-socksify (0.2.1)
|
21
|
+
eventmachine (>= 1.0.0.beta.4)
|
22
|
+
eventmachine (1.0.0)
|
23
|
+
http_parser.rb (0.5.3)
|
24
|
+
macaddr (1.6.1)
|
25
|
+
systemu (~> 2.5.0)
|
26
|
+
systemu (2.5.2)
|
27
|
+
uuid (2.3.6)
|
28
|
+
macaddr (~> 1.0)
|
29
|
+
|
30
|
+
PLATFORMS
|
31
|
+
ruby
|
32
|
+
|
33
|
+
DEPENDENCIES
|
34
|
+
siriproxy-sancho!
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2012 崔峥
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# Siriproxy::Sancho
|
2
|
+
|
3
|
+
TODO: Write a gem description
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'siriproxy-sancho'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install siriproxy-sancho
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
TODO: Write usage instructions here
|
22
|
+
|
23
|
+
## Contributing
|
24
|
+
|
25
|
+
1. Fork it
|
26
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
27
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
28
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
29
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
@@ -0,0 +1,55 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require "siriproxy-sancho/version"
|
3
|
+
|
4
|
+
require 'cora'
|
5
|
+
require 'uuid'
|
6
|
+
require 'siri_objects'
|
7
|
+
require "eventmachine"
|
8
|
+
require "em-http-request"
|
9
|
+
|
10
|
+
class SiriProxy::Plugin::Sancho < SiriProxy::Plugin
|
11
|
+
def initialize(config)
|
12
|
+
end
|
13
|
+
|
14
|
+
def show_fashion_weekend
|
15
|
+
# TODO
|
16
|
+
# 未来这些数据要来源于数据库或者API
|
17
|
+
magzines = %w{140_03fmrw.pdf 140_04-05st.pdf 140_06-07rw.pdf 140_12-13.pdf 140_13.pdf 140_fm.pdf}.map{|path| "http://42.121.89.18/pdf/#{path}"}
|
18
|
+
add_views = SiriAddViews.new
|
19
|
+
add_views.make_root(last_ref_id)
|
20
|
+
answer = SiriAnswer.new("这是最近几期的《时尚周末》", magzines.map{|m| SiriAnswerLine.new(m)})
|
21
|
+
add_views.views << SiriAnswerSnippet.new([answer])
|
22
|
+
send_object add_views
|
23
|
+
end
|
24
|
+
|
25
|
+
listen_for /写字板/i do
|
26
|
+
say "请您打开黑板."
|
27
|
+
key = UUID.generate.gsub('-','')
|
28
|
+
bb_url = "http://42.121.89.18:8000/black_board?key=#{key}"
|
29
|
+
mc_url = "http://42.121.89.18:8000/mc/pub"
|
30
|
+
say "请打开浏览器访问这个地址:#{mc_url}"
|
31
|
+
response = ask "您请讲吧"
|
32
|
+
while !(response.gsub(%r{\s},'') =~ /(结束)|(写好)|(完工)/i)
|
33
|
+
request = EM::HttpRequest.new(mc_url).post(:body => {:content => response, :key => key}, :timeout => 2)
|
34
|
+
response = ask "继续"
|
35
|
+
end
|
36
|
+
say "记录完毕."
|
37
|
+
request_completed
|
38
|
+
end
|
39
|
+
|
40
|
+
listen_for /(时尚)|(周末)/i do
|
41
|
+
response = ask "您问的是时尚周末吗?"
|
42
|
+
if response =~ /(是)|(是的)|(杂志)|(时尚周末)/
|
43
|
+
show_fashion_weekend
|
44
|
+
request_completed
|
45
|
+
else
|
46
|
+
say "抱歉,我没有理解您的意思."
|
47
|
+
request_completed
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
listen_for /时尚周末/i do
|
52
|
+
show_fashion_weekend
|
53
|
+
request_completed
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'siriproxy-sancho/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |gem|
|
7
|
+
gem.name = "siriproxy-sancho"
|
8
|
+
gem.version = Siriproxy::Sancho::VERSION
|
9
|
+
gem.authors = ["崔峥"]
|
10
|
+
gem.email = ["zheng.cuizh@gmail.com"]
|
11
|
+
gem.description = %q{just a siriproxy plugin for myself}
|
12
|
+
gem.summary = %q{nothing}
|
13
|
+
gem.homepage = ""
|
14
|
+
|
15
|
+
gem.files = `git ls-files`.split($/)
|
16
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
17
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
18
|
+
gem.require_paths = ["lib"]
|
19
|
+
|
20
|
+
gem.add_runtime_dependency "eventmachine"
|
21
|
+
gem.add_runtime_dependency "em-http-request"
|
22
|
+
gem.add_runtime_dependency "uuid"
|
23
|
+
end
|
metadata
ADDED
@@ -0,0 +1,103 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: siriproxy-sancho
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- 崔峥
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-12-27 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: eventmachine
|
16
|
+
requirement: !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: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: em-http-request
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :runtime
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: uuid
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
type: :runtime
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
description: just a siriproxy plugin for myself
|
63
|
+
email:
|
64
|
+
- zheng.cuizh@gmail.com
|
65
|
+
executables: []
|
66
|
+
extensions: []
|
67
|
+
extra_rdoc_files: []
|
68
|
+
files:
|
69
|
+
- .gitignore
|
70
|
+
- Gemfile
|
71
|
+
- Gemfile.lock
|
72
|
+
- LICENSE.txt
|
73
|
+
- README.md
|
74
|
+
- Rakefile
|
75
|
+
- lib/siriproxy-sancho.rb
|
76
|
+
- lib/siriproxy-sancho/version.rb
|
77
|
+
- siriproxy-sancho.gemspec
|
78
|
+
homepage: ''
|
79
|
+
licenses: []
|
80
|
+
post_install_message:
|
81
|
+
rdoc_options: []
|
82
|
+
require_paths:
|
83
|
+
- lib
|
84
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
85
|
+
none: false
|
86
|
+
requirements:
|
87
|
+
- - ! '>='
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
91
|
+
none: false
|
92
|
+
requirements:
|
93
|
+
- - ! '>='
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: '0'
|
96
|
+
requirements: []
|
97
|
+
rubyforge_project:
|
98
|
+
rubygems_version: 1.8.24
|
99
|
+
signing_key:
|
100
|
+
specification_version: 3
|
101
|
+
summary: nothing
|
102
|
+
test_files: []
|
103
|
+
has_rdoc:
|