measured 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/measured/measurable.rb +2 -0
- data/lib/measured/version.rb +1 -1
- data/test/measurable_test.rb +6 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5a69b542ffb24ed97433592b86e4b9528adb4e95
|
4
|
+
data.tar.gz: 1a7f476e754cdb1781fda2b31c630746f91977d3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0a864576e69e8a8df51ba081597ab43c684220c6485b1c04da07fb48cbabe0a15532055e197bfb43c3ad5a14066f8b2c949d103ffa10465fd3d068a5d7fe3cc9
|
7
|
+
data.tar.gz: 955237150a140886a4be19ae03de0d8745befdfa076db4f9239b01964631f4064a6de13680bb846ff5cb058987e0a42801819b32159563234afc20d1926549df
|
data/lib/measured/measurable.rb
CHANGED
@@ -8,6 +8,8 @@ class Measured::Measurable
|
|
8
8
|
raise Measured::UnitError, "Unit #{ unit } does not exits." unless self.class.conversion.unit_or_alias?(unit)
|
9
9
|
|
10
10
|
@value = case value
|
11
|
+
when NilClass
|
12
|
+
raise Measured::UnitError, "Unit value cannot be nil"
|
11
13
|
when Float
|
12
14
|
BigDecimal(value, self.class.conversion.significant_digits)
|
13
15
|
when BigDecimal
|
data/lib/measured/version.rb
CHANGED
data/test/measurable_test.rb
CHANGED
@@ -41,6 +41,12 @@ class Measured::MeasurableTest < ActiveSupport::TestCase
|
|
41
41
|
assert_equal "fireball", Magic.new(1, :fire).unit
|
42
42
|
end
|
43
43
|
|
44
|
+
test "#initialize raises an expected error when initializing with nil" do
|
45
|
+
assert_raises Measured::UnitError do
|
46
|
+
Magic.new(nil, :fire)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
44
50
|
test "#unit allows you to read the unit string" do
|
45
51
|
assert_equal "magic_missile", @magic.unit
|
46
52
|
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.
|
4
|
+
version: 0.0.4
|
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-04-
|
11
|
+
date: 2015-04-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|