ruby-units 1.3.1 → 1.3.2.a
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.
- data/CHANGELOG.txt +8 -0
- data/Gemfile +4 -0
- data/README.md +3 -3
- data/RakeFile +36 -9
- data/VERSION +1 -1
- data/autotest/discover.rb +1 -0
- data/lib/ruby_units/array.rb +1 -1
- data/lib/ruby_units/date.rb +5 -5
- data/lib/ruby_units/math.rb +6 -6
- data/lib/ruby_units/string.rb +105 -97
- data/lib/ruby_units/string/extra.rb +132 -0
- data/lib/ruby_units/time.rb +6 -6
- data/lib/ruby_units/unit.rb +55 -57
- data/lib/ruby_units/unit_definitions.rb +9 -5
- data/ruby-units.gemspec +21 -8
- data/spec/ruby-units/string/extra_spec.rb +45 -0
- data/spec/ruby-units/string_spec.rb +2 -43
- data/spec/ruby-units/unit_spec.rb +88 -11
- data/spec/spec_helper.rb +2 -1
- data/test/test_ruby-units.rb +16 -51
- metadata +121 -55
@@ -5,49 +5,7 @@ describe String do
|
|
5
5
|
specify { "1 mm".to_unit.should be_instance_of Unit }
|
6
6
|
specify { "1 mm".unit.should be_instance_of Unit }
|
7
7
|
specify { "1 mm".u.should be_instance_of Unit }
|
8
|
-
specify { "1 m".
|
9
|
-
end
|
10
|
-
|
11
|
-
context "Time syntax sugar" do
|
12
|
-
before(:each) do
|
13
|
-
Time.stub(:now).and_return(Time.at(1303656390))
|
14
|
-
Date.stub(:today).and_return(Date.new(2011,4,1))
|
15
|
-
DateTime.stub(:now).and_return(DateTime.new(2011,4,1,0,0,0))
|
16
|
-
end
|
17
|
-
specify { "5 min".ago.should be_instance_of Time }
|
18
|
-
|
19
|
-
specify { "5 min".from.should be_instance_of Time }
|
20
|
-
specify { "5 min".from('now').should be_instance_of Time }
|
21
|
-
specify { "5 min".from_now.should be_instance_of Time }
|
22
|
-
|
23
|
-
specify { "5 min".after('12:00').should be_instance_of Time }
|
24
|
-
|
25
|
-
specify { "5 min".before.should be_instance_of Time}
|
26
|
-
specify { "5 min".before('now').should be_instance_of Time}
|
27
|
-
specify { "5 min".before_now.should be_instance_of Time}
|
28
|
-
specify { "5 min".before('12:00').should be_instance_of Time}
|
29
|
-
|
30
|
-
specify { "min".since.should be_instance_of Unit}
|
31
|
-
specify { "min".since("12:00").should be_instance_of Unit}
|
32
|
-
specify { "min".since(Time.now - 60).should == Unit("1 min")}
|
33
|
-
specify { "days".since(Date.today - 3).should == Unit("3 d")}
|
34
|
-
specify { expect {"days".since(1000) }.to raise_error(ArgumentError, "Must specify a Time, DateTime, or String")}
|
35
|
-
|
36
|
-
specify { "min".until.should be_instance_of Unit}
|
37
|
-
specify { "min".until("12:00").should be_instance_of Unit}
|
38
|
-
specify { "min".until(Time.now + 60).should == Unit("1 min")}
|
39
|
-
specify { "days".until(Date.today + 3).should == Unit("3 d")}
|
40
|
-
specify { expect {"days".until(1000) }.to raise_error(ArgumentError, "Must specify a Time, DateTime, or String")}
|
41
|
-
|
42
|
-
specify { "today".to_date.should be_instance_of Date }
|
43
|
-
specify { "2011-4-1".to_date.should be_instance_of Date }
|
44
|
-
|
45
|
-
specify { "now".to_datetime.should be_instance_of DateTime }
|
46
|
-
specify { "now".to_time.should be_instance_of Time }
|
47
|
-
|
48
|
-
specify { "10001-01-01 12:00".time.should be_instance_of Time }
|
49
|
-
specify { "2001-01-01 12:00".time.should be_instance_of Time }
|
50
|
-
|
8
|
+
specify { "1 m".convert_to("ft").should be_within(Unit("0.01 ft")).of Unit("3.28084 ft") }
|
51
9
|
end
|
52
10
|
|
53
11
|
context "output format" do
|
@@ -58,4 +16,5 @@ describe String do
|
|
58
16
|
specify { ("km/h^2" % subject).should == "15999.9 km/h^2"}
|
59
17
|
specify { ("%H:%M:%S" % Unit("1.5 h")).should == "01:30:00"}
|
60
18
|
end
|
19
|
+
|
61
20
|
end
|
@@ -1,5 +1,14 @@
|
|
1
1
|
require File.dirname(__FILE__) + '/../spec_helper'
|
2
2
|
|
3
|
+
describe Unit.base_units do
|
4
|
+
it {should be_a Array}
|
5
|
+
it {should have(14).elements}
|
6
|
+
%w{kilogram meter second Ampere degK tempK mole candela each dollar steradian radian decibel byte}.each do |u|
|
7
|
+
it {should include(Unit(u))}
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
|
3
12
|
describe "Create some simple units" do
|
4
13
|
|
5
14
|
describe Unit("0") do
|
@@ -315,7 +324,21 @@ describe "Create some simple units" do
|
|
315
324
|
it {should_not be_zero}
|
316
325
|
its(:base) {should be_a Numeric}
|
317
326
|
its(:temperature_scale) {should be_nil}
|
318
|
-
it { subject.
|
327
|
+
it { subject.convert_to("in/s").should be_within(Unit("0.0001 in/s")).of(Unit("1.0043269330917 in/s"))}
|
328
|
+
end
|
329
|
+
|
330
|
+
describe Unit.new("1 F") do
|
331
|
+
it {should be_an_instance_of Unit}
|
332
|
+
its(:scalar) {should be_an Integer}
|
333
|
+
its(:units) {should == "F"}
|
334
|
+
its(:kind) {should == :capacitance}
|
335
|
+
it {should_not be_temperature}
|
336
|
+
it {should_not be_degree}
|
337
|
+
it {should_not be_base}
|
338
|
+
it {should_not be_unitless}
|
339
|
+
it {should_not be_zero}
|
340
|
+
its(:base) {should be_a Numeric}
|
341
|
+
its(:temperature_scale) {should be_nil}
|
319
342
|
end
|
320
343
|
|
321
344
|
|
@@ -457,20 +480,20 @@ end
|
|
457
480
|
describe "Unit Conversions" do
|
458
481
|
|
459
482
|
context "between compatible units" do
|
460
|
-
specify { Unit("1 s").
|
483
|
+
specify { Unit("1 s").convert_to("ns").should == Unit("1e9 ns")}
|
461
484
|
specify { Unit("1 s").convert_to("ns").should == Unit("1e9 ns")}
|
462
485
|
specify { (Unit("1 s") >> "ns").should == Unit("1e9 ns")}
|
463
486
|
|
464
|
-
specify { Unit("1 m").
|
487
|
+
specify { Unit("1 m").convert_to(Unit("ft")).should be_within(Unit("0.001 ft")).of(Unit("3.28084 ft"))}
|
465
488
|
end
|
466
489
|
|
467
490
|
context "between incompatible units" do
|
468
|
-
specify { expect { Unit("1 s").
|
491
|
+
specify { expect { Unit("1 s").convert_to("m")}.to raise_error(ArgumentError,"Incompatible Units")}
|
469
492
|
end
|
470
493
|
|
471
494
|
context "given bad input" do
|
472
|
-
specify { expect { Unit("1 m").
|
473
|
-
specify { expect { Unit("1 m").
|
495
|
+
specify { expect { Unit("1 m").convert_to("random string")}.to raise_error(ArgumentError,"'random string' Unit not recognized")}
|
496
|
+
specify { expect { Unit("1 m").convert_to(STDOUT)}.to raise_error(ArgumentError,"Unknown target units")}
|
474
497
|
end
|
475
498
|
|
476
499
|
context "between temperature scales" do
|
@@ -492,15 +515,20 @@ describe "Unit Conversions" do
|
|
492
515
|
specify { Unit("558.27 tempR").should be_within(Unit("0.01 degK")).of(Unit("310.15 tempK"))}
|
493
516
|
specify { Unit("0 tempR").should == Unit("0 tempK") }
|
494
517
|
|
495
|
-
specify { Unit("100 tempK").
|
496
|
-
specify { Unit("100 tempK").
|
497
|
-
specify { Unit("100 tempK").
|
518
|
+
specify { Unit("100 tempK").convert_to("tempC").should be_within(U"0.01 degC").of(Unit("-173.15 tempC"))}
|
519
|
+
specify { Unit("100 tempK").convert_to("tempF").should be_within(U"0.01 degF").of(Unit("-279.67 tempF"))}
|
520
|
+
specify { Unit("100 tempK").convert_to("tempR").should be_within(U"0.01 degR").of(Unit("180 tempR"))}
|
498
521
|
|
499
522
|
specify { Unit("1 degC").should == Unit("1 degK")}
|
500
523
|
specify { Unit("1 degF").should == Unit("1 degR")}
|
501
524
|
specify { Unit("1 degC").should == Unit("1.8 degR")}
|
502
525
|
specify { Unit("1 degF").should be_within(Unit("0.001 degK")).of(Unit("0.5555 degK"))}
|
503
526
|
end
|
527
|
+
|
528
|
+
context "reported bugs" do
|
529
|
+
specify { (Unit("189 Mtonne") * Unit("1189 g/tonne")).should == Unit("224721 tonne") }
|
530
|
+
specify { (Unit("189 Mtonne") * Unit("1189 g/tonne")).convert_to("tonne").should == Unit("224721 tonne") }
|
531
|
+
end
|
504
532
|
end
|
505
533
|
|
506
534
|
describe "Unit Math" do
|
@@ -840,6 +868,55 @@ describe "Unit Math" do
|
|
840
868
|
specify { Unit("1 km").divmod(Unit("2 m")).should == [500,0] }
|
841
869
|
end
|
842
870
|
|
871
|
+
context "Time helper functions" do
|
872
|
+
before do
|
873
|
+
Time.stub!(:now).and_return(Time.utc(2011,10,16))
|
874
|
+
DateTime.stub!(:now).and_return(DateTime.civil(2011,10,16))
|
875
|
+
Date.stub!(:today).and_return(Date.civil(2011,10,16))
|
876
|
+
end
|
877
|
+
|
878
|
+
context '#since' do
|
879
|
+
specify { Unit("min").since(Time.utc(2001,4,1,0,0,0)).should == Unit("5544000 min")}
|
880
|
+
specify { Unit("min").since(DateTime.civil(2001,4,1,0,0,0)).should == Unit("5544000 min")}
|
881
|
+
specify { Unit("min").since(Date.civil(2001,4,1)).should == Unit("5544000 min")}
|
882
|
+
specify { expect {Unit("min").since("4-1-2001")}.to raise_error(ArgumentError, "Must specify a Time, Date, or DateTime") }
|
883
|
+
specify { expect {Unit("min").since(nil)}.to raise_error(ArgumentError, "Must specify a Time, Date, or DateTime") }
|
884
|
+
end
|
885
|
+
|
886
|
+
context '#before' do
|
887
|
+
specify { Unit("5 min").before(Time.now).should == Time.utc(2011,10,15,23,55)}
|
888
|
+
specify { Unit("5 min").before(DateTime.now).should == DateTime.civil(2011,10,15,23,55)}
|
889
|
+
specify { Unit("5 min").before(Date.today).should == DateTime.civil(2011,10,15,23,55)}
|
890
|
+
specify { expect {Unit('5 min').before(nil)}.to raise_error(ArgumentError, "Must specify a Time, Date, or DateTime")}
|
891
|
+
specify { expect {Unit('5 min').before("12:00")}.to raise_error(ArgumentError, "Must specify a Time, Date, or DateTime")}
|
892
|
+
end
|
893
|
+
|
894
|
+
context '#ago' do
|
895
|
+
specify { Unit("5 min").ago.should be_kind_of Time}
|
896
|
+
specify { Unit("10000 y").ago.should be_kind_of Time}
|
897
|
+
specify { Unit("1 year").ago.should == Time.utc(2010,10,16)}
|
898
|
+
end
|
899
|
+
|
900
|
+
context '#until' do
|
901
|
+
specify { Unit("min").until(Date.civil(2011,10,17)).should == Unit("1440 min")}
|
902
|
+
specify { Unit("min").until(DateTime.civil(2011,10,21)).should == Unit("7200 min")}
|
903
|
+
specify { Unit("min").until(Time.utc(2011,10,21)).should == Unit("7200 min")}
|
904
|
+
specify { expect {Unit('5 min').until(nil)}.to raise_error(ArgumentError, "Must specify a Time, Date, or DateTime")}
|
905
|
+
specify { expect {Unit('5 min').until("12:00")}.to raise_error(ArgumentError, "Must specify a Time, Date, or DateTime")}
|
906
|
+
end
|
907
|
+
|
908
|
+
context '#from' do
|
909
|
+
specify { Unit("1 day").from(Date.civil(2011,10,17)).should == Date.civil(2011,10,18)}
|
910
|
+
specify { Unit("5 min").from(DateTime.civil(2011,10,21)).should == DateTime.civil(2011,10,21,00,05)}
|
911
|
+
specify { Unit("5 min").from(Time.utc(2011,10,21)).should == Time.utc(2011,10,21,00,05)}
|
912
|
+
specify { expect {Unit('5 min').from(nil)}.to raise_error(ArgumentError, "Must specify a Time, Date, or DateTime")}
|
913
|
+
specify { expect {Unit('5 min').from("12:00")}.to raise_error(ArgumentError, "Must specify a Time, Date, or DateTime")}
|
914
|
+
end
|
915
|
+
|
916
|
+
end
|
917
|
+
|
918
|
+
|
919
|
+
|
843
920
|
end
|
844
921
|
|
845
922
|
describe "Unit Output formatting" do
|
@@ -865,7 +942,7 @@ describe "Foot-inch conversions" do
|
|
865
942
|
["88 in", %Q{7'4"}],
|
866
943
|
["89 in", %Q{7'5"}]
|
867
944
|
].each do |inches, feet|
|
868
|
-
specify { Unit(inches).
|
945
|
+
specify { Unit(inches).convert_to("ft").should == Unit(feet)}
|
869
946
|
specify { Unit(inches).to_s(:ft).should == feet}
|
870
947
|
end
|
871
948
|
end
|
@@ -881,7 +958,7 @@ describe "pound-ounce conversions" do
|
|
881
958
|
["88 oz", "5 lbs, 8 oz"],
|
882
959
|
["89 oz", "5 lbs, 9 oz"]
|
883
960
|
].each do |ounces, pounds|
|
884
|
-
specify { Unit(ounces).
|
961
|
+
specify { Unit(ounces).convert_to("lbs").should == Unit(pounds)}
|
885
962
|
specify { Unit(ounces).to_s(:lbs).should == pounds}
|
886
963
|
end
|
887
964
|
end
|
data/spec/spec_helper.rb
CHANGED
data/test/test_ruby-units.rb
CHANGED
@@ -99,52 +99,17 @@ class TestRubyUnits < Test::Unit::TestCase
|
|
99
99
|
assert_equal "s", a.to_unit.units
|
100
100
|
assert_equal a + 3600, a + "1 h".unit
|
101
101
|
assert_equal a - 3600, a - "1 h".unit
|
102
|
-
assert_in_delta Time.now - "1 h".unit, "1 h".ago, 1
|
103
|
-
assert_in_delta Time.now + 3600, "1 h".
|
104
|
-
assert_in_delta Time.now + "1 h".unit, "1 h".
|
105
|
-
assert_in_delta Time.now - 3600, "1 h".before_now, 1
|
106
|
-
assert_equal "60 min", "min".until(Time.now + 3600).to_s
|
107
|
-
assert_equal "01:00", "min".since(Time.now - 3600).to_s("%H:%M")
|
108
|
-
assert_in_delta Time.now, "now".time, 1
|
102
|
+
assert_in_delta Time.now - "1 h".unit, Unit("1 h").ago, 1
|
103
|
+
assert_in_delta Time.now + 3600, Unit("1 h").from(Time.now), 1
|
104
|
+
assert_in_delta Time.now + "1 h".unit, Unit("1 h").from(Time.now), 1
|
105
|
+
assert_in_delta Time.now - 3600, Unit("1 h").before_now, 1
|
106
|
+
assert_equal "60 min", Unit("min").until(Time.now + 3600).to_s
|
107
|
+
assert_equal "01:00", Unit("min").since(Time.now - 3600).to_s("%H:%M")
|
109
108
|
end
|
110
109
|
|
111
|
-
def test_from_now
|
112
|
-
assert_equal "1 day".from_now, @april_fools + 86400
|
113
|
-
end
|
114
|
-
|
115
|
-
def test_from
|
116
|
-
assert_equal "1 day".from("now"), @april_fools + 86400
|
117
|
-
end
|
118
|
-
|
119
|
-
def test_ago
|
120
|
-
assert_equal "1 day".ago, @april_fools - 86400
|
121
|
-
end
|
122
|
-
|
123
|
-
def test_before_now
|
124
|
-
assert_equal "1 day".before_now, @april_fools - 86400
|
125
|
-
end
|
126
|
-
|
127
|
-
def test_before
|
128
|
-
assert_equal '1 days'.before('now'), @april_fools - 86400
|
129
|
-
end
|
130
|
-
|
131
|
-
def test_since
|
132
|
-
assert_equal 'days'.since(@april_fools - 86400), "1 day".unit
|
133
|
-
assert_equal 'days'.since('2006-3-31 12:00:00 -5:00'), "1 day".unit
|
134
|
-
assert_equal 'days'.since(DateTime.parse('2006-3-31 12:00 -5:00')), "1 day".unit
|
135
|
-
assert_raises(ArgumentError) { 'days'.since(1) }
|
136
|
-
end
|
137
|
-
|
138
|
-
def test_until
|
139
|
-
assert_equal 'days'.until('2006-04-2 12:00:00 -5:00'), '1 day'.unit
|
140
|
-
assert_raises(ArgumentError) { 'days'.until(1) }
|
141
|
-
end
|
142
|
-
|
143
110
|
def test_time_helpers
|
144
111
|
assert_equal @april_fools, Time.now
|
145
112
|
assert_equal @april_fools_datetime, DateTime.now
|
146
|
-
assert_equal Time.now, 'now'.time
|
147
|
-
assert_equal DateTime.now, 'now'.datetime
|
148
113
|
assert_equal 1143910800, Unit.new(Time.now).scalar
|
149
114
|
assert_equal @april_fools.unit.to_time, @april_fools
|
150
115
|
assert_equal Time.in('1 day'), @april_fools + 86400
|
@@ -153,7 +118,7 @@ class TestRubyUnits < Test::Unit::TestCase
|
|
153
118
|
end
|
154
119
|
|
155
120
|
def test_string_helpers
|
156
|
-
assert_equal '1 mm'.
|
121
|
+
assert_equal '1 mm'.convert_to('in'), Unit('1 mm').convert_to('in')
|
157
122
|
end
|
158
123
|
|
159
124
|
[:sin, :cos, :tan, :sinh, :cosh, :tanh].each do |trig|
|
@@ -343,9 +308,9 @@ class TestRubyUnits < Test::Unit::TestCase
|
|
343
308
|
assert_equal ['<1>'],unit3.denominator
|
344
309
|
}
|
345
310
|
assert_raises(ArgumentError) { unit1 >> 5.0}
|
346
|
-
assert_equal unit1, unit1.
|
347
|
-
assert_equal unit1, unit1.
|
348
|
-
assert_equal unit1, unit1.
|
311
|
+
assert_equal unit1, unit1.convert_to(true)
|
312
|
+
assert_equal unit1, unit1.convert_to(false)
|
313
|
+
assert_equal unit1, unit1.convert_to(nil)
|
349
314
|
end
|
350
315
|
|
351
316
|
def test_compare
|
@@ -638,7 +603,7 @@ class TestRubyUnits < Test::Unit::TestCase
|
|
638
603
|
assert_raises(ArgumentError) { a / b }
|
639
604
|
assert_raises(ArgumentError) { a ** 2 }
|
640
605
|
assert_raises(ArgumentError) { c - '400 degK'.unit}
|
641
|
-
assert_equal a, a.
|
606
|
+
assert_equal a, a.convert_to('tempF')
|
642
607
|
end
|
643
608
|
|
644
609
|
def test_feet
|
@@ -723,7 +688,7 @@ class TestRubyUnits < Test::Unit::TestCase
|
|
723
688
|
v = Unit "1 m^3"
|
724
689
|
n = Unit "1 mole"
|
725
690
|
r = Unit "8.31451 J/mol*degK"
|
726
|
-
t = ((p*v)/(n*r)).
|
691
|
+
t = ((p*v)/(n*r)).convert_to('tempK')
|
727
692
|
assert_in_delta 12027.16,t.base_scalar, 0.1
|
728
693
|
end
|
729
694
|
|
@@ -839,10 +804,10 @@ class TestRubyUnits < Test::Unit::TestCase
|
|
839
804
|
end
|
840
805
|
|
841
806
|
def test_time_conversions
|
842
|
-
today =
|
807
|
+
today = Time.now
|
843
808
|
assert_equal today,@april_fools
|
844
809
|
last_century = today - '150 years'.unit
|
845
|
-
assert_equal last_century.to_date, '1856-04-01'
|
810
|
+
assert_equal last_century.to_date, DateTime.parse('1856-04-01')
|
846
811
|
end
|
847
812
|
|
848
813
|
def test_coercion
|
@@ -942,7 +907,7 @@ class TestRubyUnits < Test::Unit::TestCase
|
|
942
907
|
end
|
943
908
|
|
944
909
|
def test_natural_language
|
945
|
-
assert_equal Unit.parse("10 mm in cm"), '10 mm'.unit.
|
910
|
+
assert_equal Unit.parse("10 mm in cm"), '10 mm'.unit.convert_to('cm')
|
946
911
|
end
|
947
912
|
|
948
913
|
def test_round_pounds
|
@@ -971,7 +936,7 @@ class TestRubyUnits < Test::Unit::TestCase
|
|
971
936
|
end
|
972
937
|
|
973
938
|
def test_version
|
974
|
-
assert_equal('1.3.
|
939
|
+
assert_equal('1.3.2.a', Unit::VERSION)
|
975
940
|
end
|
976
941
|
|
977
942
|
def test_negation
|
metadata
CHANGED
@@ -1,73 +1,103 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby-units
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.3.2.a
|
5
|
+
prerelease: 6
|
6
6
|
platform: ruby
|
7
|
-
authors:
|
7
|
+
authors:
|
8
8
|
- Kevin Olbrich, Ph.D.
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
- !ruby/object:Gem::Dependency
|
12
|
+
date: 2011-10-17 00:00:00.000000000Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
16
15
|
name: bundler
|
17
|
-
requirement: &
|
16
|
+
requirement: &2154574080 !ruby/object:Gem::Requirement
|
18
17
|
none: false
|
19
|
-
requirements:
|
18
|
+
requirements:
|
20
19
|
- - ~>
|
21
|
-
- !ruby/object:Gem::Version
|
22
|
-
version:
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '1.0'
|
23
22
|
type: :development
|
24
23
|
prerelease: false
|
25
|
-
version_requirements: *
|
26
|
-
- !ruby/object:Gem::Dependency
|
24
|
+
version_requirements: *2154574080
|
25
|
+
- !ruby/object:Gem::Dependency
|
27
26
|
name: rcov
|
28
|
-
requirement: &
|
27
|
+
requirement: &2154573580 !ruby/object:Gem::Requirement
|
29
28
|
none: false
|
30
|
-
requirements:
|
31
|
-
- -
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version:
|
29
|
+
requirements:
|
30
|
+
- - ! '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
34
33
|
type: :development
|
35
34
|
prerelease: false
|
36
|
-
version_requirements: *
|
37
|
-
- !ruby/object:Gem::Dependency
|
35
|
+
version_requirements: *2154573580
|
36
|
+
- !ruby/object:Gem::Dependency
|
38
37
|
name: jeweler
|
39
|
-
requirement: &
|
38
|
+
requirement: &2154573100 !ruby/object:Gem::Requirement
|
40
39
|
none: false
|
41
|
-
requirements:
|
42
|
-
- -
|
43
|
-
- !ruby/object:Gem::Version
|
44
|
-
version:
|
40
|
+
requirements:
|
41
|
+
- - ! '>='
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '0'
|
45
44
|
type: :development
|
46
45
|
prerelease: false
|
47
|
-
version_requirements: *
|
48
|
-
- !ruby/object:Gem::Dependency
|
46
|
+
version_requirements: *2154573100
|
47
|
+
- !ruby/object:Gem::Dependency
|
49
48
|
name: rspec
|
50
|
-
requirement: &
|
49
|
+
requirement: &2154572600 !ruby/object:Gem::Requirement
|
51
50
|
none: false
|
52
|
-
requirements:
|
51
|
+
requirements:
|
53
52
|
- - ~>
|
54
|
-
- !ruby/object:Gem::Version
|
55
|
-
version:
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '2.5'
|
56
55
|
type: :development
|
57
56
|
prerelease: false
|
58
|
-
version_requirements: *
|
57
|
+
version_requirements: *2154572600
|
58
|
+
- !ruby/object:Gem::Dependency
|
59
|
+
name: autotest
|
60
|
+
requirement: &2154572100 !ruby/object:Gem::Requirement
|
61
|
+
none: false
|
62
|
+
requirements:
|
63
|
+
- - ! '>='
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: '0'
|
66
|
+
type: :development
|
67
|
+
prerelease: false
|
68
|
+
version_requirements: *2154572100
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: autotest-growl
|
71
|
+
requirement: &2154571620 !ruby/object:Gem::Requirement
|
72
|
+
none: false
|
73
|
+
requirements:
|
74
|
+
- - ! '>='
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '0'
|
77
|
+
type: :development
|
78
|
+
prerelease: false
|
79
|
+
version_requirements: *2154571620
|
80
|
+
- !ruby/object:Gem::Dependency
|
81
|
+
name: autotest-fsevent
|
82
|
+
requirement: &2154571120 !ruby/object:Gem::Requirement
|
83
|
+
none: false
|
84
|
+
requirements:
|
85
|
+
- - ! '>='
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
version: '0'
|
88
|
+
type: :development
|
89
|
+
prerelease: false
|
90
|
+
version_requirements: *2154571120
|
59
91
|
description: Provides classes and methods to perform unit math and conversions
|
60
|
-
email:
|
92
|
+
email:
|
61
93
|
- kevin.olbrich+ruby_units@gmail.com
|
62
94
|
executables: []
|
63
|
-
|
64
95
|
extensions: []
|
65
|
-
|
66
|
-
extra_rdoc_files:
|
96
|
+
extra_rdoc_files:
|
67
97
|
- LICENSE.txt
|
68
98
|
- README.md
|
69
99
|
- TODO
|
70
|
-
files:
|
100
|
+
files:
|
71
101
|
- CHANGELOG.txt
|
72
102
|
- Gemfile
|
73
103
|
- LICENSE.txt
|
@@ -76,6 +106,7 @@ files:
|
|
76
106
|
- RakeFile
|
77
107
|
- TODO
|
78
108
|
- VERSION
|
109
|
+
- autotest/discover.rb
|
79
110
|
- lib/ruby-units.rb
|
80
111
|
- lib/ruby_units.rb
|
81
112
|
- lib/ruby_units/array.rb
|
@@ -86,6 +117,7 @@ files:
|
|
86
117
|
- lib/ruby_units/numeric.rb
|
87
118
|
- lib/ruby_units/object.rb
|
88
119
|
- lib/ruby_units/string.rb
|
120
|
+
- lib/ruby_units/string/extra.rb
|
89
121
|
- lib/ruby_units/time.rb
|
90
122
|
- lib/ruby_units/unit.rb
|
91
123
|
- lib/ruby_units/unit_definitions.rb
|
@@ -97,6 +129,7 @@ files:
|
|
97
129
|
- spec/ruby-units/math_spec.rb
|
98
130
|
- spec/ruby-units/numeric_spec.rb
|
99
131
|
- spec/ruby-units/object_spec.rb
|
132
|
+
- spec/ruby-units/string/extra_spec.rb
|
100
133
|
- spec/ruby-units/string_spec.rb
|
101
134
|
- spec/ruby-units/time_spec.rb
|
102
135
|
- spec/ruby-units/unit_spec.rb
|
@@ -105,30 +138,63 @@ files:
|
|
105
138
|
- test/test_ruby-units.rb
|
106
139
|
homepage: https://github.com/olbrich/ruby-units
|
107
140
|
licenses: []
|
141
|
+
post_install_message: ! '====================
|
108
142
|
|
109
|
-
|
110
|
-
|
143
|
+
Deprecation Warning
|
144
|
+
|
145
|
+
====================
|
146
|
+
|
147
|
+
|
148
|
+
Several convenience methods that ruby-units added to the string class have
|
149
|
+
|
150
|
+
been deprecated in this release. These methods include String#to, String#from,
|
151
|
+
String#ago, String#before and others.
|
111
152
|
|
112
|
-
|
153
|
+
If your code relies on these functions, they can be added back by adding this line
|
154
|
+
to your code.
|
155
|
+
|
156
|
+
|
157
|
+
require ''ruby-units/string/extras''
|
158
|
+
|
159
|
+
# note that these methods do not play well with Rails, which is one of the reasons
|
160
|
+
they are being removed.
|
161
|
+
|
162
|
+
|
163
|
+
The extra functions mostly work the same, but will no longer properly handle cases
|
164
|
+
when they are called with strings..
|
165
|
+
|
166
|
+
|
167
|
+
''min''.from("4-1-2011") # => Exception
|
168
|
+
|
169
|
+
|
170
|
+
Pass in a Date, Time, or DateTime object to get the expected result.
|
171
|
+
|
172
|
+
|
173
|
+
They will probably go away completely in an upcoming release, so it would be a good
|
174
|
+
idea to refactor your code
|
175
|
+
|
176
|
+
to avoid using them. They will also throw deprecation warnings when they are used.
|
177
|
+
|
178
|
+
'
|
179
|
+
rdoc_options: []
|
180
|
+
require_paths:
|
113
181
|
- lib
|
114
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
182
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
115
183
|
none: false
|
116
|
-
requirements:
|
117
|
-
- -
|
118
|
-
- !ruby/object:Gem::Version
|
119
|
-
version:
|
120
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
184
|
+
requirements:
|
185
|
+
- - ! '>='
|
186
|
+
- !ruby/object:Gem::Version
|
187
|
+
version: '0'
|
188
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
121
189
|
none: false
|
122
|
-
requirements:
|
123
|
-
- -
|
124
|
-
- !ruby/object:Gem::Version
|
125
|
-
version:
|
190
|
+
requirements:
|
191
|
+
- - ! '>'
|
192
|
+
- !ruby/object:Gem::Version
|
193
|
+
version: 1.3.1
|
126
194
|
requirements: []
|
127
|
-
|
128
195
|
rubyforge_project:
|
129
|
-
rubygems_version: 1.
|
196
|
+
rubygems_version: 1.8.10
|
130
197
|
signing_key:
|
131
198
|
specification_version: 3
|
132
199
|
summary: A class that performs unit conversions and unit math
|
133
200
|
test_files: []
|
134
|
-
|