combinatorics 0.3.0 → 0.3.1

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/.document CHANGED
@@ -1,4 +1,4 @@
1
- lib/**/*.rb
2
1
  -
3
2
  LICENSE.txt
3
+ Benchmarks.md
4
4
  ChangeLog.md
data/Benchmarks.md ADDED
@@ -0,0 +1,50 @@
1
+ # Benchmarks
2
+
3
+ Benchmarks for the {Combinatorics} code can be found in the `benchmarks/`
4
+ directory.
5
+
6
+ Benchmark machine specs:
7
+
8
+ * CPU: AMD Athlon(tm) 64 Processor 3400+ (2202.785 MHz)
9
+ * Cache Size: 1024 KB
10
+ * Memory: 1 Gb
11
+
12
+ ## List Comprehensions:
13
+
14
+ Ruby 1.9.2-p0 (2010-08-18 revision 29036) [x86_64-linux]:
15
+
16
+ user system total real
17
+ singleton: 0.060000 0.010000 0.070000 ( 0.090075)
18
+ single-enum: 0.020000 0.000000 0.020000 ( 0.035206)
19
+ depth 1: 0.000000 0.000000 0.000000 ( 0.002489)
20
+ depth 2: 0.240000 0.000000 0.240000 ( 0.306060)
21
+ depth 3: 40.090000 0.250000 40.340000 ( 51.830667)
22
+
23
+ Ruby 1.8.7 (2010-08-16 patchlevel 302) [x86_64-linux]:
24
+
25
+ user system total real
26
+ singleton: 0.410000 0.290000 0.700000 ( 0.929625)
27
+ single-enum: 0.050000 0.130000 0.180000 ( 0.348974)
28
+ depth 1: 0.030000 0.050000 0.080000 ( 0.111043)
29
+ depth 2: 15.650000 0.560000 16.210000 ( 23.012478)
30
+ depth 3: 3239.310000 15.950000 3255.260000 (3739.261379)
31
+
32
+ JRuby 1.5.3 (ruby 1.8.7 patchlevel 249) (2010-09-28 7ca06d7)
33
+ (OpenJDK 64-Bit Server VM 1.6.0_18) [amd64-java]:
34
+
35
+ user system total real
36
+ singleton: 1.019000 0.000000 1.019000 ( 0.870000)
37
+ single-enum: 0.325000 0.000000 0.325000 ( 0.325000)
38
+ depth 1: 0.088000 0.000000 0.088000 ( 0.088000)
39
+ depth 2: 5.045000 0.000000 5.045000 ( 5.044000)
40
+ depth 3: 275.765000 0.000000 275.765000 (275.765000)
41
+
42
+ Rubinius 1.1.1dev (1.8.7 8bc2dc9a 2010-09-23 JI) [x86_64-unknown-linux-gnu]:
43
+
44
+ user system total real
45
+ singleton: 1.143827 0.088987 1.232814 ( 1.523531)
46
+ single-enum: 0.313953 0.028996 0.342949 ( 0.423621)
47
+ depth 1: 0.001999 0.000999 0.002998 ( 0.003840)
48
+ depth 2: 1.051840 0.030996 1.082836 ( 1.293856)
49
+ depth 3: 42.303569 5.777121 48.080690 ( 57.556785)
50
+
data/ChangeLog.md CHANGED
@@ -1,3 +1,10 @@
1
+ ### 0.3.1 / 2010-10-26
2
+
3
+ * Do not call `enum_for` on `Enumerator` objects passed to
4
+ {Array#comprehension}.
5
+ * Improved {Array#comprehension} benchmarks.
6
+ * Added [benchmark results] (see {file:Benchmarks.md}).
7
+
1
8
  ### 0.3.0 / 2010-10-17
2
9
 
3
10
  * Added {Combinatorics::Generator} which auto-detects the `Generator`
data/README.md CHANGED
@@ -92,5 +92,7 @@ List comprehensions:
92
92
 
93
93
  ## License
94
94
 
95
+ Copyright (c) 2010 Hal Brodigan
96
+
95
97
  See {file:LICENSE.txt} for license information.
96
98
 
data/Rakefile CHANGED
@@ -2,35 +2,28 @@ require 'rubygems'
2
2
  require 'rake'
3
3
 
4
4
  begin
5
- gem 'jeweler', '~> 1.4.0'
6
- require 'jeweler'
5
+ require 'ore/tasks'
6
+ Ore::Tasks.new
7
+ rescue LoadError => e
8
+ STDERR.puts e.message
9
+ STDERR.puts "Run `gem install ore-tasks` to install 'ore/tasks'."
10
+ end
7
11
 
8
- Jeweler::Tasks.new do |gem|
9
- gem.name = 'combinatorics'
10
- gem.summary = %Q{Bringing (more) Combinatorics to Ruby}
11
- gem.description = %Q{A collection of modules and methods for performing Combinatoric calculations.}
12
- gem.email = 'postmodern.mod3@gmail.com'
13
- gem.homepage = 'http://github.com/postmodern/combinatorics'
14
- gem.authors = ['Postmodern']
15
- gem.add_development_dependency 'rspec', '~> 2.0.0'
16
- gem.add_development_dependency 'yard', '~> 0.6.0'
17
- gem.add_development_dependency 'jeweler', '~> 1.4.0'
12
+ begin
13
+ require 'rspec/core/rake_task'
14
+ RSpec::Core::RakeTask.new
15
+ rescue LoadError => e
16
+ task :spec do
17
+ abort "Please run `gem install rspec` to install RSpec."
18
18
  end
19
- Jeweler::GemcutterTasks.new
20
- rescue LoadError
21
- puts 'Jeweler (or a dependency) not available. Install it with: gem install jeweler'
22
19
  end
23
-
24
- require 'rspec/core/rake_task'
25
- RSpec::Core::RakeTask.new
26
20
  task :default => :spec
27
21
 
28
22
  begin
29
23
  require 'yard'
30
-
31
- YARD::Rake::YardocTask.new
32
- rescue LoadError
24
+ YARD::Rake::YardocTask.new
25
+ rescue LoadError => e
33
26
  task :yard do
34
- abort 'YARD is not available. In order to run yard, you must: gem install yard'
27
+ abort "Please run `gem install yard` to install YARD."
35
28
  end
36
29
  end
@@ -7,6 +7,25 @@ $LOAD_PATH << lib_dir unless $LOAD_PATH.include?(lib_dir)
7
7
  require 'benchmark'
8
8
  require 'combinatorics/list_comprehension'
9
9
 
10
- list = [(1..200)] * 3
10
+ Benchmark.bm(12) do |b|
11
+ singleton_list = ([1] * 500)
12
+ single_enum_list = [1..200, 1]
13
+ depth_list = [1..200]
11
14
 
12
- puts Benchmark.measure { list.comprehension.each { |list| } }
15
+ b.report('singleton:') do
16
+ singleton_list.comprehension.each { |list| list.last }
17
+ end
18
+
19
+
20
+ b.report('single-enum:') do
21
+ single_enum_list.comprehension.each { |list| list.last }
22
+ end
23
+
24
+ (1..3).each do |n|
25
+ deep_list = (depth_list * n)
26
+
27
+ b.report("depth #{n}:") do
28
+ deep_list.comprehension.each { |list| list.last }
29
+ end
30
+ end
31
+ end
@@ -1,90 +1,10 @@
1
- # Generated by jeweler
2
- # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
1
  # -*- encoding: utf-8 -*-
5
2
 
6
- Gem::Specification.new do |s|
7
- s.name = %q{combinatorics}
8
- s.version = "0.3.0"
9
-
10
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
- s.authors = ["Postmodern"]
12
- s.date = %q{2010-10-17}
13
- s.description = %q{A collection of modules and methods for performing Combinatoric calculations.}
14
- s.email = %q{postmodern.mod3@gmail.com}
15
- s.extra_rdoc_files = [
16
- "ChangeLog.md",
17
- "LICENSE.txt",
18
- "README.md"
19
- ]
20
- s.files = [
21
- ".document",
22
- ".gitignore",
23
- ".rspec",
24
- ".yardopts",
25
- "ChangeLog.md",
26
- "LICENSE.txt",
27
- "README.md",
28
- "Rakefile",
29
- "VERSION",
30
- "benchmarks/list_comprehension.rb",
31
- "combinatorics.gemspec",
32
- "lib/combinatorics.rb",
33
- "lib/combinatorics/enumerator.rb",
34
- "lib/combinatorics/extensions.rb",
35
- "lib/combinatorics/extensions/range.rb",
36
- "lib/combinatorics/generator.rb",
37
- "lib/combinatorics/list_comprehension.rb",
38
- "lib/combinatorics/power_set.rb",
39
- "lib/combinatorics/power_set/extensions.rb",
40
- "lib/combinatorics/power_set/extensions/array.rb",
41
- "lib/combinatorics/power_set/extensions/set.rb",
42
- "lib/combinatorics/power_set/mixin.rb",
43
- "spec/.rspec",
44
- "spec/combinatorics_spec.rb",
45
- "spec/enumerator_spec.rb",
46
- "spec/extensions/range_spec.rb",
47
- "spec/generator_spec.rb",
48
- "spec/list_comprehension_spec.rb",
49
- "spec/power_set/array_spec.rb",
50
- "spec/power_set/mixin_examples.rb",
51
- "spec/power_set/set_spec.rb",
52
- "spec/spec_helper.rb"
53
- ]
54
- s.homepage = %q{http://github.com/postmodern/combinatorics}
55
- s.rdoc_options = ["--charset=UTF-8"]
56
- s.require_paths = ["lib"]
57
- s.rubygems_version = %q{1.3.7}
58
- s.summary = %q{Bringing (more) Combinatorics to Ruby}
59
- s.test_files = [
60
- "spec/enumerator_spec.rb",
61
- "spec/combinatorics_spec.rb",
62
- "spec/list_comprehension_spec.rb",
63
- "spec/generator_spec.rb",
64
- "spec/extensions/range_spec.rb",
65
- "spec/spec_helper.rb",
66
- "spec/power_set/set_spec.rb",
67
- "spec/power_set/array_spec.rb",
68
- "spec/power_set/mixin_examples.rb"
69
- ]
70
-
71
- if s.respond_to? :specification_version then
72
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
73
- s.specification_version = 3
74
-
75
- if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
76
- s.add_development_dependency(%q<rspec>, ["~> 2.0.0"])
77
- s.add_development_dependency(%q<yard>, ["~> 0.6.0"])
78
- s.add_development_dependency(%q<jeweler>, ["~> 1.4.0"])
79
- else
80
- s.add_dependency(%q<rspec>, ["~> 2.0.0"])
81
- s.add_dependency(%q<yard>, ["~> 0.6.0"])
82
- s.add_dependency(%q<jeweler>, ["~> 1.4.0"])
83
- end
84
- else
85
- s.add_dependency(%q<rspec>, ["~> 2.0.0"])
86
- s.add_dependency(%q<yard>, ["~> 0.6.0"])
87
- s.add_dependency(%q<jeweler>, ["~> 1.4.0"])
3
+ begin
4
+ Ore::Specification.new do |gemspec|
5
+ # custom logic here
88
6
  end
7
+ rescue NameError
8
+ STDERR.puts "The 'combinatorics.gemspec' file requires Ore."
9
+ STDERR.puts "Run `gem install ore` to install Ore."
89
10
  end
90
-
data/gemspec.yml ADDED
@@ -0,0 +1,16 @@
1
+ name: combinatorics
2
+ summary: Bringing (more) Combinatorics to Ruby
3
+ description:
4
+ A collection of modules and methods for performing Combinatoric
5
+ calculations.
6
+ license: MIT
7
+ authors: Postmodern
8
+ email: postmodern.mod3@gmail.com
9
+ homepage: http://github.com/postmodern/combinatorics
10
+ has_yard: true
11
+
12
+ development_dependencies:
13
+ ore: ~> 0.1.0
14
+ ore-tasks: ~> 0.1.0
15
+ rspec: ~> 2.0.0
16
+ yard: ~> 0.6.0
data/lib/combinatorics.rb CHANGED
@@ -1,3 +1,4 @@
1
1
  require 'combinatorics/extensions'
2
2
  require 'combinatorics/list_comprehension'
3
3
  require 'combinatorics/power_set'
4
+ require 'combinatorics/version'
@@ -53,7 +53,7 @@ class Range
53
53
 
54
54
  self.first.upto(other.first) do |start|
55
55
  self.last.upto(other.last) do |stop|
56
- yield (start..stop)
56
+ yield start..stop
57
57
  end
58
58
  end
59
59
  end
@@ -89,7 +89,7 @@ class Range
89
89
 
90
90
  self.first.downto(other.first) do |start|
91
91
  self.last.downto(other.last) do |stop|
92
- yield (start..stop)
92
+ yield start..stop
93
93
  end
94
94
  end
95
95
  end
@@ -1,3 +1,5 @@
1
+ require 'combinatorics/enumerator'
2
+
1
3
  class Array
2
4
 
3
5
  #
@@ -48,7 +50,10 @@ class Array
48
50
  end
49
51
 
50
52
  enums = self.map do |value|
51
- if value.kind_of?(Enumerable)
53
+ case value
54
+ when Combinatorics::Enumerator
55
+ value
56
+ when Enumerable
52
57
  value.enum_for
53
58
  else
54
59
  [value].enum_for
@@ -0,0 +1,4 @@
1
+ module Combinatorics
2
+ # combinatorics version
3
+ VERSION = '0.3.1'
4
+ end
@@ -1,4 +1,8 @@
1
1
  require 'spec_helper'
2
+ require 'combinatorics/version'
2
3
 
3
- describe "Combinatorics" do
4
+ describe Combinatorics do
5
+ it "should have a VERSION constant" do
6
+ subject.const_get('VERSION').should_not be_empty
7
+ end
4
8
  end
@@ -54,7 +54,7 @@ describe "Array#comprehension" do
54
54
  [1,2],
55
55
  Combinatorics::Generator.new { |g|
56
56
  multiplier += 1
57
- 5.times { |i| g.yield (i * multiplier) }
57
+ 5.times { |i| g.yield(i * multiplier) }
58
58
  }
59
59
  ]
60
60
 
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 3
8
- - 0
9
- version: 0.3.0
8
+ - 1
9
+ version: 0.3.1
10
10
  platform: ruby
11
11
  authors:
12
12
  - Postmodern
@@ -14,11 +14,11 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-10-17 00:00:00 -07:00
17
+ date: 2010-10-26 00:00:00 -07:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
- name: rspec
21
+ name: ore
22
22
  prerelease: false
23
23
  requirement: &id001 !ruby/object:Gem::Requirement
24
24
  none: false
@@ -26,14 +26,14 @@ dependencies:
26
26
  - - ~>
27
27
  - !ruby/object:Gem::Version
28
28
  segments:
29
- - 2
30
29
  - 0
30
+ - 1
31
31
  - 0
32
- version: 2.0.0
32
+ version: 0.1.0
33
33
  type: :development
34
34
  version_requirements: *id001
35
35
  - !ruby/object:Gem::Dependency
36
- name: yard
36
+ name: ore-tasks
37
37
  prerelease: false
38
38
  requirement: &id002 !ruby/object:Gem::Requirement
39
39
  none: false
@@ -42,13 +42,13 @@ dependencies:
42
42
  - !ruby/object:Gem::Version
43
43
  segments:
44
44
  - 0
45
- - 6
45
+ - 1
46
46
  - 0
47
- version: 0.6.0
47
+ version: 0.1.0
48
48
  type: :development
49
49
  version_requirements: *id002
50
50
  - !ruby/object:Gem::Dependency
51
- name: jeweler
51
+ name: rspec
52
52
  prerelease: false
53
53
  requirement: &id003 !ruby/object:Gem::Requirement
54
54
  none: false
@@ -56,12 +56,27 @@ dependencies:
56
56
  - - ~>
57
57
  - !ruby/object:Gem::Version
58
58
  segments:
59
- - 1
60
- - 4
59
+ - 2
61
60
  - 0
62
- version: 1.4.0
61
+ - 0
62
+ version: 2.0.0
63
63
  type: :development
64
64
  version_requirements: *id003
65
+ - !ruby/object:Gem::Dependency
66
+ name: yard
67
+ prerelease: false
68
+ requirement: &id004 !ruby/object:Gem::Requirement
69
+ none: false
70
+ requirements:
71
+ - - ~>
72
+ - !ruby/object:Gem::Version
73
+ segments:
74
+ - 0
75
+ - 6
76
+ - 0
77
+ version: 0.6.0
78
+ type: :development
79
+ version_requirements: *id004
65
80
  description: A collection of modules and methods for performing Combinatoric calculations.
66
81
  email: postmodern.mod3@gmail.com
67
82
  executables: []
@@ -69,21 +84,22 @@ executables: []
69
84
  extensions: []
70
85
 
71
86
  extra_rdoc_files:
72
- - ChangeLog.md
73
- - LICENSE.txt
74
87
  - README.md
88
+ - LICENSE.txt
89
+ - Benchmarks.md
90
+ - ChangeLog.md
75
91
  files:
76
92
  - .document
77
- - .gitignore
78
93
  - .rspec
79
94
  - .yardopts
95
+ - Benchmarks.md
80
96
  - ChangeLog.md
81
97
  - LICENSE.txt
82
98
  - README.md
83
99
  - Rakefile
84
- - VERSION
85
100
  - benchmarks/list_comprehension.rb
86
101
  - combinatorics.gemspec
102
+ - gemspec.yml
87
103
  - lib/combinatorics.rb
88
104
  - lib/combinatorics/enumerator.rb
89
105
  - lib/combinatorics/extensions.rb
@@ -95,6 +111,7 @@ files:
95
111
  - lib/combinatorics/power_set/extensions/array.rb
96
112
  - lib/combinatorics/power_set/extensions/set.rb
97
113
  - lib/combinatorics/power_set/mixin.rb
114
+ - lib/combinatorics/version.rb
98
115
  - spec/.rspec
99
116
  - spec/combinatorics_spec.rb
100
117
  - spec/enumerator_spec.rb
@@ -105,13 +122,13 @@ files:
105
122
  - spec/power_set/mixin_examples.rb
106
123
  - spec/power_set/set_spec.rb
107
124
  - spec/spec_helper.rb
108
- has_rdoc: true
125
+ has_rdoc: yard
109
126
  homepage: http://github.com/postmodern/combinatorics
110
- licenses: []
111
-
127
+ licenses:
128
+ - MIT
112
129
  post_install_message:
113
- rdoc_options:
114
- - --charset=UTF-8
130
+ rdoc_options: []
131
+
115
132
  require_paths:
116
133
  - lib
117
134
  required_ruby_version: !ruby/object:Gem::Requirement
@@ -143,7 +160,5 @@ test_files:
143
160
  - spec/list_comprehension_spec.rb
144
161
  - spec/generator_spec.rb
145
162
  - spec/extensions/range_spec.rb
146
- - spec/spec_helper.rb
147
163
  - spec/power_set/set_spec.rb
148
164
  - spec/power_set/array_spec.rb
149
- - spec/power_set/mixin_examples.rb
data/.gitignore DELETED
@@ -1,8 +0,0 @@
1
- pkg
2
- doc
3
- web
4
- tmp
5
- .DS_Store
6
- .yardoc
7
- *.swp
8
- *~
data/VERSION DELETED
@@ -1 +0,0 @@
1
- 0.3.0