-
Notifications
You must be signed in to change notification settings - Fork 59
/
reverse_valid
executable file
·94 lines (88 loc) · 2.08 KB
/
reverse_valid
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#!/usr/bin/env ruby
require 'json'
require_relative './check_output'
def action_metadata
metadata = {
:description => "schema test",
:configuration => {
:type => "object",
:properties => {
:spam_dir => {
:type => "string"
},
:eggs_dir => {
:type => "string"
},
:beans_file => {
:type => "string"
}
},
:required => [:spam_dir, :eggs_dir, :beans_file],
:additionalProperties => false,
},
:actions => [
{ :name => "string",
:description => "reverses a string",
:input => {
:type => "object",
:properties => {
:argument => {
:type => "string",
},
},
:required => [ :argument ],
},
:results => {
:type => "object",
:properties => {
:output => {
:type => "string",
},
},
:required => [ :output ],
},
},
{ :name => "hash",
:description => "reverses an element of a hash",
:input => {
:type => "object",
:properties => {
:the_input => {
:type => 'string',
},
},
:required => [ :input ],
},
:results => {
:type => "object",
:properties => {
:the_input => {
:type => 'string',
},
:the_output => {
:type => 'string',
},
},
:required => [ :input, :output ],
},
},
],
}
puts metadata.to_json
end
def action_string
args = JSON.load($stdin)
check_output_files(args)
input_args = args['input']
results = { :output => input_args['argument'].reverse }
puts results.to_json
end
def action_hash
args = JSON.load($stdin)
check_output_files(args)
input_args = args['input']
input_args['the_output'] = input_args['the_input'].reverse
puts input_args.to_json
end
action = ARGV.shift || 'metadata'
Object.send("action_#{action}".to_sym)