weighable 1.2.0 → 1.2.1

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: 03334b7e6f21d02d412415c4f3e489153f616700
4
- data.tar.gz: 450fffc6175fdf9275ec245eb4098b67fe62a1ec
3
+ metadata.gz: 59590559bae37c9a8917af5d48557eb23f46c6bb
4
+ data.tar.gz: 427bd3b26282dbdf5a4b0a6d942f88e01289bce4
5
5
  SHA512:
6
- metadata.gz: 1bb65307014f18a2eca97b831a6a462eeec631f890319d5e59797ddfc844ac785427bc9a8d8b11ee1e3f8deafb2d54ac40ef623cc7f21225fedf19193c773ba4
7
- data.tar.gz: 1d39b80722b28ef393b901f9aa9dc697c453e57b03191d064a07061dc624243640738c5361de65dd7131754acee85130bcf6b5a69aa363879d8687c8d9f3cfe5
6
+ metadata.gz: c708051394c9f605113a082143d34663deb83e5fd5f1f7c86b1c6efd2655a16ce82583340674b285b85e8e0e432eabb457109d84eb68726da93a712eae803cf7
7
+ data.tar.gz: d1c5fcafe0e8f6933f4ade09e505e46e9f1b5830abc33f2cb6eb546e1d50b40607ad15fd66852409e20ebf54fc00f088395bb8fdf9e71def20e61e9ed8056e8c
@@ -1,3 +1,3 @@
1
1
  module Weighable
2
- VERSION = '1.2.0'.freeze
2
+ VERSION = '1.2.1'.freeze
3
3
  end
@@ -107,19 +107,20 @@ module Weighable
107
107
  }.freeze
108
108
 
109
109
  def self.parse(string)
110
- unit_start = string.index(' ')
110
+ trimmed = string.strip
111
+ unit_start = trimmed.index(' ')
111
112
  if unit_start
112
- unit = string.slice!(unit_start + 1..-1)
113
- value = string.slice!(0..unit_start - 1)
113
+ unit = trimmed.slice!(unit_start + 1..-1)
114
+ value = trimmed.slice!(0..unit_start - 1)
114
115
  from_value_and_unit(value, unit)
115
116
  else
116
- from_value_and_unit(string, nil)
117
+ from_value_and_unit(trimmed, nil)
117
118
  end
118
119
  end
119
120
 
120
121
  def self.from_value_and_unit(value, unit)
121
122
  unit = parse_unit(unit)
122
- fail ArgumentError, 'invalid weight' if unit.nil? || value.nil?
123
+ fail ArgumentError, 'invalid weight' if unit.nil? || value.to_s.strip.empty?
123
124
  Weight.new(value, unit)
124
125
  end
125
126
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: weighable
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Trae Robrock
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-05-07 00:00:00.000000000 Z
11
+ date: 2019-05-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport