borel 0.3.4 → 0.4.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.
- checksums.yaml +7 -0
- data/.gitignore +1 -0
- data/.travis.yml +13 -0
- data/Changes.md +7 -0
- data/Gemfile +7 -6
- data/README.md +16 -1
- data/Rakefile +4 -2
- data/lib/borel/interval.rb +0 -6
- data/lib/borel/interval_simple.rb +3 -1
- data/lib/borel/version.rb +2 -2
- data/lib/tasks/gem.rb +9 -0
- data/{tasks → lib/tasks}/rspec.rb +0 -0
- data/spec/array_spec.rb +1 -0
- data/spec/interval_multiple_spec.rb +1 -0
- data/spec/interval_simple_spec.rb +12 -0
- data/spec/interval_spec.rb +1 -0
- data/spec/math_extensions/interval_arithmetic_spec.rb +1 -0
- data/spec/math_extensions/randomizable_spec.rb +2 -1
- data/spec/math_extensions_spec.rb +1 -0
- data/spec/nil_class_spec.rb +1 -0
- data/spec/numeric_spec.rb +1 -0
- data/spec/range_spec.rb +1 -0
- data/spec/spec_helper.rb +8 -0
- metadata +17 -17
- data/tasks/gem.rb +0 -28
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 0a103a33e79f18299ce5153dbfde44acabac24fe
|
4
|
+
data.tar.gz: 7723990250221d1084db8d74c27f79a71296b739
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: abb376784ea3a9e1b2f2e691f8c9bd4b113abe0f973104ed44361116851069a69ab014aa148b323ba26885f7584182e095e5b2a6cd158f505ce038375b69a99d
|
7
|
+
data.tar.gz: d36bbc7b73a75d1fc69555924603c05a6401c307b65cc7bcaed66eb9c58edb23094a9114a8cc0b177bb4c1cbb8a8554f1b31ac0a88998a28bea5e6abedf6249b
|
data/.gitignore
CHANGED
data/.travis.yml
ADDED
data/Changes.md
ADDED
data/Gemfile
CHANGED
@@ -2,10 +2,11 @@ source "http://www.rubygems.org"
|
|
2
2
|
|
3
3
|
gemspec
|
4
4
|
|
5
|
-
group :development do
|
6
|
-
gem '
|
7
|
-
gem '
|
8
|
-
|
9
|
-
|
10
|
-
|
5
|
+
group :development, :test do
|
6
|
+
gem 'rake'
|
7
|
+
gem 'rspec', '~> 2'
|
8
|
+
end
|
9
|
+
|
10
|
+
group :test do
|
11
|
+
gem 'coveralls', require: false
|
11
12
|
end
|
data/README.md
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
Borel
|
2
2
|
=====
|
3
3
|
|
4
|
+
[](https://travis-ci.org/badosu/borel) [](http://badge.fury.io/rb/borel) [](https://codeclimate.com/github/badosu/borel)
|
5
|
+
|
4
6
|
Borelian sets are formed by enumerable union, intersection or
|
5
7
|
complement, of intervals.
|
6
8
|
|
@@ -146,7 +148,20 @@ Interval[1,5].rand # -> Random.new.rand 1..5
|
|
146
148
|
Interval[1,5].width # -> 5-1, only for simple intervals
|
147
149
|
```
|
148
150
|
|
149
|
-
It's supported only for `Numeric`, `Comparable` and arithmetic supported
|
151
|
+
It's supported only for `Numeric`, `Comparable` and arithmetic supported
|
152
|
+
classes
|
153
|
+
|
154
|
+
Implementations
|
155
|
+
---------------
|
156
|
+
|
157
|
+
The following engines and versions are continuosly tested:
|
158
|
+
|
159
|
+
* MRI 1.9.3
|
160
|
+
* MRI 2.0.0
|
161
|
+
* Latest jRuby Stable
|
162
|
+
* Latest Rubinius Stable
|
163
|
+
|
164
|
+
MRI 1.8.7 has limited supported with some patches
|
150
165
|
|
151
166
|
Remarks
|
152
167
|
-------
|
data/Rakefile
CHANGED
@@ -1,6 +1,8 @@
|
|
1
|
-
task_file_pattern = File.expand_path("../tasks/**/*.rb", __FILE__)
|
1
|
+
task_file_pattern = File.expand_path("../lib/tasks/**/*.rb", __FILE__)
|
2
2
|
Dir[task_file_pattern].each do |task_file|
|
3
3
|
require File.expand_path(task_file)
|
4
4
|
end
|
5
5
|
|
6
|
-
|
6
|
+
require 'bundler/gem_tasks'
|
7
|
+
|
8
|
+
task :default => [ :spec ]
|
data/lib/borel/interval.rb
CHANGED
@@ -71,12 +71,6 @@ class Interval
|
|
71
71
|
Interval.union(other.to_interval, self)
|
72
72
|
end
|
73
73
|
|
74
|
-
# @return [Interval]
|
75
|
-
def intersect(other)
|
76
|
-
other.to_interval.map{|y| map{|x| x.intersect(y)}}.
|
77
|
-
flatten.reduce(:union) || Interval[]
|
78
|
-
end
|
79
|
-
|
80
74
|
# @return [Interval]
|
81
75
|
def complement
|
82
76
|
map{|x| x.to_interval.map(&:complement).reduce(:intersect)}.
|
@@ -21,7 +21,9 @@ class Interval::Simple < Interval
|
|
21
21
|
|
22
22
|
# @return [Interval]
|
23
23
|
def intersect(other)
|
24
|
-
|
24
|
+
other.map{ |component|
|
25
|
+
Interval[[inf, component.inf].max, [sup, component.sup].min]
|
26
|
+
}.reduce(:union) || Interval[]
|
25
27
|
end
|
26
28
|
|
27
29
|
# @return [Interval::Multiple]
|
data/lib/borel/version.rb
CHANGED
data/lib/tasks/gem.rb
ADDED
File without changes
|
data/spec/array_spec.rb
CHANGED
data/spec/interval_spec.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
require 'spec_helper'
|
1
2
|
require 'borel/math_extensions/randomizable'
|
2
3
|
|
3
4
|
describe Borel::Randomizable do
|
@@ -11,7 +12,7 @@ describe Borel::Randomizable do
|
|
11
12
|
|
12
13
|
context '#random' do
|
13
14
|
let(:interval){ Interval[1,10] }
|
14
|
-
let(:rand_mock) {
|
15
|
+
let(:rand_mock) { double }
|
15
16
|
|
16
17
|
it 'should be a point inside the interval' do
|
17
18
|
interval.should include interval.rand
|
data/spec/nil_class_spec.rb
CHANGED
data/spec/numeric_spec.rb
CHANGED
data/spec/range_spec.rb
CHANGED
data/spec/spec_helper.rb
ADDED
metadata
CHANGED
@@ -1,28 +1,28 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: borel
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
5
|
-
prerelease:
|
4
|
+
version: 0.4.0
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Amadeus Folego
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2016-07-29 00:00:00.000000000 Z
|
13
12
|
dependencies: []
|
14
|
-
description:
|
15
|
-
|
13
|
+
description: |-
|
14
|
+
Borel sets are made of enumerable union and intersection of
|
16
15
|
intervals. Borel performs regular operations on intervals of any
|
17
|
-
|
18
|
-
Comparable class.'
|
16
|
+
Comparable class.
|
19
17
|
email:
|
20
18
|
- amadeusfolego@gmail.com
|
21
19
|
executables: []
|
22
20
|
extensions: []
|
23
21
|
extra_rdoc_files: []
|
24
22
|
files:
|
25
|
-
- .gitignore
|
23
|
+
- ".gitignore"
|
24
|
+
- ".travis.yml"
|
25
|
+
- Changes.md
|
26
26
|
- Gemfile
|
27
27
|
- Guardfile
|
28
28
|
- LICENSE
|
@@ -42,8 +42,11 @@ files:
|
|
42
42
|
- lib/borel/numeric.rb
|
43
43
|
- lib/borel/range.rb
|
44
44
|
- lib/borel/version.rb
|
45
|
+
- lib/tasks/gem.rb
|
46
|
+
- lib/tasks/rspec.rb
|
45
47
|
- spec/array_spec.rb
|
46
48
|
- spec/interval_multiple_spec.rb
|
49
|
+
- spec/interval_simple_spec.rb
|
47
50
|
- spec/interval_spec.rb
|
48
51
|
- spec/math_extensions/interval_arithmetic_spec.rb
|
49
52
|
- spec/math_extensions/randomizable_spec.rb
|
@@ -51,31 +54,28 @@ files:
|
|
51
54
|
- spec/nil_class_spec.rb
|
52
55
|
- spec/numeric_spec.rb
|
53
56
|
- spec/range_spec.rb
|
54
|
-
-
|
55
|
-
- tasks/rspec.rb
|
57
|
+
- spec/spec_helper.rb
|
56
58
|
homepage: http://github.com/badosu/borel
|
57
59
|
licenses: []
|
60
|
+
metadata: {}
|
58
61
|
post_install_message:
|
59
62
|
rdoc_options: []
|
60
63
|
require_paths:
|
61
64
|
- lib
|
62
65
|
required_ruby_version: !ruby/object:Gem::Requirement
|
63
|
-
none: false
|
64
66
|
requirements:
|
65
|
-
- -
|
67
|
+
- - ">="
|
66
68
|
- !ruby/object:Gem::Version
|
67
69
|
version: 1.9.2
|
68
70
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
69
|
-
none: false
|
70
71
|
requirements:
|
71
|
-
- -
|
72
|
+
- - ">="
|
72
73
|
- !ruby/object:Gem::Version
|
73
74
|
version: 1.3.6
|
74
75
|
requirements: []
|
75
76
|
rubyforge_project: borel
|
76
|
-
rubygems_version:
|
77
|
+
rubygems_version: 2.5.1
|
77
78
|
signing_key:
|
78
|
-
specification_version:
|
79
|
+
specification_version: 4
|
79
80
|
summary: Interval operation on Comparable classes
|
80
81
|
test_files: []
|
81
|
-
has_rdoc:
|
data/tasks/gem.rb
DELETED
@@ -1,28 +0,0 @@
|
|
1
|
-
gemspec = eval(File.read("borel.gemspec"))
|
2
|
-
|
3
|
-
desc "Validate the gemspec"
|
4
|
-
task :gemspec do
|
5
|
-
gemspec.validate
|
6
|
-
end
|
7
|
-
|
8
|
-
desc "Build gem locally"
|
9
|
-
task :build => :gemspec do
|
10
|
-
system "gem build #{gemspec.name}.gemspec"
|
11
|
-
FileUtils.mkdir_p "pkg"
|
12
|
-
FileUtils.mv "#{gemspec.name}-#{gemspec.version}.gem", "pkg"
|
13
|
-
end
|
14
|
-
|
15
|
-
desc "Install gem locally"
|
16
|
-
task :install => :build do
|
17
|
-
system "gem install pkg/#{gemspec.name}-#{gemspec.version}"
|
18
|
-
end
|
19
|
-
|
20
|
-
desc "Launches interactive console with borel"
|
21
|
-
task :console => :install do
|
22
|
-
system "irb -r #{gemspec.name}"
|
23
|
-
end
|
24
|
-
|
25
|
-
desc "Clean automatically generated files"
|
26
|
-
task :clean do
|
27
|
-
FileUtils.rm_rf "pkg"
|
28
|
-
end
|