eqn 1.3.0 → 1.3.1

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: 39b0293f4a288d1ef8c13ad3627ce4aa23b62ebd
4
- data.tar.gz: d4e32c1a62b84f9821c4782e3bc7751134a7c56f
3
+ metadata.gz: dcea04f191cf70d2f6248b5d46ed239e67993062
4
+ data.tar.gz: 0cde20afa46cfcabd29a11240eeb47b082a93cb3
5
5
  SHA512:
6
- metadata.gz: 91490640f171957c8b7fe85967d74f04f6620898d0bf4a7c67fa7d05f915952bf7b818735054a9c97d1369d72de8821cae8acc9e01a287954cb11dd2a778d00a
7
- data.tar.gz: c2f498b84bda0b3cb31ca054c6012d94ba79f8ebcbe80e8025ce6ca966c185f38a6e2992bb5a274ba3a9c574b3101578aae4ee175b61138dedfac6e545ff5377
6
+ metadata.gz: b0d4e68fae317102d84ebfd8bbd920dbb60e04826764a7f9a7ca5c813d169f1a734a4e26f62878923c58932a521268ddcef52f176de060cb535ebf9442aaf6c9
7
+ data.tar.gz: 3535a6c2ebaa09fb57f1c082e2e691b57d582755939df737853ba5d6dc90182b6b94d0345f59d246a314dbd0dec8be1f103d5129c8e0255305f6c08ef67403d5
data/.rubocop.yml CHANGED
@@ -3,8 +3,6 @@ AllCops:
3
3
  - db/**/*
4
4
  - vendor/**/*
5
5
 
6
- AbcSize:
7
- Enabled: false
8
6
  BlockNesting:
9
7
  Max: 4
10
8
  ClassLength:
data/eqn.gemspec CHANGED
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
10
10
  spec.email = ['zach@aha.io']
11
11
 
12
12
  spec.summary = 'A gem to evaluate numerical equations.'
13
- spec.description = 'A gem to evaluate numerical equations. Includes support for functions.'
13
+ spec.description = 'A gem to evaluate numerical equations. Includes support for variables and functions.'
14
14
  spec.homepage = 'https://github.com/schneidmaster/eqn'
15
15
  spec.license = 'MIT'
16
16
 
@@ -15,7 +15,7 @@ module Eqn
15
15
  def valid?(data, vars = {})
16
16
  calc(data, vars)
17
17
  true
18
- rescue NonNumericVariableError, NoVariableValueError, ParseError, ZeroDivisionError
18
+ rescue EqnError
19
19
  false
20
20
  end
21
21
  end
data/lib/eqn/errors.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  module Eqn
2
- class NonNumericVariableError < StandardError; end
3
- class NoVariableValueError < StandardError; end
4
- class ParseError < StandardError; end
5
- class ZeroDivisionError < StandardError; end
2
+ class EqnError < StandardError; end
3
+ class NonNumericVariableError < EqnError; end
4
+ class NoVariableValueError < EqnError; end
5
+ class ParseError < EqnError; end
6
+ class ZeroDivisionError < EqnError; end
6
7
  end
data/lib/eqn/function.rb CHANGED
@@ -8,11 +8,7 @@ module Eqn
8
8
  ls = elements.shift.value
9
9
  rs = elements.shift.value
10
10
 
11
- if comp_val
12
- ls
13
- else
14
- rs
15
- end
11
+ comp_val ? ls : rs
16
12
  end
17
13
  end
18
14
 
data/lib/eqn/number.rb CHANGED
@@ -18,11 +18,7 @@ module Eqn
18
18
  value = elements.shift.value
19
19
 
20
20
  # Apply sign if any.
21
- if sign_negative
22
- -value
23
- else
24
- value
25
- end
21
+ sign_negative ? -value : value
26
22
  end
27
23
  end
28
24
 
data/lib/eqn/terminal.rb CHANGED
@@ -3,6 +3,7 @@ module Eqn
3
3
  class Node < Treetop::Runtime::SyntaxNode; end
4
4
 
5
5
  class Variable < Node
6
+ # rubocop:disable Metrics/AbcSize
6
7
  def value
7
8
  unless Eqn::Calculator.class_variable_get(:@@vars).key? text_value.intern
8
9
  fail NoVariableValueError, "No value given for: #{text_value}"
@@ -12,6 +13,7 @@ module Eqn
12
13
  end
13
14
  Eqn::Calculator.class_variable_get(:@@vars)[text_value.intern]
14
15
  end
16
+ # rubocop:enable Metrics/AbcSize
15
17
  end
16
18
 
17
19
  class Digits < Node
data/lib/eqn/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Eqn
2
- VERSION = '1.3.0'
2
+ VERSION = '1.3.1'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: eqn
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0
4
+ version: 1.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Zach Schneider
@@ -108,7 +108,8 @@ dependencies:
108
108
  - - ~>
109
109
  - !ruby/object:Gem::Version
110
110
  version: 0.10.0
111
- description: A gem to evaluate numerical equations. Includes support for functions.
111
+ description: A gem to evaluate numerical equations. Includes support for variables
112
+ and functions.
112
113
  email:
113
114
  - zach@aha.io
114
115
  executables: []