combinatorics 0.4.4 → 0.5.0

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.
Files changed (55) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ruby.yml +4 -4
  3. data/.gitignore +2 -1
  4. data/ChangeLog.md +6 -0
  5. data/Gemfile +2 -0
  6. data/LICENSE.txt +1 -1
  7. data/README.md +1 -3
  8. data/Rakefile +0 -2
  9. data/combinatorics.gemspec +1 -4
  10. data/gemspec.yml +1 -1
  11. data/lib/combinatorics/cartesian_product/cardinality.rb +2 -0
  12. data/lib/combinatorics/cartesian_product/extensions/array.rb +3 -1
  13. data/lib/combinatorics/cartesian_product/extensions/set.rb +3 -1
  14. data/lib/combinatorics/cartesian_product/extensions.rb +4 -2
  15. data/lib/combinatorics/cartesian_product/mixin.rb +3 -1
  16. data/lib/combinatorics/cartesian_product.rb +5 -3
  17. data/lib/combinatorics/choose/cardinality.rb +3 -1
  18. data/lib/combinatorics/choose/extensions/array.rb +3 -1
  19. data/lib/combinatorics/choose/extensions/set.rb +4 -1
  20. data/lib/combinatorics/choose/extensions.rb +4 -2
  21. data/lib/combinatorics/choose/mixin.rb +2 -0
  22. data/lib/combinatorics/choose.rb +5 -3
  23. data/lib/combinatorics/derange/cardinality.rb +3 -1
  24. data/lib/combinatorics/derange/extensions/array.rb +3 -1
  25. data/lib/combinatorics/derange/extensions.rb +3 -1
  26. data/lib/combinatorics/derange/mixin.rb +2 -0
  27. data/lib/combinatorics/derange.rb +5 -3
  28. data/lib/combinatorics/enumerator.rb +2 -0
  29. data/lib/combinatorics/extensions/math.rb +2 -0
  30. data/lib/combinatorics/extensions/range.rb +2 -0
  31. data/lib/combinatorics/extensions.rb +3 -1
  32. data/lib/combinatorics/generator.rb +2 -0
  33. data/lib/combinatorics/list_comprehension.rb +3 -1
  34. data/lib/combinatorics/permute/cardinality.rb +3 -1
  35. data/lib/combinatorics/permute/extensions/array.rb +3 -1
  36. data/lib/combinatorics/permute/extensions/set.rb +3 -1
  37. data/lib/combinatorics/permute/extensions.rb +4 -2
  38. data/lib/combinatorics/permute/mixin.rb +2 -0
  39. data/lib/combinatorics/permute.rb +5 -3
  40. data/lib/combinatorics/power_set/cardinality.rb +3 -1
  41. data/lib/combinatorics/power_set/extensions/array.rb +3 -1
  42. data/lib/combinatorics/power_set/extensions/set.rb +3 -1
  43. data/lib/combinatorics/power_set/extensions.rb +4 -2
  44. data/lib/combinatorics/power_set/mixin.rb +2 -0
  45. data/lib/combinatorics/power_set.rb +5 -3
  46. data/lib/combinatorics/version.rb +3 -1
  47. data/lib/combinatorics.rb +12 -10
  48. data/spec/cartesian_product/cardinality_spec.rb +1 -3
  49. data/spec/choose/cardinality_spec.rb +1 -3
  50. data/spec/derange/cardinality_spec.rb +1 -3
  51. data/spec/permute/cardinality_spec.rb +1 -3
  52. data/spec/power_set/cardinality_spec.rb +1 -3
  53. data/spec/spec_helper.rb +2 -3
  54. metadata +4 -5
  55. data/.gemtest +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e0761711a88421b7b0214a3b585b6a843401bd1e84bb189c87a0c4167d7e5f32
4
- data.tar.gz: 6c42e53311328f5d0f6c27ea339c3539046fee352dfb548155d35183a19d5aef
3
+ metadata.gz: a2e5a4e1e77069bf882a67e27933b8640723ee43a209b3a7d4b442238a4d7e45
4
+ data.tar.gz: 595e89e295c7f9dae763f890f460f745edd743ac12340c5f8785677caa6a56b6
5
5
  SHA512:
6
- metadata.gz: 1d9df890fc1669969b84e48a0b3d6126111cc6e13369308f76c274e0227fcd475a9047872ef247dc83b009f4b5d234526aa9d88c0c59cff7c9129d080c93a044
7
- data.tar.gz: 53eabbc7025dbaa9e79d8fe44c8d68c0182de3b575f425f6b4d0231c88920a8ee7b8c85bfd8f94743b8a618184525d0db5264d37232bd8793396b93afbfb1a0f
6
+ metadata.gz: 7eaec1f50156aa63c48212782b2cddd9a18b7dab7ba5986201f97c16b1ca9d01311b675c503b1cbe19ecb9ad63cef946a47f0eeef58742b62a8deb53b228ff30
7
+ data.tar.gz: af34206cde9e21f8637ac54449563456c81f939a3ca032c64e0a98fe5220918d5f9c03b6eefe3cf8c5b8c44280701c1121b7770ae1b4d6c8323eed0091cb2eb0
@@ -9,15 +9,15 @@ jobs:
9
9
  fail-fast: false
10
10
  matrix:
11
11
  ruby:
12
- - 2.6
13
- - 2.7
14
12
  - '3.0'
15
- - 3.1
13
+ - '3.1'
14
+ - '3.2'
15
+ - '3.3'
16
16
  - jruby
17
17
  - truffleruby
18
18
  name: Ruby ${{ matrix.ruby }}
19
19
  steps:
20
- - uses: actions/checkout@v2
20
+ - uses: actions/checkout@v4
21
21
  - name: Set up Ruby
22
22
  uses: ruby/setup-ruby@v1
23
23
  with:
data/.gitignore CHANGED
@@ -1,6 +1,7 @@
1
1
  /Gemfile.lock
2
- /pkg
2
+ /coverage
3
3
  /doc
4
+ /pkg
4
5
  /.yardoc
5
6
  .DS_Store
6
7
  *.swp
data/ChangeLog.md CHANGED
@@ -1,3 +1,9 @@
1
+ ### 0.5.0 / 2024-01-25
2
+
3
+ * Require [ruby](http://www.ruby-lang.org/) >= 2.0.0.
4
+ * Switched to using `require_relative` to improve load-times.
5
+ * Added `# frozen_string_literal: true` to all files.
6
+
1
7
  ### 0.4.4 / 2022-01-16
2
8
 
3
9
  * Fixed a bug in {Combinatorics::Choose.cardinality} for when `0`
data/Gemfile CHANGED
@@ -7,8 +7,10 @@ group :development do
7
7
  gem 'rubygems-tasks', '~> 0.2'
8
8
 
9
9
  gem 'rspec', '~> 3.0'
10
+ gem 'simplecov', '~> 0.20', require: false
10
11
 
11
12
  gem 'kramdown'
13
+ gem 'redcarpet', platform: :mri
12
14
  gem 'yard', '~> 0.9'
13
15
  gem 'yard-spellcheck', require: false
14
16
  end
data/LICENSE.txt CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2010-2022 Hal Brodigan
1
+ Copyright (c) 2010-2024 Hal Brodigan
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
data/README.md CHANGED
@@ -190,7 +190,7 @@ Enumerate over every sub-range between two ranges:
190
190
 
191
191
  ## Requirements
192
192
 
193
- * [ruby](http://www.ruby-lang.org/) >= 1.8.7
193
+ * [ruby](http://www.ruby-lang.org/) >= 2.0.0
194
194
 
195
195
  ## Install
196
196
 
@@ -200,6 +200,4 @@ $ gem install combinatorics
200
200
 
201
201
  ## Copyright
202
202
 
203
- Copyright (c) 2010-2022 Hal Brodigan
204
-
205
203
  See {file:LICENSE.txt} for license information.
data/Rakefile CHANGED
@@ -1,5 +1,3 @@
1
- require 'rubygems'
2
-
3
1
  require 'rubygems/tasks'
4
2
  Gem::Tasks.new
5
3
 
@@ -7,10 +7,7 @@ Gem::Specification.new do |gem|
7
7
 
8
8
  gem.name = gemspec.fetch('name')
9
9
  gem.version = gemspec.fetch('version') do
10
- lib_dir = File.join(File.dirname(__FILE__),'lib')
11
- $LOAD_PATH << lib_dir unless $LOAD_PATH.include?(lib_dir)
12
-
13
- require 'combinatorics/version'
10
+ require_relative 'lib/combinatorics/version'
14
11
  Combinatorics::VERSION
15
12
  end
16
13
 
data/gemspec.yml CHANGED
@@ -19,7 +19,7 @@ metadata:
19
19
  bug_tracker_uri: https://github.com/postmodern/combinatorics.rb/issues
20
20
  changelog_uri: https://github.com/postmodern/combinatorics.rb/blob/master/ChangeLog.md
21
21
 
22
- required_ruby_version: ">= 1.8.7"
22
+ required_ruby_version: ">= 2.0.0"
23
23
 
24
24
  development_dependencies:
25
25
  bundler: ~> 2.0
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Combinatorics
2
4
  #
3
5
  # @author duper <super@manson.vistech.net>
@@ -1,4 +1,6 @@
1
- require 'combinatorics/cartesian_product/mixin'
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../mixin'
2
4
 
3
5
  class Array
4
6
 
@@ -1,4 +1,6 @@
1
- require 'combinatorics/cartesian_product/mixin'
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../mixin'
2
4
 
3
5
  require 'set'
4
6
 
@@ -1,2 +1,4 @@
1
- require 'combinatorics/cartesian_product/extensions/array'
2
- require 'combinatorics/cartesian_product/extensions/set'
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'extensions/array'
4
+ require_relative 'extensions/set'
@@ -1,4 +1,6 @@
1
- require 'combinatorics/list_comprehension'
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../list_comprehension'
2
4
 
3
5
  module Combinatorics
4
6
  module CartesianProduct
@@ -1,3 +1,5 @@
1
- require 'combinatorics/cartesian_product/mixin'
2
- require 'combinatorics/cartesian_product/extensions'
3
- require 'combinatorics/cartesian_product/cardinality'
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'cartesian_product/mixin'
4
+ require_relative 'cartesian_product/extensions'
5
+ require_relative 'cartesian_product/cardinality'
@@ -1,4 +1,6 @@
1
- require 'combinatorics/extensions/math'
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../extensions/math'
2
4
 
3
5
  module Combinatorics
4
6
  #
@@ -1,4 +1,6 @@
1
- require 'combinatorics/choose/mixin'
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../mixin'
2
4
 
3
5
  class Array
4
6
  include Combinatorics::Choose::Mixin
@@ -1,5 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../mixin'
4
+
1
5
  require 'set'
2
- require 'combinatorics/choose/mixin'
3
6
 
4
7
  class Set
5
8
  include Combinatorics::Choose::Mixin
@@ -1,2 +1,4 @@
1
- require 'combinatorics/choose/extensions/array'
2
- require 'combinatorics/choose/extensions/set'
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'extensions/array'
4
+ require_relative 'extensions/set'
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'set'
2
4
 
3
5
  module Combinatorics
@@ -1,3 +1,5 @@
1
- require 'combinatorics/choose/mixin'
2
- require 'combinatorics/choose/extensions'
3
- require 'combinatorics/choose/cardinality'
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'choose/mixin'
4
+ require_relative 'choose/extensions'
5
+ require_relative 'choose/cardinality'
@@ -1,4 +1,6 @@
1
- require 'combinatorics/extensions/math'
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../extensions/math'
2
4
 
3
5
  module Combinatorics
4
6
  module Derange
@@ -1,4 +1,6 @@
1
- require 'combinatorics/derange/mixin'
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../mixin'
2
4
 
3
5
  class Array
4
6
  include Combinatorics::Derange::Mixin
@@ -1 +1,3 @@
1
- require 'combinatorics/derange/extensions/array'
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'extensions/array'
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Combinatorics
2
4
  module Derange
3
5
  #
@@ -1,3 +1,5 @@
1
- require 'combinatorics/derange/mixin'
2
- require 'combinatorics/derange/extensions'
3
- require 'combinatorics/derange/cardinality'
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'derange/mixin'
4
+ require_relative 'derange/extensions'
5
+ require_relative 'derange/cardinality'
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'enumerator'
2
4
 
3
5
  module Combinatorics
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  #
2
4
  # @author duper <super@manson.vistech.net>
3
5
  #
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Range
2
4
 
3
5
  #
@@ -1 +1,3 @@
1
- require 'combinatorics/extensions/range'
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'extensions/range'
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'enumerator'
2
4
  require 'generator' if RUBY_VERSION < '1.9'
3
5
 
@@ -1,4 +1,6 @@
1
- require 'combinatorics/enumerator'
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'enumerator'
2
4
 
3
5
  class Array
4
6
 
@@ -1,4 +1,6 @@
1
- require 'combinatorics/extensions/math'
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../extensions/math'
2
4
 
3
5
  module Combinatorics
4
6
  #
@@ -1,4 +1,6 @@
1
- require 'combinatorics/permute/mixin'
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../mixin'
2
4
 
3
5
  class Array
4
6
 
@@ -1,4 +1,6 @@
1
- require 'combinatorics/permute/mixin'
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../mixin'
2
4
 
3
5
  require 'set'
4
6
 
@@ -1,2 +1,4 @@
1
- require 'combinatorics/permute/extensions/array'
2
- require 'combinatorics/permute/extensions/set'
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'extensions/array'
4
+ require_relative 'extensions/set'
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Combinatorics
2
4
  module Permute
3
5
  #
@@ -1,3 +1,5 @@
1
- require 'combinatorics/permute/cardinality'
2
- require 'combinatorics/permute/mixin'
3
- require 'combinatorics/permute/extensions'
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'permute/cardinality'
4
+ require_relative 'permute/mixin'
5
+ require_relative 'permute/extensions'
@@ -1,4 +1,6 @@
1
- require 'combinatorics/extensions/math'
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../extensions/math'
2
4
 
3
5
  module Combinatorics
4
6
  module PowerSet
@@ -1,4 +1,6 @@
1
- require 'combinatorics/power_set/mixin'
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../mixin'
2
4
 
3
5
  class Array
4
6
 
@@ -1,4 +1,6 @@
1
- require 'combinatorics/power_set/mixin'
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../mixin'
2
4
 
3
5
  require 'set'
4
6
 
@@ -1,2 +1,4 @@
1
- require 'combinatorics/power_set/extensions/array'
2
- require 'combinatorics/power_set/extensions/set'
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'extensions/array'
4
+ require_relative 'extensions/set'
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Combinatorics
2
4
  module PowerSet
3
5
  #
@@ -1,3 +1,5 @@
1
- require 'combinatorics/power_set/mixin'
2
- require 'combinatorics/power_set/extensions'
3
- require 'combinatorics/power_set/cardinality'
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'power_set/mixin'
4
+ require_relative 'power_set/extensions'
5
+ require_relative 'power_set/cardinality'
@@ -1,4 +1,6 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Combinatorics
2
4
  # Combinatorics module revision number
3
- VERSION = '0.4.4'
5
+ VERSION = '0.5.0'
4
6
  end
data/lib/combinatorics.rb CHANGED
@@ -1,11 +1,13 @@
1
- require 'combinatorics/cartesian_product'
2
- require 'combinatorics/choose'
3
- require 'combinatorics/derange'
4
- require 'combinatorics/extensions'
5
- require 'combinatorics/list_comprehension'
6
- require 'combinatorics/power_set'
7
- require 'combinatorics/permute'
8
- require 'combinatorics/version'
1
+ # frozen_string_literal: true
9
2
 
10
- # @todo inversions (permutation mutations)
11
- # @todo set families (approximate power set subsets)
3
+ require_relative 'combinatorics/cartesian_product'
4
+ require_relative 'combinatorics/choose'
5
+ require_relative 'combinatorics/derange'
6
+ require_relative 'combinatorics/extensions'
7
+ require_relative 'combinatorics/list_comprehension'
8
+ require_relative 'combinatorics/power_set'
9
+ require_relative 'combinatorics/permute'
10
+ require_relative 'combinatorics/version'
11
+
12
+ # TODO: inversions (permutation mutations)
13
+ # TODO: set families (approximate power set subsets)
@@ -1,9 +1,7 @@
1
1
  require 'spec_helper'
2
2
  require 'combinatorics/cartesian_product'
3
3
 
4
- describe CartesianProduct do
5
- subject { CartesianProduct }
6
-
4
+ describe Combinatorics::CartesianProduct do
7
5
  describe "cardinality" do
8
6
  it "should return 1 for cardinality(1, 1)" do
9
7
  expect(subject.cardinality(1, 1)).to eq(1)
@@ -1,9 +1,7 @@
1
1
  require 'spec_helper'
2
2
  require 'combinatorics/choose'
3
3
 
4
- describe Choose do
5
- subject { Choose }
6
-
4
+ describe Combinatorics::Choose do
7
5
  describe "cardinality" do
8
6
  it "should raise RangeError if n is negative" do
9
7
  expect { subject.cardinality(-1) }.to raise_error(RangeError)
@@ -1,9 +1,7 @@
1
1
  require 'spec_helper'
2
2
  require 'combinatorics/derange/cardinality'
3
3
 
4
- describe Derange do
5
- subject { Derange }
6
-
4
+ describe Combinatorics::Derange do
7
5
  it "should alias cardinality to subfactorial" do
8
6
  should respond_to(:cardinality)
9
7
  end
@@ -1,9 +1,7 @@
1
1
  require 'spec_helper'
2
2
  require 'combinatorics/permute'
3
3
 
4
- describe Permute do
5
- subject { Permute }
6
-
4
+ describe Combinatorics::Permute do
7
5
  describe "cardinality" do
8
6
  it "should raise RangeError if n is negative without passing r" do
9
7
  expect { subject.cardinality(-1) }.to raise_error(RangeError)
@@ -1,9 +1,7 @@
1
1
  require 'spec_helper'
2
2
  require 'combinatorics/power_set'
3
3
 
4
- describe PowerSet do
5
- subject { PowerSet }
6
-
4
+ describe Combinatorics::PowerSet do
7
5
  describe "cardinality" do
8
6
  it "should return 1 for cardinality(0)" do
9
7
  subject.cardinality(0) == 1
data/spec/spec_helper.rb CHANGED
@@ -1,4 +1,3 @@
1
1
  require 'rspec'
2
- require 'combinatorics/version'
3
-
4
- include Combinatorics
2
+ require 'simplecov'
3
+ SimpleCov.start
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: combinatorics
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.4
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Postmodern
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2022-01-17 00:00:00.000000000 Z
12
+ date: 2024-01-25 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -38,7 +38,6 @@ extra_rdoc_files:
38
38
  - README.md
39
39
  files:
40
40
  - ".document"
41
- - ".gemtest"
42
41
  - ".github/workflows/ruby.yml"
43
42
  - ".gitignore"
44
43
  - ".rspec"
@@ -137,14 +136,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
137
136
  requirements:
138
137
  - - ">="
139
138
  - !ruby/object:Gem::Version
140
- version: 1.8.7
139
+ version: 2.0.0
141
140
  required_rubygems_version: !ruby/object:Gem::Requirement
142
141
  requirements:
143
142
  - - ">="
144
143
  - !ruby/object:Gem::Version
145
144
  version: '0'
146
145
  requirements: []
147
- rubygems_version: 3.2.22
146
+ rubygems_version: 3.4.10
148
147
  signing_key:
149
148
  specification_version: 4
150
149
  summary: Bringing (more) Combinatorics to Ruby
data/.gemtest DELETED
File without changes