unitwise 2.0.0 → 2.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: dfd97b3dc7b4fbee73653902232de8df74d79967
4
- data.tar.gz: 25837b28be1ab4e3fbb71100bf6221986419fd65
3
+ metadata.gz: 85c8f9524b9cffa66bf645e212104c3985e4efa3
4
+ data.tar.gz: b8a7623a2eb3186faef2d8c11056307f454d29ef
5
5
  SHA512:
6
- metadata.gz: bd81647b67a9ca56b420b6cf47d4c60e2f6311a1d7aef97d6a41309fd4e6a4ba43b746d9c4f776d9dd8dd0d82c95ec69d2e53ba0a211aee7dc49a2045092384e
7
- data.tar.gz: 7fda14718114a1430b56873b68336e5eb92636f97597dce3e743ca72346499d2d3cdfcb4bb61eeedcd6162bfa3b90318f9eec0cc025e19f234f3e0eab7bc73a6
6
+ metadata.gz: 7cb7314cfefef4d4f4172c8608463b4e2f31c70aecc54115b4584eff913f76301a5114be12b79c64926b5ca19d33f106916c798643eb4999f7b16bce4e911fdb
7
+ data.tar.gz: c7e97adc9d4dc60f53f6ccff5d1d8b3522361b7f0118f08ccb61a8cc58cacb005e34802f6f1219c9b4ff3546bbc7749c171e47a514a362e4dfa9fe9d4d52699d
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 2.2.0
1
+ 2.4.1
data/.travis.yml CHANGED
@@ -3,18 +3,13 @@ cache: bundler
3
3
  bundler_args: --without yard pry
4
4
  sudo: false
5
5
  rvm:
6
- - 1.9.3
7
- - 2.0.0
8
- - 2.1
9
- - 2.2
6
+ - 2.2.7
7
+ - 2.3.4
8
+ - 2.4.1
9
+ - jruby-9.1.8.0
10
10
  - ruby-head
11
- - rbx-2
11
+ - jruby-head
12
12
  matrix:
13
- include:
14
- - rvm: jruby-19mode
15
- env: JRUBY_OPTS="$JRUBY_OPTS --debug"
16
- - rvm: jruby-head
17
- env: JRUBY_OPTS="$JRUBY_OPTS --debug"
18
13
  allow_failures:
19
14
  - rvm: ruby-head
20
15
  - rvm: jruby-head
data/CHANGELOG.md CHANGED
@@ -5,6 +5,44 @@ version 1.0.0.
5
5
 
6
6
  Unitwise uses semantic versioning.
7
7
 
8
+ ## Unreleased
9
+
10
+ ## 2.2.0 - 2017-07-14
11
+
12
+ ### Fixed
13
+
14
+ - Default units now stored as BigDecimal or Integer to reduce floating point
15
+ accuracy loss.
16
+ - Added missing conversion for Degree Réaumur.
17
+
18
+ ### Changed
19
+
20
+ - Performing mathematical operations or converting units will now use Rational
21
+ math to prevent accuracy loss. In most cases, this means converted/operated
22
+ on `Measurement`s will have a `Rational` `#value`. If you have an explicit
23
+ dependency on the exact `Numeric` type that `Measurement#value` returns,
24
+ consider using `#to_f` or `#to_i` instead.
25
+
26
+ ### Removed
27
+
28
+ - Support for MRI 2.1
29
+
30
+ ## 2.1.0 - 2017-04-28
31
+
32
+ ### Removed
33
+
34
+ - Support for Ruby MRI 1.9.3, MRI 2.0, and Rubinius
35
+
36
+ ### Added
37
+
38
+ - `Unitwise.register` is a new method that allows user defined units
39
+ - Support for MRI 2.3 and 2.4
40
+
41
+ ### Changed
42
+
43
+ - Unit data refreshed from latest UCUM spec. Most notably, some metric atoms
44
+ names have seen case changes.
45
+
8
46
  ## 2.0.0 - 2015-09-13
9
47
 
10
48
  ### Fixed
data/Gemfile CHANGED
@@ -1,10 +1,6 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
3
  gem 'coveralls', '~> 0.7'
4
- if RUBY_VERSION >= '2.2.0'
5
- gem 'bigdecimal', '~> 1.2.6', :platform => :mri
6
- else
7
- gem 'bigdecimal', '~> 1.2.5', :platform => :mri
8
- end
4
+ gem 'bigdecimal', '>= 1.2.6', :platform => :mri
9
5
 
10
6
  gemspec
data/README.md CHANGED
@@ -237,17 +237,46 @@ Unitwise(1, "meter/s") # Does not work, mixed designations (name and primar
237
237
  Unitwise(1, "meter") / Unitwise(1, "s") # Also works
238
238
  ```
239
239
 
240
+
241
+ ### Adding custom units
242
+
243
+ While UCUM's list of units is rather exhaustive, there may still be occasions
244
+ where you need custom or uncommon measurements. You can add them yourself
245
+ with `Unitwise.register`, which will allow you to convert to or from the new
246
+ unit.
247
+
248
+ For example, if your app needed to pour "3 fingers" of bourbon, you could
249
+ register an atom for that:
250
+
251
+ ```ruby
252
+ Unitwise.register(
253
+ names: ["finger", "fingers"],
254
+ symbol: "🥃",
255
+ primary_code: "fng",
256
+ secondary_code: "fng",
257
+ scale: {
258
+ value: 1.0,
259
+ unit_code: '[foz_us]'
260
+ },
261
+ property: 'fluid volume'
262
+ )
263
+
264
+ Unitwise(1, "gallon").to_fingers
265
+ # => #<Unitwise::Measurement value=0.153721590464621430998E3 unit=fingers>
266
+
267
+ Unitwise(1, "🥃").to_cup
268
+ # => #<Unitwise::Measurement value=0.125 unit=cup>
269
+ ```
270
+
240
271
  ## Supported Ruby Versions
241
272
 
242
273
  This library aims to support and is tested against the following Ruby
243
274
  implementations:
244
275
 
245
- * Ruby 1.9.3
246
- * Ruby 2.0.0
247
- * Ruby 2.1
248
276
  * Ruby 2.2
277
+ * Ruby 2.3
278
+ * Ruby 2.4
249
279
  * [JRuby](http://jruby.org/)
250
- * [Rubinius](http://rubini.us/)
251
280
 
252
281
  If something doesn't work on one of these versions, it's a bug.
253
282
 
data/data/base_unit.yaml CHANGED
@@ -23,13 +23,13 @@
23
23
  :secondary_code: RAD
24
24
  :property: plane angle
25
25
  :dim: A
26
- - :names: Kelvin
26
+ - :names: kelvin
27
27
  :symbol: K
28
28
  :primary_code: K
29
29
  :secondary_code: K
30
30
  :property: temperature
31
31
  :dim: C
32
- - :names: Coulomb
32
+ - :names: coulomb
33
33
  :symbol: C
34
34
  :primary_code: C
35
35
  :secondary_code: C