faastruby 0.4.4 → 0.4.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/Gemfile.lock +3 -3
- data/exe/faastruby-server +58 -8
- data/lib/faastruby/cli/commands/credentials/add.rb +1 -1
- data/lib/faastruby/cli/commands/credentials/list.rb +1 -1
- data/lib/faastruby/cli/commands/function/build.rb +1 -1
- data/lib/faastruby/cli/commands/function/deploy_to.rb +1 -1
- data/lib/faastruby/cli/commands/function/new.rb +1 -1
- data/lib/faastruby/cli/commands/function/remove_from.rb +1 -1
- data/lib/faastruby/cli/commands/function/run.rb +1 -1
- data/lib/faastruby/cli/commands/function/test.rb +1 -1
- data/lib/faastruby/cli/commands/function/update_context.rb +1 -1
- data/lib/faastruby/cli/commands/function/upgrade.rb +1 -1
- data/lib/faastruby/cli/commands/help.rb +1 -2
- data/lib/faastruby/cli/commands/workspace/create.rb +1 -1
- data/lib/faastruby/cli/commands/workspace/deploy.rb +1 -1
- data/lib/faastruby/cli/commands/workspace/destroy.rb +1 -1
- data/lib/faastruby/cli/commands/workspace/list.rb +1 -1
- data/lib/faastruby/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 404957e8c7556650be4140ad86b4f566e272904d0381cb345be161620d09660d
|
4
|
+
data.tar.gz: 6543bd8471cd41b9139ab21f9d89f6eb004c0c1fbb082253eb9e96a20ae6ab57
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 437bc09653b94ccf8745ae38288d01b89530bb8ec4cde8daa26bf0605a517aa4461609f45e5542f73dcfd9436b04b0caf6d261d2e9500750f75ee184e322653c
|
7
|
+
data.tar.gz: 3e016234385dda335740febe62f2a76dc436b8ac56b890424f04d379b9a7236a6e946bf360d34515cd108278da27b54943891801d562a240dbb1275421952313
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
faastruby (0.4.
|
4
|
+
faastruby (0.4.4)
|
5
5
|
colorize (~> 0.8)
|
6
|
-
faastruby-rpc (~> 0.2.
|
6
|
+
faastruby-rpc (~> 0.2.1)
|
7
7
|
oj (~> 3.6)
|
8
8
|
puma (~> 3.12)
|
9
9
|
rest-client (~> 2.0)
|
@@ -26,7 +26,7 @@ GEM
|
|
26
26
|
domain_name (0.5.20180417)
|
27
27
|
unf (>= 0.0.5, < 1.0.0)
|
28
28
|
equatable (0.5.0)
|
29
|
-
faastruby-rpc (0.2.
|
29
|
+
faastruby-rpc (0.2.1)
|
30
30
|
oj (~> 3.6)
|
31
31
|
hashdiff (0.3.7)
|
32
32
|
http-cookie (1.0.3)
|
data/exe/faastruby-server
CHANGED
@@ -5,6 +5,7 @@ require 'sinatra/multi_route'
|
|
5
5
|
require 'yaml'
|
6
6
|
require 'oj'
|
7
7
|
require 'faastruby-rpc'
|
8
|
+
require 'base64'
|
8
9
|
|
9
10
|
module FaaStRuby
|
10
11
|
class DoubleRenderError < StandardError; end
|
@@ -41,15 +42,31 @@ module FaaStRuby
|
|
41
42
|
@rendered
|
42
43
|
end
|
43
44
|
|
44
|
-
def respond_with(body, status: 200, headers: {})
|
45
|
+
def respond_with(body, status: 200, headers: {}, binary: false)
|
45
46
|
raise FaaStRuby::DoubleRenderError.new("You called 'render' or 'respond_with' twice in your handler method") if rendered?
|
46
|
-
response = FaaStRuby::Response.new(body: body, status: status, headers: headers)
|
47
|
+
response = FaaStRuby::Response.new(body: body, status: status, headers: headers, binary: binary)
|
47
48
|
rendered!
|
48
49
|
response
|
49
50
|
end
|
50
51
|
|
51
|
-
def render(
|
52
|
+
def render(
|
53
|
+
js: nil,
|
54
|
+
body: nil,
|
55
|
+
inline: nil,
|
56
|
+
html: nil,
|
57
|
+
json: nil,
|
58
|
+
yaml: nil,
|
59
|
+
text: nil,
|
60
|
+
data: nil,
|
61
|
+
png: nil,
|
62
|
+
svg: nil,
|
63
|
+
jpeg: nil,
|
64
|
+
gif: nil,
|
65
|
+
icon: nil,
|
66
|
+
status: 200, headers: {}, content_type: nil, binary: false
|
67
|
+
)
|
52
68
|
headers["Content-Type"] = content_type if content_type
|
69
|
+
bin = false
|
53
70
|
case
|
54
71
|
when json
|
55
72
|
headers["Content-Type"] ||= "application/json"
|
@@ -65,12 +82,36 @@ module FaaStRuby
|
|
65
82
|
resp_body = yaml.is_a?(String) ? yaml : YAML.load(yaml)
|
66
83
|
when body
|
67
84
|
headers["Content-Type"] ||= "application/octet-stream"
|
68
|
-
|
85
|
+
bin = binary
|
86
|
+
resp_body = bin ? Base64.urlsafe_encode64(body) : body
|
87
|
+
when data
|
88
|
+
headers["Content-Type"] ||= "application/octet-stream"
|
89
|
+
resp_body = Base64.urlsafe_encode64(data)
|
90
|
+
bin = true
|
69
91
|
when js
|
70
92
|
headers["Content-Type"] ||= "text/javascript"
|
71
93
|
resp_body = js
|
94
|
+
when png
|
95
|
+
headers["Content-Type"] ||= "image/png"
|
96
|
+
resp_body = Base64.urlsafe_encode64(png)
|
97
|
+
bin = true
|
98
|
+
when svg
|
99
|
+
headers["Content-Type"] ||= "image/svg+xml"
|
100
|
+
resp_body = svg
|
101
|
+
when jpeg
|
102
|
+
headers["Content-Type"] ||= "image/jpeg"
|
103
|
+
resp_body = Base64.urlsafe_encode64(jpeg)
|
104
|
+
bin = true
|
105
|
+
when gif
|
106
|
+
headers["Content-Type"] ||= "image/gif"
|
107
|
+
resp_body = Base64.urlsafe_encode64(gif)
|
108
|
+
bin = true
|
109
|
+
when icon
|
110
|
+
headers["Content-Type"] ||= "image/x-icon"
|
111
|
+
resp_body = Base64.urlsafe_encode64(icon)
|
112
|
+
bin = true
|
72
113
|
end
|
73
|
-
respond_with(resp_body, status: status, headers: headers)
|
114
|
+
respond_with(resp_body, status: status, headers: headers, binary: bin)
|
74
115
|
end
|
75
116
|
end
|
76
117
|
|
@@ -78,11 +119,16 @@ module FaaStRuby
|
|
78
119
|
end
|
79
120
|
|
80
121
|
class Response
|
81
|
-
attr_accessor :body, :status, :headers
|
82
|
-
def initialize(body:, status: 200, headers: {})
|
122
|
+
attr_accessor :body, :status, :headers, :binary
|
123
|
+
def initialize(body:, status: 200, headers: {}, binary: false)
|
83
124
|
@body = body
|
84
125
|
@status = status
|
85
126
|
@headers = headers
|
127
|
+
@binary = binary
|
128
|
+
end
|
129
|
+
|
130
|
+
def binary?
|
131
|
+
@binary
|
86
132
|
end
|
87
133
|
end
|
88
134
|
end
|
@@ -117,7 +163,11 @@ class FaaStRubyServer < Sinatra::Application
|
|
117
163
|
response = FaaStRuby::Runner.new.call(params[:workspace_name], params[:function_name], event, rpc_args)
|
118
164
|
status response.status
|
119
165
|
headers response.headers
|
120
|
-
|
166
|
+
if response.binary?
|
167
|
+
body Base64.urlsafe_decode64(response.body)
|
168
|
+
else
|
169
|
+
body response.body
|
170
|
+
end
|
121
171
|
end
|
122
172
|
|
123
173
|
def parse_body(body, content_type, method)
|
@@ -12,8 +12,7 @@ module FaaStRuby
|
|
12
12
|
puts
|
13
13
|
puts 'help, -h, --help # Displays this help'
|
14
14
|
puts '-v # Print version and exit'
|
15
|
-
puts '--region tor1
|
16
|
-
puts
|
15
|
+
puts '--region tor1 # Specify a region. "tor1" (default) is the only region available'
|
17
16
|
workspaces = ["Workspaces:"]
|
18
17
|
functions = ["Functions:"]
|
19
18
|
credentials = ["Credentials:"]
|
@@ -30,7 +30,7 @@ module FaaStRuby
|
|
30
30
|
end
|
31
31
|
|
32
32
|
def self.help
|
33
|
-
"create-workspace".
|
33
|
+
"create-workspace".light_cyan + " WORKSPACE_NAME [--stdout|-c, --credentials-file CREDENTIALS_FILE] [-e, --email YOUR_EMAIL_ADDRESS]"
|
34
34
|
end
|
35
35
|
|
36
36
|
def usage
|
@@ -37,7 +37,7 @@ module FaaStRuby
|
|
37
37
|
end
|
38
38
|
|
39
39
|
def self.help
|
40
|
-
"deploy".
|
40
|
+
"deploy".light_cyan + " [WORKSPACE_FOLDER1] [WORKSPACE_FOLDER2]... # Deploy all workspaces in the current directory and their functions"
|
41
41
|
end
|
42
42
|
|
43
43
|
def usage
|
data/lib/faastruby/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: faastruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Paulo Arruda
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-01-
|
11
|
+
date: 2019-01-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rest-client
|