auom 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (50) hide show
  1. checksums.yaml +7 -0
  2. data/.rspec +1 -0
  3. data/.rubocop.yml +2 -6
  4. data/.travis.yml +5 -2
  5. data/Changelog.md +5 -1
  6. data/Gemfile +0 -5
  7. data/README.md +17 -22
  8. data/TODO +1 -1
  9. data/auom.gemspec +14 -14
  10. data/circle.yml +3 -0
  11. data/config/flay.yml +1 -1
  12. data/config/flog.yml +1 -1
  13. data/config/reek.yml +2 -1
  14. data/config/rubocop.yml +130 -34
  15. data/lib/auom.rb +0 -2
  16. data/lib/auom/algebra.rb +5 -7
  17. data/lib/auom/equalization.rb +0 -2
  18. data/lib/auom/inspection.rb +26 -23
  19. data/lib/auom/relational.rb +2 -4
  20. data/lib/auom/unit.rb +15 -17
  21. data/spec/shared/incompatible_operation_behavior.rb +0 -2
  22. data/spec/shared/operation_behavior.rb +5 -4
  23. data/spec/shared/sunits_shared.rb +0 -2
  24. data/spec/spec_helper.rb +1 -4
  25. data/spec/unit/auom/algebra/add_spec.rb +12 -16
  26. data/spec/unit/auom/algebra/divide_spec.rb +50 -52
  27. data/spec/unit/auom/algebra/multiply_spec.rb +17 -21
  28. data/spec/unit/auom/algebra/substract_spec.rb +4 -8
  29. data/spec/unit/auom/equalization/equality_operator_spec.rb +3 -7
  30. data/spec/unit/auom/inspection/class_methods/prettify_unit_part_spec.rb +7 -7
  31. data/spec/unit/auom/inspection/inspect_spec.rb +1 -5
  32. data/spec/unit/auom/relational/greater_than_or_equal_to_predicate_spec.rb +0 -4
  33. data/spec/unit/auom/relational/greater_than_predicate_spec.rb +0 -4
  34. data/spec/unit/auom/relational/less_than_or_equal_to_predicate_spec.rb +0 -4
  35. data/spec/unit/auom/relational/less_than_predicate_spec.rb +0 -4
  36. data/spec/unit/auom/unit/assert_same_unit_spec.rb +2 -6
  37. data/spec/unit/auom/unit/class_methods/convert_spec.rb +0 -4
  38. data/spec/unit/auom/unit/class_methods/lookup_spec.rb +2 -6
  39. data/spec/unit/auom/unit/class_methods/new_spec.rb +16 -21
  40. data/spec/unit/auom/unit/class_methods/try_convert_spec.rb +0 -4
  41. data/spec/unit/auom/unit/class_methods/units_spec.rb +0 -4
  42. data/spec/unit/auom/unit/denominators_spec.rb +0 -4
  43. data/spec/unit/auom/unit/numerators_spec.rb +0 -4
  44. data/spec/unit/auom/unit/same_unit_predicate_spec.rb +1 -5
  45. data/spec/unit/auom/unit/scalar_spec.rb +0 -4
  46. data/spec/unit/auom/unit/unit_spec.rb +0 -4
  47. data/spec/unit/auom/unit/unitless_predicate_spec.rb +0 -4
  48. metadata +29 -22
  49. data/Gemfile.devtools +0 -71
  50. data/Guardfile +0 -8
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 0052fcab4f594eaadb81ddb9c50b5383a1f6ccbe
4
+ data.tar.gz: 7dee775c276bad51bfa0b8a926b022278f2c008b
5
+ SHA512:
6
+ metadata.gz: 010b60063558dc2268e38fd1af143492334a37f45a5613e52bfb052a2bee8337305ff1df52ebf5ec8d35aca7db1d92185ca6b7fa9f10aba0aef1d12a75f037c8
7
+ data.tar.gz: 4db585b70f9db889c5ff9e39a1afb4793bec6d3d62e2dd710661d29711af67c3b3cbb0874a98057b3ad3675755bc1cbed0969d3cae570050a29c6f0ab06b5067
data/.rspec CHANGED
@@ -1 +1,2 @@
1
1
  --color
2
+ --require spec_helper
@@ -1,7 +1,3 @@
1
1
  AllCops:
2
- Includes:
3
- - 'Gemfile'
4
- Excludes:
5
- - 'Gemfile.devtools'
6
- - 'vendor/**'
7
- - 'benchmarks/**'
2
+ DisplayCopNames: true
3
+ TargetRubyVersion: 2.2
@@ -1,6 +1,9 @@
1
1
  language: ruby
2
2
  script: 'bundle exec rake ci'
3
3
  rvm:
4
- - 1.9.3
5
- - jruby-19mode
4
+ - 2.1
6
5
  - rbx
6
+ matrix:
7
+ include:
8
+ - rvm: jruby
9
+ env: JRUBY_OPTS="$JRUBY_OPTS --debug --2.0"
@@ -1,3 +1,7 @@
1
+ # v0.2.0 2017-09-29
2
+
3
+ * [breaking-change] Drop support for < 2.4
4
+
1
5
  # v0.1.0 2014-03-24
2
6
 
3
7
  * [breaking-change] Drop support for 1.8
@@ -12,7 +16,7 @@
12
16
 
13
17
  # v0.0.4 2012-11-20
14
18
 
15
- * [feature] Support for relational operatiors >, <, >= and <=
19
+ * [feature] Support for relational operators >, <, >= and <=
16
20
 
17
21
  [Compare v0.0.3..v0.0.4](https://github.com/mbj/auom/compare/v0.0.3...v0.0.4)
18
22
 
data/Gemfile CHANGED
@@ -1,8 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  source 'https://rubygems.org'
4
2
 
5
3
  gemspec
6
-
7
- gem 'devtools', git: 'https://github.com/rom-rb/devtools.git'
8
- eval_gemfile 'Gemfile.devtools'
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- AUOM Algebra (for) Units of Measuerment
1
+ AUOM Algebra (for) Units of Measurement
2
2
  =======================================
3
3
 
4
4
  [![Build Status](https://secure.travis-ci.org/mbj/auom.png?branch=master)](http://travis-ci.org/mbj/auom)
@@ -6,7 +6,7 @@ AUOM Algebra (for) Units of Measuerment
6
6
  [![Code Climate](https://codeclimate.com/github/mbj/auom.png)](https://codeclimate.com/github/mbj/auom)
7
7
 
8
8
  This is another unit system for ruby.
9
- It was created since I was not confident about the existing once.
9
+ It was created since I was not confident about the existing ones.
10
10
 
11
11
  Features:
12
12
 
@@ -17,38 +17,33 @@ Features:
17
17
  * No magic coercion from number like strings to numbers.
18
18
  * Will never loose precision (Uses rational as scalar internally)
19
19
  * Allows namespacing of unit systems via subclass.
20
- * Well tested (100% heckle coverage)
20
+ * Well tested (100% mutation coverage via [mutant](https://github.com/mbj/mutant))
21
21
 
22
- The default set of predefined units is miminal as this library should be used in an application
23
- specific subclass. Override: ```AUOR::Unit.units```
22
+ The default set of predefined units is minimal as this library should be used in an application
23
+ specific subclass. Override: ```AUOM::Unit.units```
24
24
 
25
25
  Installation
26
26
  ------------
27
27
 
28
- In your **Gemfile**
29
-
30
- ``` ruby
31
- gem 'auom', :git => 'https://github.com/mbj/auom'
32
- ```
28
+ Install the gem `auom` via your preferred method.
33
29
 
34
30
  Examples
35
31
  --------
36
32
 
37
33
  ``` ruby
38
-
39
- # Create a unit
40
34
  require 'auom'
41
35
 
42
36
  include AUOM
43
37
 
44
- u = Unit.new(1, :meter) # <AUOM::Unit @scalar=1 meter>
45
- u * 100 # <AUOM::Unit @scalar=100 meter>
46
- u / Unit.new(10,:meter) # <AUOM::Unit @scalar=0.1>
47
- u * Unit.new(10,:meter) # <AUOM::Unit @scalar=10 meter^2>
48
- u * Unit.new(1, :euro) # <AUOM::Unit @scalar=1 euro*meter>
49
- u - Unit.new(1, :meter) # <AUOM::Unit @scalar=0 meter>
50
- u + Unit.new(1, :meter) # <AUOM::Unit @scalar=2 meter>
51
- u + Unit.new(1, :euro) # raises error about incompatible units
38
+ u = Unit.new(1, :meter) # <AUOM::Unit @scalar=1 meter>
39
+ u * 100 # <AUOM::Unit @scalar=100 meter>
40
+ u / Unit.new(10, :meter) # <AUOM::Unit @scalar=0.1>
41
+ u / Unit.new(10, [ :meter, :meter ]) # <AUOM::Unit @scaler=0.1 1/meter>
42
+ u * Unit.new(10, :meter) # <AUOM::Unit @scalar=10 meter^2>
43
+ u * Unit.new(1, :euro) # <AUOM::Unit @scalar=1 euro*meter>
44
+ u - Unit.new(1, :meter) # <AUOM::Unit @scalar=0 meter>
45
+ u + Unit.new(1, :meter) # <AUOM::Unit @scalar=2 meter>
46
+ u + Unit.new(1, :euro) # raises error about incompatible units
52
47
  ```
53
48
 
54
49
  Credits
@@ -70,6 +65,6 @@ Contributing
70
65
  Copyright
71
66
  ---------
72
67
 
73
- Copyright (c) 2012 Markus Schirp
68
+ Copyright (c) 2014 Markus Schirp
74
69
 
75
- See LICENSE for details
70
+ See `LICENSE` for details
data/TODO CHANGED
@@ -1 +1 @@
1
- * Make buildin units configurable
1
+ * Make built-in units configurable
@@ -1,20 +1,20 @@
1
- # -*- encoding: utf-8 -*-
1
+ Gem::Specification.new do |gem|
2
+ gem.name = 'auom'
3
+ gem.version = '0.2.0'
2
4
 
3
- Gem::Specification.new do |s|
4
- s.name = 'auom'
5
- s.version = '0.1.0'
5
+ gem.authors = ['Markus Schirp']
6
+ gem.email = 'mbj@schirp-dso.com'
7
+ gem.summary = 'Algebra (with) Units Of Measurement'
8
+ gem.homepage = 'http://github.com/mbj/auom'
6
9
 
7
- s.authors = ['Markus Schirp']
8
- s.email = 'mbj@schirp-dso.com'
9
- s.summary = 'Algebra (with) Units Of Measurement'
10
- s.homepage = 'http://github.com/mbj/auom'
10
+ gem.files = `git ls-files`.split("\n")
11
+ gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
12
+ gem.require_paths = %w[lib]
13
+ gem.extra_rdoc_files = %w[TODO LICENSE]
11
14
 
12
- s.files = `git ls-files`.split("\n")
13
- s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
14
- s.require_paths = %w(lib)
15
- s.extra_rdoc_files = %w(TODO LICENSE)
15
+ gem.required_ruby_version = '>= 2.4'
16
16
 
17
- s.rubygems_version = '1.8.10'
17
+ gem.add_dependency('equalizer', '~> 0.0.9')
18
18
 
19
- s.add_dependency('equalizer', '~> 0.0.9')
19
+ gem.add_development_dependency('devtools', '~> 0.1.12')
20
20
  end
data/circle.yml CHANGED
@@ -1,4 +1,7 @@
1
1
  ---
2
+ machine:
3
+ ruby:
4
+ version: '2.4.2'
2
5
  test:
3
6
  override:
4
7
  - bundle exec rake ci
@@ -1,3 +1,3 @@
1
1
  ---
2
2
  threshold: 12
3
- total_score: 87.0
3
+ total_score: 88
@@ -1,2 +1,2 @@
1
1
  ---
2
- threshold: 20.6
2
+ threshold: 15.1
@@ -55,7 +55,8 @@ NestedIterators:
55
55
  TooManyStatements:
56
56
  max_statements: 6
57
57
  exclude:
58
- - "AUOM::Inspection#pretty_unit" # 7 statements
58
+ - AUOM::Inspection#pretty_unit # 7 statements
59
+ - AUOM::Unit#initialize # 8 statements
59
60
  enabled: true
60
61
  DuplicateMethodCall:
61
62
  allow_calls: []
@@ -1,18 +1,5 @@
1
1
  inherit_from: ../.rubocop.yml
2
2
 
3
- # General note about rubocop.
4
- # It does NOT allow to silence a specific rule violation.
5
- # For that reason I sometimes have to disable a whole cop where
6
- # I just tried to whitelist a specific occurence.
7
-
8
-
9
- AllCops:
10
- Includes:
11
- - '../**/*.rake'
12
- - 'Gemfile'
13
- - 'Gemfile.triage'
14
- - 'mutant.gemspec'
15
-
16
3
  # Avoid parameter lists longer than five parameters.
17
4
  ParameterLists:
18
5
  Max: 3
@@ -24,27 +11,36 @@ BlockNesting:
24
11
 
25
12
  # Align with the style guide.
26
13
  CollectionMethods:
14
+ Enabled: true
27
15
  PreferredMethods:
28
16
  collect: 'map'
29
17
  inject: 'reduce'
30
18
  find: 'detect'
31
19
  find_all: 'select'
32
20
 
33
- MethodLength:
34
- CountComments: false
35
- Max: 17 # TODO: Bring down to 10
36
-
37
- RegexpLiteral: # I do not agree %r(\A) is more readable than /\A/
38
- Enabled: false
21
+ AccessModifierIndentation:
22
+ EnforcedStyle: outdent
39
23
 
40
24
  # Limit line length
41
25
  LineLength:
42
- Max: 124 # TODO: lower to 79
26
+ Max: 120
43
27
 
44
28
  # Disable documentation checking until a class needs to be documented once
45
29
  Documentation:
46
30
  Enabled: false
47
31
 
32
+ # Permit
33
+ #
34
+ # boolean_check? or fail
35
+ #
36
+ # Reject
37
+ #
38
+ # if foo or bar
39
+ # ...
40
+ # end
41
+ AndOr:
42
+ EnforcedStyle: conditionals
43
+
48
44
  # Do not favor modifier if/unless usage when you have a single-line body
49
45
  IfUnlessModifier:
50
46
  Enabled: false
@@ -61,29 +57,129 @@ ConstantName:
61
57
  TrivialAccessors:
62
58
  Enabled: false
63
59
 
64
- # And also have a differend opinion here
65
- AndOr:
60
+ # Allow empty lines around class body
61
+ EmptyLinesAroundClassBody:
66
62
  Enabled: false
67
63
 
68
- # I like my raise
69
- SignalException:
64
+ # Allow empty lines around module body
65
+ EmptyLinesAroundModuleBody:
66
+ Enabled: false
67
+
68
+ # Allow empty lines around block body
69
+ EmptyLinesAroundBlockBody:
70
70
  Enabled: false
71
71
 
72
- # I need to chain optparse builder, else it is more ugly
73
- MultilineBlockChain:
72
+ # Allow multiple line operations to not require indentation
73
+ MultilineOperationIndentation:
74
74
  Enabled: false
75
75
 
76
- ClassLength:
77
- Max: 119
76
+ # Prefer String#% over Kernel#sprintf
77
+ FormatString:
78
+ EnforcedStyle: format
79
+
80
+ # Use square brackets for literal Array objects
81
+ PercentLiteralDelimiters:
82
+ PreferredDelimiters:
83
+ '%': '{}'
84
+ '%i': '[]'
85
+ '%q': ()
86
+ '%Q': ()
87
+ '%r': '{}'
88
+ '%s': ()
89
+ '%w': '[]'
90
+ '%W': '[]'
91
+ '%x': ()
92
+
93
+ # Use %i[...] for arrays of symbols
94
+ SymbolArray:
95
+ Enabled: true
96
+
97
+ # Align if/else blocks with the variable assignment
98
+ EndAlignment:
99
+ EnforcedStyleAlignWith: variable
100
+
101
+ # Prefer #kind_of? over #is_a?
102
+ ClassCheck:
103
+ EnforcedStyle: kind_of?
104
+
105
+ # Do not prefer double quotes to be used when %q or %Q is more appropriate
106
+ UnneededPercentQ:
107
+ Enabled: false
108
+
109
+ # Allow a maximum ABC score
110
+ Metrics/AbcSize:
111
+ Max: 21.02
78
112
 
79
- # I align private keywords with class body
80
- IndentationWidth:
113
+ Metrics/BlockLength:
81
114
  Enabled: false
82
115
 
83
- # I like to have an empty line before closing the currently opened body
84
- EmptyLinesAroundBody:
116
+ # Do not prefer lambda.call(...) over lambda.(...)
117
+ LambdaCall:
85
118
  Enabled: false
86
119
 
87
- # I like my style more
88
- AccessModifierIndentation:
120
+ # Buggy cop, returns false positive for our code base
121
+ NonLocalExitFromIterator:
122
+ Enabled: false
123
+
124
+ # To allow alignment of similar expressions we want to allow more than one
125
+ # space around operators:
126
+ #
127
+ # let(:a) { bar + something }
128
+ # let(:b) { foobar + something }
129
+ #
130
+ SpaceAroundOperators:
131
+ Enabled: false
132
+
133
+ # We use parallel assignments with great success
134
+ ParallelAssignment:
135
+ Enabled: false
136
+
137
+ # Allow additional specs
138
+ ExtraSpacing:
139
+ AllowForAlignment: true
140
+
141
+ # Buggy
142
+ FormatParameterMismatch:
143
+ Enabled: false
144
+
145
+ # Different preference
146
+ SignalException:
147
+ EnforcedStyle: semantic
148
+
149
+ # Do not use `alias`
150
+ Alias:
151
+ EnforcedStyle: prefer_alias_method
152
+
153
+ # Teaching people to ignore singleton class is pointless
154
+ RedundantFreeze:
155
+ Enabled: false
156
+
157
+ # Do not waste my horizontal or vertical space
158
+ IndentArray:
159
+ Enabled: false
160
+
161
+ # Prefer
162
+ #
163
+ # some_receiver
164
+ # .foo
165
+ # .bar
166
+ # .baz
167
+ #
168
+ # Over
169
+ #
170
+ # some_receiver.foo
171
+ # .bar
172
+ # .baz
173
+ MultilineMethodCallIndentation:
174
+ EnforcedStyle: indented
175
+
176
+ # Align keys and values in a multiline hash
177
+ AlignHash:
178
+ EnforcedColonStyle: table
179
+
180
+ # Prefer `public_send` and `__send__` over `send`
181
+ Send:
182
+ Enabled: true
183
+
184
+ Lint/UnifiedInteger:
89
185
  Enabled: false
@@ -1,5 +1,3 @@
1
- # encoding: UTF-8
2
-
3
1
  require 'rational'
4
2
  require 'equalizer'
5
3
 
@@ -1,5 +1,3 @@
1
- # encoding: UTF-8
2
-
3
1
  module AUOM
4
2
  # The AUOM algebra
5
3
  module Algebra
@@ -31,7 +29,7 @@ module AUOM
31
29
 
32
30
  alias_method :+, :add
33
31
 
34
- # Return substraction result
32
+ # Return subtraction result
35
33
  #
36
34
  # @param [Object] operand
37
35
  #
@@ -50,11 +48,11 @@ module AUOM
50
48
  #
51
49
  # @api public
52
50
  #
53
- def substract(operand)
51
+ def subtract(operand)
54
52
  add(operand * -1)
55
53
  end
56
54
 
57
- alias_method :-, :substract
55
+ alias_method :-, :subtract
58
56
 
59
57
  # Return multiplication result
60
58
  #
@@ -70,7 +68,7 @@ module AUOM
70
68
  # # with unit
71
69
  # Unit.new(2, :meter) * Unit.new(1, :meter) # => <AUOM::Unit @scalar=2 meter^2>
72
70
  #
73
- # # differend units
71
+ # # different units
74
72
  # Unit.new(2, :meter) * Unit.new(1, :euro) # => <AUOM::Unit @scalar=2 meter*euro>
75
73
  #
76
74
  # @api public
@@ -102,7 +100,7 @@ module AUOM
102
100
  # # with unit
103
101
  # Unit.new(2, :meter) / Unit.new(1, :meter) # => <AUOM::Unit @scalar=2>
104
102
  #
105
- # # differend units
103
+ # # different units
106
104
  # Unit.new(2, :meter) / Unit.new(1, :euro) # => <AUOM::Unit @scalar=2 meter/euro>
107
105
  #
108
106
  # @api public