forked from jruizgit/rules
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtestdynamic.rb
49 lines (41 loc) · 1023 Bytes
/
testdynamic.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
require "durable"
require "sinatra"
require "redis"
require "json"
class MyHost < Engine::Host
def initialize()
super()
@_redis = Redis.new
end
def get_action(action_name)
print_lambda = -> c {
c.s.label = action_name
puts "Executing #{action_name}"
}
end
def load_ruleset(ruleset_name)
ruleset = @_redis.get(ruleset_name)
puts(ruleset)
puts JSON.parse(ruleset)
JSON.parse(ruleset)
end
def save_ruleset(ruleset_name, ruleset_definition)
ruleset = JSON.generate(ruleset_definition)
@_redis.set ruleset_name, ruleset
end
end
class MyApplication < Interface::Application
get "/testdynamic.html" do
send_file File.dirname(__FILE__) + "/testdynamic.html"
end
get "/durableVisual.js" do
send_file File.dirname(__FILE__) + "/durableVisual.js"
end
get "/:ruleset_name/admin.html" do
send_file File.dirname(__FILE__) + "/admin.html"
end
end
main_host = MyHost.new
main_host.start!
MyApplication.set_host main_host
MyApplication.run!