tuomas-knights_tour 0.3.3 → 0.3.4
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/CHANGELOG.rdoc +5 -0
- data/MIT-LICENSE.txt +19 -0
- data/README.rdoc +3 -22
- data/Rakefile +11 -9
- data/bin/knights_tour +3 -4
- data/lib/knights_tour.rb +1 -21
- data/spec/knights_tour_spec.rb +1 -1
- metadata +9 -6
data/CHANGELOG.rdoc
CHANGED
data/MIT-LICENSE.txt
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
Copyright (c) 2008-2009 Tuomas Kareinen.
|
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.rdoc
CHANGED
@@ -20,7 +20,7 @@ The program is compatible with Ruby 1.9.1.
|
|
20
20
|
|
21
21
|
== Usage
|
22
22
|
|
23
|
-
|
23
|
+
In the command line, run the program by entering
|
24
24
|
|
25
25
|
$ knights_tour
|
26
26
|
|
@@ -62,24 +62,5 @@ com >.
|
|
62
62
|
|
63
63
|
== Legal notes
|
64
64
|
|
65
|
-
|
66
|
-
|
67
|
-
Copyright (c) 2008-2009 Tuomas Kareinen.
|
68
|
-
|
69
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
70
|
-
of this software and associated documentation files (the "Software"), to
|
71
|
-
deal in the Software without restriction, including without limitation the
|
72
|
-
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
73
|
-
sell copies of the Software, and to permit persons to whom the Software is
|
74
|
-
furnished to do so, subject to the following conditions:
|
75
|
-
|
76
|
-
The above copyright notice and this permission notice shall be included in
|
77
|
-
all copies or substantial portions of the Software.
|
78
|
-
|
79
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
80
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
81
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
82
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
83
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
84
|
-
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
85
|
-
IN THE SOFTWARE.
|
65
|
+
Copyright (c) 2008-2009 Tuomas Kareinen. See MIT-LICENSE.txt in this
|
66
|
+
directory.
|
data/Rakefile
CHANGED
@@ -1,11 +1,11 @@
|
|
1
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), "lib"))
|
2
|
+
|
1
3
|
require "rubygems"
|
2
4
|
|
3
5
|
full_name = "Knight's Tour"
|
4
6
|
package_name = "knights_tour"
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
version = KnightsTour::Meta::VERSION.to_s
|
7
|
+
require "#{package_name}"
|
8
|
+
version = KnightsTour::VERSION
|
9
9
|
|
10
10
|
require "rake/clean"
|
11
11
|
|
@@ -21,13 +21,13 @@ spec = Gem::Specification.new do |s|
|
|
21
21
|
s.email = "tkareine@gmail.com"
|
22
22
|
|
23
23
|
s.platform = Gem::Platform::RUBY
|
24
|
-
s.files = FileList["Rakefile", "*.rdoc", "bin/**/*", "lib/**/*", "spec/**/*"].to_a
|
24
|
+
s.files = FileList["Rakefile", "MIT-LICENSE.txt", "*.rdoc", "bin/**/*", "lib/**/*", "spec/**/*"].to_a
|
25
25
|
s.executables = ["knights_tour"]
|
26
26
|
|
27
27
|
s.add_dependency("trollop", ">= 1.10.0")
|
28
28
|
|
29
29
|
s.has_rdoc = true
|
30
|
-
s.extra_rdoc_files = FileList["*.rdoc"].to_a
|
30
|
+
s.extra_rdoc_files = FileList["MIT-LICENSE.txt", "*.rdoc"].to_a
|
31
31
|
s.rdoc_options << "--title" << "#{full_name} #{version}" \
|
32
32
|
<< "--main" << "README.rdoc" \
|
33
33
|
<< "--exclude" << "spec" \
|
@@ -60,16 +60,17 @@ Rake::RDocTask.new(:rdoc) do |rd|
|
|
60
60
|
rd.rdoc_dir = "rdoc"
|
61
61
|
rd.title = "#{full_name} #{version}"
|
62
62
|
rd.main = "README.rdoc"
|
63
|
-
rd.rdoc_files.include("*.rdoc", "lib/**/*.rb")
|
63
|
+
rd.rdoc_files.include("MIT-LICENSE.txt", "*.rdoc", "lib/**/*.rb")
|
64
64
|
rd.options << "--line-numbers"
|
65
65
|
end
|
66
66
|
|
67
67
|
require "spec/rake/spectask"
|
68
68
|
desc "Run specs"
|
69
69
|
Spec::Rake::SpecTask.new(:spec) do |t|
|
70
|
-
t.spec_files = FileList["spec
|
70
|
+
t.spec_files = FileList["spec/**/*_spec.rb"]
|
71
71
|
t.spec_opts = ["--colour --format progress --loadby mtime"]
|
72
72
|
t.warning = true
|
73
|
+
t.libs << "lib"
|
73
74
|
end
|
74
75
|
|
75
76
|
desc "Run specs with RCov"
|
@@ -77,6 +78,7 @@ Spec::Rake::SpecTask.new(:rcov) do |t|
|
|
77
78
|
t.spec_files = FileList["spec/**/*.rb"]
|
78
79
|
t.rcov = true
|
79
80
|
t.rcov_opts = ["--exclude", "spec"]
|
81
|
+
t.libs << "lib"
|
80
82
|
end
|
81
83
|
|
82
84
|
desc "Find code smells"
|
@@ -86,7 +88,7 @@ end
|
|
86
88
|
|
87
89
|
desc "Search unfinished parts of source code"
|
88
90
|
task :todo do
|
89
|
-
FileList["**/*.rb"].egrep
|
91
|
+
FileList["**/*.rb", "**/*.rdoc", "**/*.txt"].egrep /(TODO|FIXME)/
|
90
92
|
end
|
91
93
|
|
92
94
|
task :default => :spec
|
data/bin/knights_tour
CHANGED
@@ -1,15 +1,14 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
require "rubygems"
|
4
3
|
require "trollop"
|
5
|
-
require
|
4
|
+
require "knights_tour"
|
6
5
|
|
7
6
|
# Parse the command line arguments and invoke the application.
|
8
7
|
|
9
8
|
include KnightsTour
|
10
9
|
|
11
10
|
options = Trollop::options do
|
12
|
-
version
|
11
|
+
version "#{File.basename($0)} #{VERSION}"
|
13
12
|
|
14
13
|
banner <<-EOS
|
15
14
|
A program that attempts to find a solution to the Knight's Tour problem.
|
@@ -38,4 +37,4 @@ rescue ArgumentError => e
|
|
38
37
|
Trollop::die e.to_s
|
39
38
|
end
|
40
39
|
|
41
|
-
|
40
|
+
puts app.solve
|
data/lib/knights_tour.rb
CHANGED
@@ -1,23 +1,5 @@
|
|
1
1
|
module KnightsTour
|
2
|
-
|
3
|
-
module VERSION #:nodoc:
|
4
|
-
MAJOR = 0
|
5
|
-
MINOR = 3
|
6
|
-
PATCH = 3
|
7
|
-
|
8
|
-
def self.to_s
|
9
|
-
[ MAJOR, MINOR, PATCH ].join(".")
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
COPYRIGHT = "Copyright (c) Tuomas Kareinen"
|
14
|
-
|
15
|
-
LICENSE = "Licensed under the terms of the \"MIT license\". See README.rdoc."
|
16
|
-
|
17
|
-
def self.version
|
18
|
-
"#{File.basename($0)} #{Meta::VERSION}\n#{Meta::COPYRIGHT}\n#{Meta::LICENSE}"
|
19
|
-
end
|
20
|
-
end
|
2
|
+
VERSION = "0.3.4"
|
21
3
|
|
22
4
|
class Application
|
23
5
|
def initialize(params = {})
|
@@ -70,8 +52,6 @@ module KnightsTour
|
|
70
52
|
# to a new position in each recursive step of the algorithm, instead of
|
71
53
|
# modifying a single shared board in place.
|
72
54
|
def traverse(knight)
|
73
|
-
#$stdout.puts StringResult.new(board) # debug
|
74
|
-
|
75
55
|
unless knight.traversed?
|
76
56
|
next_positions = knight.find_next_positions
|
77
57
|
next_positions.each do |next_position|
|
data/spec/knights_tour_spec.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tuomas-knights_tour
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tuomas Kareinen
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-
|
12
|
+
date: 2009-09-03 00:00:00 -07:00
|
13
13
|
default_executable: knights_tour
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -29,21 +29,24 @@ executables:
|
|
29
29
|
extensions: []
|
30
30
|
|
31
31
|
extra_rdoc_files:
|
32
|
+
- MIT-LICENSE.txt
|
32
33
|
- CHANGELOG.rdoc
|
33
34
|
- README.rdoc
|
34
35
|
files:
|
35
36
|
- Rakefile
|
37
|
+
- MIT-LICENSE.txt
|
36
38
|
- CHANGELOG.rdoc
|
37
39
|
- README.rdoc
|
38
40
|
- bin/knights_tour
|
39
41
|
- lib/knights_tour.rb
|
40
42
|
- spec/knights_tour_spec.rb
|
41
|
-
has_rdoc:
|
43
|
+
has_rdoc: false
|
42
44
|
homepage: http://github.com/tuomas/knights_tour
|
45
|
+
licenses:
|
43
46
|
post_install_message:
|
44
47
|
rdoc_options:
|
45
48
|
- --title
|
46
|
-
- Knight's Tour 0.3.
|
49
|
+
- Knight's Tour 0.3.4
|
47
50
|
- --main
|
48
51
|
- README.rdoc
|
49
52
|
- --exclude
|
@@ -66,9 +69,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
66
69
|
requirements: []
|
67
70
|
|
68
71
|
rubyforge_project:
|
69
|
-
rubygems_version: 1.
|
72
|
+
rubygems_version: 1.3.5
|
70
73
|
signing_key:
|
71
|
-
specification_version:
|
74
|
+
specification_version: 3
|
72
75
|
summary: Solves Knight's Tour problem.
|
73
76
|
test_files: []
|
74
77
|
|