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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 20c01b0ec0fd646988062e2c636f5f87e9b4d336c6e3a0a5803059c3b7dd0c72
4
- data.tar.gz: 1f4e2ab166e2e29accc17f637830ae9869837f3d57faa7623af95255d8d1655a
3
+ metadata.gz: 5e5912714ef95bb38fdaad9a0bd20cca003fe28d9696f769fc11120ab36032c4
4
+ data.tar.gz: 6945914a71f85bf8682f68ddb26eea4db7cf43d82cc7a66baee97d37d2b23649
5
5
  SHA512:
6
- metadata.gz: ba9b23891348962ca8247bba003f0495f8888bc6b6e4de67f1860ba67cf7eb10c388e88c53b66db1006d2b9b57c76a8d3e604697319933606bbd312b161fbd39
7
- data.tar.gz: 72b3ee56ac48a105e837176eb280276d63ea3ab3be2eaa7579731530408464e682b81745b5fd5a7da55ec20f69f392f8d32cb0c6fd89f0ad05c129a432622e94
6
+ metadata.gz: 5bc9e92eba96d265cb35272504c73b01533c3b827ca4bdeed9dc575dd5630e9edd40163656f508bae0125adc1ea48a7cf27ba0f858c4af6a6179bf3b5d90ef1b
7
+ data.tar.gz: 892424f39ef10d36b402feb63a7708c03eb29aa3da4c828721855602d4f0c76b74f3fe6d22de3380fd8001fb93da0405d76fe081415aadee4c3ff06ccc0a30f7
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- xaases (0.2.0)
4
+ xaases (0.2.1)
5
5
  highline (~> 2.0, >= 2.0.0)
6
6
 
7
7
  GEM
@@ -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
- #@js.strict!
11
- #@js.const(aws: "require('aws-sdk')")
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(dyn: 'new aws.DynamoDB()')
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 'dyn.put', params_js, handler
42
+ @js.call 'db.put', params_js, handler
38
43
  end
39
44
 
40
45
  def render
@@ -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
@@ -9,13 +9,23 @@ module Xaases
9
9
  end
10
10
 
11
11
  def strict!
12
- @s = "'use strict';"
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
- @s += 'const ' + list.map do |key, value|
17
- key.to_s + '=' + value.to_s
18
- end.join(',') + ';'
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)
@@ -1,3 +1,3 @@
1
1
  module Xaases
2
- VERSION = "0.2.0"
2
+ VERSION = "0.2.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: xaases
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - myun2