continued_fractions 1.8.1 → 1.8.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6f5e54a2a88348ca82c9441587086590b750fd8535da5299c2d952d3dd8238f5
4
- data.tar.gz: 1778ffab3d3d9550d8227c2d99dd6370f5ea4c9a4ef53eac998ddfb06cfb182c
3
+ metadata.gz: fc3cc4f4da6b42a3c0ef5cf2824484521259c8166aa17d27647daeff911039da
4
+ data.tar.gz: 63349536f6492a66972004b7a65db93db0c63c1835d4652a74ff9198a738e711
5
5
  SHA512:
6
- metadata.gz: 88c8d2bc9140b2b0b983af39d075f810349fa3fed4111e3e5e32029e680a5e717ccfefed0049c3de5b4faeefdd3233b5945273471a1b4573f1563980be1789ea
7
- data.tar.gz: 6cec9280ee990520504d076d38d485118ea12458e5f4b644fd0c39e498738bd416c2b2b1194ac53028f98c7af56eb30c08a55129f9b551bbf0af462c2d5a5226
6
+ metadata.gz: fb01d65d0952130b356d90c20d6ee980fe16001f6973a45e1c4e3a798e4246e544e813954d6eb8a633eaf8c4723fa01da6a3692a7114cf6af7d93bb0f3445baf
7
+ data.tar.gz: e99077dfdd3897a341c04eb8d73fe0c455b5ddd6fbf2139472d02259dc79d4c589f3c90845bd5d1aaacfba09e7a11906729d28651a212e19567dc3e14a27186f
@@ -0,0 +1,23 @@
1
+ 1.8.2 - Make gemspec data dynamic
2
+
3
+ 1.8.1 - Include Github repo in gemspec
4
+
5
+ 1.8.0 - Add comparison
6
+
7
+ 1.7.0 - Accept Float and Rational as well as Integer in operators
8
+
9
+ 1.6.1 - Remove dependency on Echoe
10
+
11
+ v1.6.0 Handle rational numbers, finite continued fractions
12
+
13
+ v1.5.0 Remove ContinuedFractions module; Move its methods into ContinuedFraction class
14
+
15
+ v1.4.0 Eliminate need to invoke "include ContinuedFractions"
16
+
17
+ v1.3.0 Add binary operators: + - * /
18
+
19
+ v1.2.0 Change parameter signature of ContinuedFraction#convergents_as_rationals
20
+
21
+ v1.1.0 Change public class representation of convergents from an array of Rationals to an array of arrays.
22
+
23
+ v0.1.0 Initial release
@@ -1,3 +1,3 @@
1
1
  module ContinuedFractions
2
- VERSION = "1.8.1"
2
+ VERSION = "1.8.2"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: continued_fractions
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.8.1
4
+ version: 1.8.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jose Hales-Garcia
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-10-26 00:00:00.000000000 Z
11
+ date: 2019-09-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -33,15 +33,11 @@ extra_rdoc_files:
33
33
  - README.md
34
34
  - lib/continued_fractions.rb
35
35
  files:
36
- - Gemfile
36
+ - CHANGELOG.md
37
37
  - LICENSE
38
38
  - README.md
39
- - Rakefile
40
- - continued_fractions.gemspec
41
39
  - lib/continued_fractions.rb
42
40
  - lib/continued_fractions/version.rb
43
- - spec/continued_fractions/continued_fraction_spec.rb
44
- - spec/spec_helper.rb
45
41
  homepage: http://jolohaga.github.io/continued_fractions
46
42
  licenses:
47
43
  - MIT
data/Gemfile DELETED
@@ -1,4 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- # Specify your gem's dependencies in continued_fractions.gemspec
4
- gemspec
data/Rakefile DELETED
@@ -1,6 +0,0 @@
1
- require "bundler/gem_tasks"
2
- require "rspec/core/rake_task"
3
-
4
- RSpec::Core::RakeTask.new(:spec)
5
-
6
- task :default => :spec
@@ -1,40 +0,0 @@
1
- # -*- encoding: utf-8 -*-
2
- lib = File.expand_path('../lib', __FILE__)
3
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require 'continued_fractions/version'
5
-
6
- Gem::Specification.new do |spec|
7
- spec.name = "continued_fractions"
8
- spec.version = ContinuedFractions::VERSION
9
-
10
- spec.required_rubygems_version = Gem::Requirement.new(">= 1.2") if spec.respond_to? :required_rubygems_version=
11
- spec.require_paths = ["lib"]
12
- spec.authors = ["Jose Hales-Garcia"]
13
- spec.date = "2016-10-26"
14
- spec.description = "Class for working with continued fractions"
15
- spec.email = "jolohaga@me.com"
16
- spec.extra_rdoc_files = ["LICENSE", "README.md", "lib/continued_fractions.rb"]
17
- spec.files = ["Gemfile", "LICENSE", "README.md", "Rakefile", "continued_fractions.gemspec", "lib/continued_fractions.rb", "lib/continued_fractions/version.rb", "spec/continued_fractions/continued_fraction_spec.rb", "spec/spec_helper.rb"]
18
- spec.homepage = "http://jolohaga.github.io/continued_fractions"
19
- spec.licenses = ["MIT"]
20
- spec.rdoc_options = ["--line-numbers", "--title", "continued_fractions", "--main", "README.md"]
21
- spec.required_ruby_version = Gem::Requirement.new(">= 2.2.2")
22
- spec.rubyforge_project = "continued_fractions"
23
- spec.rubygems_version = "3.0.3"
24
- spec.summary = "Generate continued fractions"
25
- spec.metadata = {
26
- "source_code_uri" => "https://github.com/jolohaga/continued_fractions"
27
- }
28
-
29
- if spec.respond_to? :specification_version then
30
- spec.specification_version = 4
31
-
32
- if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
33
- spec.add_development_dependency(%q<rspec>, ["~> 3.2"])
34
- else
35
- spec.add_dependency(%q<rspec>, ["~> 3.2"])
36
- end
37
- else
38
- spec.add_dependency(%q<rspec>, ["~> 3.2"])
39
- end
40
- end
@@ -1,90 +0,0 @@
1
- require File.join(File.dirname(__FILE__), "/../spec_helper")
2
-
3
- describe ContinuedFraction do
4
- let(:cf) { described_class.new(number, 10) }
5
- let(:number) { rand }
6
-
7
- describe '#convergents' do
8
- it "returns an array" do
9
- expect(cf.convergents).to be_kind_of(Array)
10
- end
11
-
12
- context 'with irrational numbers' do
13
- it "accurately calculates the convergents" do
14
- # First 10 convergents of PI are...
15
- convs = [3/1r, 22/7r, 333/106r, 355/113r, 103993/33102r, 104348/33215r, 208341/66317r, 312689/99532r, 833719/265381r, 1146408/364913r]
16
- cf = described_class.new(Math::PI,10)
17
- expect((cf.convergents_as_rationals - convs)).to be_empty
18
- end
19
-
20
- it "contains convergents approaching the number" do
21
- 0.upto(cf.convergents.length-2) do |i|
22
- convergent_rational_i_plus1, convergent_rational_i = cf.convergent_to_rational(cf.convergents[i+1]), cf.convergent_to_rational(cf.convergents[i])
23
- expect(((convergent_rational_i_plus1 - cf.number).abs <= (convergent_rational_i - cf.number).abs)).to be true
24
- end
25
- end
26
-
27
- it "contains convergents which are expressed in lowest terms" do
28
- 1.upto(cf.convergents.length-1) do |i|
29
- convergent_rational_i, convergent_rational_i_plus1 = cf.convergent_to_rational(cf.convergent(i)), cf.convergent_to_rational(cf.convergent(i+1))
30
- expect((convergent_rational_i.numerator*convergent_rational_i_plus1.denominator - convergent_rational_i_plus1.numerator*convergent_rational_i.denominator)).to eq (-1)**(i)
31
- end
32
- end
33
- end
34
-
35
- context 'with rational numbers' do
36
- it 'changes the limit to the number of convergents calculated' do
37
- expect(described_class.new(1.5, 10).limit).to be 2
38
- end
39
-
40
- it 'calculates the convergents' do
41
- convs = [ 1/1r, 3/2r ]
42
- expect(described_class.new(1.5, 10).convergents_as_rationals - convs).to be_empty
43
- end
44
- end
45
- end
46
-
47
- describe '#number' do
48
- it "preserves the number input" do
49
- expect(cf.number).to eq number
50
- end
51
- end
52
-
53
- describe 'operators' do
54
- let(:cf2) { described_class.new(rand, 20) }
55
-
56
- %i{+ - * /}.each do |op|
57
- describe "#{op}" do
58
- [3, 3.0, 3/1r, described_class.new(rand, 20)].each do |rhs|
59
- it "#{rhs.class.name} operates on the right-hand side and returns a ContinuedFraction" do
60
- expect(cf.send(op, rhs)).to be_kind_of(ContinuedFraction)
61
- end
62
- end
63
-
64
- it "Assigns the max limit of the two operands" do
65
- result = cf.send(op, cf2)
66
- expect(result.limit).to eq [cf.limit, cf2.limit].max
67
- end
68
- end
69
- end
70
- end
71
-
72
- describe 'comparing' do
73
- context 'when numbers are the same' do
74
- let(:cf2) { described_class.new(cf.number) }
75
-
76
- it "the ContinuedFractions are equal" do
77
- expect(cf).to eq cf2
78
- end
79
- end
80
-
81
- context 'when numbers are different' do
82
- let(:cond) { [['+', '<'], ['-', '>']].sample }
83
- let(:cf2) { described_class.new(cf.number.send(cond[0], 1.0)) }
84
-
85
- it "the ContinuedFractions are unequal" do
86
- expect(cf.send(cond[1], cf2)).to be true
87
- end
88
- end
89
- end
90
- end
@@ -1,13 +0,0 @@
1
- $LOAD_PATH << File.join(File.dirname(__FILE__), "/../lib")
2
- require 'rubygems'
3
- require 'rspec'
4
- require 'continued_fractions'
5
-
6
- RSpec.configure do |config|
7
- # Run specs in random order to surface order dependencies. If you find an
8
- # order dependency and want to debug it, you can fix the order by providing
9
- # the seed, which is printed after each run.
10
- # --seed 1234
11
- config.order = "random"
12
- config.formatter = :documentation
13
- end