bool 1.0.11-java → 1.0.13-java
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/bool.rb +1 -0
- data/lib/bool/ast.rb +11 -11
- data/lib/bool/evaluator.rb +7 -7
- data/lib/bool/renderer.rb +35 -0
- data/lib/bool_ext.jar +0 -0
- metadata +12 -17
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: e168549a0fb6139e9a1405d4b159df8beb8e21cc
|
4
|
+
data.tar.gz: c376b7a4de44b63fc504ced32da8fbd2f158b71b
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: a612ae1921281dbaaaa1508be2e817319074dc057b3187d6da6b0c51dd8de69e327d35828d5f22203587708ee3b15ce96445fbf39c2547e7b6717cd289f1aab1
|
7
|
+
data.tar.gz: 55fb8e3b6f2a461135022ce0d478329b5ede5f5ce91d9772bd9385f44738d704092f98e1e277a494a5461c7e990744afd3dacc1fda728fe63ed3d4285c792a96
|
data/lib/bool.rb
CHANGED
data/lib/bool/ast.rb
CHANGED
@@ -9,8 +9,8 @@ module Bool
|
|
9
9
|
@name = name
|
10
10
|
end
|
11
11
|
|
12
|
-
def
|
13
|
-
visitor.
|
12
|
+
def accept(visitor, arg)
|
13
|
+
visitor.visit_var(self, arg)
|
14
14
|
end
|
15
15
|
end
|
16
16
|
|
@@ -21,8 +21,8 @@ module Bool
|
|
21
21
|
@left, @right = left, right
|
22
22
|
end
|
23
23
|
|
24
|
-
def
|
25
|
-
visitor.
|
24
|
+
def accept(visitor, arg)
|
25
|
+
visitor.visit_and(self, arg)
|
26
26
|
end
|
27
27
|
end
|
28
28
|
|
@@ -33,20 +33,20 @@ module Bool
|
|
33
33
|
@left, @right = left, right
|
34
34
|
end
|
35
35
|
|
36
|
-
def
|
37
|
-
visitor.
|
36
|
+
def accept(visitor, arg)
|
37
|
+
visitor.visit_or(self, arg)
|
38
38
|
end
|
39
39
|
end
|
40
40
|
|
41
41
|
class Not
|
42
|
-
attr_reader :
|
42
|
+
attr_reader :operand
|
43
43
|
|
44
|
-
def initialize(
|
45
|
-
@
|
44
|
+
def initialize(operand)
|
45
|
+
@operand = operand
|
46
46
|
end
|
47
47
|
|
48
|
-
def
|
49
|
-
visitor.
|
48
|
+
def accept(visitor, arg)
|
49
|
+
visitor.visit_not(self, arg)
|
50
50
|
end
|
51
51
|
end
|
52
52
|
end
|
data/lib/bool/evaluator.rb
CHANGED
@@ -8,26 +8,26 @@ module Bool
|
|
8
8
|
end
|
9
9
|
|
10
10
|
else
|
11
|
-
def
|
11
|
+
def visit_var(node, vars)
|
12
12
|
!!vars.index(node.name)
|
13
13
|
end
|
14
14
|
|
15
|
-
def
|
15
|
+
def visit_and(node, vars)
|
16
16
|
evaluate(node.left, vars) && evaluate(node.right, vars)
|
17
17
|
end
|
18
18
|
|
19
|
-
def
|
19
|
+
def visit_or(node, vars)
|
20
20
|
evaluate(node.left, vars) || evaluate(node.right, vars)
|
21
21
|
end
|
22
22
|
|
23
|
-
def
|
24
|
-
!evaluate(node.
|
23
|
+
def visit_not(node, vars)
|
24
|
+
!evaluate(node.operand, vars)
|
25
25
|
end
|
26
26
|
|
27
|
-
|
27
|
+
private
|
28
28
|
|
29
29
|
def evaluate(node, vars)
|
30
|
-
node.
|
30
|
+
node.accept(self, vars)
|
31
31
|
end
|
32
32
|
end
|
33
33
|
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module Bool
|
2
|
+
class Renderer
|
3
|
+
if RUBY_PLATFORM =~ /java/
|
4
|
+
require 'bool_ext'
|
5
|
+
|
6
|
+
def self.new
|
7
|
+
Java::Bool::Renderer.new
|
8
|
+
end
|
9
|
+
|
10
|
+
else
|
11
|
+
def visit_var(node, vars)
|
12
|
+
node.name
|
13
|
+
end
|
14
|
+
|
15
|
+
def visit_and(node, vars)
|
16
|
+
"(" + render(node.left) + " && " + render(node.right) + ")"
|
17
|
+
end
|
18
|
+
|
19
|
+
def visit_or(node, vars)
|
20
|
+
"(" + render(node.left) + " || " + render(node.right) + ")"
|
21
|
+
end
|
22
|
+
|
23
|
+
def visit_not(node, vars)
|
24
|
+
"!" + render(node.operand)
|
25
|
+
end
|
26
|
+
|
27
|
+
private
|
28
|
+
|
29
|
+
def render(node)
|
30
|
+
node.accept(self, nil)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
data/lib/bool_ext.jar
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,48 +1,43 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bool
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
5
|
-
prerelease:
|
4
|
+
version: 1.0.13
|
6
5
|
platform: java
|
7
6
|
authors:
|
8
7
|
- Aslak Hellesøy
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date: 2013-
|
11
|
+
date: 2013-03-16 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: rake
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
|
-
- -
|
17
|
+
- - '>='
|
20
18
|
- !ruby/object:Gem::Version
|
21
19
|
version: '0'
|
22
20
|
type: :development
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
|
-
- -
|
24
|
+
- - '>='
|
28
25
|
- !ruby/object:Gem::Version
|
29
26
|
version: '0'
|
30
27
|
- !ruby/object:Gem::Dependency
|
31
28
|
name: bundler
|
32
29
|
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
30
|
requirements:
|
35
31
|
- - ~>
|
36
32
|
- !ruby/object:Gem::Version
|
37
|
-
version: 1.3.0
|
33
|
+
version: 1.3.0
|
38
34
|
type: :development
|
39
35
|
prerelease: false
|
40
36
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
37
|
requirements:
|
43
38
|
- - ~>
|
44
39
|
- !ruby/object:Gem::Version
|
45
|
-
version: 1.3.0
|
40
|
+
version: 1.3.0
|
46
41
|
description:
|
47
42
|
email:
|
48
43
|
executables: []
|
@@ -51,30 +46,30 @@ extra_rdoc_files: []
|
|
51
46
|
files:
|
52
47
|
- lib/bool/ast.rb
|
53
48
|
- lib/bool/evaluator.rb
|
49
|
+
- lib/bool/renderer.rb
|
54
50
|
- lib/bool.rb
|
55
51
|
- lib/bool_ext.jar
|
56
52
|
homepage:
|
57
53
|
licenses: []
|
54
|
+
metadata: {}
|
58
55
|
post_install_message:
|
59
56
|
rdoc_options: []
|
60
57
|
require_paths:
|
61
58
|
- lib
|
62
59
|
required_ruby_version: !ruby/object:Gem::Requirement
|
63
|
-
none: false
|
64
60
|
requirements:
|
65
|
-
- -
|
61
|
+
- - '>='
|
66
62
|
- !ruby/object:Gem::Version
|
67
63
|
version: '0'
|
68
64
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
69
|
-
none: false
|
70
65
|
requirements:
|
71
|
-
- -
|
66
|
+
- - '>='
|
72
67
|
- !ruby/object:Gem::Version
|
73
68
|
version: '0'
|
74
69
|
requirements: []
|
75
70
|
rubyforge_project:
|
76
|
-
rubygems_version:
|
71
|
+
rubygems_version: 2.0.0.rc.2
|
77
72
|
signing_key:
|
78
|
-
specification_version:
|
73
|
+
specification_version: 4
|
79
74
|
summary: Boolean expression evaluator
|
80
75
|
test_files: []
|