permutation 0.1.4 → 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -1,5 +1,6 @@
1
1
  require 'rake/gempackagetask'
2
2
  require 'rbconfig'
3
+ require 'rake/clean'
3
4
 
4
5
  include Config
5
6
 
@@ -23,46 +24,20 @@ task :test do
23
24
  end
24
25
 
25
26
  spec = Gem::Specification.new do |s|
26
-
27
- #### Basic information.
28
-
29
27
  s.name = 'permutation'
30
28
  s.version = PKG_VERSION
31
29
  s.summary = 'Permutation library in pure Ruby'
32
30
  s.description = "Library to perform different operations with permutations of sequences (strings, arrays, etc.)"
33
31
 
34
- #### Dependencies and requirements.
35
-
36
- #s.add_dependency('log4r', '> 1.0.4')
37
- #s.requirements << ""
38
-
39
32
  s.files = PKG_FILES
40
33
 
41
- #### C code extensions.
42
-
43
- #s.extensions << "ext/extconf.rb"
44
-
45
- #### Load-time details: library and application (you will need one or both).
46
-
47
- s.require_path = 'lib' # Use these for libraries.
48
- #s.autorequire = 'permutation'
49
-
50
- #s.bindir = "bin" # Use these for applications.
51
- #s.executables = ["bla.rb"]
52
- #s.default_executable = "bla.rb"
53
-
54
- #### Documentation and testing.
34
+ s.require_path = 'lib'
55
35
 
56
36
  s.has_rdoc = true
57
- #s.extra_rdoc_files = rd.rdoc_files.reject { |fn| fn =~ /\.rb$/ }.to_a
58
- #s.rdoc_options <<
59
- # '--title' << 'Rake -- Ruby Make' <<
60
- # '--main' << 'README' <<
61
- # '--line-numbers'
37
+ s.rdoc_options << '--title' << 'Permutation' << '--line-numbers'
38
+ s.extra_rdoc_files = Dir['lib/**/*.rb']
62
39
  s.test_files << 'test/test.rb'
63
40
 
64
- #### Author and project details.
65
-
66
41
  s.author = "Florian Frank"
67
42
  s.email = "flori@ping.de"
68
43
  s.homepage = "http://permutation.rubyforge.org"
@@ -74,5 +49,22 @@ Rake::GemPackageTask.new(spec) do |pkg|
74
49
  pkg.package_files += PKG_FILES
75
50
  end
76
51
 
77
- task :release => :package
52
+ desc m = "Writing version information for #{PKG_VERSION}"
53
+ task :version do
54
+ puts m
55
+ File.open(File.join('lib', 'permutation', 'version.rb'), 'w') do |v|
56
+ v.puts <<EOT
57
+ class Permutation
58
+ # Permutation version
59
+ VERSION = '#{PKG_VERSION}'
60
+ VERSION_ARRAY = VERSION.split(/\\./).map { |x| x.to_i } # :nodoc:
61
+ VERSION_MAJOR = VERSION_ARRAY[0] # :nodoc:
62
+ VERSION_MINOR = VERSION_ARRAY[1] # :nodoc:
63
+ VERSION_BUILD = VERSION_ARRAY[2] # :nodoc:
64
+ end
65
+ EOT
66
+ end
67
+ end
68
+
69
+ task :release => [ :clean, :version, :package ]
78
70
  # vim: set et sw=2 ts=2:
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.4
1
+ 0.1.5
data/install.rb CHANGED
@@ -6,7 +6,7 @@ include FileUtils::Verbose
6
6
 
7
7
  include Config
8
8
 
9
- file = 'lib/permutation.rb'
10
9
  dest = CONFIG["sitelibdir"]
11
- install(file, dest)
10
+ install('lib/permutation.rb', dest)
11
+ install('lib/permutation/version.rb', File.join(dest, 'permutation'))
12
12
  # vim: set et sw=4 ts=4:
@@ -120,7 +120,6 @@
120
120
  #
121
121
 
122
122
  class Permutation
123
-
124
123
  include Enumerable
125
124
  include Comparable
126
125
 
@@ -431,13 +430,11 @@ class Permutation
431
430
 
432
431
  private
433
432
 
434
- @@factorial_cache = {}
433
+ @@fcache = [ 1 ]
435
434
 
436
435
  def factorial(n)
437
- f = @@factorial_cache[n] and return f
438
- f = 1
439
- for i in 2..n do f *= i end
440
- @@factorial_cache[n] = f
436
+ @@fcache.size.upto(n) { |i| @@fcache[i] = i * @@fcache[i - 1] }
437
+ @@fcache[n]
441
438
  end
442
439
 
443
440
  def rank_indices(p)
@@ -466,6 +463,5 @@ class Permutation
466
463
  end
467
464
  result
468
465
  end
469
-
470
466
  end
471
467
  # vim: set et sw=4 ts=4:
@@ -0,0 +1,8 @@
1
+ class Permutation
2
+ # Permutation version
3
+ VERSION = '0.1.5'
4
+ VERSION_ARRAY = VERSION.split(/\./).map { |x| x.to_i } # :nodoc:
5
+ VERSION_MAJOR = VERSION_ARRAY[0] # :nodoc:
6
+ VERSION_MINOR = VERSION_ARRAY[1] # :nodoc:
7
+ VERSION_BUILD = VERSION_ARRAY[2] # :nodoc:
8
+ end
metadata CHANGED
@@ -1,10 +1,10 @@
1
1
  --- !ruby/object:Gem::Specification
2
- rubygems_version: 0.8.11
2
+ rubygems_version: 0.9.2
3
3
  specification_version: 1
4
4
  name: permutation
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.1.4
7
- date: 2006-03-11 00:00:00 +01:00
6
+ version: 0.1.5
7
+ date: 2007-04-17 00:00:00 +02:00
8
8
  summary: Permutation library in pure Ruby
9
9
  require_paths:
10
10
  - lib
@@ -25,27 +25,33 @@ required_ruby_version: !ruby/object:Gem::Version::Requirement
25
25
  platform: ruby
26
26
  signing_key:
27
27
  cert_chain:
28
+ post_install_message:
28
29
  authors:
29
30
  - Florian Frank
30
31
  files:
31
- - examples
32
- - install.rb
32
+ - VERSION
33
33
  - GPL
34
- - test
34
+ - README.en
35
+ - install.rb
35
36
  - Rakefile
36
- - VERSION
37
- - CHANGES
37
+ - examples
38
38
  - lib
39
- - README.en
39
+ - test
40
+ - CHANGES
40
41
  - examples/tsp.rb
41
- - test/test.rb
42
42
  - lib/permutation.rb
43
+ - lib/permutation
44
+ - lib/permutation/version.rb
45
+ - test/test.rb
43
46
  test_files:
44
47
  - test/test.rb
45
- rdoc_options: []
46
-
47
- extra_rdoc_files: []
48
-
48
+ rdoc_options:
49
+ - --title
50
+ - Permutation
51
+ - --line-numbers
52
+ extra_rdoc_files:
53
+ - lib/permutation.rb
54
+ - lib/permutation/version.rb
49
55
  executables: []
50
56
 
51
57
  extensions: []