ruby-sfn-local 0.1.7 → 0.1.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/sfn/mock_macros.rb +6 -0
- data/lib/sfn/state_machine.rb +8 -8
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 84a623fc6db39626f2c4562e6f6613827428629409425c18864ceca3f88c954d
|
4
|
+
data.tar.gz: 9077be558acade75591926166e04e2428f9225c11dd897206124697b9a4e6c4e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c61caf572c5957664eaed371552f438780bf6354962a1aff13aa1355acd06e73ebbfbeeb171dbe63f208934d493d36e4a4be8736c7b07bea2cf611759c2d3ced
|
7
|
+
data.tar.gz: edb7519af4ee46230ed1e578358fe97f4430dd07491cd05897549de628f9aab43a5b8ebef95521aae1c68e2f7f293913b408908057e100687a777bc75a555302
|
data/lib/sfn/mock_macros.rb
CHANGED
@@ -4,6 +4,7 @@ require 'sfn/mock_macros/lambda'
|
|
4
4
|
require 'sfn/mock_macros/step_function'
|
5
5
|
require 'sfn/mock_macros/api_gateway'
|
6
6
|
require 'sfn/mock_macros/sns'
|
7
|
+
require 'sfn/mock_macros/sqs'
|
7
8
|
|
8
9
|
module Sfn
|
9
10
|
module MockMacros
|
@@ -11,6 +12,7 @@ module Sfn
|
|
11
12
|
include StepFunction
|
12
13
|
include ApiGateway
|
13
14
|
include Sns
|
15
|
+
include Sqs
|
14
16
|
|
15
17
|
def self.gateway_response(data)
|
16
18
|
ApiGateway.response(data)
|
@@ -24,6 +26,10 @@ module Sfn
|
|
24
26
|
Sns.response(data)
|
25
27
|
end
|
26
28
|
|
29
|
+
def self.sqs_response(data)
|
30
|
+
Sqs.response(data)
|
31
|
+
end
|
32
|
+
|
27
33
|
def self.step_function_response(data)
|
28
34
|
StepFunction.response(data)
|
29
35
|
end
|
data/lib/sfn/state_machine.rb
CHANGED
@@ -9,7 +9,7 @@ module Sfn
|
|
9
9
|
class StateMachine
|
10
10
|
ROLE = 'arn:aws:iam::123456789012:role/DummyRole'
|
11
11
|
|
12
|
-
attr_accessor :name, :definition, :arn, :executions, :execution_arn
|
12
|
+
attr_accessor :name, :path, :definition, :arn, :executions, :execution_arn
|
13
13
|
|
14
14
|
def self.all
|
15
15
|
Collection.instance.all.map { |sf| new(sf['name'], sf['stateMachineArn']) }
|
@@ -28,8 +28,9 @@ module Sfn
|
|
28
28
|
end
|
29
29
|
|
30
30
|
def initialize(name, arn = nil)
|
31
|
-
self.
|
32
|
-
self.
|
31
|
+
self.path = "#{Sfn.configuration.definition_path}/#{name}.json"
|
32
|
+
self.name = name.split("/").last
|
33
|
+
self.arn = arn || self.class.find_by_name(self.name)&.arn || create_state_machine
|
33
34
|
self.executions = {}
|
34
35
|
end
|
35
36
|
|
@@ -53,18 +54,17 @@ module Sfn
|
|
53
54
|
|
54
55
|
def create_state_machine
|
55
56
|
self.arn = AwsCli.run('stepfunctions', 'create-state-machine',
|
56
|
-
{ definition: load_definition
|
57
|
+
{ definition: load_definition, name: name, 'role-arn': ROLE }, 'stateMachineArn')
|
57
58
|
raise Sf::DefinitionError if arn.empty?
|
58
59
|
|
59
60
|
Collection.instance.add(to_hash)
|
60
61
|
arn
|
61
62
|
end
|
62
63
|
|
63
|
-
def load_definition
|
64
|
+
def load_definition
|
64
65
|
local_definition_path = Tempfile.new(['name', '.json']).path
|
65
|
-
|
66
|
-
|
67
|
-
definition = File.read(remote_definition_path)
|
66
|
+
|
67
|
+
definition = File.read(self.path)
|
68
68
|
local_definition = definition.gsub(/"MaxConcurrency": [0-9]+/, '"MaxConcurrency": 1')
|
69
69
|
|
70
70
|
File.open(local_definition_path, 'w') { |file| file.puts local_definition }
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby-sfn-local
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gianni Mazza
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-06-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake-release
|