ruby-units 2.2.1 → 2.3.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
- SHA1:
3
- metadata.gz: 52d0abf6dc2d186c597aa3543dfb64a2e4e58437
4
- data.tar.gz: bc9f92f2eaf3eeefb1df33699785d21a2ff9fcf8
2
+ SHA256:
3
+ metadata.gz: 1a7f0ef586984958760da336474f343c66b598b063991b55c7b1cbedda49d630
4
+ data.tar.gz: 71831000f4bcdd187ea834ca7e227c40eb2e143f8ccdddef4c0b3e4c0d3c385d
5
5
  SHA512:
6
- metadata.gz: cf20400a8552f515beb913042d5d8736402ac244736718fe515058b5556b4f13b3b04fc8091f65fde2adcdb5da8af48af5f32a54b7bdf51f1824ba1371df9f3b
7
- data.tar.gz: '066711448923f74c7f9995bfd3f1c700495018ffe142ea48e1dbe1158e3842f3d19a363268ecd38546fc35768196334f8fbd05cf3aae693335217e43b3c70d83'
6
+ metadata.gz: bdab6e591cc0aaa668382d49d9e8a01846da31f46f2a3330f66a7b66445b5f649287d21943b1bd75648de3cce44b64e7f06070e00a070f50e8f1794451675511
7
+ data.tar.gz: 55723037f57f90d181643792f47452a8bd4c5150ae6ddc4038d998a4f30b9331aa73e331d3fc090776fdf3a0424032975cd0a5fb56c85d289b545f0c2ff682af
@@ -1,5 +1,8 @@
1
1
  Change Log for Ruby-units
2
2
  =========================
3
+ 2018-03-06 2.3.0 * Fix add (+) and subtract (-) for BigDecimal scalars. (see #167)
4
+ * Update ruby versions (#163)
5
+ * fix: temperature converting rational issue (#164)
3
6
  2017-12-07 2.2.1 * fix an issue with formatting of rational scalars (see #159)
4
7
  2017-08-07 2.2.0 * add support for ruby 2.4.1
5
8
  * drop support for ruby 2.1.0
data/VERSION CHANGED
@@ -1 +1 @@
1
- 2.2.1
1
+ 2.3.0
@@ -847,14 +847,7 @@ module RubyUnits
847
847
  RubyUnits::Unit.new(scalar: (other.scalar + convert_to(other.temperature_scale).scalar), numerator: other.numerator, denominator: other.denominator, signature: other.signature)
848
848
  end
849
849
  else
850
- @q ||= begin
851
- begin
852
- Rational(@@cached_units[units].scalar, @@cached_units[units].base_scalar)
853
- rescue
854
- units.to_unit.to_base.scalar
855
- end
856
- end
857
- RubyUnits::Unit.new(scalar: (base_scalar + other.base_scalar) * @q, numerator: @numerator, denominator: @denominator, signature: @signature)
850
+ RubyUnits::Unit.new(scalar: (base_scalar + other.base_scalar), numerator: base.numerator, denominator: base.denominator, signature: @signature).to(units)
858
851
  end
859
852
  else
860
853
  raise ArgumentError, "Incompatible Units ('#{self}' not compatible with '#{other}')"
@@ -890,14 +883,7 @@ module RubyUnits
890
883
  elsif other.temperature?
891
884
  raise ArgumentError, 'Cannot subtract a temperature from a differential degree unit'
892
885
  else
893
- @q ||= begin
894
- begin
895
- Rational(@@cached_units[units].scalar, @@cached_units[units].base_scalar)
896
- rescue
897
- Rational(units.to_unit.scalar, units.to_unit.to_base.scalar)
898
- end
899
- end
900
- RubyUnits::Unit.new(scalar: (base_scalar - other.base_scalar) * @q, numerator: @numerator, denominator: @denominator, signature: @signature)
886
+ RubyUnits::Unit.new(scalar: (base_scalar - other.base_scalar), numerator: base.numerator, denominator: base.denominator, signature: @signature).to(units)
901
887
  end
902
888
  else
903
889
  raise ArgumentError, "Incompatible Units ('#{self}' not compatible with '#{other}')"
@@ -1104,19 +1090,19 @@ module RubyUnits
1104
1090
  when '<tempK>'
1105
1091
  @scalar
1106
1092
  when '<tempF>'
1107
- (@scalar + 459.67) * Rational(5, 9)
1093
+ (@scalar + 459.67).to_r * Rational(5, 9)
1108
1094
  when '<tempR>'
1109
- @scalar * Rational(5, 9)
1095
+ @scalar.to_r * Rational(5, 9)
1110
1096
  end
1111
1097
  q = case @@unit_map[target_unit]
1112
1098
  when '<tempC>'
1113
- @base_scalar - 273.15
1099
+ @base_scalar - 273.15r
1114
1100
  when '<tempK>'
1115
1101
  @base_scalar
1116
1102
  when '<tempF>'
1117
- @base_scalar * Rational(9, 5) - 459.67
1103
+ @base_scalar.to_r * Rational(9, 5) - 459.67r
1118
1104
  when '<tempR>'
1119
- @base_scalar * Rational(9, 5)
1105
+ @base_scalar.to_r * Rational(9, 5)
1120
1106
  end
1121
1107
  return RubyUnits::Unit.new("#{q} #{target_unit}")
1122
1108
  else
@@ -2,16 +2,16 @@
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
3
  # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
- # stub: ruby-units 2.2.1 ruby lib
5
+ # stub: ruby-units 2.3.0 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "ruby-units".freeze
9
- s.version = "2.2.1"
9
+ s.version = "2.3.0"
10
10
 
11
11
  s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
12
12
  s.require_paths = ["lib".freeze]
13
13
  s.authors = ["Kevin Olbrich, Ph.D.".freeze]
14
- s.date = "2017-12-07"
14
+ s.date = "2018-03-06"
15
15
  s.description = "Provides classes and methods to perform unit math and conversions".freeze
16
16
  s.email = ["kevin.olbrich+ruby_units@gmail.com".freeze]
17
17
  s.extra_rdoc_files = [
@@ -46,7 +46,7 @@ Gem::Specification.new do |s|
46
46
  ]
47
47
  s.homepage = "https://github.com/olbrich/ruby-units".freeze
48
48
  s.licenses = ["MIT".freeze]
49
- s.rubygems_version = "2.6.13".freeze
49
+ s.rubygems_version = "2.7.4".freeze
50
50
  s.summary = "A class that performs unit conversions and unit math".freeze
51
51
 
52
52
  if s.respond_to? :specification_version then
@@ -58,6 +58,7 @@ Gem::Specification.new do |s|
58
58
  s.add_development_dependency(%q<jeweler>.freeze, [">= 0"])
59
59
  s.add_development_dependency(%q<pry>.freeze, [">= 0"])
60
60
  s.add_development_dependency(%q<pry-byebug>.freeze, [">= 0"])
61
+ s.add_development_dependency(%q<ruby-prof>.freeze, [">= 0"])
61
62
  s.add_development_dependency(%q<terminal-notifier>.freeze, [">= 0"])
62
63
  s.add_development_dependency(%q<terminal-notifier-guard>.freeze, [">= 0"])
63
64
  else
@@ -66,6 +67,7 @@ Gem::Specification.new do |s|
66
67
  s.add_dependency(%q<jeweler>.freeze, [">= 0"])
67
68
  s.add_dependency(%q<pry>.freeze, [">= 0"])
68
69
  s.add_dependency(%q<pry-byebug>.freeze, [">= 0"])
70
+ s.add_dependency(%q<ruby-prof>.freeze, [">= 0"])
69
71
  s.add_dependency(%q<terminal-notifier>.freeze, [">= 0"])
70
72
  s.add_dependency(%q<terminal-notifier-guard>.freeze, [">= 0"])
71
73
  end
@@ -75,6 +77,7 @@ Gem::Specification.new do |s|
75
77
  s.add_dependency(%q<jeweler>.freeze, [">= 0"])
76
78
  s.add_dependency(%q<pry>.freeze, [">= 0"])
77
79
  s.add_dependency(%q<pry-byebug>.freeze, [">= 0"])
80
+ s.add_dependency(%q<ruby-prof>.freeze, [">= 0"])
78
81
  s.add_dependency(%q<terminal-notifier>.freeze, [">= 0"])
79
82
  s.add_dependency(%q<terminal-notifier-guard>.freeze, [">= 0"])
80
83
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-units
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.1
4
+ version: 2.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kevin Olbrich, Ph.D.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-12-07 00:00:00.000000000 Z
11
+ date: 2018-03-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -80,6 +80,20 @@ dependencies:
80
80
  - - ">="
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: ruby-prof
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
83
97
  - !ruby/object:Gem::Dependency
84
98
  name: terminal-notifier
85
99
  requirement: !ruby/object:Gem::Requirement
@@ -161,7 +175,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
161
175
  version: '0'
162
176
  requirements: []
163
177
  rubyforge_project:
164
- rubygems_version: 2.6.13
178
+ rubygems_version: 2.7.4
165
179
  signing_key:
166
180
  specification_version: 4
167
181
  summary: A class that performs unit conversions and unit math