eqn 1.0.3 → 1.0.4

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: 5169b7bc9b7ffba3e28eae977ec4ec934a56ae22
4
- data.tar.gz: 320adbd2103e2303abafa6a04bc3ac3956904e92
3
+ metadata.gz: 2e11ea96f9a2aaa28a8cc84f85f2d9cddc3dbdf9
4
+ data.tar.gz: 343629ec590a51c1d1cc681e765847fd678f1a93
5
5
  SHA512:
6
- metadata.gz: 43290301b723b40ef8f834038b612c0c382a20bbc835210fa3be6d510afbf20039e78eaf9de2405c9a80ec9326ce15782b7530602b2b4d702f5a3e5043946a87
7
- data.tar.gz: 6b9a586c947a93085d89d0f21d0a040d996a9b2611ef06a07e2751755452220aebab7a4915a4fcd3cf8e258e05af6a82ac083bf35cec00f62c7f3ceca28c9418
6
+ metadata.gz: fdc50130a2876c2071250e64d517c0941b00ed450dc5e133182354e752729c037db43a46c8739baeb05c0c32cc86a51d3f5058b3642fb3ad637b78cf032a4b69
7
+ data.tar.gz: 7b26401ea648a23376c8ab5cd27faf39bea1a3cf2cfba87763c5576bc66488631a5b972e08baa70d72993a03c17d457dfbc75868b41aa57c1954f30084446239
@@ -1,3 +1,9 @@
1
1
  language: ruby
2
2
  rvm:
3
3
  - 2.2.0
4
+ install:
5
+ - gem uninstall bundler
6
+ - gem install bundler --version '1.8.5'
7
+ - bundle
8
+ script:
9
+ - bundle exec rspec
data/README.md CHANGED
@@ -1,3 +1,5 @@
1
+ [![Build Status](https://travis-ci.org/schneidmaster/eqn.svg?branch=master)](https://travis-ci.org/schneidmaster/eqn)
2
+
1
3
  # Eqn
2
4
 
3
5
  Eqn uses the Treetop parser generator to safely evaluate mathematical expressions in Ruby.
@@ -29,7 +31,7 @@ You can also check if an equation is valid:
29
31
 
30
32
  $ Eqn::Calculator.valid?('1 + 1')
31
33
  # => true
32
- $ Eqn::Calculator.valid?('1 + + 1')
34
+ $ Eqn::Calculator.valid?('1 + / 1')
33
35
  # => false
34
36
 
35
37
  If you want to peek at how Eqn is parsing an equation, run the following to get the syntax tree:
@@ -24,5 +24,5 @@ Gem::Specification.new do |spec|
24
24
  spec.add_development_dependency 'bundler', '~> 1.8'
25
25
  spec.add_development_dependency 'rake', '~> 10.0'
26
26
  spec.add_development_dependency 'rubocop', '~> 0.31'
27
- spec.add_development_dependency 'byebug'
27
+ spec.add_development_dependency 'rspec', '~> 3.2.0'
28
28
  end
@@ -2,7 +2,9 @@ module Eqn
2
2
  class Calculator
3
3
  class << self
4
4
  def calc(data)
5
- Parser.parse(data).value
5
+ result = Parser.parse(data).value
6
+ fail ZeroDivisionError if result == Float::INFINITY
7
+ result
6
8
  end
7
9
 
8
10
  def valid?(data)
@@ -15,7 +15,7 @@ module Eqn
15
15
  def self.parse(data)
16
16
  # Remove any whitespace and pass the data over to the parser instance.
17
17
  data.downcase!
18
- while data =~ Eqn::WHITESPACE_REGEX do
18
+ while data =~ Eqn::WHITESPACE_REGEX
19
19
  data = data.downcase.gsub(Eqn::WHITESPACE_REGEX) do
20
20
  Regexp.last_match.to_s.delete(' ')
21
21
  end
@@ -1,3 +1,3 @@
1
1
  module Eqn
2
- VERSION = '1.0.3'
2
+ VERSION = '1.0.4'
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.0.3
4
+ version: 1.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Zach Schneider
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-05-22 00:00:00.000000000 Z
11
+ date: 2015-05-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: treetop
@@ -67,19 +67,19 @@ dependencies:
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0.31'
69
69
  - !ruby/object:Gem::Dependency
70
- name: byebug
70
+ name: rspec
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - ">="
73
+ - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: '0'
75
+ version: 3.2.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: '0'
82
+ version: 3.2.0
83
83
  description: A gem to evaluate numerical equations. Includes support for functions.
84
84
  email:
85
85
  - zach@aha.io