aws_sam_yarn_builder 0.1.5 → 0.2.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
- SHA1:
3
- metadata.gz: 2540ed6bbdd9bfff7222124da1b6feaecbe13e69
4
- data.tar.gz: d88b69ef4644e2fd65cc671b08854dc5015f8504
2
+ SHA256:
3
+ metadata.gz: 0e465237a62e0e25560d584c7bc3807fa1c61d9acf0f3380efd92d6073ab1ebc
4
+ data.tar.gz: 4aa8a1f1069a3092a74164715f9591b70dd893c7a72a80797ffe05848519b4c3
5
5
  SHA512:
6
- metadata.gz: 593fd08c6c34ec550bf0c1899664eead38b61a20114ed2bb903a5ce580c32690fcb67a2a3f6be5f6f6b89b3928939d547b575a751534bdc30c8c585b7aa8745b
7
- data.tar.gz: a6d0b424e36881e7a22a89342b87d2f4961ad2c178dccde5dee84d04f721be5b01a35c9bc3ab06d51e14a3fc6783738df58934f1166b417b3281085014a463bc
6
+ metadata.gz: e34e5afbbe6875a7ea6342d29549418cafdbd2d742a0fa772d5fa67acb022d6a08e7d64a02aeb0ec13ff5a7124ada0a60657b91dac2fd95381c72928fc88b205
7
+ data.tar.gz: 9f9bb5efe92648b4cefbc76c01d2f8645d6cf4b44eaa130762ffa2ad88c2daa23e67d4bf58594757afdf9b8826a3ddbfd33ac50b78477cd417d22c21d1144d43
@@ -2,20 +2,20 @@ PATH
2
2
  remote: .
3
3
  specs:
4
4
  aws_sam_yarn_builder (0.1.4)
5
- activesupport (~> 5.2.2)
5
+ activesupport (~> 5.2.0)
6
6
  slop (~> 4.6.0)
7
7
 
8
8
  GEM
9
9
  remote: https://rubygems.org/
10
10
  specs:
11
- activesupport (5.2.2)
11
+ activesupport (5.2.3)
12
12
  concurrent-ruby (~> 1.0, >= 1.0.2)
13
13
  i18n (>= 0.7, < 2)
14
14
  minitest (~> 5.1)
15
15
  tzinfo (~> 1.1)
16
16
  coderay (1.1.2)
17
- concurrent-ruby (1.1.4)
18
- i18n (1.4.0)
17
+ concurrent-ruby (1.1.5)
18
+ i18n (1.6.0)
19
19
  concurrent-ruby (~> 1.0)
20
20
  method_source (0.9.2)
21
21
  minitest (5.11.3)
@@ -20,7 +20,7 @@ Gem::Specification.new do |spec|
20
20
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
21
21
 
22
22
  spec.add_dependency "slop", "~> 4.6.0"
23
- spec.add_dependency "activesupport", "~> 5.2.2"
23
+ spec.add_dependency "activesupport", "~> 5.2.0"
24
24
 
25
25
  spec.add_development_dependency "bundler", "~> 1.16"
26
26
  spec.add_development_dependency "rake", "~> 10.0"
@@ -23,7 +23,7 @@ module AwsSamYarnBuilder
23
23
  package.build function.name, destination_dir, destination_staging_dir
24
24
  end
25
25
 
26
- template.write_to_output(destination_dir)
26
+ template.write_to_output(destination_dir, template_base_dir)
27
27
 
28
28
  FileUtils.rm_rf(destination_staging_dir)
29
29
  end
@@ -2,6 +2,19 @@ require "yaml"
2
2
 
3
3
  module AwsSamYarnBuilder
4
4
  class Template
5
+ String.class_eval do
6
+ def indent(count, char = " ")
7
+ gsub(/([^\n]*)(\n|$)/) do |match|
8
+ last_iteration = ($1 == "" && $2 == "")
9
+ line = ""
10
+ line << (char * count) unless last_iteration
11
+ line << $1
12
+ line << $2
13
+ line
14
+ end
15
+ end
16
+ end
17
+
5
18
  class FunctionResource
6
19
  def initialize(name, properties = {})
7
20
  self.name = name
@@ -29,9 +42,9 @@ module AwsSamYarnBuilder
29
42
  self.contents = contents
30
43
  end
31
44
 
32
- def write_to_output(output)
45
+ def write_to_output(output, source_directory)
33
46
  File.open(File.join(output, "template.yaml"), "w+") do |file|
34
- file << contents_with_transformed_function_paths
47
+ file << transformed_contents(source_directory)
35
48
  end
36
49
  end
37
50
 
@@ -51,8 +64,22 @@ module AwsSamYarnBuilder
51
64
  @document ||= YAML.load(contents)
52
65
  end
53
66
 
54
- def contents_with_transformed_function_paths
55
- contents.gsub(/CodeUri:\s*(.*)/) do |_|
67
+ def transformed_contents(source_directory)
68
+ contents_with_transformed_step_function_definitions(contents_with_transformed_function_paths(contents), source_directory)
69
+ end
70
+
71
+ def contents_with_transformed_step_function_definitions(c, source_directory)
72
+ c.gsub(/^(\s*)DefinitionUri:\s*(.*)/) do |_|
73
+ "#{$1}DefinitionString: !Sub |\n#{resolve_step_function_definition_string($2, source_directory).indent($1.length + 2)}"
74
+ end
75
+ end
76
+
77
+ def resolve_step_function_definition_string(definition_uri, source_directory)
78
+ File.read(File.expand_path(File.join(source_directory, definition_uri)))
79
+ end
80
+
81
+ def contents_with_transformed_function_paths(c)
82
+ c.gsub(/CodeUri:\s*(.*)/) do |_|
56
83
  "CodeUri: ./#{find_function_name_for_code_uri($1)}"
57
84
  end
58
85
  end
@@ -1,3 +1,3 @@
1
1
  module AwsSamYarnBuilder
2
- VERSION = "0.1.5"
2
+ VERSION = "0.2.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aws_sam_yarn_builder
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eric Allam
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-01-28 00:00:00.000000000 Z
11
+ date: 2019-04-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: slop
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 5.2.2
33
+ version: 5.2.0
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: 5.2.2
40
+ version: 5.2.0
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: bundler
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -108,7 +108,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
108
108
  version: '0'
109
109
  requirements: []
110
110
  rubyforge_project:
111
- rubygems_version: 2.6.11
111
+ rubygems_version: 2.7.6
112
112
  signing_key:
113
113
  specification_version: 4
114
114
  summary: A command line program to produce builds for aws-sam-cli for nodejs/yarn