fdk 0.0.7 → 0.0.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/lib/fdk/runner.rb +83 -38
- data/lib/fdk/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 8958c018c5730c72cf314b69f19e7930ba7995fb3b1dddb3b012ebcf66dc6171
|
4
|
+
data.tar.gz: 915b07e47c9f919333e380d919f46abcc50a624bdae77153c503246f2ef61576
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 235b4bcf982c408099fa2f1713a4cc658af7c9ff86b61cf1e21bbd72645a39594a063f12b9d34c8e73a4b61931e6825f3f8411cd92dc0ede3d03406cd1e201d7
|
7
|
+
data.tar.gz: 5f506adf41f2df8e0d719b96162c438f8fec6dc118ea10bb8e08927cf9cda73b58ed3a9b35cae8ae7ca01f04e365a5ead1df5969b584e25519c600dbedb50e96
|
data/lib/fdk/runner.rb
CHANGED
@@ -11,46 +11,91 @@ module FDK
|
|
11
11
|
format = ENV['FN_FORMAT']
|
12
12
|
if format == "json"
|
13
13
|
obs = ""
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
# STDERR.puts "
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
14
|
+
first_bracket = false
|
15
|
+
# end_bracket=false
|
16
|
+
stack_count = 0
|
17
|
+
STDIN.each_char do |c|
|
18
|
+
# STDERR.puts "c: #{c}"
|
19
|
+
if c == '{'
|
20
|
+
if !first_bracket
|
21
|
+
# STDERR.puts "setting first_bracket"
|
22
|
+
first_bracket = true
|
23
|
+
end
|
24
|
+
stack_count += 1
|
25
|
+
elsif c == '}'
|
26
|
+
stack_count -= 1
|
27
|
+
end
|
28
|
+
if first_bracket
|
29
|
+
# STDERR.puts "in first_bracket stack_count: #{stack_count}"
|
30
|
+
obs += c
|
31
|
+
if stack_count == 0 # found last bracket, so close this out
|
32
|
+
# STDERR.puts "OBJECT: #{obs}"
|
33
|
+
payload = JSON.parse(obs)
|
34
|
+
# STDERR.puts "payload: #{payload.inspect}"
|
35
|
+
ctx = Context.new(payload)
|
36
|
+
# STDERR.puts "context: " + ctx.inspect
|
37
|
+
# STDERR.flush
|
38
|
+
body = payload['body']
|
39
|
+
if ctx.content_type == 'application/json' && body != ""
|
40
|
+
body = JSON.parse(body)
|
41
|
+
end
|
42
|
+
# TODO: begin/rescue so we can respond with proper error response and code
|
43
|
+
se = FDK.single_event(func, ctx, body)
|
44
|
+
response = {
|
45
|
+
headers: {
|
46
|
+
'Content-Type' => 'application/json'
|
47
|
+
},
|
48
|
+
'status_code' => 200,
|
49
|
+
body: se.to_json,
|
50
|
+
}
|
51
|
+
STDOUT.puts response.to_json
|
52
|
+
STDOUT.puts
|
53
|
+
STDOUT.flush
|
54
|
+
first_bracket = false
|
55
|
+
obs = ""
|
34
56
|
end
|
35
|
-
# TODO: begin/rescue so we can respond with proper error response and code
|
36
|
-
s = FDK.single_event(func, c, body)
|
37
|
-
response = {
|
38
|
-
headers: {
|
39
|
-
'Content-Type' => 'application/json'
|
40
|
-
},
|
41
|
-
'status_code' => 200,
|
42
|
-
body: s.to_json,
|
43
|
-
}
|
44
|
-
STDOUT.puts response.to_json
|
45
|
-
STDOUT.puts
|
46
|
-
STDOUT.flush
|
47
|
-
obs = ""
|
48
|
-
next
|
49
|
-
else
|
50
|
-
endbracket = false
|
51
57
|
end
|
52
|
-
obs += line
|
53
58
|
end
|
59
|
+
|
60
|
+
# STDIN.each do |line|
|
61
|
+
# STDERR.puts "LINE: --#{line}--"
|
62
|
+
# STDERR.flush
|
63
|
+
# ls = line.strip
|
64
|
+
# STDERR.puts "ls: #{ls}"
|
65
|
+
# if ls == "}"
|
66
|
+
# # STDERR.puts "endbracket true"
|
67
|
+
# endbracket=true
|
68
|
+
# elsif ls == "" && endbracket
|
69
|
+
# # TODO: this isn't very robust, probably needs to be better :/
|
70
|
+
# STDERR.puts "OBJECT: #{obs}"
|
71
|
+
# payload = JSON.parse(obs)
|
72
|
+
# STDERR.puts "payload: #{payload.inspect}"
|
73
|
+
# c = Context.new(payload)
|
74
|
+
# STDERR.puts "context: " + c.inspect
|
75
|
+
# STDERR.flush
|
76
|
+
# body = payload['body']
|
77
|
+
# if c.content_type == 'application/json'
|
78
|
+
# body = JSON.parse(body)
|
79
|
+
# end
|
80
|
+
# # TODO: begin/rescue so we can respond with proper error response and code
|
81
|
+
# s = FDK.single_event(func, c, body)
|
82
|
+
# response = {
|
83
|
+
# headers: {
|
84
|
+
# 'Content-Type' => 'application/json'
|
85
|
+
# },
|
86
|
+
# 'status_code' => 200,
|
87
|
+
# body: s.to_json,
|
88
|
+
# }
|
89
|
+
# STDOUT.puts response.to_json
|
90
|
+
# STDOUT.puts
|
91
|
+
# STDOUT.flush
|
92
|
+
# obs = ""
|
93
|
+
# next
|
94
|
+
# else
|
95
|
+
# endbracket = false
|
96
|
+
# end
|
97
|
+
# obs += line
|
98
|
+
# end
|
54
99
|
elsif format == "default"
|
55
100
|
# TODO: check if content type json, and if so, parse it before passing it in
|
56
101
|
body = STDIN.read
|
@@ -69,7 +114,7 @@ module FDK
|
|
69
114
|
end
|
70
115
|
puts FDK.single_event(func, c, body).to_json
|
71
116
|
else
|
72
|
-
raise "Format #{format} not supported in Ruby FDK."
|
117
|
+
raise "Format '#{format}' not supported in Ruby FDK."
|
73
118
|
end
|
74
119
|
end
|
75
120
|
|
data/lib/fdk/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fdk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Travis Reeder
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-03-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json
|
@@ -63,7 +63,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
63
63
|
version: '0'
|
64
64
|
requirements: []
|
65
65
|
rubyforge_project:
|
66
|
-
rubygems_version: 2.6
|
66
|
+
rubygems_version: 2.7.6
|
67
67
|
signing_key:
|
68
68
|
specification_version: 4
|
69
69
|
summary: Ruby FDK for Fn Project
|