faastruby 0.5.25 → 0.5.26
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/Gemfile.lock +3 -3
- data/LICENSE +201 -29
- data/dev-setup.sh +28 -0
- data/lib/faastruby/base.rb +8 -0
- data/lib/faastruby/cli.rb +7 -1
- data/lib/faastruby/local.rb +5 -3
- data/lib/faastruby/server.rb +4 -2
- data/lib/faastruby/server/app.rb +16 -6
- data/lib/faastruby/user.rb +18 -27
- data/lib/faastruby/version.rb +1 -1
- data/lib/faastruby/workspace.rb +8 -16
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0bbc36fb5886f04e18c1d094bd6041216676663675a9d043a475cbb70c98dc7d
|
4
|
+
data.tar.gz: d183b83303c6b68174297d0512e35b6d5bf493c8fec9ed9450477991ba0b3d26
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1bb75d649198d703b9f0e5ae9627d94128e950befcc479e67dcf675a36860001f81fff4a4908f4d8d4e0e67940479a62b3dd272a96d8d31507f9bef820845a44
|
7
|
+
data.tar.gz: e9238c9f5c358c2ec1d8d6d67e9db6e18c6f068da1f16ecebc874aa8e2cb4bf42a7faa27c8a80471a777e6d0c953196d808722ae5e6bb362073f5260c15246a6
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,10 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## 0.5.26 - May 16 2019
|
4
|
+
- Fix bug preventing login in certain cases
|
5
|
+
- Fix bug while detecting Crystal executable
|
6
|
+
- Fix bug with parsing form data
|
7
|
+
|
3
8
|
## 0.5.25 - Apr 25 2019
|
4
9
|
- Refactor API call and post-response processing in Workspace class
|
5
10
|
- Prompt user to confirm password as part of the signup process
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
faastruby (0.5.
|
4
|
+
faastruby (0.5.26)
|
5
5
|
colorize (~> 0.8)
|
6
6
|
faastruby-rpc (~> 0.2.7)
|
7
7
|
listen (~> 3.1)
|
@@ -24,7 +24,7 @@ GEM
|
|
24
24
|
addressable (2.5.2)
|
25
25
|
public_suffix (>= 2.0.2, < 4.0)
|
26
26
|
ast (2.4.0)
|
27
|
-
backports (3.
|
27
|
+
backports (3.15.0)
|
28
28
|
colorize (0.8.1)
|
29
29
|
crack (0.4.3)
|
30
30
|
safe_yaml (~> 1.0.0)
|
@@ -132,7 +132,7 @@ GEM
|
|
132
132
|
unf (0.1.4)
|
133
133
|
unf_ext
|
134
134
|
unf_ext (0.0.7.6)
|
135
|
-
unicode-display_width (1.
|
135
|
+
unicode-display_width (1.6.0)
|
136
136
|
unicode_utils (1.4.0)
|
137
137
|
webmock (3.4.2)
|
138
138
|
addressable (>= 2.3.6)
|
data/LICENSE
CHANGED
@@ -1,29 +1,201 @@
|
|
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
|
-
|
1
|
+
Apache License
|
2
|
+
Version 2.0, January 2004
|
3
|
+
http://www.apache.org/licenses/
|
4
|
+
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
6
|
+
|
7
|
+
1. Definitions.
|
8
|
+
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
11
|
+
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
13
|
+
the copyright owner that is granting the License.
|
14
|
+
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
16
|
+
other entities that control, are controlled by, or are under common
|
17
|
+
control with that entity. For the purposes of this definition,
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
19
|
+
direction or management of such entity, whether by contract or
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
22
|
+
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
24
|
+
exercising permissions granted by this License.
|
25
|
+
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
27
|
+
including but not limited to software source code, documentation
|
28
|
+
source, and configuration files.
|
29
|
+
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
31
|
+
transformation or translation of a Source form, including but
|
32
|
+
not limited to compiled object code, generated documentation,
|
33
|
+
and conversions to other media types.
|
34
|
+
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
36
|
+
Object form, made available under the License, as indicated by a
|
37
|
+
copyright notice that is included in or attached to the work
|
38
|
+
(an example is provided in the Appendix below).
|
39
|
+
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
46
|
+
the Work and Derivative Works thereof.
|
47
|
+
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
49
|
+
the original version of the Work and any modifications or additions
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
61
|
+
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
64
|
+
subsequently incorporated within the Work.
|
65
|
+
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
72
|
+
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
78
|
+
where such license applies only to those patent claims licensable
|
79
|
+
by such Contributor that are necessarily infringed by their
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
82
|
+
institute patent litigation against any entity (including a
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
85
|
+
or contributory patent infringement, then any patent licenses
|
86
|
+
granted to You under this License for that Work shall terminate
|
87
|
+
as of the date such litigation is filed.
|
88
|
+
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
91
|
+
modifications, and in Source or Object form, provided that You
|
92
|
+
meet the following conditions:
|
93
|
+
|
94
|
+
(a) You must give any other recipients of the Work or
|
95
|
+
Derivative Works a copy of this License; and
|
96
|
+
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
98
|
+
stating that You changed the files; and
|
99
|
+
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
102
|
+
attribution notices from the Source form of the Work,
|
103
|
+
excluding those notices that do not pertain to any part of
|
104
|
+
the Derivative Works; and
|
105
|
+
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
108
|
+
include a readable copy of the attribution notices contained
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
111
|
+
of the following places: within a NOTICE text file distributed
|
112
|
+
as part of the Derivative Works; within the Source form or
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
114
|
+
within a display generated by the Derivative Works, if and
|
115
|
+
wherever such third-party notices normally appear. The contents
|
116
|
+
of the NOTICE file are for informational purposes only and
|
117
|
+
do not modify the License. You may add Your own attribution
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
120
|
+
that such additional attribution notices cannot be construed
|
121
|
+
as modifying the License.
|
122
|
+
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
124
|
+
may provide additional or different license terms and conditions
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
128
|
+
the conditions stated in this License.
|
129
|
+
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
133
|
+
this License, without any additional terms or conditions.
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
135
|
+
the terms of any separate license agreement you may have executed
|
136
|
+
with Licensor regarding such Contributions.
|
137
|
+
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
140
|
+
except as required for reasonable and customary use in describing the
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
142
|
+
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
152
|
+
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
158
|
+
incidental, or consequential damages of any character arising as a
|
159
|
+
result of this License or out of the use or inability to use the
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
162
|
+
other commercial damages or losses), even if such Contributor
|
163
|
+
has been advised of the possibility of such damages.
|
164
|
+
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
168
|
+
or other liability obligations and/or rights consistent with this
|
169
|
+
License. However, in accepting such obligations, You may act only
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
174
|
+
of your accepting any such warranty or additional liability.
|
175
|
+
|
176
|
+
END OF TERMS AND CONDITIONS
|
177
|
+
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
179
|
+
|
180
|
+
To apply the Apache License to your work, attach the following
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "{}"
|
182
|
+
replaced with your own identifying information. (Don't include
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
184
|
+
comment syntax for the file format. We also recommend that a
|
185
|
+
file or class name and description of purpose be included on the
|
186
|
+
same "printed page" as the copyright notice for easier
|
187
|
+
identification within third-party archives.
|
188
|
+
|
189
|
+
Copyright 2019 Paulo Arruda <paulo at faastruby dot io>
|
190
|
+
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
192
|
+
you may not use this file except in compliance with the License.
|
193
|
+
You may obtain a copy of the License at
|
194
|
+
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
196
|
+
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
200
|
+
See the License for the specific language governing permissions and
|
201
|
+
limitations under the License.
|
data/dev-setup.sh
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
#!/bin/bash
|
2
|
+
set -e
|
3
|
+
! which rvm && echo "Sorry, but this script only works with RVM" && exit 1
|
4
|
+
[[ -z $GEM_HOME ]] && echo "You need to have \$GEM_HOME set before continuing." && exit 1
|
5
|
+
GEMS=$GEM_HOME/gems
|
6
|
+
echo Gems detected at: $GEMS
|
7
|
+
which faastruby && echo "Removing all installed versions" && gem uninstall -a -I -x faastruby
|
8
|
+
echo "Cleaning up stale links"
|
9
|
+
rm -f $GEMS/faastruby-0*
|
10
|
+
echo "Building gem from source"
|
11
|
+
VERSION=$(gem build faastruby.gemspec |grep Version|cut -f4 -d" ")
|
12
|
+
echo "Installing new gem"
|
13
|
+
gem install faastruby-$VERSION.gem
|
14
|
+
SOURCECODE=$PWD
|
15
|
+
INSTALL_DIR=$GEMS/faastruby-$VERSION
|
16
|
+
echo -e "\n\nThe directory below is about to be removed. Press ENTER to continue or CTRL+C to abort."
|
17
|
+
echo $INSTALL_DIR
|
18
|
+
read
|
19
|
+
rm -rf $INSTALL_DIR
|
20
|
+
echo "Creating symlink $INSTALL_DIR -> $SOURCECODE"
|
21
|
+
ln -s $SOURCECODE $INSTALL_DIR
|
22
|
+
echo "Running 'faastruby -v'"
|
23
|
+
faastruby -v
|
24
|
+
touch ".test"
|
25
|
+
[[ -e $INSTALL_DIR/.test ]] && rm .test && echo Done && exit 0
|
26
|
+
rm -f .test
|
27
|
+
echo "ERROR: The symbolik link $INSTALL_DIR is not working."
|
28
|
+
exit 1
|
data/lib/faastruby/base.rb
CHANGED
@@ -54,6 +54,14 @@ module FaaStRuby
|
|
54
54
|
assign_attributes(params)
|
55
55
|
end
|
56
56
|
|
57
|
+
def call_api
|
58
|
+
response = yield
|
59
|
+
@status_code = response.code
|
60
|
+
@errors += response.errors if response.errors.any?
|
61
|
+
|
62
|
+
response
|
63
|
+
end
|
64
|
+
|
57
65
|
def mass_assign(attrs)
|
58
66
|
attrs.each do |key, value|
|
59
67
|
self.public_send("#{key}=", value)
|
data/lib/faastruby/cli.rb
CHANGED
@@ -64,16 +64,22 @@ module FaaStRuby
|
|
64
64
|
parsed = []
|
65
65
|
parsed << 'FAASTRUBY_PROJECT_SYNC_ENABLED=true' if args.delete('--sync')
|
66
66
|
parsed << 'DEBUG=true' if args.delete('--debug')
|
67
|
+
server_port = '3000'
|
68
|
+
|
67
69
|
args.each_with_index do |arg, i|
|
68
70
|
if ['--env', '-e'].include?(arg)
|
69
71
|
args.delete_at(i)
|
70
72
|
parsed << "FAASTRUBY_PROJECT_DEPLOY_ENVIRONMENT=#{args.delete_at(i)}"
|
73
|
+
else ['-p', '--port'].include?(arg)
|
74
|
+
args.delete_at(i)
|
75
|
+
server_port = args.delete_at(i)
|
71
76
|
end
|
72
77
|
end
|
78
|
+
parsed << "SERVER_PORT=#{server_port}"
|
73
79
|
server_dir = "#{Gem::Specification.find_by_name("faastruby").gem_dir}/lib/faastruby/server"
|
74
80
|
config_ru = "#{server_dir}/config.ru"
|
75
81
|
puma_config = "#{server_dir}/puma.rb"
|
76
|
-
exec "#{parsed.join(' ')} puma -C #{puma_config} #{args.join(' ')} #{config_ru}"
|
82
|
+
exec "#{parsed.join(' ')} puma -C #{puma_config} -p #{server_port} #{args.join(' ')} #{config_ru}"
|
77
83
|
end
|
78
84
|
def self.start_tmuxinator
|
79
85
|
if system("tmux -V > /dev/null")
|
data/lib/faastruby/local.rb
CHANGED
@@ -66,8 +66,10 @@ module FaaStRuby
|
|
66
66
|
SECRETS_YAML_FILE = "#{SERVER_ROOT}/secrets.yml"
|
67
67
|
DEPLOY_ENVIRONMENT = ENV['DEPLOY_ENVIRONMENT'] || 'stage'
|
68
68
|
SYNC_ENABLED = ENV['SYNC'] && check_if_logged_in
|
69
|
-
|
70
|
-
|
69
|
+
if CRYSTAL_ENABLED
|
70
|
+
CRYSTAL_VERSION = get_crystal_version.freeze
|
71
|
+
DEFAULT_CRYSTAL_RUNTIME = "crystal:#{CRYSTAL_VERSION}".freeze
|
72
|
+
end
|
71
73
|
DEFAULT_RUBY_RUNTIME = "ruby:#{CURRENT_MINOR_RUBY}".freeze
|
72
74
|
FUNCTIONS_EVENT_QUEUE = Queue.new
|
73
75
|
PUBLIC_EVENT_QUEUE = Queue.new
|
@@ -163,7 +165,7 @@ module FaaStRuby
|
|
163
165
|
|
164
166
|
# initial_compile
|
165
167
|
puts "Listening for changes."
|
166
|
-
puts "faastRuby Local is ready at http://localhost
|
168
|
+
puts "faastRuby Local is ready at http://localhost:#{ENV['SERVER_PORT']}"
|
167
169
|
puts "Your cloud workspace address is #{URL_PROTOCOL}://#{workspace}.#{FaaStRuby.region}.#{WORKSPACE_BASE_HOST}" if SYNC_ENABLED
|
168
170
|
sleep
|
169
171
|
ensure
|
data/lib/faastruby/server.rb
CHANGED
@@ -42,8 +42,10 @@ module FaaStRuby
|
|
42
42
|
DEPLOY_ENVIRONMENT = ENV['FAASTRUBY_PROJECT_DEPLOY_ENVIRONMENT'] || 'stage'
|
43
43
|
WORKSPACE_NAME = "#{PROJECT_NAME}-#{DEPLOY_ENVIRONMENT}"
|
44
44
|
CHDIR_MUTEX = Mutex.new
|
45
|
-
|
46
|
-
|
45
|
+
if CRYSTAL_ENABLED
|
46
|
+
CRYSTAL_VERSION = get_crystal_version.freeze
|
47
|
+
DEFAULT_CRYSTAL_RUNTIME = "crystal:#{CRYSTAL_VERSION}".freeze
|
48
|
+
end
|
47
49
|
DEFAULT_RUBY_RUNTIME = "ruby:#{CURRENT_MINOR_RUBY}".freeze
|
48
50
|
require 'faastruby/server/logger'
|
49
51
|
require 'faastruby/server/project_config'
|
data/lib/faastruby/server/app.rb
CHANGED
@@ -13,6 +13,7 @@ module FaaStRuby
|
|
13
13
|
set :logging, true
|
14
14
|
set :root, SERVER_ROOT
|
15
15
|
set :public_folder, FaaStRuby::ProjectConfig.public_dir
|
16
|
+
|
16
17
|
set :static, true
|
17
18
|
set :static_cache_control, [:must_revalidate, :proxy_revalidate, :max_age => 0]
|
18
19
|
register Sinatra::MultiRoute
|
@@ -33,7 +34,7 @@ module FaaStRuby
|
|
33
34
|
# rpc_args = []
|
34
35
|
# end
|
35
36
|
|
36
|
-
body = parse_body(request
|
37
|
+
body = parse_body(request, request_headers['Content-Type'], request.request_method)
|
37
38
|
rpc_args = []
|
38
39
|
request_headers['X-Request-Id'] = request_uuid
|
39
40
|
request_headers['Request-Method'] = request.request_method
|
@@ -84,11 +85,20 @@ module FaaStRuby
|
|
84
85
|
File.file?("#{FaaStRuby::ProjectConfig.functions_dir}/#{name}/faastruby.yml")
|
85
86
|
end
|
86
87
|
|
87
|
-
def parse_body(
|
88
|
+
def parse_body(request, content_type, method)
|
88
89
|
return nil if method == 'GET'
|
89
|
-
return
|
90
|
-
|
91
|
-
|
90
|
+
return form_content(request.env) if content_type == 'application/x-www-form-urlencoded'
|
91
|
+
body_content(request.body)
|
92
|
+
end
|
93
|
+
|
94
|
+
def form_content(request_env)
|
95
|
+
return {} if (content = request_env['rack.request.form_hash']).nil?
|
96
|
+
content.to_json
|
97
|
+
end
|
98
|
+
|
99
|
+
def body_content(request_body)
|
100
|
+
return {} if (content = request_body.read).nil?
|
101
|
+
content
|
92
102
|
end
|
93
103
|
|
94
104
|
def parse_query(query_string)
|
@@ -113,4 +123,4 @@ module FaaStRuby
|
|
113
123
|
result
|
114
124
|
end
|
115
125
|
end
|
116
|
-
end
|
126
|
+
end
|
data/lib/faastruby/user.rb
CHANGED
@@ -23,23 +23,22 @@ module FaaStRuby
|
|
23
23
|
attr_accessor :email, :password, :status_code, :errors, :api_key, :api_secret, :confirmation_token
|
24
24
|
|
25
25
|
def logout(all: false)
|
26
|
-
response = @api.logout(api_key: @api_key, api_secret: @api_secret, all: all)
|
27
|
-
|
28
|
-
@errors += response.errors if response.errors.any?
|
26
|
+
response = call_api { @api.logout(api_key: @api_key, api_secret: @api_secret, all: all) }
|
27
|
+
|
29
28
|
self
|
30
29
|
end
|
31
30
|
|
31
|
+
def assign_credentials(response)
|
32
|
+
return if response.body['credentials'].nil?
|
33
|
+
|
34
|
+
@api_key = response.body['credentials']['api_key']
|
35
|
+
@api_secret = response.body['credentials']['api_secret']
|
36
|
+
end
|
37
|
+
|
32
38
|
def login
|
33
|
-
response = @api.login(email: @email, password: @password)
|
34
|
-
|
35
|
-
|
36
|
-
@errors += response.errors
|
37
|
-
return self
|
38
|
-
end
|
39
|
-
if response.body['credentials']
|
40
|
-
@api_key = response.body['credentials']['api_key']
|
41
|
-
@api_secret = response.body['credentials']['api_secret']
|
42
|
-
end
|
39
|
+
response = call_api { @api.login(email: @email, password: @password) }
|
40
|
+
assign_credentials(response) unless response.errors.any?
|
41
|
+
|
43
42
|
self
|
44
43
|
end
|
45
44
|
|
@@ -48,30 +47,22 @@ module FaaStRuby
|
|
48
47
|
end
|
49
48
|
|
50
49
|
def confirm_account!
|
51
|
-
response = @api.confirm_account(@confirmation_token)
|
52
|
-
|
53
|
-
|
54
|
-
@errors += response.errors
|
55
|
-
return self
|
56
|
-
end
|
57
|
-
if response.body['credentials']
|
58
|
-
@api_key = response.body['credentials']['api_key']
|
59
|
-
@api_secret = response.body['credentials']['api_secret']
|
60
|
-
end
|
50
|
+
response = call_api { @api.confirm_account(@confirmation_token) }
|
51
|
+
assign_credentials(response) unless response.errors.any?
|
52
|
+
|
61
53
|
self
|
62
54
|
end
|
63
55
|
|
64
56
|
def send_confirmation_code
|
65
|
-
response = @api.send_confirmation_code(@email)
|
66
|
-
|
67
|
-
@errors += response.errors if response.errors.any?
|
57
|
+
response = call_api { @api.send_confirmation_code(@email) }
|
58
|
+
|
68
59
|
self
|
69
60
|
end
|
70
61
|
|
71
62
|
def save_credentials
|
63
|
+
|
72
64
|
credentials_file = NewCredentials::CredentialsFile.new
|
73
65
|
credentials_file.save(email: @email, api_key: @api_key, api_secret: @api_secret)
|
74
66
|
end
|
75
|
-
|
76
67
|
end
|
77
68
|
end
|
data/lib/faastruby/version.rb
CHANGED
data/lib/faastruby/workspace.rb
CHANGED
@@ -29,59 +29,51 @@ module FaaStRuby
|
|
29
29
|
##### Instance methods
|
30
30
|
attr_accessor :name, :errors, :functions, :email, :object, :credentials, :updated_at, :created_at, :status_code, :provider, :runners_max, :runners_current, :static_metadata
|
31
31
|
|
32
|
-
def make_request
|
33
|
-
response = yield
|
34
|
-
@status_code = response.code
|
35
|
-
@errors += response.errors if response.errors.any?
|
36
|
-
|
37
|
-
response
|
38
|
-
end
|
39
|
-
|
40
32
|
def destroy
|
41
|
-
|
33
|
+
call_api { @api.destroy_workspace(@name) }
|
42
34
|
end
|
43
35
|
|
44
36
|
def deploy(package_file_name, root_to: false, catch_all: false, context: false)
|
45
|
-
|
37
|
+
call_api { @api.deploy(workspace_name: @name, package: package_file_name, root_to: root_to, catch_all: catch_all, context: context) }
|
46
38
|
|
47
39
|
self
|
48
40
|
end
|
49
41
|
|
50
42
|
def refresh_credentials
|
51
|
-
response =
|
43
|
+
response = call_api { @api.refresh_credentials(@name) }
|
52
44
|
@credentials = response.body[@name] unless response.body.nil?
|
53
45
|
|
54
46
|
self
|
55
47
|
end
|
56
48
|
|
57
49
|
def update_runners(value)
|
58
|
-
response =
|
50
|
+
response = call_api { @api.update_runners(workspace_name: @name, runners_max: value) }
|
59
51
|
@runners_max = response.body['runners_max'].to_i if response.body['runners_max'] rescue nil
|
60
52
|
|
61
53
|
self
|
62
54
|
end
|
63
55
|
|
64
56
|
def fetch
|
65
|
-
response =
|
57
|
+
response = call_api { @api.get_workspace_info(@name) }
|
66
58
|
parse_attributes(response.body) unless response.errors.any?
|
67
59
|
|
68
60
|
self
|
69
61
|
end
|
70
62
|
|
71
63
|
def upload_file(package_file_name, relative_path:)
|
72
|
-
|
64
|
+
call_api { @api.upload_file(workspace_name: @name, package: package_file_name, relative_path: relative_path) }
|
73
65
|
|
74
66
|
self
|
75
67
|
end
|
76
68
|
|
77
69
|
def delete_file(relative_path:)
|
78
|
-
|
70
|
+
call_api { @api.delete_file(workspace_name: @name, relative_path: relative_path) }
|
79
71
|
|
80
72
|
self
|
81
73
|
end
|
82
74
|
|
83
75
|
def static_metadata
|
84
|
-
response =
|
76
|
+
response = call_api { @api.get_static_metadata(@name) }
|
85
77
|
@static_metadata = response.body['metadata']
|
86
78
|
|
87
79
|
self
|
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.5.
|
4
|
+
version: 0.5.26
|
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-
|
11
|
+
date: 2019-05-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rest-client
|
@@ -296,6 +296,7 @@ files:
|
|
296
296
|
- Rakefile
|
297
297
|
- bin/console
|
298
298
|
- bin/setup
|
299
|
+
- dev-setup.sh
|
299
300
|
- exe/faastruby
|
300
301
|
- faastruby.gemspec
|
301
302
|
- lib/faastruby.rb
|