-
Notifications
You must be signed in to change notification settings - Fork 31
/
udf.rb
41 lines (35 loc) · 957 Bytes
/
udf.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
require_relative 'udf_harness'
class Runner
ARGS_HELP = """
Usage:
ruby #{__FILE__} <action> [udf_name]
Actions:
load Loads UDFs into your database
drop Removes UDFs from your database
test Runs UDF unit tests on your database
print Pretty-print SQL for making the UDFs
Examples:
ruby #{__FILE__} load
ruby #{__FILE__} drop harmonic_mean
ruby #{__FILE__} test json_array_first
ruby #{__FILE__} print
"""
def self.run(args = [])
if args.nil? or args.empty?
puts ARGS_HELP
exit
end
u = UdfHarness.new(args[1])
case args.first.to_sym
when :load then u.create_udfs
when :drop then u.drop_udfs
when :test then u.test_udfs
when :print then u.print_udfs
else
puts "Args not understood, showing help instead."
puts ARGS_HELP
exit
end
end
end
Runner.run(ARGV) if __FILE__ == $PROGRAM_NAME