simple_logic 0.0.1 → 0.0.2

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: f6509f93fc93262c3a09463d3f0174a5608c1016
4
- data.tar.gz: 5e5cd5ded451b4a9d5bb0416ab9925747fd1a3cb
3
+ metadata.gz: d9543681b9629b68fd281afcb83d423e6e598e57
4
+ data.tar.gz: 77d0fece03df9ce903d0e7fd9198fb481200707a
5
5
  SHA512:
6
- metadata.gz: 3d71ad530e7da3f544fdc4643f2ef0d95ec319431976bebbf00ddd0883b411c4b06d0fa21fdf77cea5cc346a94c22cff7b26f731a280919b373b0056af3e1728
7
- data.tar.gz: 7c5739d0001d4c00c604621d7579bd13bca266723545efb3a2b04bd4268ec252c5a0d9e0b732d4786ce656d49c8e643651f7190165e00fe1b51b4e7f6758cd5c
6
+ metadata.gz: 681c6ef9151f362279edecb00ad78cf409adf2057d91302ee416cc673e0216ca8374209b225dcc53dd28afe5f057e31d7681fc5fd0abfb72e67a3954104574b3
7
+ data.tar.gz: df951bd3063c702d309895be9819cfc1ba0044c4b5f480a2ede78ce38fe18a07bf2da8ba1da3dcd33cf171a3a5a5c6c95fdd26349ade3a3399e093928daa4f4c
data/README.md CHANGED
@@ -1,6 +1,11 @@
1
1
  # SimpleLogic
2
2
 
3
- A ruby gem that parses and evaluates simple boolean statements specified as a string. Useful for evaluating user supplied input in your application without using ruby's eval().
3
+ A ruby gem that parses and evaluates simple boolean statements specified as a string. Useful for evaluating user supplied business rules in your application without using ruby's eval().
4
+
5
+ [![Build Status](https://travis-ci.org/ps2/simple_logic.svg?branch=master)][travis]
6
+
7
+
8
+ [travis]: http://travis-ci.org/ps2/simple_logic
4
9
 
5
10
  ## Installation
6
11
 
@@ -7,9 +7,10 @@ module SimpleLogic
7
7
  end
8
8
 
9
9
  class UndefinedVariableError < StandardError
10
- attr_reader :offset
11
- def initialize(offset)
10
+ attr_reader :offset, :name
11
+ def initialize(offset, name)
12
12
  @offset = offset
13
+ @name = name
13
14
  end
14
15
  end
15
16
 
@@ -63,7 +63,7 @@ module SimpleLogic
63
63
  if context.include?(key)
64
64
  context[key]
65
65
  else
66
- raise UndefinedVariableError, "Undefined variable: \"#{text_value}\""
66
+ raise UndefinedVariableError.new(interval.first, text_value), "Undefined variable: \"#{text_value}\""
67
67
  end
68
68
  end
69
69
  end
@@ -1,3 +1,3 @@
1
1
  module SimpleLogic
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -53,7 +53,11 @@ describe SimpleLogic do
53
53
  it "should raise an exception on undefined variable" do
54
54
  expect {
55
55
  SimpleLogic.eval("testing && hungry", {testing: true})
56
- }.to raise_error(SimpleLogic::UndefinedVariableError)
56
+ }.to raise_error(SimpleLogic::UndefinedVariableError) {|e|
57
+ expect(e.offset).to eq 11
58
+ expect(e.name).to eq "hungry"
59
+ }
60
+
57
61
  end
58
62
 
59
63
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simple_logic
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pete Schwamb
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-05-30 00:00:00.000000000 Z
11
+ date: 2014-06-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler