unitwise 1.1.0 → 2.0.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
2
  SHA1:
3
- metadata.gz: cdeefee8c44bb010c6198248b58819010f753d6f
4
- data.tar.gz: 3e7283137b22b8bf7bf621b8585ce29680ce993e
3
+ metadata.gz: dfd97b3dc7b4fbee73653902232de8df74d79967
4
+ data.tar.gz: 25837b28be1ab4e3fbb71100bf6221986419fd65
5
5
  SHA512:
6
- metadata.gz: 1727d64bdd2929aa882a8150ca3f735a9e95035aebc06fb466e87108f4ba5bf9a3b4d2f734b0cebae0ef37fb9125616c2a307f61951802094fe0db7f656728f1
7
- data.tar.gz: 9c516ce0638721abfe37b8a5f3236d39214896b96c46b813e9a8507027020c40748d9f64e24dcf16dd9228e790fcc6a47c3529fcccbc8f196510a7b5b1e8c142
6
+ metadata.gz: bd81647b67a9ca56b420b6cf47d4c60e2f6311a1d7aef97d6a41309fd4e6a4ba43b746d9c4f776d9dd8dd0d82c95ec69d2e53ba0a211aee7dc49a2045092384e
7
+ data.tar.gz: 7fda14718114a1430b56873b68336e5eb92636f97597dce3e743ca72346499d2d3cdfcb4bb61eeedcd6162bfa3b90318f9eec0cc025e19f234f3e0eab7bc73a6
@@ -1,10 +1,8 @@
1
1
  language: ruby
2
2
  cache: bundler
3
3
  bundler_args: --without yard pry
4
+ sudo: false
4
5
  rvm:
5
- - ree
6
- - 1.8.7
7
- - 1.9.2
8
6
  - 1.9.3
9
7
  - 2.0.0
10
8
  - 2.1
@@ -13,8 +11,6 @@ rvm:
13
11
  - rbx-2
14
12
  matrix:
15
13
  include:
16
- - rvm: jruby-18mode
17
- env: JRUBY_OPTS="$JRUBY_OPTS --debug"
18
14
  - rvm: jruby-19mode
19
15
  env: JRUBY_OPTS="$JRUBY_OPTS --debug"
20
16
  - rvm: jruby-head
@@ -22,4 +18,4 @@ matrix:
22
18
  allow_failures:
23
19
  - rvm: ruby-head
24
20
  - rvm: jruby-head
25
- fast_finish: true
21
+ fast_finish: true
@@ -5,15 +5,34 @@ version 1.0.0.
5
5
 
6
6
  Unitwise uses semantic versioning.
7
7
 
8
+ ## 2.0.0 - 2015-09-13
9
+
10
+ ### Fixed
11
+
12
+ - Gem dependencies are less restrictive; now works with additional versions of
13
+ parslet and blankslate.
14
+
15
+ ### Removed
16
+
17
+ - 'unitwise/ext' is now officially removed. The core Numeric extensions are no
18
+ longer available. Instead of `1.volt` or `2.0.to_joule`, use `Unitwise(1,
19
+ 'volt')` and `Unitwise(2.0, 'Joule')`.
20
+ - Dropped support for Ruby 1.8.7, 1.9.2, and REE.
21
+
8
22
  ## 1.1.0 - 2015-09-10
9
23
 
24
+ ### Fixed
25
+
26
+ - `#to_s` should no longer return the unexpected ' 1' suffix for dimless measurements.
27
+ - `#to_s(mode)` will fall back to using the atom's `primary_code` if the mode
28
+ isn't available.
29
+
30
+ ### Deprecated
31
+
10
32
  - `require unitwise/ext` has been deprecated as it is a performance drag and
11
33
  violates Ruby best practices. Use `require unitwise` instead. Any use of the
12
34
  Numeric helpers like `1.meter`, `2.to_foot` will need to change to
13
35
  `Unitwise(1, 'meter')`, and `Unitwise(2, 'foot')`.
14
- - `#to_s` should no longer return the unexpected ' 1' suffix for dimless measurements.
15
- - `#to_s(mode)` will fall back to using the atom's `primary_code` if the mode
16
- isn't available.
17
36
 
18
37
  ## 1.0.4 - 2015-01-10
19
38
 
data/Gemfile CHANGED
@@ -1,12 +1,10 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
- if RUBY_VERSION > '1.8.7'
4
- gem 'coveralls', '~> 0.7'
5
- if RUBY_VERSION >= '2.2.0'
6
- gem 'bigdecimal', '~> 1.2.6', :platform => :mri
7
- else
8
- gem 'bigdecimal', '~> 1.2.5', :platform => :mri
9
- end
3
+ gem 'coveralls', '~> 0.7'
4
+ if RUBY_VERSION >= '2.2.0'
5
+ gem 'bigdecimal', '~> 1.2.6', :platform => :mri
6
+ else
7
+ gem 'bigdecimal', '~> 1.2.5', :platform => :mri
10
8
  end
11
9
 
12
10
  gemspec
data/README.md CHANGED
@@ -237,34 +237,17 @@ Unitwise(1, "meter/s") # Does not work, mixed designations (name and primar
237
237
  Unitwise(1, "meter") / Unitwise(1, "s") # Also works
238
238
  ```
239
239
 
240
- ## Core extensions (deprecated)
241
-
242
- Unitwise doesn't mess with the core library by default. However, you can
243
- optionally require the core extensions for some handy helpers. I find these
244
- fun for doing calculations in an irb or pry session, but use them in your
245
- application at your own risk. These extensions have been known to negatively
246
- impact performance, and will be removed in a future version.
247
-
248
- ```ruby
249
- require 'unitwise/ext'
250
-
251
- 4.teaspoon # => #<Unitwise::Measurement value=4 unit=teaspoon>
252
- 1.convert_to('liter') # => #<Unitwise::Measurement value=1 unit=liter>
253
- ```
254
-
255
240
  ## Supported Ruby Versions
256
241
 
257
242
  This library aims to support and is tested against the following Ruby
258
243
  implementations:
259
244
 
260
- * Ruby 1.8.7
261
- * Ruby 1.9.2
262
245
  * Ruby 1.9.3
263
246
  * Ruby 2.0.0
264
- * Ruby 2.1.0
247
+ * Ruby 2.1
248
+ * Ruby 2.2
265
249
  * [JRuby](http://jruby.org/)
266
250
  * [Rubinius](http://rubini.us/)
267
- * [Ruby Enterprise Edition](http://www.rubyenterpriseedition.com/)
268
251
 
269
252
  If something doesn't work on one of these versions, it's a bug.
270
253
 
@@ -1,3 +1,3 @@
1
1
  module Unitwise
2
- VERSION = '1.1.0'
2
+ VERSION = '2.0.0'
3
3
  end
@@ -23,9 +23,9 @@ Gem::Specification.new do |gem|
23
23
  gem.add_dependency 'liner', '~> 0.2'
24
24
  gem.add_dependency 'signed_multiset', '~> 0.2'
25
25
  gem.add_dependency 'memoizable', '~> 0.4'
26
- gem.add_dependency 'parslet', '~> 1.5.0'
26
+ gem.add_dependency 'parslet', '~> 1.5'
27
27
 
28
- gem.add_development_dependency 'nokogiri', '~> 1.5.10'
28
+ gem.add_development_dependency 'nokogiri', '~> 1.5'
29
29
  gem.add_development_dependency 'pry', '~> 0.9'
30
30
  gem.add_development_dependency 'minitest', '~> 5.0'
31
31
  gem.add_development_dependency 'rake', '~> 10.0'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: unitwise
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Josh Lewis
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-09-10 00:00:00.000000000 Z
11
+ date: 2015-09-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: liner
@@ -58,28 +58,28 @@ dependencies:
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: 1.5.0
61
+ version: '1.5'
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: 1.5.0
68
+ version: '1.5'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: nokogiri
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: 1.5.10
75
+ version: '1.5'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: 1.5.10
82
+ version: '1.5'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: pry
85
85
  requirement: !ruby/object:Gem::Requirement
@@ -165,8 +165,6 @@ files:
165
165
  - lib/unitwise/expression/matcher.rb
166
166
  - lib/unitwise/expression/parser.rb
167
167
  - lib/unitwise/expression/transformer.rb
168
- - lib/unitwise/ext.rb
169
- - lib/unitwise/ext/numeric.rb
170
168
  - lib/unitwise/functional.rb
171
169
  - lib/unitwise/measurement.rb
172
170
  - lib/unitwise/prefix.rb
@@ -190,7 +188,6 @@ files:
190
188
  - test/unitwise/expression/decomposer_test.rb
191
189
  - test/unitwise/expression/matcher_test.rb
192
190
  - test/unitwise/expression/parser_test.rb
193
- - test/unitwise/ext/numeric_test.rb
194
191
  - test/unitwise/functional_test.rb
195
192
  - test/unitwise/measurement_test.rb
196
193
  - test/unitwise/prefix_test.rb
@@ -233,7 +230,6 @@ test_files:
233
230
  - test/unitwise/expression/decomposer_test.rb
234
231
  - test/unitwise/expression/matcher_test.rb
235
232
  - test/unitwise/expression/parser_test.rb
236
- - test/unitwise/ext/numeric_test.rb
237
233
  - test/unitwise/functional_test.rb
238
234
  - test/unitwise/measurement_test.rb
239
235
  - test/unitwise/prefix_test.rb
@@ -1,5 +0,0 @@
1
- require 'unitwise'
2
- require 'unitwise/ext/numeric'
3
-
4
- warn '`unitwise/ext` is deprecated. These core extensions will be removed ' \
5
- 'in a future version. Please use `unitwise` instead.'
@@ -1,47 +0,0 @@
1
- # Unitwise extends Numeric to add these dyanmic method conveniences: `1.meter`,
2
- # `26.2.to_mile`, and `4.convert_to("Joule")`. These overrides are optional
3
- # and may be enabled with `require 'unitwise/ext'`. These methods are known to
4
- # reduce performance, as well as violate Ruby best practices. They are
5
- # deprecated and will be removed in a future version.
6
- class Numeric
7
- # Converts numeric to a measurement
8
- # @param unit [Unitwise::Unit, String] The unit to use in the measurement
9
- # @return [Unitwise::Measurement]
10
- # @example
11
- # 26.2.convert_to('mile') # => #<Unitwise::Measurement 1 mile>
12
- # @api public
13
- def convert_to(unit)
14
- Unitwise::Measurement.new(self, unit)
15
- end
16
-
17
- # Converts numeric to a measurement by the method name
18
- # @example
19
- # 26.2.mile # => #<Unitwise::Measurement 26.2 mile>
20
- # 100.to_foot # => #<Unitwise::Measurement 100 foot>
21
- # @api semipublic
22
- def method_missing(meth, *args, &block)
23
- if args.empty? && !block_given?
24
- unit = (match = /\Ato_(\w+)\Z/.match(meth.to_s)) ? match[1] : meth
25
- converted = begin
26
- convert_to(unit)
27
- rescue Unitwise::ExpressionError
28
- nil
29
- end
30
- end
31
- if converted
32
- Numeric.define_unit_conversion_methods_for(unit)
33
- converted
34
- else
35
- super(meth, *args, &block)
36
- end
37
- end
38
-
39
- def self.define_unit_conversion_methods_for(name)
40
- [name.to_sym, "to_#{ name }".to_sym].each do |meth|
41
- next if method_defined?(meth)
42
- define_method meth do
43
- convert_to(name)
44
- end
45
- end
46
- end
47
- end
@@ -1,54 +0,0 @@
1
- require 'test_helper'
2
- require 'unitwise/ext'
3
- describe Numeric do
4
- describe "#convert" do
5
- it "must work for Integer" do
6
- measurement = 22.convert_to("kg")
7
- measurement.must_be_instance_of(Unitwise::Measurement)
8
- measurement.value.must_equal 22
9
- end
10
- it "must work for Fixnum" do
11
- measurement = 24.25.convert_to("[ft_i]")
12
- measurement.must_be_instance_of(Unitwise::Measurement)
13
- measurement.value.must_equal 24.25
14
- end
15
- it "must work for Float" do
16
- measurement = (22.0/7).convert_to("[mi_i]")
17
- measurement.must_be_instance_of(Unitwise::Measurement)
18
- measurement.value.must_equal 3.142857142857143
19
- end
20
- it "must work for Rational" do
21
- measurement = Rational(22/7).convert_to("N/m2")
22
- measurement.must_be_instance_of(Unitwise::Measurement)
23
- measurement.value.must_equal Rational(22/7)
24
- end
25
- end
26
-
27
- describe "#method_missing" do
28
- it "must match 'mm'" do
29
- mm = 2.5.mm
30
- mm.must_be_instance_of(Unitwise::Measurement)
31
- mm.value.must_equal 2.5
32
- 1.0.respond_to?(:mm).must_equal true
33
- 3.respond_to?(:to_mm).must_equal true
34
- end
35
- it "must match 'to_mm'" do
36
- mm = 2.5.to_mm
37
- mm.must_be_instance_of(Unitwise::Measurement)
38
- mm.value.must_equal 2.5
39
- 4.0.methods.grep(/mm/).count.must_equal 2
40
- 1.methods.grep(/mm/).count.must_equal 2
41
- end
42
-
43
- it "must not match 'foo'" do
44
- lambda { 1.foo }.must_raise NoMethodError
45
- end
46
-
47
- it "must not match 'to_foo'" do
48
- lambda { 1.to_foo }.must_raise NoMethodError
49
- end
50
-
51
- end
52
-
53
-
54
- end