rubin 0.0.0 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +21 -1
- data/Rakefile +12 -21
- data/VERSION +1 -1
- data/lib/rubin.rb +44 -0
- data/spec/rubin_spec.rb +5 -0
- data/spec/spec.opts +1 -0
- data/{test/helper.rb → spec/spec_helper.rb} +5 -6
- metadata +16 -13
- data/test/test_rubin.rb +0 -7
data/README.rdoc
CHANGED
@@ -1,6 +1,26 @@
|
|
1
1
|
= rubin
|
2
2
|
|
3
|
-
|
3
|
+
Round Robin Generator
|
4
|
+
|
5
|
+
== Usage
|
6
|
+
|
7
|
+
require 'rubin'
|
8
|
+
|
9
|
+
teams = %w(England, France, Italy, Germany)
|
10
|
+
teams.compete
|
11
|
+
|
12
|
+
# Output
|
13
|
+
Round 1
|
14
|
+
Englind v Italy
|
15
|
+
France v Germany
|
16
|
+
|
17
|
+
Round 2
|
18
|
+
France v Englind
|
19
|
+
Italy v Germany
|
20
|
+
|
21
|
+
Round 3
|
22
|
+
Italy v France
|
23
|
+
Englind v Germany
|
4
24
|
|
5
25
|
== Note on Patches/Pull Requests
|
6
26
|
|
data/Rakefile
CHANGED
@@ -5,42 +5,33 @@ begin
|
|
5
5
|
require 'jeweler'
|
6
6
|
Jeweler::Tasks.new do |gem|
|
7
7
|
gem.name = "rubin"
|
8
|
-
gem.summary = "Round Robin
|
8
|
+
gem.summary = "Round Robin Generator"
|
9
9
|
gem.description = "Round Robin Generator"
|
10
10
|
gem.email = "rit@quietdynamite.com"
|
11
11
|
gem.homepage = "http://github.com/rit/rubin"
|
12
12
|
gem.authors = ["Rit Li"]
|
13
|
-
gem.add_development_dependency "
|
14
|
-
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
13
|
+
gem.add_development_dependency "rspec", ">= 1.2.9"
|
15
14
|
end
|
16
15
|
Jeweler::GemcutterTasks.new
|
17
16
|
rescue LoadError
|
18
17
|
puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
|
19
18
|
end
|
20
19
|
|
21
|
-
require 'rake/
|
22
|
-
Rake::
|
23
|
-
|
24
|
-
|
25
|
-
test.verbose = true
|
20
|
+
require 'spec/rake/spectask'
|
21
|
+
Spec::Rake::SpecTask.new(:spec) do |spec|
|
22
|
+
spec.libs << 'lib' << 'spec'
|
23
|
+
spec.spec_files = FileList['spec/**/*_spec.rb']
|
26
24
|
end
|
27
25
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
test.pattern = 'test/**/test_*.rb'
|
33
|
-
test.verbose = true
|
34
|
-
end
|
35
|
-
rescue LoadError
|
36
|
-
task :rcov do
|
37
|
-
abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
|
38
|
-
end
|
26
|
+
Spec::Rake::SpecTask.new(:rcov) do |spec|
|
27
|
+
spec.libs << 'lib' << 'spec'
|
28
|
+
spec.pattern = 'spec/**/*_spec.rb'
|
29
|
+
spec.rcov = true
|
39
30
|
end
|
40
31
|
|
41
|
-
task :
|
32
|
+
task :spec => :check_dependencies
|
42
33
|
|
43
|
-
task :default => :
|
34
|
+
task :default => :spec
|
44
35
|
|
45
36
|
require 'rake/rdoctask'
|
46
37
|
Rake::RDocTask.new do |rdoc|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.1.0
|
data/lib/rubin.rb
CHANGED
@@ -0,0 +1,44 @@
|
|
1
|
+
module Rubin
|
2
|
+
def each_pair
|
3
|
+
members = self.dup
|
4
|
+
members << nil if members.size.odd?
|
5
|
+
rounds = members.size - 1
|
6
|
+
1.upto(rounds) do |round|
|
7
|
+
members._pairing do |left, right|
|
8
|
+
yield [left, right, round]
|
9
|
+
end
|
10
|
+
members._spin
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def _spin
|
15
|
+
# 1 4 2 1
|
16
|
+
# 2 5 => 3 4
|
17
|
+
# 3 6 5 6
|
18
|
+
# 6 is fixed
|
19
|
+
self.insert(self.size/2-1, self.delete_at(-2), self.shift)
|
20
|
+
end
|
21
|
+
|
22
|
+
def _pairing
|
23
|
+
members = self.dup
|
24
|
+
count = members.size/2
|
25
|
+
0.upto(count-1) do |i|
|
26
|
+
yield [members[i], members[i+count]]
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def compete
|
31
|
+
current = 0
|
32
|
+
each_pair do |left, right, round|
|
33
|
+
if current < round
|
34
|
+
puts "\nRound #{round}"
|
35
|
+
current = round
|
36
|
+
end
|
37
|
+
puts "#{left} v #{right}" if left && right
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
class Array
|
43
|
+
include Rubin
|
44
|
+
end
|
data/spec/rubin_spec.rb
ADDED
data/spec/spec.opts
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--color
|
@@ -1,10 +1,9 @@
|
|
1
|
-
require 'rubygems'
|
2
|
-
require 'test/unit'
|
3
|
-
require 'shoulda'
|
4
|
-
|
5
|
-
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
6
1
|
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
2
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
7
3
|
require 'rubin'
|
4
|
+
require 'spec'
|
5
|
+
require 'spec/autorun'
|
8
6
|
|
9
|
-
|
7
|
+
Spec::Runner.configure do |config|
|
8
|
+
|
10
9
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rubin
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 27
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
+
- 1
|
8
9
|
- 0
|
9
|
-
|
10
|
-
version: 0.0.0
|
10
|
+
version: 0.1.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Rit Li
|
@@ -15,21 +15,23 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-
|
18
|
+
date: 2010-10-05 00:00:00 -07:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
22
|
-
name:
|
22
|
+
name: rspec
|
23
23
|
prerelease: false
|
24
24
|
requirement: &id001 !ruby/object:Gem::Requirement
|
25
25
|
none: false
|
26
26
|
requirements:
|
27
27
|
- - ">="
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
hash:
|
29
|
+
hash: 13
|
30
30
|
segments:
|
31
|
-
-
|
32
|
-
|
31
|
+
- 1
|
32
|
+
- 2
|
33
|
+
- 9
|
34
|
+
version: 1.2.9
|
33
35
|
type: :development
|
34
36
|
version_requirements: *id001
|
35
37
|
description: Round Robin Generator
|
@@ -49,8 +51,9 @@ files:
|
|
49
51
|
- Rakefile
|
50
52
|
- VERSION
|
51
53
|
- lib/rubin.rb
|
52
|
-
-
|
53
|
-
-
|
54
|
+
- spec/rubin_spec.rb
|
55
|
+
- spec/spec.opts
|
56
|
+
- spec/spec_helper.rb
|
54
57
|
has_rdoc: true
|
55
58
|
homepage: http://github.com/rit/rubin
|
56
59
|
licenses: []
|
@@ -84,7 +87,7 @@ rubyforge_project:
|
|
84
87
|
rubygems_version: 1.3.7
|
85
88
|
signing_key:
|
86
89
|
specification_version: 3
|
87
|
-
summary: Round Robin
|
90
|
+
summary: Round Robin Generator
|
88
91
|
test_files:
|
89
|
-
-
|
90
|
-
-
|
92
|
+
- spec/rubin_spec.rb
|
93
|
+
- spec/spec_helper.rb
|