continued_fractions 0.1.6 → 0.1.7

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.
@@ -1,3 +1,7 @@
1
+ === 0.1.7 / 2010-03-15
2
+
3
+ * Including spec files in distribution (forgot to add them to the manifest).
4
+
1
5
  === 0.1.6 / 2010-03-15
2
6
 
3
7
  * Refactored code generating matrix that holds convergences. Renamed the method convergence_matrix.
data/Manifest CHANGED
@@ -3,3 +3,5 @@ Manifest
3
3
  README.txt
4
4
  Rakefile
5
5
  lib/continued_fractions.rb
6
+ spec/continued_fractions/continued_fraction_spec.rb
7
+ spec/spec_helper.rb
data/Rakefile CHANGED
@@ -2,7 +2,7 @@ require 'rubygems'
2
2
  require 'rake'
3
3
  require 'echoe'
4
4
 
5
- Echoe.new('continued_fractions', '0.1.6') do |config|
5
+ Echoe.new('continued_fractions', '0.1.7') do |config|
6
6
  config.description = 'Generate continued fractions.'
7
7
  config.author = 'Jose Hales-Garcia'
8
8
  config.url = 'http://bitbucket.org/jolohaga/continued_fractions/'
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{continued_fractions}
5
- s.version = "0.1.6"
5
+ s.version = "0.1.7"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Jose Hales-Garcia"]
@@ -10,7 +10,7 @@ Gem::Specification.new do |s|
10
10
  s.description = %q{Generate continued fractions.}
11
11
  s.email = %q{jolohaga@me.com}
12
12
  s.extra_rdoc_files = ["README.txt", "lib/continued_fractions.rb"]
13
- s.files = ["History.txt", "Manifest", "README.txt", "Rakefile", "lib/continued_fractions.rb", "continued_fractions.gemspec"]
13
+ s.files = ["History.txt", "Manifest", "README.txt", "Rakefile", "lib/continued_fractions.rb", "spec/continued_fractions/continued_fraction_spec.rb", "spec/spec_helper.rb", "continued_fractions.gemspec"]
14
14
  s.homepage = %q{http://bitbucket.org/jolohaga/continued_fractions/}
15
15
  s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Continued_fractions", "--main", "README.txt"]
16
16
  s.require_paths = ["lib"]
@@ -1,4 +1,4 @@
1
- module ContinuedFractions
1
+ module ContinuedFractions #:nodoc:
2
2
  # Requires Ruby 1.9
3
3
  class ContinuedFraction
4
4
  attr_accessor :number, :quotients, :limit
@@ -0,0 +1,35 @@
1
+ require File.join(File.dirname(__FILE__), "/../spec_helper")
2
+
3
+ module ContinuedFractions
4
+ describe ContinuedFraction do
5
+ it "should accurately calculate the convergents of a real number" do
6
+ # First 10 convergents of PI are...
7
+ convs = ['3/1', '22/7', '333/106', '355/113', '103993/33102', '104348/33215', '208341/66317', '312689/99532', '833719/265381', '1146408/364913'].map{|c| Rational(c)}
8
+ @cf = ContinuedFraction.new(Math::PI,10)
9
+ (@cf.convergents - convs).empty?.should == true
10
+ end
11
+
12
+ before(:each) do
13
+ @number = rand
14
+ @cf = ContinuedFraction.new(@number,10)
15
+ end
16
+
17
+ it "should return array for convergents method" do
18
+ @cf.convergents.class.should == Array
19
+ end
20
+
21
+ it "should preserve the number input" do
22
+ @cf.number.should == @number
23
+ end
24
+
25
+ it "should contain convergents approaching the number" do
26
+ 0.upto(@cf.convergents.length) do |i|
27
+ begin
28
+ (@cf.convergents[i+1] - @cf.number).abs <= (@cf.convergents[i] - @cf.number).abs.should == true
29
+ rescue
30
+ # i+1 has run past the limit of the array.
31
+ end
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,4 @@
1
+ $LOAD_PATH << File.join(File.dirname(__FILE__), "/../lib")
2
+ require 'rubygems'
3
+ require 'spec'
4
+ require 'continued_fractions'
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 1
8
- - 6
9
- version: 0.1.6
8
+ - 7
9
+ version: 0.1.7
10
10
  platform: ruby
11
11
  authors:
12
12
  - Jose Hales-Garcia
@@ -33,6 +33,8 @@ files:
33
33
  - README.txt
34
34
  - Rakefile
35
35
  - lib/continued_fractions.rb
36
+ - spec/continued_fractions/continued_fraction_spec.rb
37
+ - spec/spec_helper.rb
36
38
  - continued_fractions.gemspec
37
39
  has_rdoc: true
38
40
  homepage: http://bitbucket.org/jolohaga/continued_fractions/