eqn 1.6.4 → 1.6.5

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: e3c2babed433b6bdbeec3165078ea736c56bdcd9
4
- data.tar.gz: 21b7734540dc5612fd68489dffdac08fb522efde
2
+ SHA256:
3
+ metadata.gz: 807944d76a7626f0a7772757f110600324c9fa63c12aaad04ad68c07c162ea90
4
+ data.tar.gz: 8debccddd120f9acc3523e6ca8b5a0835823d1c9240177751103b5a886fc7971
5
5
  SHA512:
6
- metadata.gz: 3af53478ab744d25f0cb7ab6b3f5f08f02fa86311936182f660885fa100bcdbd4276e6a570530c53a1b2f08f8d0b89ca94561a2069b8072e9e64d0cc533e59e3
7
- data.tar.gz: e9fbd3a367a4041243fd6f61ac6e37be55558b2550578efb482e3d6cd2ae834bfdd19397c722168af719c08c7ce33e87c86b6342a6cd965dc82660e89c325c16
6
+ metadata.gz: 4b3efde4aa07b6f310bb23085328186253c2874e1cf91d93cc13dc4289d9a8ea903d38052091a3194fedb8e66af2a74945298009fcf436610a011dfadfe84e8c
7
+ data.tar.gz: 865205a5958a138849e8e254ce3dcf4145fa10f27d8934a2132e710682919f234f0c021ea6b3b43e08a9f1a7172535cca43d6fa9b8b3066bd08cca4befd24d91
data/eqn.gemspec CHANGED
@@ -27,9 +27,9 @@ Gem::Specification.new do |spec|
27
27
  spec.add_development_dependency 'appraisal', '~> 2.2.0'
28
28
  spec.add_development_dependency 'bundler', '>= 1.9'
29
29
  spec.add_development_dependency 'codeclimate-test-reporter', '~> 1.0'
30
- spec.add_development_dependency 'rake', '~> 11.0'
31
- spec.add_development_dependency 'rubocop', '~> 0.49'
32
- spec.add_development_dependency 'rubocop-rspec', '~> 1.15'
30
+ spec.add_development_dependency 'rake', '~> 13.0'
31
+ spec.add_development_dependency 'rubocop', '~> 0.60'
32
+ spec.add_development_dependency 'rubocop-rspec', '~> 1.30'
33
33
  spec.add_development_dependency 'rspec', '~> 3.5.0'
34
- spec.add_development_dependency 'simplecov', '~> 0.14'
34
+ spec.add_development_dependency 'simplecov', '< 0.18'
35
35
  end
data/lib/eqn.rb CHANGED
@@ -7,4 +7,4 @@ Treetop.load(File.join(__dir__, 'eqn.treetop'))
7
7
  require File.join(__dir__, 'eqn', 'eqn_node')
8
8
 
9
9
  # Load other eqn classes.
10
- Dir.glob File.join(__dir__, 'eqn', '**', '*.rb'), &method(:require)
10
+ Dir.glob(File.join(__dir__, 'eqn', '**', '*.rb')).sort.each(&method(:require))
data/lib/eqn.treetop CHANGED
@@ -40,19 +40,19 @@ grammar Eqn
40
40
  end
41
41
 
42
42
  rule if_func
43
- 'if' space? '(' comparation ',' expression ',' expression ')' <Eqn::Function::If>
43
+ ('if' / 'IF') space? '(' comparation ',' expression ',' expression ')' <Eqn::Function::If>
44
44
  end
45
45
 
46
46
  rule round_func
47
- 'round' space? '(' expression round_group? ')' <Eqn::Function::Round>
47
+ ('round' / 'ROUND') space? '(' expression round_group? ')' <Eqn::Function::Round>
48
48
  end
49
49
 
50
50
  rule roundup_func
51
- 'roundup' space? '(' expression round_group? ')' <Eqn::Function::RoundUp>
51
+ ('roundup' / 'ROUNDUP') space? '(' expression round_group? ')' <Eqn::Function::RoundUp>
52
52
  end
53
53
 
54
54
  rule rounddown_func
55
- 'rounddown' space? '(' expression round_group? ')' <Eqn::Function::RoundDown>
55
+ ('rounddown' / 'ROUNDDOWN') space? '(' expression round_group? ')' <Eqn::Function::RoundDown>
56
56
  end
57
57
 
58
58
  rule round_group
@@ -27,7 +27,7 @@ module Eqn
27
27
  end
28
28
 
29
29
  def respond_to_missing?(method, _include_private = false)
30
- delegated_method?(method) || match_setter?(method) || match_getter?(method)
30
+ delegated_method?(method) || match_setter?(method) || match_getter?(method) || super
31
31
  end
32
32
 
33
33
  private
@@ -39,6 +39,7 @@ module Eqn
39
39
  def setter_key(method)
40
40
  match = method.to_s.match(/^[A-Za-z]+=$/)
41
41
  return unless match
42
+
42
43
  match.to_s.delete('=').to_sym
43
44
  end
44
45
 
@@ -49,8 +50,10 @@ module Eqn
49
50
  def getter_key(method)
50
51
  match = method.to_s.match(/^[A-Za-z]+$/)
51
52
  return if match.nil?
53
+
52
54
  key = match.to_s.to_sym
53
55
  return unless @vars.key?(key)
56
+
54
57
  key
55
58
  end
56
59
 
@@ -62,6 +65,7 @@ module Eqn
62
65
  def calculate(equation, vars = {})
63
66
  result = Parser.parse(equation).value(vars)
64
67
  raise ZeroDivisionError if result.is_a?(Float) && (result.abs == Float::INFINITY || result.nan?)
68
+
65
69
  result
66
70
  end
67
71
  alias calc calculate
@@ -19,12 +19,14 @@ module Eqn
19
19
 
20
20
  def consume_while_left_associative(base, vars)
21
21
  return base unless left_associative?
22
+
22
23
  base = apply_next_operator(base, vars)
23
24
  consume_while_left_associative(base, vars)
24
25
  end
25
26
 
26
27
  def apply_next_operator(base, vars)
27
28
  return base if term?
29
+
28
30
  left_associative = elements.last.left_associative?
29
31
  op, num_expr = elements.shift.value(vars)
30
32
  if left_associative
@@ -34,10 +36,10 @@ module Eqn
34
36
  end
35
37
  end
36
38
 
37
- def apply_left_associative(base, vars, op, num_expr)
39
+ def apply_left_associative(base, vars, operator, num_expr)
38
40
  num_expr_operand = num_expr.elements.shift
39
41
  elements.push(num_expr.elements.shift) unless num_expr.term?
40
- base.send(op, num_expr_operand.value(vars))
42
+ base.send(operator, num_expr_operand.value(vars))
41
43
  end
42
44
 
43
45
  # Node class for the operator and latter component of an expression.
data/lib/eqn/function.rb CHANGED
@@ -16,6 +16,7 @@ module Eqn
16
16
  def value(vars)
17
17
  value = elements.shift.value(vars)
18
18
  raise ZeroDivisionError if value.is_a?(Float) && (value.abs == Float::INFINITY || value.nan?)
19
+
19
20
  if term?
20
21
  value.send(self.class::ROUND_METHOD)
21
22
  else
data/lib/eqn/terminal.rb CHANGED
@@ -6,6 +6,7 @@ module Eqn
6
6
  val = vars[text_value.to_sym]
7
7
  raise NoVariableValueError, "No value given for: #{text_value}" unless val
8
8
  raise NonNumericVariableError, "Variable #{text_value} value is nonnumeric: #{val}" unless val.is_a?(Numeric)
9
+
9
10
  val
10
11
  end
11
12
  end
data/lib/eqn/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Eqn
2
- VERSION = '1.6.4'.freeze
2
+ VERSION = '1.6.5'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: eqn
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.4
4
+ version: 1.6.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Zach Schneider
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-08-23 00:00:00.000000000 Z
11
+ date: 2021-02-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: treetop
@@ -72,42 +72,42 @@ dependencies:
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: '11.0'
75
+ version: '13.0'
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: '11.0'
82
+ version: '13.0'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: rubocop
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
87
  - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: '0.49'
89
+ version: '0.60'
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
- version: '0.49'
96
+ version: '0.60'
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: rubocop-rspec
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
101
  - - "~>"
102
102
  - !ruby/object:Gem::Version
103
- version: '1.15'
103
+ version: '1.30'
104
104
  type: :development
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
108
  - - "~>"
109
109
  - !ruby/object:Gem::Version
110
- version: '1.15'
110
+ version: '1.30'
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: rspec
113
113
  requirement: !ruby/object:Gem::Requirement
@@ -126,16 +126,16 @@ dependencies:
126
126
  name: simplecov
127
127
  requirement: !ruby/object:Gem::Requirement
128
128
  requirements:
129
- - - "~>"
129
+ - - "<"
130
130
  - !ruby/object:Gem::Version
131
- version: '0.14'
131
+ version: '0.18'
132
132
  type: :development
133
133
  prerelease: false
134
134
  version_requirements: !ruby/object:Gem::Requirement
135
135
  requirements:
136
- - - "~>"
136
+ - - "<"
137
137
  - !ruby/object:Gem::Version
138
- version: '0.14'
138
+ version: '0.18'
139
139
  description: A gem to evaluate mathematical equations. Includes support for variables
140
140
  and functions.
141
141
  email:
@@ -168,7 +168,7 @@ homepage: https://github.com/schneidmaster/eqn
168
168
  licenses:
169
169
  - MIT
170
170
  metadata: {}
171
- post_install_message:
171
+ post_install_message:
172
172
  rdoc_options: []
173
173
  require_paths:
174
174
  - lib
@@ -183,9 +183,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
183
183
  - !ruby/object:Gem::Version
184
184
  version: '0'
185
185
  requirements: []
186
- rubyforge_project:
187
- rubygems_version: 2.6.12
188
- signing_key:
186
+ rubygems_version: 3.0.3
187
+ signing_key:
189
188
  specification_version: 4
190
189
  summary: A gem to evaluate mathematical equations.
191
190
  test_files: []