acappella 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 5c26718b7718d6472e64e75621286167b823032f
4
+ data.tar.gz: e3a6ba550d871c0f72201076259f83ffc2735caa
5
+ SHA512:
6
+ metadata.gz: 42e20dbc440f230aeb6326acc213ceaf5d8fa430ae9145baa48f5b36b8c6e62efdbadfc3d56df21ad9fad354cc487ca031ebfdf7acbf1ff1900ae9bed41656d4
7
+ data.tar.gz: 73774fa65942d583a13e8d878fb5c8b3c354f55ea5ab5722c2f4558e8a411c07c55a9b7903c72f72e47855c1dbb0fdb0bfafcd326163a43ebff120f5ef93c23b
data/LICENSE ADDED
@@ -0,0 +1,19 @@
1
+ Copyright (c) 2014 Koichi ITO
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to deal
5
+ in the Software without restriction, including without limitation the rights
6
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ copies of the Software, and to permit persons to whom the Software is
8
+ furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in
11
+ all copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+ THE SOFTWARE.
@@ -0,0 +1,39 @@
1
+ # A Cappella
2
+
3
+ A client-server model talk tool. Server speak characters that client was typing.
4
+
5
+ ## INSTALL
6
+
7
+ ```
8
+ $ gem install acappella
9
+ ```
10
+
11
+ ## USAGE
12
+
13
+ 1. Please perform the following in server side terminal.
14
+
15
+ ```
16
+ $ acappella-server
17
+ acappella 0.0.1 starting on druby://localhost:8989
18
+ Run `acappella-server --help` for more startup options
19
+ Ctrl-C to shutdown server
20
+ ```
21
+
22
+ 2. Please perform the following in client side terminal.
23
+
24
+ ```
25
+ $ acappella-client
26
+ Connect to druby://localhost:8989
27
+ Ctrl-D to exit
28
+ > words you want to talk'
29
+ ```
30
+
31
+ Server speak characters that client was typing.
32
+
33
+ ## Operating environment
34
+
35
+ Mac OS X (only)
36
+
37
+ ## LICENCE
38
+
39
+ MIT
@@ -0,0 +1,19 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ lib_path = File.expand_path('../../lib', __FILE__)
4
+ $:.unshift(lib_path)
5
+
6
+ require 'acappella'
7
+ require 'readline'
8
+
9
+ options = ACappella::OptionParser.parse(ARGV) rescue exit(false)
10
+
11
+ client = ACappella::Client.new(options)
12
+
13
+ Signal.trap(:EXIT) { puts; exit(false) }
14
+
15
+ puts 'Ctrl-D to exit'
16
+
17
+ while message = Readline.readline('> ', true)
18
+ client.send(message)
19
+ end
@@ -0,0 +1,12 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ lib_path = File.expand_path('../../lib', __FILE__)
4
+ $:.unshift(lib_path)
5
+
6
+ require 'acappella'
7
+
8
+ options = ACappella::OptionParser.parse(ARGV) rescue exit(false)
9
+
10
+ server = ACappella::Server.new(options)
11
+
12
+ server.start
@@ -0,0 +1,9 @@
1
+ module ACappella; end
2
+
3
+ require 'acappella/client'
4
+ require 'acappella/option_parser'
5
+ require 'acappella/server'
6
+ require 'acappella/set_list'
7
+ require 'acappella/singer'
8
+ require 'acappella/songwriter'
9
+ require 'acappella/version'
@@ -0,0 +1,24 @@
1
+ require 'drb/drb'
2
+ require 'uri'
3
+
4
+ module ACappella
5
+ class Client
6
+ def initialize(options = {})
7
+ host = options[:host] || 'localhost'
8
+ port = options[:port] || '8989'
9
+
10
+ uri = URI.parse("druby://#{host}:#{port}").to_s
11
+
12
+ puts "Connect to #{uri}"
13
+ puts 'Run `acappella-client --help` for more startup options'
14
+
15
+ @songwriter = DRb::DRbObject.new_with_uri(uri)
16
+ end
17
+
18
+ def send(lyrics)
19
+ @songwriter.write(lyrics)
20
+ rescue => e
21
+ puts e.message
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,22 @@
1
+ require 'optparse'
2
+
3
+ module ACappella
4
+ class OptionParser
5
+ def self.parse(argv)
6
+ opt = ::OptionParser.new
7
+
8
+ options = {}
9
+
10
+ opt.on('-h', '--host=VAL') {|v| options[:host] = v }
11
+ opt.on('-p', '--port=VAL') {|v| options[:port] = v }
12
+
13
+ opt.parse!(argv)
14
+
15
+ options
16
+ rescue ::OptionParser::MissingArgument => e
17
+ puts opt.help
18
+
19
+ raise e
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,42 @@
1
+ require 'drb/drb'
2
+ require 'uri'
3
+
4
+ module ACappella
5
+ class Server
6
+ def initialize(options = {})
7
+ host = options[:host] || 'localhost'
8
+ port = options[:port] || '8989'
9
+
10
+ @uri = URI.parse("druby://#{host}:#{port}").to_s
11
+
12
+ @set_list = SetList.new
13
+
14
+ @songwriter = Songwriter.new(@set_list)
15
+
16
+ @singer = Singer.new
17
+ end
18
+
19
+ def start
20
+ @server = DRb.start_service(@uri, @songwriter)
21
+
22
+ puts "acappella #{ACappella::VERSION} starting on #{DRb.uri}"
23
+ puts 'Run `acappella-server --help` for more startup options'
24
+
25
+ Signal.trap(:INT) do
26
+ puts; puts('Stopping ...')
27
+
28
+ @server.stop_service
29
+
30
+ puts('Exiting ...'); exit(false)
31
+ end
32
+
33
+ puts 'Ctrl-C to shutdown server'
34
+
35
+ loop do
36
+ if song = @set_list.next_song
37
+ @singer.sing(song)
38
+ end
39
+ end
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,15 @@
1
+ module ACappella
2
+ class SetList
3
+ def initialize
4
+ @songs = []
5
+ end
6
+
7
+ def request(lyrics)
8
+ @songs << lyrics
9
+ end
10
+
11
+ def next_song
12
+ @songs.shift
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,17 @@
1
+ module ACappella
2
+ class Singer
3
+ def sing(lyrics)
4
+ logging(lyrics)
5
+
6
+ system('say', lyrics)
7
+ end
8
+
9
+ private
10
+
11
+ def logging(lyrics)
12
+ sung_at = Time.now.strftime('%Y-%m-%d %H:%M:%S')
13
+
14
+ puts [sung_at, lyrics].join("\t")
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,11 @@
1
+ module ACappella
2
+ class Songwriter
3
+ def initialize(set_list)
4
+ @set_list = set_list
5
+ end
6
+
7
+ def write(lyrics)
8
+ @set_list.request(lyrics)
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,3 @@
1
+ module ACappella
2
+ VERSION = '0.0.1'
3
+ end
metadata ADDED
@@ -0,0 +1,60 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: acappella
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Koichi ITO
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-12-15 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: A client-server model talk tool. Server speak characters that client
14
+ was typing.
15
+ email: koic.ito@gmail.com
16
+ executables:
17
+ - acappella-client
18
+ - acappella-server
19
+ extensions: []
20
+ extra_rdoc_files: []
21
+ files:
22
+ - LICENSE
23
+ - README.md
24
+ - bin/acappella-client
25
+ - bin/acappella-server
26
+ - lib/acappella.rb
27
+ - lib/acappella/client.rb
28
+ - lib/acappella/option_parser.rb
29
+ - lib/acappella/server.rb
30
+ - lib/acappella/set_list.rb
31
+ - lib/acappella/singer.rb
32
+ - lib/acappella/songwriter.rb
33
+ - lib/acappella/version.rb
34
+ homepage: http://github.com/koic/acappella
35
+ licenses:
36
+ - MIT
37
+ metadata: {}
38
+ post_install_message:
39
+ rdoc_options: []
40
+ require_paths:
41
+ - lib
42
+ required_ruby_version: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: '0'
47
+ required_rubygems_version: !ruby/object:Gem::Requirement
48
+ requirements:
49
+ - - ">="
50
+ - !ruby/object:Gem::Version
51
+ version: '0'
52
+ requirements: []
53
+ rubyforge_project:
54
+ rubygems_version: 2.2.0
55
+ signing_key:
56
+ specification_version: 4
57
+ summary: A client-server model talk tool. Server speak characters that client was
58
+ typing.
59
+ test_files: []
60
+ has_rdoc: