jets 0.6.6 → 0.6.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -0
- data/Gemfile.lock +1 -1
- data/lib/jets/builders/node-shim.js +1 -0
- data/lib/jets/cfn/template_builders/function_properties/base_builder.rb +4 -4
- data/lib/jets/controller.rb +1 -0
- data/lib/jets/core.rb +46 -1
- data/lib/jets/pascalize.rb +28 -26
- data/lib/jets/rule/task.rb +1 -1
- data/lib/jets/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f8dbba7d45f12322d2e782fa668a76f36a6818967e237681af10007bf95f2bdd
|
4
|
+
data.tar.gz: 4a9be05f3d832828ad0362b3f897ac57ad7c47a450b457f7b38fa4bdd3e6ab3e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 64b4ea7178ecfda89454067f08232b3f2cdb0f6df32ca6ff626026b7d5709dd1ac69fec5833da1a29762910f5fcb0963f5cc9f20895444c26666cea873601111
|
7
|
+
data.tar.gz: 6c008490354e438e024e839a48c26917a01e3d62e4727183314884ec19f7dde5404175ec971c30e7e7cb35e53c95a3f854830de53fe466a9ffb936de9b85432e
|
data/CHANGELOG.md
CHANGED
@@ -3,6 +3,9 @@
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
4
4
|
This project *tries* to adhere to [Semantic Versioning](http://semver.org/), even before v1.0.
|
5
5
|
|
6
|
+
## [0.6.7]
|
7
|
+
- eager load jets lib also, pull request #16
|
8
|
+
|
6
9
|
## [0.6.6]
|
7
10
|
- improve puts handling: PR #15
|
8
11
|
|
data/Gemfile.lock
CHANGED
@@ -168,6 +168,7 @@ exports.<%= function_name %> = (event, context, callback) => {
|
|
168
168
|
if (require.main === module) {
|
169
169
|
// fake event and context
|
170
170
|
var event = {"hello": "world"}
|
171
|
+
// var event = {"_prewarm": "1"} // prewarm special payload
|
171
172
|
// var event = {"body": {"hello": "world"}} // API Gateway wrapper structure
|
172
173
|
var context = {"fake": "context"}
|
173
174
|
exports.<%= @deducer.functions.first %>(event, context, (error, message) => {
|
@@ -68,7 +68,7 @@ module Jets::Cfn::TemplateBuilders::FunctionProperties
|
|
68
68
|
}.deep_stringify_keys
|
69
69
|
|
70
70
|
app_config_props = Jets.application.config.function.to_h
|
71
|
-
app_config_props = Pascalize.pascalize(app_config_props.deep_stringify_keys)
|
71
|
+
app_config_props = Jets::Pascalize.pascalize(app_config_props.deep_stringify_keys)
|
72
72
|
|
73
73
|
baseline.deep_merge(app_config_props)
|
74
74
|
end
|
@@ -92,7 +92,7 @@ module Jets::Cfn::TemplateBuilders::FunctionProperties
|
|
92
92
|
map = Jets::Cfn::TemplateMappers::IamPolicy::ClassPolicyMapper.new(klass)
|
93
93
|
class_properties[:Role] = "!GetAtt #{map.logical_id}.Arn"
|
94
94
|
end
|
95
|
-
Pascalize.pascalize(class_properties.deep_stringify_keys)
|
95
|
+
Jets::Pascalize.pascalize(class_properties.deep_stringify_keys)
|
96
96
|
end
|
97
97
|
|
98
98
|
# Function properties example:
|
@@ -116,12 +116,12 @@ module Jets::Cfn::TemplateBuilders::FunctionProperties
|
|
116
116
|
map = Jets::Cfn::TemplateMappers::IamPolicy::FunctionPolicyMapper.new(@task)
|
117
117
|
properties[:Role] = "!GetAtt #{map.logical_id}.Arn"
|
118
118
|
end
|
119
|
-
Pascalize.pascalize(properties.deep_stringify_keys)
|
119
|
+
Jets::Pascalize.pascalize(properties.deep_stringify_keys)
|
120
120
|
end
|
121
121
|
|
122
122
|
def env_file_properties
|
123
123
|
env_vars = Jets::Dotenv.load!(true)
|
124
|
-
Pascalize.pascalize(environment: { variables: env_vars })
|
124
|
+
Jets::Pascalize.pascalize(environment: { variables: env_vars })
|
125
125
|
end
|
126
126
|
end
|
127
127
|
end
|
data/lib/jets/controller.rb
CHANGED
@@ -3,6 +3,7 @@ class Jets::Controller
|
|
3
3
|
autoload :Layout, "jets/controller/layout"
|
4
4
|
autoload :Callbacks, "jets/controller/callbacks"
|
5
5
|
autoload :Request, "jets/controller/request"
|
6
|
+
autoload :Renderers, "jets/controller/renderers"
|
6
7
|
autoload :Rendering, "jets/controller/rendering"
|
7
8
|
autoload :Redirection, "jets/controller/redirection"
|
8
9
|
autoload :Params, "jets/controller/params"
|
data/lib/jets/core.rb
CHANGED
@@ -82,6 +82,51 @@ module Jets::Core
|
|
82
82
|
end
|
83
83
|
|
84
84
|
def eager_load!
|
85
|
+
eager_load_jets
|
86
|
+
eager_load_app
|
87
|
+
end
|
88
|
+
|
89
|
+
# Eager load jet's lib and classes
|
90
|
+
def eager_load_jets
|
91
|
+
lib_jets = File.expand_path(".", File.dirname(__FILE__))
|
92
|
+
Dir.glob("#{lib_jets}/**/*.rb").select do |path|
|
93
|
+
# puts "path #{path}"
|
94
|
+
next if !File.file?(path)
|
95
|
+
next if skip_eager_load_paths?(path)
|
96
|
+
|
97
|
+
path = path.sub("#{lib_jets}/","jets/")
|
98
|
+
class_name = path
|
99
|
+
.sub(/\.rb$/,'') # remove .rb
|
100
|
+
.sub(/^\.\//,'') # remove ./
|
101
|
+
.sub(/app\/\w+\//,'') # remove app/controllers or app/jobs etc
|
102
|
+
.camelize
|
103
|
+
# special class mappings
|
104
|
+
class_name = class_mappings(class_name)
|
105
|
+
class_name.constantize # use constantize instead of require so dont have to worry about order.
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
# Skip these paths because eager loading doesnt work for them.
|
110
|
+
def skip_eager_load_paths?(path)
|
111
|
+
path =~ %r{/templates/} ||
|
112
|
+
path =~ %r{/version} ||
|
113
|
+
path =~ %r{/rails_overrides} ||
|
114
|
+
path =~ %r{/default/application} ||
|
115
|
+
path =~ %r{/internal/app} ||
|
116
|
+
path =~ %r{/webpacker} ||
|
117
|
+
path =~ %r{/cli} ||
|
118
|
+
path =~ %r{/core_ext}
|
119
|
+
end
|
120
|
+
|
121
|
+
def class_mappings(class_name)
|
122
|
+
map = {
|
123
|
+
"Jets::Io" => "Jets::IO",
|
124
|
+
}
|
125
|
+
map[class_name] || class_name
|
126
|
+
end
|
127
|
+
|
128
|
+
# Eager load user's application
|
129
|
+
def eager_load_app
|
85
130
|
Dir.glob("#{Jets.root}app/**/*.rb").select do |path|
|
86
131
|
next if !File.file?(path) or path =~ %r{/javascript/} or path =~ %r{/views/}
|
87
132
|
|
@@ -91,7 +136,7 @@ module Jets::Core
|
|
91
136
|
.sub(/app\/\w+\//,'') # remove app/controllers or app/jobs etc
|
92
137
|
.classify
|
93
138
|
puts "eager_load! loading path: #{path} class_name: #{class_name}" if ENV['DEBUG']
|
94
|
-
class_name.constantize # dont have to worry about order.
|
139
|
+
class_name.constantize # use constantize instead of require so dont have to worry about order.
|
95
140
|
end
|
96
141
|
end
|
97
142
|
|
data/lib/jets/pascalize.rb
CHANGED
@@ -1,30 +1,32 @@
|
|
1
|
-
|
2
|
-
class
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
1
|
+
module Jets
|
2
|
+
class Pascalize
|
3
|
+
class << self
|
4
|
+
# Specialized pascalize that will not pascalize keys under the
|
5
|
+
# Variables part of the hash structure.
|
6
|
+
# Based on: https://stackoverflow.com/questions/8706930/converting-nested-hash-keys-from-camelcase-to-snake-case-in-ruby
|
7
|
+
def pascalize(value, parent_key=nil)
|
8
|
+
case value
|
9
|
+
when Array
|
10
|
+
value.map { |v| pascalize(v) }
|
11
|
+
when Hash
|
12
|
+
initializer = value.map do |k, v|
|
13
|
+
new_key = pascal_key(k, parent_key)
|
14
|
+
[new_key, pascalize(v, new_key)]
|
15
|
+
end
|
16
|
+
Hash[initializer]
|
17
|
+
else
|
18
|
+
value
|
19
|
+
end
|
20
|
+
end
|
20
21
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
22
|
+
def pascal_key(k, parent_key=nil)
|
23
|
+
if parent_key == "Variables" # do not pascalize keys anything under Variables
|
24
|
+
k
|
25
|
+
else
|
26
|
+
k = k.to_s.camelize
|
27
|
+
k.slice(0,1).capitalize + k.slice(1..-1) # capitalize first letter only
|
28
|
+
end
|
27
29
|
end
|
28
30
|
end
|
29
31
|
end
|
30
|
-
end
|
32
|
+
end
|
data/lib/jets/rule/task.rb
CHANGED
data/lib/jets/version.rb
CHANGED