xaases 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/xaases/aws/lambda_js.rb +10 -5
- data/lib/xaases/cli.rb +4 -1
- data/lib/xaases/js.rb +14 -4
- data/lib/xaases/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5e5912714ef95bb38fdaad9a0bd20cca003fe28d9696f769fc11120ab36032c4
|
4
|
+
data.tar.gz: 6945914a71f85bf8682f68ddb26eea4db7cf43d82cc7a66baee97d37d2b23649
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5bc9e92eba96d265cb35272504c73b01533c3b827ca4bdeed9dc575dd5630e9edd40163656f508bae0125adc1ea48a7cf27ba0f858c4af6a6179bf3b5d90ef1b
|
7
|
+
data.tar.gz: 892424f39ef10d36b402feb63a7708c03eb29aa3da4c828721855602d4f0c76b74f3fe6d22de3380fd8001fb93da0405d76fe081415aadee4c3ff06ccc0a30f7
|
data/Gemfile.lock
CHANGED
data/lib/xaases/aws/lambda_js.rb
CHANGED
@@ -4,15 +4,20 @@ module Xaases
|
|
4
4
|
class LambdaJs
|
5
5
|
attr_reader :minify
|
6
6
|
|
7
|
-
def initialize(minify: true)
|
7
|
+
def initialize(minify: true, header: false)
|
8
8
|
@minify = minify
|
9
9
|
@js = Xaases::Js.new(minify: minify)
|
10
|
-
|
11
|
-
|
10
|
+
header! if header
|
11
|
+
end
|
12
|
+
|
13
|
+
def header!
|
14
|
+
@js.strict!
|
15
|
+
@js.const(aws: "require('aws-sdk')")
|
16
|
+
use_dynamo!
|
12
17
|
end
|
13
18
|
|
14
19
|
def use_dynamo!
|
15
|
-
@js.const(
|
20
|
+
@js.const(db: 'new aws.DynamoDB()')
|
16
21
|
end
|
17
22
|
|
18
23
|
def export(name, content)
|
@@ -34,7 +39,7 @@ module Xaases
|
|
34
39
|
'Item' => Xaases::Js.new(minify: minify).hash(data)
|
35
40
|
}
|
36
41
|
params_js = Xaases::Js.new(minify: minify).hash(params)
|
37
|
-
@js.call '
|
42
|
+
@js.call 'db.put', params_js, handler
|
38
43
|
end
|
39
44
|
|
40
45
|
def render
|
data/lib/xaases/cli.rb
CHANGED
@@ -23,10 +23,13 @@ begin
|
|
23
23
|
name = sls.add_function *options
|
24
24
|
sls.write
|
25
25
|
|
26
|
+
need_head = !File.exist?('handler.js')
|
27
|
+
|
28
|
+
# respone
|
26
29
|
res = Xaases::Aws::LambdaJs.new(minify: false)
|
27
30
|
res.res(200, '"OK."')
|
28
31
|
|
29
|
-
js = Xaases::Aws::LambdaJs.new(minify: false)
|
32
|
+
js = Xaases::Aws::LambdaJs.new(minify: false, header: need_head)
|
30
33
|
js.export name, res.render
|
31
34
|
f = File.open 'handler.js', 'a'
|
32
35
|
f.write js.render
|
data/lib/xaases/js.rb
CHANGED
@@ -9,13 +9,23 @@ module Xaases
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def strict!
|
12
|
-
|
12
|
+
if minify
|
13
|
+
@s = "'use strict';"
|
14
|
+
else
|
15
|
+
@s = "'use strict';\n"
|
16
|
+
end
|
13
17
|
end
|
14
18
|
|
15
19
|
def const(list)
|
16
|
-
|
17
|
-
|
18
|
-
|
20
|
+
if minify
|
21
|
+
@s += 'const ' + list.map do |key, value|
|
22
|
+
key.to_s + '=' + value.to_s
|
23
|
+
end.join(',') + ';'
|
24
|
+
else
|
25
|
+
@s += 'const ' + list.map do |key, value|
|
26
|
+
key.to_s + ' = ' + value.to_s
|
27
|
+
end.join(",\n ") + ";\n"
|
28
|
+
end
|
19
29
|
end
|
20
30
|
|
21
31
|
def call(name, *params)
|
data/lib/xaases/version.rb
CHANGED