ruby-sfn-local 0.1.6 → 0.1.9

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: 5fe17e00c8d4e14a4fce01894eb055a416e43abe8bcc9e7c9335a7af385e20af
4
- data.tar.gz: d5fbd90070b32dd0c8d3afd1b6c7096842679b97028d8538efd19c0a70d29b98
3
+ metadata.gz: c91b50b39f94e77840a25e9179e86fca730a556d7884fcee41997f76e6273ae0
4
+ data.tar.gz: 36465c625f9169533a80018d4a5d3840bff585fcfac216b9ab43d0f8df933211
5
5
  SHA512:
6
- metadata.gz: fcde4ca78448650c0dfd234c9783a01f7ef9e90e819f3d678a9094a8702a2b3c3affdbcf99bd1450bfc04e74715f1c2e3de98bbe20098826758b71aa10eec79b
7
- data.tar.gz: 2fdd25a501f35fd1d9b76198e1a3b71328eddc1b1c9dd470f8cf225655eb41f61271496cd6ba1bc3b0d1890c18be939e6d005d93d5fcf066a7077eec28148a73
6
+ metadata.gz: 3dfe1991cac8fdecccf933a4b83c1bd328875dc6b6fa236098ab0d64f79a5dc8a6adeba45e45987182b57c974957a7d01852d03dce23c284feb4ba9a907d31e5
7
+ data.tar.gz: 3405576ab516b3d7f5f9f59478d8113ec31da189a01a2aa1ee255e0163b349991274e1b00c1310cb69cbd3047fafb8261cd0fed1ed0561653756ae99c24deceb
@@ -33,12 +33,12 @@ module Sfn
33
33
  state_name = parsed_event.state_name
34
34
 
35
35
  unless state_name.nil?
36
- profile[state_name] ||= { input: [], output: [], parameters: [] }
37
- profile[state_name][:input] << parsed_event.profile[:input] unless parsed_event.profile[:input].nil?
38
- profile[state_name][:output] << parsed_event.profile[:output] unless parsed_event.profile[:output].nil?
36
+ profile[state_name] ||= { 'input' => [], 'output' => [], 'parameters' => [] }
37
+ profile[state_name]['input'] << parsed_event.profile['input'] unless parsed_event.profile['input'].nil?
38
+ profile[state_name]['output'] << parsed_event.profile['output'] unless parsed_event.profile['output'].nil?
39
39
  end
40
- if !last_state_name.nil? && !parsed_event.profile[:parameters].nil?
41
- profile[last_state_name][:parameters] << parsed_event.profile[:parameters]
40
+ if !last_state_name.nil? && !parsed_event.profile['parameters'].nil?
41
+ profile[last_state_name]['parameters'] << parsed_event.profile['parameters']
42
42
  end
43
43
  end
44
44
  [output, profile]
@@ -66,9 +66,9 @@ module Sfn
66
66
 
67
67
  def profile
68
68
  {
69
- input: try_parse(event.dig('stateEnteredEventDetails', 'input')),
70
- output: try_parse(event.dig('stateExitedEventDetails', 'output')),
71
- parameters: try_parse(event.dig('taskScheduledEventDetails', 'parameters'))
69
+ 'input' => try_parse(event.dig('stateEnteredEventDetails', 'input')),
70
+ 'output' => try_parse(event.dig('stateExitedEventDetails', 'output')),
71
+ 'parameters' => try_parse(event.dig('taskScheduledEventDetails', 'parameters'))
72
72
  }.compact
73
73
  end
74
74
 
@@ -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.name = name
32
- self.arn = arn || self.class.find_by_name(name)&.arn || create_state_machine
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(name), name: name, 'role-arn': ROLE }, 'stateMachineArn')
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(_name)
64
+ def load_definition
64
65
  local_definition_path = Tempfile.new(['name', '.json']).path
65
- remote_definition_path = "#{Sfn.configuration.definition_path}/#{name}.json"
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.6
4
+ version: 0.1.9
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-05-05 00:00:00.000000000 Z
11
+ date: 2022-05-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake-release