expressive 0.0.13 → 0.0.14
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +2 -2
- data/lib/expressive/version.rb +1 -1
- data/lib/expressive.rb +10 -6
- data/lib/scope.rb +6 -2
- data/spec/expressive_spec.rb +10 -1
- metadata +5 -5
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
expressive (0.0.
|
4
|
+
expressive (0.0.14)
|
5
5
|
awesome_print (~> 1.0.2)
|
6
6
|
json
|
7
7
|
polyglot (~> 0.3.3)
|
@@ -28,7 +28,7 @@ GEM
|
|
28
28
|
rb-fsevent (~> 0.9.1)
|
29
29
|
rb-inotify (~> 0.8.8)
|
30
30
|
method_source (0.8)
|
31
|
-
mime-types (1.
|
31
|
+
mime-types (1.21)
|
32
32
|
polyglot (0.3.3)
|
33
33
|
pry (0.9.10)
|
34
34
|
coderay (~> 1.0.5)
|
data/lib/expressive/version.rb
CHANGED
data/lib/expressive.rb
CHANGED
@@ -24,25 +24,25 @@ module Expressive
|
|
24
24
|
end
|
25
25
|
|
26
26
|
module Boolean
|
27
|
-
def eval(scope)
|
27
|
+
def eval(scope = nil)
|
28
28
|
'true' == text_value
|
29
29
|
end
|
30
30
|
end
|
31
31
|
|
32
32
|
module IntegerValue
|
33
|
-
def eval(scope)
|
33
|
+
def eval(scope = nil)
|
34
34
|
text_value.to_i
|
35
35
|
end
|
36
36
|
end
|
37
37
|
|
38
38
|
module FloatValue
|
39
|
-
def eval(scope)
|
39
|
+
def eval(scope = nil)
|
40
40
|
text_value.to_f
|
41
41
|
end
|
42
42
|
end
|
43
43
|
|
44
44
|
module StringValue
|
45
|
-
def eval(scope)
|
45
|
+
def eval(scope = nil)
|
46
46
|
text_value.gsub('"', '')
|
47
47
|
end
|
48
48
|
end
|
@@ -61,8 +61,12 @@ module Expressive
|
|
61
61
|
end
|
62
62
|
|
63
63
|
def eval(scope)
|
64
|
-
|
65
|
-
|
64
|
+
first_elem = statements.first.eval(scope)
|
65
|
+
if first_elem.is_a? Function
|
66
|
+
first_elem.call(scope, statements[1..-1])
|
67
|
+
else
|
68
|
+
statements.map {|stat| stat.eval(scope) }
|
69
|
+
end
|
66
70
|
end
|
67
71
|
end
|
68
72
|
|
data/lib/scope.rb
CHANGED
@@ -14,7 +14,7 @@ module Expressive
|
|
14
14
|
@lookups[lookup_table_name].merge!(lookups)
|
15
15
|
end
|
16
16
|
|
17
|
-
def add_lookup_function(lookup_function_name, passed_in_options, &func_proc)
|
17
|
+
def add_lookup_function(lookup_function_name, passed_in_options = {}, &func_proc)
|
18
18
|
@lookups[lookup_function_name] = [passed_in_options, func_proc]
|
19
19
|
end
|
20
20
|
|
@@ -22,6 +22,10 @@ module Expressive
|
|
22
22
|
@lookups.clear
|
23
23
|
end
|
24
24
|
|
25
|
+
def include?(name)
|
26
|
+
@symbols.include?(name) or @lookups.include?(name)
|
27
|
+
end
|
28
|
+
|
25
29
|
def [](name)
|
26
30
|
@symbols[name] || @parent[name]
|
27
31
|
end
|
@@ -83,7 +87,7 @@ module Expressive
|
|
83
87
|
elsif lookup_result.is_a?(Array)
|
84
88
|
options = lookup_result.first
|
85
89
|
the_proc = lookup_result.last
|
86
|
-
the_proc.call(options, key)
|
90
|
+
the_proc.call(options, key, *cells[2..-1].map {|cell| cell.eval(scope)})
|
87
91
|
end
|
88
92
|
end
|
89
93
|
end
|
data/spec/expressive_spec.rb
CHANGED
@@ -6,7 +6,7 @@ describe "Expressive" do
|
|
6
6
|
end
|
7
7
|
|
8
8
|
describe "all_symbols" do
|
9
|
-
it { Expressive.all_symbols.should =~ %w(+ - * / = set sum get put post >= > < <= and or if date lookup) }
|
9
|
+
it { Expressive.all_symbols.should =~ %w(+ - * / = set sum get put post >= > < <= and or if date lookup round) }
|
10
10
|
end
|
11
11
|
|
12
12
|
describe "understands booleans" do
|
@@ -151,6 +151,15 @@ describe "Expressive" do
|
|
151
151
|
end
|
152
152
|
Expressive.run('(lookup account_reverse_login "ijonas")', @scope).should eql "ea-sanoji"
|
153
153
|
end
|
154
|
+
|
155
|
+
it "should support multiple parameters to a lookup function" do
|
156
|
+
@scope.add_lookup_function("related_count") do |options, related_type, query_specs, last|
|
157
|
+
[related_type, query_specs.length, last]
|
158
|
+
end
|
159
|
+
|
160
|
+
Expressive.run('(lookup related_count "matters" (1 2 3) 10)', @scope).should eql ['matters', 3, 10]
|
161
|
+
end
|
162
|
+
|
154
163
|
end
|
155
164
|
|
156
165
|
describe "understands web-hook statements" do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: expressive
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.14
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-03-
|
12
|
+
date: 2013-03-21 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: ruby_gntp
|
@@ -294,7 +294,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
294
294
|
version: '0'
|
295
295
|
segments:
|
296
296
|
- 0
|
297
|
-
hash:
|
297
|
+
hash: 1436366056289508828
|
298
298
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
299
299
|
none: false
|
300
300
|
requirements:
|
@@ -303,10 +303,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
303
303
|
version: '0'
|
304
304
|
segments:
|
305
305
|
- 0
|
306
|
-
hash:
|
306
|
+
hash: 1436366056289508828
|
307
307
|
requirements: []
|
308
308
|
rubyforge_project:
|
309
|
-
rubygems_version: 1.8.
|
309
|
+
rubygems_version: 1.8.23
|
310
310
|
signing_key:
|
311
311
|
specification_version: 3
|
312
312
|
summary: Scheme-like language for manipulating CaseBlocks cases
|