quantify 1.1.0 → 1.2.0
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/.rvmrc +1 -0
- data/Gemfile +14 -0
- data/README +10 -10
- data/Rakefile +65 -0
- data/VERSION +1 -0
- data/lib/quantify/config.rb +10 -14
- data/lib/quantify/dimensions.rb +1 -1
- data/lib/quantify/quantify.rb +2 -35
- data/lib/quantify/unit/base_unit.rb +29 -25
- data/lib/quantify/unit/compound_base_unit.rb +21 -22
- data/lib/quantify/unit/compound_base_unit_list.rb +260 -0
- data/lib/quantify/unit/compound_unit.rb +78 -218
- data/lib/quantify/unit/unit.rb +119 -4
- data/lib/quantify.rb +1 -0
- data/quantify.gemspec +90 -0
- data/spec/compound_unit_spec.rb +124 -13
- data/spec/quantify_spec.rb +0 -14
- data/spec/quantity_spec.rb +6 -6
- data/spec/unit_spec.rb +57 -39
- metadata +130 -32
data/spec/unit_spec.rb
CHANGED
@@ -3,20 +3,38 @@ include Quantify
|
|
3
3
|
|
4
4
|
describe Unit do
|
5
5
|
|
6
|
-
|
7
|
-
|
6
|
+
describe "superscript configuration" do
|
7
|
+
|
8
|
+
after :all do
|
9
|
+
Unit.use_superscript_characters!
|
10
|
+
end
|
11
|
+
|
12
|
+
it "should initialize superscript format" do
|
13
|
+
Unit.use_superscript_characters?.should be_true
|
14
|
+
end
|
15
|
+
|
16
|
+
it "should set superscript usage to true" do
|
17
|
+
Unit.use_superscript_characters=true
|
18
|
+
Unit.use_superscript_characters?.should be_true
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should set superscript usage to false" do
|
22
|
+
Unit.use_superscript_characters=false
|
23
|
+
Unit.use_superscript_characters?.should be_false
|
24
|
+
end
|
25
|
+
|
8
26
|
end
|
9
|
-
|
27
|
+
|
10
28
|
describe "unit identifiers" do
|
11
29
|
|
12
30
|
describe "default configuration" do
|
13
31
|
|
14
32
|
it "should know that superscripts are to be used" do
|
15
|
-
|
33
|
+
Unit.use_superscript_characters?.should be_true
|
16
34
|
end
|
17
35
|
|
18
|
-
it "should use
|
19
|
-
|
36
|
+
it "should use superspt characters for powers of 2 and 3 by default" do
|
37
|
+
Unit.use_superscript_characters?.should be_true
|
20
38
|
Unit.cubic_metre.label.should eql 'm³'
|
21
39
|
Unit.square_metre.label.should eql 'm²'
|
22
40
|
(Unit.m**2).label.should eql 'm²'
|
@@ -42,10 +60,10 @@ describe Unit do
|
|
42
60
|
Unit.parse("m^4 K^2/s^3").label.should eql 'm^4·K²/s³'
|
43
61
|
Unit.parse("m^4 K^2 s^-3").label.should eql 'm^4·K²/s³'
|
44
62
|
|
45
|
-
Unit.parse("m^4·K²/s³").symbol.should eql 'm^4 K
|
46
|
-
Unit.parse("m^4 K²/s³").symbol.should eql 'm^4 K
|
47
|
-
Unit.parse("m^4 K^2/s^3").symbol.should eql 'm^4 K
|
48
|
-
Unit.parse("m^4 K^2 s^-3").symbol.should eql 'm^4 K
|
63
|
+
Unit.parse("m^4·K²/s³").symbol.should eql 'm^4 K²/s³'
|
64
|
+
Unit.parse("m^4 K²/s³").symbol.should eql 'm^4 K²/s³'
|
65
|
+
Unit.parse("m^4 K^2/s^3").symbol.should eql 'm^4 K²/s³'
|
66
|
+
Unit.parse("m^4 K^2 s^-3").symbol.should eql 'm^4 K²/s³'
|
49
67
|
|
50
68
|
Unit.parse("m^4·K²/s³").name.should eql 'metre to the 4th power square kelvin per cubic second'
|
51
69
|
Unit.parse("m^4 K²/s³").name.should eql 'metre to the 4th power square kelvin per cubic second'
|
@@ -58,15 +76,15 @@ describe Unit do
|
|
58
76
|
describe "explicitly turning off superscript characters" do
|
59
77
|
|
60
78
|
before :all do
|
61
|
-
|
79
|
+
Unit.use_superscript_characters=false
|
62
80
|
end
|
63
81
|
|
64
82
|
after :all do
|
65
|
-
|
83
|
+
Unit.use_superscript_characters!
|
66
84
|
end
|
67
85
|
|
68
86
|
it "should know that superscripts are not to be used" do
|
69
|
-
|
87
|
+
Unit.use_superscript_characters?.should be_false
|
70
88
|
end
|
71
89
|
|
72
90
|
it "should NOT use superscript characters for powers of 2 and 3" do
|
@@ -96,10 +114,10 @@ describe Unit do
|
|
96
114
|
Unit.parse("m^4 K^2 s^-3").label.should eql "m^4·K^2/s^3"
|
97
115
|
|
98
116
|
|
99
|
-
Unit.parse("m^4·K²/s³").symbol.should eql 'm^4 K^2
|
100
|
-
Unit.parse("m^4 K²/s³").symbol.should eql 'm^4 K^2
|
101
|
-
Unit.parse("m^4 K^2/s^3").symbol.should eql 'm^4 K^2
|
102
|
-
Unit.parse("m^4 K^2 s^-3").symbol.should eql 'm^4 K^2
|
117
|
+
Unit.parse("m^4·K²/s³").symbol.should eql 'm^4 K^2/s^3'
|
118
|
+
Unit.parse("m^4 K²/s³").symbol.should eql 'm^4 K^2/s^3'
|
119
|
+
Unit.parse("m^4 K^2/s^3").symbol.should eql 'm^4 K^2/s^3'
|
120
|
+
Unit.parse("m^4 K^2 s^-3").symbol.should eql 'm^4 K^2/s^3'
|
103
121
|
|
104
122
|
Unit.parse("m^4·K²/s³").name.should eql 'metre to the 4th power square kelvin per cubic second'
|
105
123
|
Unit.parse("m^4 K²/s³").name.should eql 'metre to the 4th power square kelvin per cubic second'
|
@@ -112,12 +130,12 @@ describe Unit do
|
|
112
130
|
describe "explicitly turning on superscript characters" do
|
113
131
|
|
114
132
|
before :all do
|
115
|
-
|
116
|
-
|
133
|
+
Unit.use_superscript_characters=false
|
134
|
+
Unit.use_superscript_characters=true
|
117
135
|
end
|
118
136
|
|
119
137
|
it "should know that superscripts are to be used" do
|
120
|
-
|
138
|
+
Unit.use_superscript_characters?.should be_true
|
121
139
|
end
|
122
140
|
|
123
141
|
it "should use superscript characters for powers of 2 and 3" do
|
@@ -146,10 +164,10 @@ describe Unit do
|
|
146
164
|
Unit.parse("m^4 K^2/s^3").label.should eql 'm^4·K²/s³'
|
147
165
|
Unit.parse("m^4 K^2 s^-3").label.should eql 'm^4·K²/s³'
|
148
166
|
|
149
|
-
Unit.parse("m^4·K²/s³").symbol.should eql 'm^4 K
|
150
|
-
Unit.parse("m^4 K²/s³").symbol.should eql 'm^4 K
|
151
|
-
Unit.parse("m^4 K^2/s^3").symbol.should eql 'm^4 K
|
152
|
-
Unit.parse("m^4 K^2 s^-3").symbol.should eql 'm^4 K
|
167
|
+
Unit.parse("m^4·K²/s³").symbol.should eql 'm^4 K²/s³'
|
168
|
+
Unit.parse("m^4 K²/s³").symbol.should eql 'm^4 K²/s³'
|
169
|
+
Unit.parse("m^4 K^2/s^3").symbol.should eql 'm^4 K²/s³'
|
170
|
+
Unit.parse("m^4 K^2 s^-3").symbol.should eql 'm^4 K²/s³'
|
153
171
|
|
154
172
|
Unit.parse("m^4·K²/s³").name.should eql 'metre to the 4th power square kelvin per cubic second'
|
155
173
|
Unit.parse("m^4 K²/s³").name.should eql 'metre to the 4th power square kelvin per cubic second'
|
@@ -162,12 +180,12 @@ describe Unit do
|
|
162
180
|
describe "explicitly turning on superscript characters with bang! method" do
|
163
181
|
|
164
182
|
before :all do
|
165
|
-
|
166
|
-
|
183
|
+
Unit.use_superscript_characters=false
|
184
|
+
Unit.use_superscript_characters!
|
167
185
|
end
|
168
186
|
|
169
187
|
it "should know that superscripts are to be used" do
|
170
|
-
|
188
|
+
Unit.use_superscript_characters?.should be_true
|
171
189
|
end
|
172
190
|
|
173
191
|
it "should use superscript characters for powers of 2 and 3" do
|
@@ -196,10 +214,10 @@ describe Unit do
|
|
196
214
|
Unit.parse("m^4 K^2/s^3").label.should eql 'm^4·K²/s³'
|
197
215
|
Unit.parse("m^4 K^2 s^-3").label.should eql 'm^4·K²/s³'
|
198
216
|
|
199
|
-
Unit.parse("m^4·K²/s³").symbol.should eql 'm^4 K
|
200
|
-
Unit.parse("m^4 K²/s³").symbol.should eql 'm^4 K
|
201
|
-
Unit.parse("m^4 K^2/s^3").symbol.should eql 'm^4 K
|
202
|
-
Unit.parse("m^4 K^2 s^-3").symbol.should eql 'm^4 K
|
217
|
+
Unit.parse("m^4·K²/s³").symbol.should eql 'm^4 K²/s³'
|
218
|
+
Unit.parse("m^4 K²/s³").symbol.should eql 'm^4 K²/s³'
|
219
|
+
Unit.parse("m^4 K^2/s^3").symbol.should eql 'm^4 K²/s³'
|
220
|
+
Unit.parse("m^4 K^2 s^-3").symbol.should eql 'm^4 K²/s³'
|
203
221
|
|
204
222
|
Unit.parse("m^4·K²/s³").name.should eql 'metre to the 4th power square kelvin per cubic second'
|
205
223
|
Unit.parse("m^4 K²/s³").name.should eql 'metre to the 4th power square kelvin per cubic second'
|
@@ -357,35 +375,35 @@ describe Unit do
|
|
357
375
|
end
|
358
376
|
|
359
377
|
it "should recognise compound unit with single word name" do
|
360
|
-
Unit.centimetre_per_hour.symbol.should eql "cm
|
378
|
+
Unit.centimetre_per_hour.symbol.should eql "cm/h"
|
361
379
|
end
|
362
380
|
|
363
381
|
it "should recognise compound unit with multiple word name" do
|
364
|
-
Unit.centimetre_of_mercury_per_hour.symbol.should eql "cmHg
|
382
|
+
Unit.centimetre_of_mercury_per_hour.symbol.should eql "cmHg/h"
|
365
383
|
end
|
366
384
|
|
367
385
|
it "should recognise compound unit with single word pluralized name" do
|
368
|
-
Unit.centimetres_per_hour.symbol.should eql "cm
|
386
|
+
Unit.centimetres_per_hour.symbol.should eql "cm/h"
|
369
387
|
end
|
370
388
|
|
371
389
|
it "should recognise compound unit with multiple word pluralized name" do
|
372
|
-
Unit.centimetres_of_mercury_per_hour.symbol.should eql "cmHg
|
390
|
+
Unit.centimetres_of_mercury_per_hour.symbol.should eql "cmHg/h"
|
373
391
|
end
|
374
392
|
|
375
393
|
it "should recognise compound unit with single word name" do
|
376
|
-
Unit.centimetre_per_hour_US_bushel.symbol.should eql "cm
|
394
|
+
Unit.centimetre_per_hour_US_bushel.symbol.should eql "cm/h bu (Imp)"
|
377
395
|
end
|
378
396
|
|
379
397
|
it "should recognise compound unit with multiple word name" do
|
380
|
-
Unit.centimetre_of_mercury_per_hour_US_bushel.symbol.should eql "cmHg
|
398
|
+
Unit.centimetre_of_mercury_per_hour_US_bushel.symbol.should eql "cmHg/h bu (Imp)"
|
381
399
|
end
|
382
400
|
|
383
401
|
it "should recognise compound unit with single word pluralized name" do
|
384
|
-
Unit.centimetres_per_hour_US_bushels.symbol.should eql "cm
|
402
|
+
Unit.centimetres_per_hour_US_bushels.symbol.should eql "cm/h bu (Imp)"
|
385
403
|
end
|
386
404
|
|
387
405
|
it "should recognise compound unit with multiple word pluralized name" do
|
388
|
-
Unit.centimetres_of_mercury_per_hour_US_bushels.symbol.should eql "cmHg
|
406
|
+
Unit.centimetres_of_mercury_per_hour_US_bushels.symbol.should eql "cmHg/h bu (Imp)"
|
389
407
|
end
|
390
408
|
|
391
409
|
describe "parsing unit string" do
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: quantify
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 31
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 1
|
8
|
-
-
|
8
|
+
- 2
|
9
9
|
- 0
|
10
|
-
version: 1.
|
10
|
+
version: 1.2.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Andrew Berkeley
|
@@ -15,12 +15,11 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-
|
18
|
+
date: 2011-08-04 00:00:00 +01:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
22
|
-
|
23
|
-
prerelease: false
|
22
|
+
type: :runtime
|
24
23
|
requirement: &id001 !ruby/object:Gem::Requirement
|
25
24
|
none: false
|
26
25
|
requirements:
|
@@ -30,49 +29,148 @@ dependencies:
|
|
30
29
|
segments:
|
31
30
|
- 0
|
32
31
|
version: "0"
|
33
|
-
type: :runtime
|
34
32
|
version_requirements: *id001
|
35
|
-
|
33
|
+
name: activesupport
|
34
|
+
prerelease: false
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
type: :runtime
|
37
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
38
|
+
none: false
|
39
|
+
requirements:
|
40
|
+
- - ">="
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
hash: 3
|
43
|
+
segments:
|
44
|
+
- 0
|
45
|
+
version: "0"
|
46
|
+
version_requirements: *id002
|
47
|
+
name: i18n
|
48
|
+
prerelease: false
|
49
|
+
- !ruby/object:Gem::Dependency
|
50
|
+
type: :development
|
51
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
52
|
+
none: false
|
53
|
+
requirements:
|
54
|
+
- - ~>
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
hash: 23
|
57
|
+
segments:
|
58
|
+
- 1
|
59
|
+
- 0
|
60
|
+
- 0
|
61
|
+
version: 1.0.0
|
62
|
+
version_requirements: *id003
|
63
|
+
name: bundler
|
64
|
+
prerelease: false
|
65
|
+
- !ruby/object:Gem::Dependency
|
66
|
+
type: :development
|
67
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
68
|
+
none: false
|
69
|
+
requirements:
|
70
|
+
- - ~>
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
hash: 7
|
73
|
+
segments:
|
74
|
+
- 1
|
75
|
+
- 6
|
76
|
+
- 4
|
77
|
+
version: 1.6.4
|
78
|
+
version_requirements: *id004
|
79
|
+
name: jeweler
|
80
|
+
prerelease: false
|
81
|
+
- !ruby/object:Gem::Dependency
|
82
|
+
type: :development
|
83
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
84
|
+
none: false
|
85
|
+
requirements:
|
86
|
+
- - "="
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
hash: 27
|
89
|
+
segments:
|
90
|
+
- 1
|
91
|
+
- 3
|
92
|
+
- 0
|
93
|
+
version: 1.3.0
|
94
|
+
version_requirements: *id005
|
95
|
+
name: rspec
|
96
|
+
prerelease: false
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
type: :development
|
99
|
+
requirement: &id006 !ruby/object:Gem::Requirement
|
100
|
+
none: false
|
101
|
+
requirements:
|
102
|
+
- - ">="
|
103
|
+
- !ruby/object:Gem::Version
|
104
|
+
hash: 3
|
105
|
+
segments:
|
106
|
+
- 0
|
107
|
+
version: "0"
|
108
|
+
version_requirements: *id006
|
109
|
+
name: rcov
|
110
|
+
prerelease: false
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
type: :development
|
113
|
+
requirement: &id007 !ruby/object:Gem::Requirement
|
114
|
+
none: false
|
115
|
+
requirements:
|
116
|
+
- - "="
|
117
|
+
- !ruby/object:Gem::Version
|
118
|
+
hash: 21
|
119
|
+
segments:
|
120
|
+
- 1
|
121
|
+
- 1
|
122
|
+
- 3
|
123
|
+
version: 1.1.3
|
124
|
+
version_requirements: *id007
|
125
|
+
name: rspec_spinner
|
126
|
+
prerelease: false
|
127
|
+
description: A gem to support physical quantities and unit conversions
|
36
128
|
email: andrew.berkeley.is@googlemail.com
|
37
129
|
executables: []
|
38
130
|
|
39
131
|
extensions: []
|
40
132
|
|
41
|
-
extra_rdoc_files:
|
42
|
-
|
43
|
-
files:
|
133
|
+
extra_rdoc_files:
|
44
134
|
- README
|
135
|
+
files:
|
136
|
+
- .rvmrc
|
45
137
|
- COPYING
|
46
|
-
-
|
47
|
-
-
|
48
|
-
-
|
49
|
-
-
|
50
|
-
- lib/quantify
|
51
|
-
- lib/quantify/unit/base_unit.rb
|
52
|
-
- lib/quantify/unit/si_unit.rb
|
53
|
-
- lib/quantify/unit/compound_base_unit.rb
|
54
|
-
- lib/quantify/unit/compound_unit.rb
|
55
|
-
- lib/quantify/unit/non_si_unit.rb
|
138
|
+
- Gemfile
|
139
|
+
- README
|
140
|
+
- Rakefile
|
141
|
+
- VERSION
|
142
|
+
- lib/quantify.rb
|
56
143
|
- lib/quantify/config.rb
|
57
|
-
- lib/quantify/core_extensions/string.rb
|
58
144
|
- lib/quantify/core_extensions/numeric.rb
|
145
|
+
- lib/quantify/core_extensions/string.rb
|
59
146
|
- lib/quantify/core_extensions/symbol.rb
|
60
147
|
- lib/quantify/dimensions.rb
|
61
|
-
- lib/quantify/inflections.rb
|
62
148
|
- lib/quantify/exception.rb
|
63
|
-
- lib/quantify/
|
149
|
+
- lib/quantify/inflections.rb
|
64
150
|
- lib/quantify/quantify.rb
|
65
|
-
- lib/quantify.rb
|
66
|
-
-
|
67
|
-
-
|
151
|
+
- lib/quantify/quantity.rb
|
152
|
+
- lib/quantify/unit/base_unit.rb
|
153
|
+
- lib/quantify/unit/compound_base_unit.rb
|
154
|
+
- lib/quantify/unit/compound_base_unit_list.rb
|
155
|
+
- lib/quantify/unit/compound_unit.rb
|
156
|
+
- lib/quantify/unit/non_si_unit.rb
|
157
|
+
- lib/quantify/unit/prefix/base_prefix.rb
|
158
|
+
- lib/quantify/unit/prefix/non_si_prefix.rb
|
159
|
+
- lib/quantify/unit/prefix/prefix.rb
|
160
|
+
- lib/quantify/unit/prefix/si_prefix.rb
|
161
|
+
- lib/quantify/unit/si_unit.rb
|
162
|
+
- lib/quantify/unit/unit.rb
|
163
|
+
- quantify.gemspec
|
68
164
|
- spec/compound_unit_spec.rb
|
165
|
+
- spec/dimension_spec.rb
|
166
|
+
- spec/quantify_spec.rb
|
69
167
|
- spec/quantity_spec.rb
|
168
|
+
- spec/string_spec.rb
|
70
169
|
- spec/unit_spec.rb
|
71
|
-
- spec/quantify_spec.rb
|
72
170
|
has_rdoc: true
|
73
171
|
homepage: https://github.com/spatchcock/quantify
|
74
|
-
licenses:
|
75
|
-
|
172
|
+
licenses:
|
173
|
+
- MIT
|
76
174
|
post_install_message:
|
77
175
|
rdoc_options: []
|
78
176
|
|
@@ -99,9 +197,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
99
197
|
requirements: []
|
100
198
|
|
101
199
|
rubyforge_project:
|
102
|
-
rubygems_version: 1.6.
|
200
|
+
rubygems_version: 1.6.0
|
103
201
|
signing_key:
|
104
202
|
specification_version: 3
|
105
|
-
summary:
|
203
|
+
summary: Support for handling physical quantities, unit conversions, etc
|
106
204
|
test_files: []
|
107
205
|
|