lamby 4.3.0 → 5.0.0

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: 1ee1d66c80f81d7cc0caa58bd4eeee0d107c6fe02e29228281a5fdcc231f808f
4
- data.tar.gz: ca0ce61dab155c561c94547569e680b27c5a4fc36150f739290fdc91da1d9b42
3
+ metadata.gz: bed40f788bb3ef9eecb63040924c583bee423ac369179f76aa5fe43fe797e3ec
4
+ data.tar.gz: 7fd33a98bb6cd19b202a16ef58f5a03f7f7e1e21f75e6342330b318ebb260bed
5
5
  SHA512:
6
- metadata.gz: ccec86a4dc162eaab7bb8dcf7629a7aec1d8b6d04ad1e32a6f10f41cca63054172c8a5dc1a046d871b0308a5b788a9a12933c5c524cc155fbf1101ee52df9aef
7
- data.tar.gz: 5c85d4254987888fc1f53605f6f16dcaa3aaa306fbcdff6444b63cb399216e8decca1363a4309b7603a0073b3ab18c2b8ad397c2aa03fd611c4ac121e3ad8015
6
+ metadata.gz: 8dca95a577c3afbcb3fbcb9715e54987b04cd830abeda28ac9c4df82f088a50ea866ce8a6f19212e003d80cb3d88c37370393e79c69f9f023c34ae81f967f8d5
7
+ data.tar.gz: d795ac32b599d239ad6ccfde9da12e88b79bfcff854766c77c0630ca69acbaac9f2cbd5e5c56ee9eb48c46b70bd4d683b67fc7dbf1c2cef61c6dbf0f42a81728
data/CHANGELOG.md CHANGED
@@ -2,6 +2,22 @@
2
2
 
3
3
  See this http://keepachangelog.com link for information on how we want this documented formatted.
4
4
 
5
+ ## v5.0.0
6
+
7
+ ### Changed
8
+
9
+ - ⚠️ Breaking Changes ⚠️
10
+ - Remove Lamby::Runner & Lamby::Command in favor of LambdaConsole Ruby gem.
11
+ - New runner pattern exceptions from above. Now: LambdaConsole::Run::UnknownCommandPattern
12
+ - Switch your own runner events to new https://github.com/rails-lambda/lambda-console spec.
13
+
14
+ ## v4.3.1, v4.3.2
15
+
16
+ ### Changed
17
+
18
+ - Command response will be #inspect for every command.
19
+ - Added x-lambda-console option to the event.
20
+
5
21
  ## v4.3.0
6
22
 
7
23
  ### Changed
data/Gemfile.lock CHANGED
@@ -1,7 +1,8 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- lamby (4.3.0)
4
+ lamby (5.0.0)
5
+ lambda-console-ruby
5
6
  rack
6
7
 
7
8
  GEM
@@ -98,6 +99,7 @@ GEM
98
99
  i18n (1.12.0)
99
100
  concurrent-ruby (~> 1.0)
100
101
  jmespath (1.6.2)
102
+ lambda-console-ruby (1.0.0)
101
103
  lambdakiq (2.2.0)
102
104
  activejob
103
105
  aws-sdk-sqs
data/lamby.gemspec CHANGED
@@ -19,6 +19,7 @@ Gem::Specification.new do |spec|
19
19
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
20
  spec.require_paths = ["lib"]
21
21
  spec.add_dependency 'rack'
22
+ spec.add_dependency 'lambda-console-ruby'
22
23
  spec.add_development_dependency 'aws-sdk-ssm'
23
24
  spec.add_development_dependency 'bundler'
24
25
  spec.add_development_dependency 'rake'
data/lib/lamby/config.rb CHANGED
@@ -53,7 +53,7 @@ module Lamby
53
53
  end
54
54
 
55
55
  def runner_patterns
56
- Runner::PATTERNS
56
+ LambdaConsole::Run::PATTERNS
57
57
  end
58
58
 
59
59
  def handled_proc
data/lib/lamby/handler.rb CHANGED
@@ -92,10 +92,8 @@ 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
97
- elsif runner?
98
- Lamby::Runner.cmd event: @event, context: @context
95
+ elsif LambdaConsole.handle?(@event)
96
+ LambdaConsole.handle(@event)
99
97
  elsif event_bridge?
100
98
  Lamby.config.event_bridge_handler.call @event, @context
101
99
  else
@@ -121,14 +119,6 @@ module Lamby
121
119
  defined?(::Lambdakiq) && ::Lambdakiq.jobs?(@event)
122
120
  end
123
121
 
124
- def runner?
125
- Lamby::Runner.handle?(@event)
126
- end
127
-
128
- def command?
129
- Lamby::Command.handle?(@event)
130
- end
131
-
132
122
  def lambda_cable?
133
123
  defined?(::LambdaCable) && ::LambdaCable.handle?(@event, @context)
134
124
  end
data/lib/lamby/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Lamby
2
- VERSION = '4.3.0'
2
+ VERSION = '5.0.0'
3
3
  end
data/lib/lamby.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  require 'lamby/logger'
2
2
  require 'rack'
3
3
  require 'base64'
4
+ require 'lambda-console-ruby'
4
5
  require 'lamby/version'
5
6
  require 'lamby/config'
6
7
  require 'lamby/rack'
@@ -8,8 +9,6 @@ require 'lamby/rack_alb'
8
9
  require 'lamby/rack_rest'
9
10
  require 'lamby/rack_http'
10
11
  require 'lamby/debug'
11
- require 'lamby/runner'
12
- require 'lamby/command'
13
12
  require 'lamby/handler'
14
13
 
15
14
  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.3.0
4
+ version: 5.0.0
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-15 00:00:00.000000000 Z
11
+ date: 2023-06-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rack
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: lambda-console-ruby
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: aws-sdk-ssm
29
43
  requirement: !ruby/object:Gem::Requirement
@@ -163,7 +177,6 @@ files:
163
177
  - images/social2.png
164
178
  - lamby.gemspec
165
179
  - lib/lamby.rb
166
- - lib/lamby/command.rb
167
180
  - lib/lamby/config.rb
168
181
  - lib/lamby/debug.rb
169
182
  - lib/lamby/handler.rb
@@ -175,7 +188,6 @@ files:
175
188
  - lib/lamby/rack_http.rb
176
189
  - lib/lamby/rack_rest.rb
177
190
  - lib/lamby/railtie.rb
178
- - lib/lamby/runner.rb
179
191
  - lib/lamby/ssm_parameter_store.rb
180
192
  - lib/lamby/tasks.rake
181
193
  - lib/lamby/version.rb
data/lib/lamby/command.rb DELETED
@@ -1,42 +0,0 @@
1
- module Lamby
2
- class Command
3
-
4
- class << self
5
-
6
- def handle?(event)
7
- event.dig 'lamby', 'command'
8
- end
9
-
10
- def cmd(event:, context:)
11
- new(event).call
12
- end
13
-
14
- end
15
-
16
- def initialize(event)
17
- @event = event
18
- @body = ''
19
- end
20
-
21
- def call
22
- begin
23
- body = eval(command, TOPLEVEL_BINDING).to_s
24
- body = body.inspect if body =~ /\A"/ && body =~ /"\z/
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 'lamby', 'command'
39
- end
40
-
41
- end
42
- end
data/lib/lamby/runner.rb DELETED
@@ -1,62 +0,0 @@
1
- require 'open3'
2
-
3
- module Lamby
4
- class Runner
5
- class Error < StandardError ; end
6
- class UnknownCommandPattern < Error ; end
7
-
8
- PATTERNS = [%r{.*}]
9
-
10
- class << self
11
-
12
- def handle?(event)
13
- event.dig 'lamby', 'runner'
14
- end
15
-
16
- def cmd(event:, context:)
17
- new(event).call
18
- end
19
-
20
- end
21
-
22
- def initialize(event)
23
- @event = event
24
- @body = ''
25
- end
26
-
27
- def call
28
- validate!
29
- status = Open3.popen3(env, command, chdir: chdir) do |_stdin, stdout, stderr, thread|
30
- @body << stdout.read
31
- @body << stderr.read
32
- puts @body
33
- thread.value.exitstatus
34
- end
35
- { statusCode: status, headers: {}, body: @body }
36
- end
37
-
38
- def command
39
- @event.dig 'lamby', 'runner'
40
- end
41
-
42
- private
43
-
44
- def chdir
45
- defined?(::Rails) ? ::Rails.root : Dir.pwd
46
- end
47
-
48
- def validate!
49
- return if pattern?
50
- raise UnknownCommandPattern.new(command)
51
- end
52
-
53
- def pattern?
54
- PATTERNS.any? { |p| p === command }
55
- end
56
-
57
- def env
58
- Hash[ENV.to_hash.map { |k,v| [k, ENV[k]] }]
59
- end
60
-
61
- end
62
- end