weighable 0.9.0 → 0.10.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +4 -0
- data/Guardfile +2 -2
- data/circle.yml +15 -0
- data/lib/weighable/version.rb +1 -1
- data/lib/weighable/weight.rb +13 -8
- data/weighable.gemspec +2 -0
- metadata +30 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8fcb2ad44acb8fa91d311207dafaab42e6b3bc22
|
4
|
+
data.tar.gz: 794c7738019d489ccca5c957c00f5a390d555600
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 16c995bb7cc1512e2ea0b631bae0740430897b392f8fd17fcfd02772dd964ad0dafb992fea476a4834d5cc5fc0d24941d281211219d0229af6a30b782add1192
|
7
|
+
data.tar.gz: c46c5885215fef364313d62c2f444ed7f0a573d4e56858c694d00d00aac97580eb3ffc8b506662ed332f47b5f762a5adf0e674ebe062c8068fc80a71e52cbaa8
|
data/.rubocop.yml
CHANGED
data/Guardfile
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
guard :rspec, cmd:
|
2
|
-
require
|
1
|
+
guard :rspec, cmd: 'bundle exec rspec', failed_mode: :keep do
|
2
|
+
require 'guard/rspec/dsl'
|
3
3
|
dsl = Guard::RSpec::Dsl.new(self)
|
4
4
|
|
5
5
|
# Feel free to open issues for suggestions and improvements
|
data/circle.yml
CHANGED
@@ -1,3 +1,18 @@
|
|
1
|
+
machine:
|
2
|
+
environment:
|
3
|
+
CC_TEST_REPORTER_ID: 0f917edc031f16b4e113269d2a97c6db32df02fb034919c35d95c896d68e5c2a
|
4
|
+
|
1
5
|
dependencies:
|
2
6
|
pre:
|
3
7
|
- gem update bundler
|
8
|
+
post:
|
9
|
+
- curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
|
10
|
+
- chmod +x ./cc-test-reporter
|
11
|
+
|
12
|
+
test:
|
13
|
+
pre:
|
14
|
+
- ./cc-test-reporter before-build
|
15
|
+
override:
|
16
|
+
- bundle exec rspec --format documentation --format RspecJunitFormatter -o $CIRCLE_TEST_REPORTS/rspec.xml
|
17
|
+
post:
|
18
|
+
- ./cc-test-reporter after-build --exit-code $EXIT_CODE
|
data/lib/weighable/version.rb
CHANGED
data/lib/weighable/weight.rb
CHANGED
@@ -152,20 +152,15 @@ module Weighable
|
|
152
152
|
end
|
153
153
|
|
154
154
|
def *(other)
|
155
|
-
|
156
|
-
other = other.to(unit_name)
|
157
|
-
Weight.new(@value * other.value, unit_name)
|
158
|
-
else
|
159
|
-
Weight.new(@value * other, unit_name)
|
160
|
-
end
|
155
|
+
Weight.new(@value * to_math_value(other), unit_name)
|
161
156
|
end
|
162
157
|
|
163
158
|
def /(other)
|
164
|
-
if other.is_a?
|
159
|
+
if other.is_a?(Weight) && !other.is_unit?
|
165
160
|
other = other.to(unit_name)
|
166
161
|
BigDecimal.new(@value / other.value)
|
167
162
|
else
|
168
|
-
Weight.new(@value / other, unit_name)
|
163
|
+
Weight.new(@value / to_math_value(other), unit_name)
|
169
164
|
end
|
170
165
|
end
|
171
166
|
|
@@ -209,6 +204,16 @@ module Weighable
|
|
209
204
|
|
210
205
|
private
|
211
206
|
|
207
|
+
def to_math_value(other)
|
208
|
+
if other.is_a?(Weight) && other.is_unit?
|
209
|
+
other.value
|
210
|
+
elsif other.is_a?(Weight)
|
211
|
+
other.to(unit_name).value
|
212
|
+
else
|
213
|
+
other
|
214
|
+
end
|
215
|
+
end
|
216
|
+
|
212
217
|
def unit_name
|
213
218
|
unit_from_int(@unit)
|
214
219
|
end
|
data/weighable.gemspec
CHANGED
@@ -28,4 +28,6 @@ Gem::Specification.new do |spec|
|
|
28
28
|
spec.add_development_dependency 'rspec', '~> 3.4.0'
|
29
29
|
spec.add_development_dependency 'guard', '~> 2.13.0'
|
30
30
|
spec.add_development_dependency 'guard-rspec', '~> 4.6.4'
|
31
|
+
spec.add_development_dependency 'rspec_junit_formatter'
|
32
|
+
spec.add_development_dependency 'simplecov'
|
31
33
|
end
|
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: 0.
|
4
|
+
version: 0.10.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Trae Robrock
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-01-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -108,6 +108,34 @@ dependencies:
|
|
108
108
|
- - "~>"
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: 4.6.4
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: rspec_junit_formatter
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: simplecov
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - ">="
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - ">="
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0'
|
111
139
|
description: Like BigDecimal, but for weight. Includes Rails integration.
|
112
140
|
email:
|
113
141
|
- trobrock@gmail.com
|