sane 0.22.0 → 0.23.0

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.22.0
1
+ 0.23.0
data/lib/sane/float.rb CHANGED
@@ -1,7 +1,15 @@
1
1
  if RUBY_VERSION < '1.9.2'
2
2
  class Float
3
3
  def inspect
4
- "%.20f" % self # big!
4
+ big = "%.20f" % self # big!
5
+ small = "%f" % self
6
+
7
+ if small.to_f == self
8
+ small.sub! /0+$/, ''
9
+ small.sub /\.$/, '.0'
10
+ else
11
+ big
12
+ end
5
13
  end
6
14
  end
7
15
  end
data/lib/sane.rb CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  require 'os'
7
7
  require 'andand'
8
- for file in Dir[File.dirname(__FILE__) + '/sane/*'] do
8
+ for file in Dir[File.dirname(__FILE__) + '/sane/*.rb'] do
9
9
  require file
10
10
  end
11
11
 
data/spec/spec.sane.rb CHANGED
@@ -1,7 +1,13 @@
1
1
  $:.unshift File.expand_path('../lib')
2
2
  require 'rubygems'
3
3
  require File.dirname(__FILE__) + '/../lib/sane'
4
- require 'spec/autorun'
4
+ begin
5
+ require 'spec/autorun'
6
+ rescue LoadError
7
+ require 'rspec'
8
+ end
9
+ require 'fileutils'
10
+
5
11
 
6
12
  class Object
7
13
  alias :yes :should # a.yes == [3]
@@ -81,7 +87,10 @@ describe Sane do
81
87
  # end
82
88
 
83
89
  it "should have verbose looking float#inspect" do
84
- assert( (1.1 - 0.9).inspect.include?('0.2000000')) # 0.20000000000000006661 or something close to it
90
+ (1.1 - 0.9).inspect.should include('0.2000000') # 0.20000000000000006661 or something close to it
91
+ 1.1.inspect.should == "1.1"
92
+ 1.0.inspect.should == "1.0"
93
+
85
94
  end
86
95
 
87
96
  it "should return false if you call File.executable? non_existent_file" do
@@ -164,5 +173,12 @@ describe Sane do
164
173
  a = Thread.new { sleep 1 }
165
174
  assert Benchmark.realtime{Thread.join_all_others} > 0.5
166
175
  end
176
+
177
+ it "should have an insert commas operator on numbers" do
178
+ 1_000_000.comma_format.should == '1,000,000'
179
+ 1_000_000.0.comma_format.should == '1,000,000.0'
180
+ 1_000_000.0.comma_format.should == '1,000,000.0'
181
+ end
182
+
167
183
 
168
184
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sane
3
3
  version: !ruby/object:Gem::Version
4
- hash: 71
4
+ hash: 67
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
- - 22
8
+ - 23
9
9
  - 0
10
- version: 0.22.0
10
+ version: 0.23.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Roger Pack
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-07-06 00:00:00 -06:00
18
+ date: 2010-07-21 00:00:00 -06:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency