lamby 4.2.1 → 4.3.3

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: 36672ad378e1e075df3ea97c48960dc48eaf69ef133bd73f52a8ba667689b909
4
- data.tar.gz: 4617ec443a807af7994cb1c30c3780de4785ae14fd9aae8fa21a07f38284eea1
3
+ metadata.gz: dce401866a14fbce98621f6c677ab0f17df796c1c9c0792d4a1030adc69eadbd
4
+ data.tar.gz: 593c2f449b053f4bdc6ae2dbe74602f0debd93d57a57a1811d7f791bc1b40fc9
5
5
  SHA512:
6
- metadata.gz: 624dca929cc78ffa686b784a3dbca0817547092e8ecaa3878b973c6e32960a8e980e9544f463f9ecbb00e525fd9dd7943d7013f6f2ef0f7e32db9a58c7f66dab
7
- data.tar.gz: 5c6e012bf74e0a7b3579d70fed1327f7e331d8a3b49b8efeb1e7a9c8e98e20a927be3463be3f775dbdf361dbc51584bcc1a240b38be0518c9f751e8f7a0119a6
6
+ metadata.gz: 4f119c574a97288c37eb7c5c97643650d2d730fe16ab7b7e6b06a777088e069b6050c4ab023856e32c10c7da0029d74067eb8db37492b0dc0c1a0ed3948f7ee9
7
+ data.tar.gz: 1bf90e93726e78a75f408801976f65c7dafe369cc14d567fb4ddb337832a0b3dfb10fb1d8e2f91b9b7cf20d42c176f914f0b33c3641accbbc8fd757ec3d56ba6
data/CHANGELOG.md CHANGED
@@ -2,6 +2,23 @@
2
2
 
3
3
  See this http://keepachangelog.com link for information on how we want this documented formatted.
4
4
 
5
+ ## v4.3.1, v4.3.2
6
+
7
+ ### Changed
8
+
9
+ - Command response will be #inspect for every command.
10
+ - Added x-lambda-console option to the event.
11
+
12
+ ## v4.3.0
13
+
14
+ ### Changed
15
+
16
+ - Default Lamby::Runner::PATTERNS to allow everything.
17
+
18
+ ### Added
19
+
20
+ - New Lamby::Command for IRB style top level binding evals.
21
+
5
22
  ## v4.2.1
6
23
 
7
24
  ### Added
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- lamby (4.2.1)
4
+ lamby (4.3.3)
5
5
  rack
6
6
 
7
7
  GEM
@@ -0,0 +1,43 @@
1
+ module Lamby
2
+ class Command
3
+
4
+ class << self
5
+
6
+ def handle?(event)
7
+ event.dig('x-lambda-console', 'command') ||
8
+ event.dig('lamby', 'command')
9
+ end
10
+
11
+ def cmd(event:, context:)
12
+ new(event).call
13
+ end
14
+
15
+ end
16
+
17
+ def initialize(event)
18
+ @event = event
19
+ @body = ''
20
+ end
21
+
22
+ def call
23
+ begin
24
+ body = eval(command, TOPLEVEL_BINDING).inspect
25
+ { statusCode: 200, headers: {}, body: body }
26
+ rescue Exception => e
27
+ body = "#<#{e.class}:#{e.message}>".tap do |b|
28
+ if e.backtrace
29
+ b << "\n"
30
+ b << e.backtrace.join("\n")
31
+ end
32
+ end
33
+ { statusCode: 422, headers: {}, body: body }
34
+ end
35
+ end
36
+
37
+ def command
38
+ @event.dig('x-lambda-console', 'command') ||
39
+ @event.dig('lamby', 'command')
40
+ end
41
+
42
+ end
43
+ end
data/lib/lamby/handler.rb CHANGED
@@ -92,9 +92,10 @@ module Lamby
92
92
  Lambdakiq.cmd event: @event, context: @context
93
93
  elsif lambda_cable?
94
94
  LambdaCable.cmd event: @event, context: @context
95
+ elsif command?
96
+ Lamby::Command.cmd event: @event, context: @context
95
97
  elsif runner?
96
- @status, @headers, @body = Runner.call(@event)
97
- { statusCode: status, headers: headers, body: body }
98
+ Lamby::Runner.cmd event: @event, context: @context
98
99
  elsif event_bridge?
99
100
  Lamby.config.event_bridge_handler.call @event, @context
100
101
  else
@@ -121,7 +122,11 @@ module Lamby
121
122
  end
122
123
 
123
124
  def runner?
124
- Runner.handle?(@event)
125
+ Lamby::Runner.handle?(@event)
126
+ end
127
+
128
+ def command?
129
+ Lamby::Command.handle?(@event)
125
130
  end
126
131
 
127
132
  def lambda_cable?
data/lib/lamby/runner.rb CHANGED
@@ -5,17 +5,16 @@ module Lamby
5
5
  class Error < StandardError ; end
6
6
  class UnknownCommandPattern < Error ; end
7
7
 
8
- PATTERNS = [
9
- %r{\A\./bin/(rails|rake) db:migrate.*}
10
- ]
8
+ PATTERNS = [%r{.*}]
11
9
 
12
10
  class << self
13
11
 
14
12
  def handle?(event)
15
- event.dig 'lamby', 'runner'
13
+ event.dig('x-lambda-console', 'runner') ||
14
+ event.dig('lamby', 'runner')
16
15
  end
17
16
 
18
- def call(event)
17
+ def cmd(event:, context:)
19
18
  new(event).call
20
19
  end
21
20
 
@@ -34,11 +33,12 @@ module Lamby
34
33
  puts @body
35
34
  thread.value.exitstatus
36
35
  end
37
- [status, {}, StringIO.new(@body)]
36
+ { statusCode: status, headers: {}, body: @body }
38
37
  end
39
38
 
40
39
  def command
41
- @event.dig 'lamby', 'runner'
40
+ @event.dig('x-lambda-console', 'runner') ||
41
+ @event.dig('lamby', 'runner')
42
42
  end
43
43
 
44
44
  private
data/lib/lamby/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Lamby
2
- VERSION = '4.2.1'
2
+ VERSION = '4.3.3'
3
3
  end
data/lib/lamby.rb CHANGED
@@ -9,6 +9,7 @@ require 'lamby/rack_rest'
9
9
  require 'lamby/rack_http'
10
10
  require 'lamby/debug'
11
11
  require 'lamby/runner'
12
+ require 'lamby/command'
12
13
  require 'lamby/handler'
13
14
 
14
15
  if defined?(Rails)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lamby
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.2.1
4
+ version: 4.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ken Collins
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-06-11 00:00:00.000000000 Z
11
+ date: 2023-06-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rack
@@ -163,6 +163,7 @@ files:
163
163
  - images/social2.png
164
164
  - lamby.gemspec
165
165
  - lib/lamby.rb
166
+ - lib/lamby/command.rb
166
167
  - lib/lamby/config.rb
167
168
  - lib/lamby/debug.rb
168
169
  - lib/lamby/handler.rb
@@ -198,7 +199,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
198
199
  - !ruby/object:Gem::Version
199
200
  version: '0'
200
201
  requirements: []
201
- rubygems_version: 3.3.26
202
+ rubygems_version: 3.4.6
202
203
  signing_key:
203
204
  specification_version: 4
204
205
  summary: Simple Rails & AWS Lambda Integration using Rack