ruby-units 1.0.1 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.txt CHANGED
@@ -1,64 +1,92 @@
1
1
  Change Log for Ruby-units
2
2
  =========================
3
- 2006-08-22 0.1.0 * Initial Release
3
+ 2007-01-24 1.0.2 * Minor changes in the way powers are calculated to support Uncertain
4
+ numbers better.
5
+ * Fixed parsing bug with Uncertain Numbers
6
+ * added resolution / typography units (pixels, points, pica)
7
+ Note that 'pt' means 'pints' and not 'points'
8
+ * added some pressure units ('inHg' & 'inH2O')
9
+ * changed default abbreviation of 'knots' to 'kt'
10
+ * Changed directory layout
11
+ * fixed a minor bug with Time.to_date so comparisons work properly
4
12
 
5
- 2006-08-22 0.1.1 * Added new format option "1 mm".to_unit("in") now
6
- converts the result to the indicated units
7
- * Fixed some naming issues so that the gem name matches
8
- the require name.
9
- * Added CHANGELOG
10
- * Improved test coverage (100% code coverage via RCov)
11
- * fixed a bug that prevented units with a prefix in the
12
- denominator from converting properly
13
- * can use .unit method on a string to create a new unit
14
- object
15
- * can now coerce or define units from arrays, strings,
16
- numerics.
17
- "1 mm".unit + [1, 'mm'] === "2 mm".unit
18
- [1,'mm','s'].unit === "1 mm/s".unit
19
- 2.5.unit === "2.5".unit
20
- * Added instructions on how to add custom units
13
+ 2007-01-17 1.0.1 * Force units are now defined correctly.
14
+
15
+ 2007-01-12 1.0.0 * Improved handling of complex numbers. Now you can specify
16
+ '1+1i mm'.unit to get a complex unit.
17
+ * Taking the root of a negative unit will give you a complex unit
18
+ * fixed unary minus to work again
19
+ * Math.hypot now takes units. Both parameters must be the compatible
20
+ units or it will assert. Units will be converted to a common base
21
+ before use.
22
+ * Can now specify units in rational numbers, i.e., '1/4 cup'.unit
23
+ * Seems like a good time to move to 1.0 status
21
24
 
22
- 2006-08-28 0.2.0 * Added 'ruby_unit.rb' file so that requires will still
23
- work if the wrong name is used
24
- * Added 'to' as an alias to '>>' so conversions can be
25
- done as '1 m'.unit.to('1 cm')
26
- * Added ability to convert temperatures to absolute values
27
- using the following syntax:
28
- '37 degC'.unit.to('tempF') #=> '98.6 degF'.unit
29
- * Tweaked abbreviations a bit. 'ton' is now 'tn' instead
30
- of 't'. It was causing parse collisions with 'atm'.
31
- * fixed a bug in term elimination routine
32
- * fixed a bug in parsing of powers, and added support for
33
- 'm**2' format
34
- * Added support for taking roots of units. Just
35
- exponentiate with a fraction (0.5, 1.0/3, 0.25)
36
- * renamed 'quantity' to 'scalar'
37
- * any type of Numeric can be used to initialize a Unit,
38
- although this can't really be done with a string
39
- * Units can not be forced to a float using to_f unless
40
- they are unitless. This prevents some math functions
41
- from forcing the conversion. To get the scalar, just
42
- use 'unit.scalar'
43
- * 'inspect' returns string representation
44
- * better edge-case detection with math functions.
45
- "0 mm".unit**-1 now throws a ZeroDivisionError exception
46
- * Ranges can make a series of units, so long as the end
47
- points have integer scalars.
48
- * Fixed a parsing bug with feet/pounds and scientific
49
- numbers
50
- 2006-09-17 * can now use the '%' format specifier like
51
- '%0.2f' % '1 mm'.unit #=> '1.00 mm'
52
- * works nicely with time now.
53
- '1 week'.unit + Time.now => 1.159e+09 s
54
- Time.at('1.159e+09 s'.unit)
55
- => Sat Sep 23 04:26:40 EDT 2006
56
- "1.159e9 s".unit.time
57
- => Sat Sep 23 04:26:40 EDT 2006
58
- * Time.now.unit => 1.159e9 s
59
- * works well with 'Uncertain' numerics
60
- (www.rubyforge.org/projects/uncertain)
61
- * Improved parsing
25
+ 2006-12-15 0.3.9 * forgot to increment the version in the gem file..ooops.
26
+
27
+ 2006-12-15 0.3.8 * Any object that supports a 'to_unit' method will now be
28
+ automatically coerced to a unit during math operations.
29
+
30
+ 2006-12-14 0.3.7 * improved handling of percents and added a 'wt%' unit
31
+ equivalent to 1 g/dl.
32
+ * Improved handling for units with non-alphanumeric names
33
+ (like ' for feet, # for pound)
34
+ * Now you can enter durations as "HH:MM:SS, usec" or
35
+ "HH:MM:SS:usec"
36
+
37
+ 2006-12-05 0.3.6 * Fixed bug where (unit/unit).ceil would fail
38
+
39
+ 2006-11-20 0.3.5 * Minor bug fixes
40
+ * to_int now coerces the result to an actual Integer,
41
+ but only works properly for unitless Units.
42
+
43
+ 2006-10-27 0.3.4 * Fixed a few more parsing bugs so that it will properly
44
+ complain about malformed units.
45
+ * Fixed a bug that prevents proper use of percents
46
+ * several minor tweaks
47
+ * some improved Date and DateTime handling
48
+ * can convert between Date, DateTime, and Time objects
49
+ * Time math will now return a DateTime if it goes out of
50
+ range.
51
+
52
+ 2006-10-03 0.3.3 * Apparently I can't do math late at night.
53
+ Fixed a bug that would cause problems when adding
54
+ or subtracting units to a unit with a zero scalar.
55
+ * Date and DateTime objects can be converted to 'units'
56
+
57
+ 2006-10-03 0.3.2 * More minor bug fixes
58
+ (now fixes a minor name collision with rails)
59
+
60
+ 2006-10-02 0.3.1 * minor bug fixes
61
+
62
+ 2006-10-02 0.3.0 * Performance enhanced by caching results of many
63
+ functions (Thanks to Kurt Stephens for pushing this.)
64
+ * Throws an exception if the unit is not recognized
65
+ * units can now identify what 'kind' they are
66
+ (:length, :mass, etc..)
67
+ * New constructors:
68
+ Unit(1,"mm")
69
+ Unit(1,"mm/s")
70
+ Unit(1,"mm","s")
71
+
72
+ 2006-09-22 0.2.3 * added support for date/time parsing with the Chronic gem
73
+ parsing will use Chronic if it is loaded
74
+ * allows Date / Time / DateTime conversions
75
+ * better test coverage
76
+ * The 'string'.to_time returns a Time object
77
+ * 'string'.to_datetime returns a DateTime object
78
+ * 'string'.time returns a Time object or a DateTime if the
79
+ Time object fails
80
+ * 'string'.datetime returns a DateTime or a Time if the
81
+ DateTime fails
82
+
83
+ 2006-09-19 0.2.2 * tweaked temperature handling a bit. Now enter
84
+ temperatures like this:
85
+ '0 tempC'.unit #=> 273.15 degK
86
+ They will always be converted to kelvin to avoid
87
+ problems when temperatures are used in equations.
88
+ * added Time.in("5 min")
89
+ * added Unit.to_unit to simplify some calls
62
90
 
63
91
  2006-09-18 0.2.1 * Trig math functions (sin, cos, tan, sinh, cosh, tanh)
64
92
  accept units that can be converted to radians
@@ -91,81 +119,71 @@ Change Log for Ruby-units
91
119
  * Can pass a strftime format string to to_s to format time
92
120
  output
93
121
  * can use U'1 mm' or '1 mm'.u to specify units now
94
-
95
- 2006-09-19 0.2.2 * tweaked temperature handling a bit. Now enter
96
- temperatures like this:
97
- '0 tempC'.unit #=> 273.15 degK
98
- They will always be converted to kelvin to avoid
99
- problems when temperatures are used in equations.
100
- * added Time.in("5 min")
101
- * added Unit.to_unit to simplify some calls
102
-
103
- 2006-09-22 0.2.3 * added support for date/time parsing with the Chronic gem
104
- parsing will use Chronic if it is loaded
105
- * allows Date / Time / DateTime conversions
106
- * better test coverage
107
- * The 'string'.to_time returns a Time object
108
- * 'string'.to_datetime returns a DateTime object
109
- * 'string'.time returns a Time object or a DateTime if the
110
- Time object fails
111
- * 'string'.datetime returns a DateTime or a Time if the
112
- DateTime fails
113
122
 
114
- 2006-10-02 0.3.0 * Performance enhanced by caching results of many
115
- functions (Thanks to Kurt Stephens for pushing this.)
116
- * Throws an exception if the unit is not recognized
117
- * units can now identify what 'kind' they are
118
- (:length, :mass, etc..)
119
- * New constructors:
120
- Unit(1,"mm")
121
- Unit(1,"mm/s")
122
- Unit(1,"mm","s")
123
+ 2006-09-17 * can now use the '%' format specifier like
124
+ '%0.2f' % '1 mm'.unit #=> '1.00 mm'
125
+ * works nicely with time now.
126
+ '1 week'.unit + Time.now => 1.159e+09 s
127
+ Time.at('1.159e+09 s'.unit)
128
+ => Sat Sep 23 04:26:40 EDT 2006
129
+ "1.159e9 s".unit.time
130
+ => Sat Sep 23 04:26:40 EDT 2006
131
+ * Time.now.unit => 1.159e9 s
132
+ * works well with 'Uncertain' numerics
133
+ (www.rubyforge.org/projects/uncertain)
134
+ * Improved parsing
123
135
 
124
- 2006-10-02 0.3.1 * minor bug fixes
125
-
126
- 2006-10-03 0.3.2 * More minor bug fixes
127
- (now fixes a minor name collision with rails)
128
-
129
- 2006-10-03 0.3.3 * Apparently I can't do math late at night.
130
- Fixed a bug that would cause problems when adding
131
- or subtracting units to a unit with a zero scalar.
132
- * Date and DateTime objects can be converted to 'units'
136
+ 2006-08-28 0.2.0 * Added 'ruby_unit.rb' file so that requires will still
137
+ work if the wrong name is used
138
+ * Added 'to' as an alias to '>>' so conversions can be
139
+ done as '1 m'.unit.to('1 cm')
140
+ * Added ability to convert temperatures to absolute values
141
+ using the following syntax:
142
+ '37 degC'.unit.to('tempF') #=> '98.6 degF'.unit
143
+ * Tweaked abbreviations a bit. 'ton' is now 'tn' instead
144
+ of 't'. It was causing parse collisions with 'atm'.
145
+ * fixed a bug in term elimination routine
146
+ * fixed a bug in parsing of powers, and added support for
147
+ 'm**2' format
148
+ * Added support for taking roots of units. Just
149
+ exponentiate with a fraction (0.5, 1.0/3, 0.25)
150
+ * renamed 'quantity' to 'scalar'
151
+ * any type of Numeric can be used to initialize a Unit,
152
+ although this can't really be done with a string
153
+ * Units can not be forced to a float using to_f unless
154
+ they are unitless. This prevents some math functions
155
+ from forcing the conversion. To get the scalar, just
156
+ use 'unit.scalar'
157
+ * 'inspect' returns string representation
158
+ * better edge-case detection with math functions.
159
+ "0 mm".unit**-1 now throws a ZeroDivisionError exception
160
+ * Ranges can make a series of units, so long as the end
161
+ points have integer scalars.
162
+ * Fixed a parsing bug with feet/pounds and scientific
163
+ numbers
133
164
 
134
- 2006-10-27 0.3.4 * Fixed a few more parsing bugs so that it will properly
135
- complain about malformed units.
136
- * Fixed a bug that prevents proper use of percents
137
- * several minor tweaks
138
- * some improved Date and DateTime handling
139
- * can convert between Date, DateTime, and Time objects
140
- * Time math will now return a DateTime if it goes out of
141
- range.
165
+ 2006-08-22 0.1.1 * Added new format option "1 mm".to_unit("in") now
166
+ converts the result to the indicated units
167
+ * Fixed some naming issues so that the gem name matches
168
+ the require name.
169
+ * Added CHANGELOG
170
+ * Improved test coverage (100% code coverage via RCov)
171
+ * fixed a bug that prevented units with a prefix in the
172
+ denominator from converting properly
173
+ * can use .unit method on a string to create a new unit
174
+ object
175
+ * can now coerce or define units from arrays, strings,
176
+ numerics.
177
+ "1 mm".unit + [1, 'mm'] === "2 mm".unit
178
+ [1,'mm','s'].unit === "1 mm/s".unit
179
+ 2.5.unit === "2.5".unit
180
+ * Added instructions on how to add custom units
142
181
 
143
- 2006-11-20 0.3.5 * Minor bug fixes
144
- * to_int now coerces the result to an actual Integer,
145
- but only works properly for unitless Units.
182
+ 2006-08-22 0.1.0 * Initial Release
183
+
184
+
185
+
186
+
146
187
 
147
- 2006-12-05 0.3.6 * Fixed bug where (unit/unit).ceil would fail
148
188
 
149
- 2006-12-14 0.3.7 * improved handling of percents and added a 'wt%' unit
150
- equivalent to 1 g/dl.
151
- * Improved handling for units with non-alphanumeric names
152
- (like ' for feet, # for pound)
153
- * Now you can enter durations as "HH:MM:SS, usec" or
154
- "HH:MM:SS:usec"
155
-
156
- 2006-12-15 0.3.8 * Any object that supports a 'to_unit' method will now be
157
- automatically coerced to a unit during math operations.
158
-
159
- 2006-12-15 0.3.9 * forgot to increment the version in the gem file..ooops.
160
189
 
161
- 2007-01-12 1.0.0 * Improved handling of complex numbers. Now you can specify
162
- '1+1i mm'.unit to get a complex unit.
163
- * Taking the root of a negative unit will give you a complex unit
164
- * fixed unary minus to work again
165
- * Math.hypot now takes units. Both parameters must be the compatible
166
- units or it will assert. Units will be converted to a common base
167
- before use.
168
- * Can now specify units in rational numbers, i.e., '1/4 cup'.unit
169
- * Seems like a good time to move to 1.0 status
170
-
171
- 2007-01-17 1.0.1 * Force units are now defined correctly.
data/Manifest.txt CHANGED
@@ -5,5 +5,15 @@ LICENSE.txt
5
5
  Rakefile
6
6
  lib/ruby-units.rb
7
7
  lib/ruby_units.rb
8
- lib/units.rb
8
+ lib/ruby_units/units.rb
9
+ lib/ruby_units/math.rb
10
+ lib/ruby_units/date.rb
11
+ lib/ruby_units/time.rb
12
+ lib/ruby_units/string.rb
13
+ lib/ruby_units/array.rb
14
+ lib/ruby_units/numeric.rb
15
+ lib/ruby_units/object.rb
16
+ lib/ruby_units/array.rb
17
+ lib/ruby_units/complex.rb
18
+ lib/ruby_units/ruby-units.rb
9
19
  test/test_ruby-units.rb
data/Rakefile CHANGED
@@ -1,6 +1,7 @@
1
1
  require 'rubygems'
2
2
  require 'hoe'
3
- require './lib/ruby-units.rb'
3
+ require './lib/ruby_units/units'
4
+ require './lib/ruby_units/ruby-units'
4
5
  require 'rcov/rcovtask'
5
6
 
6
7
  Rcov::RcovTask.new do |t|