measured 0.0.7 → 0.0.8

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0395d2b884e1c125cda042c4e47eac239b80e725
4
- data.tar.gz: f1452c7f31292107b865be6cd36e50fcef97c36c
3
+ metadata.gz: 731b226a8805572a4a0255a83e8afff19e69f130
4
+ data.tar.gz: aa23fde7156e88f98a1cfb394a445be33a12a922
5
5
  SHA512:
6
- metadata.gz: 609da0eabc8fca6efe42818b08c158788fa69be23ff56946ddb7beea2ee18a74592cb815d4ede7e8c0d1bacec49038708d73082ca8940da46366509d4d91adb7
7
- data.tar.gz: a9a35e7c8edd1d0b5f77ac002dca13d7604b3d24feef01c646ef7b28fcd373a77cb571e4f5e5ede49750436d81bf513a809b76b6751c28701396cc11cd6db14a
6
+ metadata.gz: 9ebf0e6ea5082bd46e7284277ad1d40906e332de6243664dc7c71597877490683e4afad21ef03ab732abcdc8e9186d48513c7a8e3a9542daad892af5af603dc4
7
+ data.tar.gz: f5318123494223864845adc4619c93df31701a4bdbb0d0f317843d0407bdc6db5205448702857855e7dedbb0be6605c4aa6da3b4c91fd8ed205bb5eec3d082a4
@@ -50,10 +50,6 @@ class Measured::Conversion
50
50
  @conversion_table ||= Measured::ConversionTable.new(@units).to_h
51
51
  end
52
52
 
53
- def significant_digits
54
- 6
55
- end
56
-
57
53
  private
58
54
 
59
55
  def add_new_unit(unit_name, aliases:, value: nil, base: false)
@@ -11,7 +11,7 @@ class Measured::Measurable
11
11
  when NilClass
12
12
  raise Measured::UnitError, "Unit value cannot be nil"
13
13
  when Float
14
- BigDecimal(value, self.class.conversion.significant_digits)
14
+ BigDecimal(value, Float::DIG+1)
15
15
  when BigDecimal
16
16
  value
17
17
  else
@@ -1,3 +1,3 @@
1
1
  module Measured
2
- VERSION = "0.0.7"
2
+ VERSION = "0.0.8"
3
3
  end
@@ -98,10 +98,6 @@ class Measured::ConversionTest < ActiveSupport::TestCase
98
98
  end
99
99
  end
100
100
 
101
- test "#significatn_digits is fixed for now" do
102
- assert_equal 6, @conversion.significant_digits
103
- end
104
-
105
101
  test "#convert raises if either unit is not found" do
106
102
  assert_raises Measured::UnitError do
107
103
  Magic.conversion.convert(1, from: "fire", to: "doesnt_exist")
@@ -37,6 +37,11 @@ class Measured::MeasurableTest < ActiveSupport::TestCase
37
37
  assert_equal BigDecimal("1.2345"), Magic.new(1.2345, :fire).value
38
38
  end
39
39
 
40
+ test "#initialize converts numbers and strings BigDecimal and does not round large numbers" do
41
+ assert_equal BigDecimal(9.1234572342342, 14), Magic.new(9.1234572342342, :fire).value
42
+ assert_equal BigDecimal("9.1234572342342"), Magic.new(9.1234572342342, :fire).value
43
+ end
44
+
40
45
  test "#initialize converts to the base unit name" do
41
46
  assert_equal "fireball", Magic.new(1, :fire).unit
42
47
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: measured
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kevin McPhillips
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-05-25 00:00:00.000000000 Z
11
+ date: 2015-06-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport