azuma 0.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: fc6dffe3b29a775863de4b40c634206fa9fb8ad8
4
+ data.tar.gz: 0181e57e71ad4b19ed71517e475822d048827edc
5
+ SHA512:
6
+ metadata.gz: 4a0db83120068a3726907282829b83d60fc0135a5f5b9e1135dd312cd082092edf9a77698d5247c55dae0f257f9d412d7c38aabce3d3fe8a928bb4306e26687b
7
+ data.tar.gz: a7c0e0f10bba63f28d77ebf1c5b5f5d703a5558e2afc3586596e3ab6f3ce2162ba6ce15faa9f23fd2e498735ccf5065bf788f717b83ef9a963da33fa5b8ee7eb
data/LICENSE ADDED
@@ -0,0 +1,19 @@
1
+ Copyright (c) 2015 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.
data/README.md ADDED
@@ -0,0 +1,36 @@
1
+ # azuma (雷)
2
+
3
+ Decide the order of Lightning Lalkers.
4
+
5
+ ## INSTALL
6
+
7
+ ```
8
+ $ gem install azuma
9
+ ```
10
+
11
+ ## USAGE
12
+
13
+ ```
14
+ azuma --talkers="小栗虫太郎,夢野久作,塔晶夫"
15
+ Ctrl-D to exit
16
+ > press enter to show next talker
17
+ 次は塔晶夫さんの番です。
18
+ > press enter to show next talker
19
+ 次は小栗虫太郎さんの番です。
20
+ > press enter to show next talker
21
+ 次は夢野久作さんの番です。
22
+ > press enter to show next talker
23
+ もう発表者はいません。お疲れ様でした。
24
+ ```
25
+
26
+ ## LICENCE
27
+
28
+ The MIT Licence
29
+
30
+ ## Contributing
31
+
32
+ 1. Fork it
33
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
34
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
35
+ 4. Push to the branch (`git push origin my-new-feature`)
36
+ 5. Create new Pull Request
data/azuma.gemspec ADDED
@@ -0,0 +1,35 @@
1
+ # encoding: utf-8
2
+
3
+ $:.push File.expand_path('../lib', __FILE__)
4
+
5
+ require 'azuma/version'
6
+
7
+ Gem::Specification.new do |s|
8
+ s.platform = Gem::Platform::RUBY
9
+ s.name = 'azuma'
10
+ s.summary = 'Decide the order of Lightning Lalkers.'
11
+ s.description = 'Decide the order of Lightning Lalkers.'
12
+
13
+ s.version = Azuma::VERSION
14
+
15
+ s.license = 'MIT'
16
+
17
+ s.authors = ['Koichi ITO']
18
+ s.email = 'koic.ito@gmail.com'
19
+ s.homepage = 'http://github.com/koic/azuma'
20
+
21
+ s.files = Dir[
22
+ 'README.md',
23
+ 'lib/**/*',
24
+ 'bin/azuma',
25
+ 'azuma.gemspec',
26
+ 'LICENSE'
27
+ ]
28
+ s.require_paths = ['lib']
29
+ s.executables = `git ls-files -- bin/*`.split("\n").map {|f| File.basename(f) }
30
+
31
+ s.required_ruby_version = '>= 2.0.0'
32
+ s.license = 'MIT'
33
+
34
+ s.add_development_dependency('rspec', '>= 3.0.0')
35
+ end
data/bin/azuma ADDED
@@ -0,0 +1,35 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # USAGE:
4
+ #
5
+ # azuma --talkers="小栗虫太郎,夢野久作,塔晶夫"
6
+ #
7
+ lib_path = File.expand_path('../../lib', __FILE__)
8
+ $:.unshift(lib_path)
9
+
10
+ require 'optparse'
11
+ require 'azuma'
12
+ require 'azuma/cli'
13
+
14
+ options = {}
15
+
16
+ opt = OptionParser.new
17
+ opt.on('-t', '--talkers="NAME1,NAME2..."') {|v| options[:talkers] = v }
18
+
19
+ begin
20
+ opt.parse!(ARGV)
21
+ rescue OptionParser::MissingArgument => e
22
+ puts opt.help
23
+
24
+ exit!
25
+ end
26
+
27
+ unless (talkers = options[:talkers])
28
+ puts opt.help
29
+
30
+ exit!
31
+ end
32
+
33
+ talkers = talkers.split(',').map(&:strip)
34
+
35
+ Azuma::CLI.start(talkers)
data/lib/azuma.rb ADDED
@@ -0,0 +1,12 @@
1
+ require 'azuma/announcement'
2
+ require 'azuma/core'
3
+
4
+ Azuma::Core.prepend Azuma::Announcement
5
+
6
+ module Azuma
7
+ def entry(talkers)
8
+ Azuma::Core.new(talkers)
9
+ end
10
+
11
+ module_function :entry
12
+ end
@@ -0,0 +1,21 @@
1
+ require 'shellwords'
2
+
3
+ module Azuma
4
+ module Announcement
5
+ def next_talker
6
+ super.tap do |talker|
7
+ message = if talker
8
+ "次は#{talker}さんの番です。"
9
+ else
10
+ "もう発表者はいません。お疲れ様でした。"
11
+ end
12
+
13
+ puts message
14
+
15
+ if /darwin/ === RUBY_PLATFORM
16
+ spawn("say #{Shellwords.shellescape(message)}")
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
data/lib/azuma/cli.rb ADDED
@@ -0,0 +1,17 @@
1
+ require 'readline'
2
+
3
+ module Azuma
4
+ class CLI
5
+ def self.start(talkers)
6
+ roulette = Azuma.entry(talkers)
7
+
8
+ Signal.trap(:EXIT) { puts; exit! }
9
+
10
+ puts 'Ctrl-D to exit'
11
+
12
+ while Readline.readline('> press enter to show next talker', true)
13
+ break unless roulette.next_talker
14
+ end
15
+ end
16
+ end
17
+ end
data/lib/azuma/core.rb ADDED
@@ -0,0 +1,11 @@
1
+ module Azuma
2
+ class Core
3
+ def initialize(talkers)
4
+ @talkers = talkers.shuffle
5
+ end
6
+
7
+ def next_talker
8
+ @talkers.pop
9
+ end
10
+ end
11
+ end
data/lib/azuma/drb.rb ADDED
@@ -0,0 +1,36 @@
1
+ #
2
+ # USAGE:
3
+ #
4
+ # 1. client side
5
+ #
6
+ # Azuma::DRb.start(['小栗虫太郎', '夢野久作', '塔晶夫'])
7
+ # > "druby://localhost:8989'
8
+ #
9
+ # 2. server side
10
+ #
11
+ # roulette = DRb::DRbObject.new_with_uri('druby://localhost:8989')
12
+ # roulette.next_talker
13
+ #
14
+ require 'drb'
15
+
16
+ module Azuma
17
+ class DRb
18
+ def self.start(talkers)
19
+ roulette = Azuma.entry(talkers)
20
+
21
+ @server = ::DRb.start_service(nil, roulette)
22
+
23
+ puts "drb starting on #{::DRb.uri}"
24
+
25
+ Signal.trap(:INT) do
26
+ puts; puts('Stopping ...')
27
+
28
+ @server.stop_service
29
+
30
+ puts('Exiting ...'); exit!
31
+ end
32
+
33
+ ::DRb.uri
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,3 @@
1
+ module Azuma
2
+ VERSION = '0.0.0'
3
+ end
metadata ADDED
@@ -0,0 +1,68 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: azuma
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Koichi ITO
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-07-08 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rspec
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 3.0.0
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: 3.0.0
27
+ description: Decide the order of Lightning Lalkers.
28
+ email: koic.ito@gmail.com
29
+ executables:
30
+ - azuma
31
+ extensions: []
32
+ extra_rdoc_files: []
33
+ files:
34
+ - LICENSE
35
+ - README.md
36
+ - azuma.gemspec
37
+ - bin/azuma
38
+ - lib/azuma.rb
39
+ - lib/azuma/announcement.rb
40
+ - lib/azuma/cli.rb
41
+ - lib/azuma/core.rb
42
+ - lib/azuma/drb.rb
43
+ - lib/azuma/version.rb
44
+ homepage: http://github.com/koic/azuma
45
+ licenses:
46
+ - MIT
47
+ metadata: {}
48
+ post_install_message:
49
+ rdoc_options: []
50
+ require_paths:
51
+ - lib
52
+ required_ruby_version: !ruby/object:Gem::Requirement
53
+ requirements:
54
+ - - ">="
55
+ - !ruby/object:Gem::Version
56
+ version: 2.0.0
57
+ required_rubygems_version: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ requirements: []
63
+ rubyforge_project:
64
+ rubygems_version: 2.4.8
65
+ signing_key:
66
+ specification_version: 4
67
+ summary: Decide the order of Lightning Lalkers.
68
+ test_files: []