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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ba1ae625286077b458d497643590d72d83d10e800ce1d8fc1bf18599260501a0
4
- data.tar.gz: cdccc52793152392901ae9c27e5bfbeafaccf49d4fc78fea70dc28feeda0d8ee
3
+ metadata.gz: f8dbba7d45f12322d2e782fa668a76f36a6818967e237681af10007bf95f2bdd
4
+ data.tar.gz: 4a9be05f3d832828ad0362b3f897ac57ad7c47a450b457f7b38fa4bdd3e6ab3e
5
5
  SHA512:
6
- metadata.gz: 6ead8f6f9e01613c614e6815e25ad777413fb2222e07b065962a7ee3e33d19dad7dcb7fd9a158da57543ba9ec65c3634043081ea44636227a633d29dbb914035
7
- data.tar.gz: 59a7f19c9e3486d68462f929d0ef93b54ec752edc4ae9b880bd535fd57d969370088a4053c4bf37cd0da63ed2b113ffe75b8804e6f7842da182c39a5b6223ace
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
@@ -11,7 +11,7 @@ GIT
11
11
  PATH
12
12
  remote: .
13
13
  specs:
14
- jets (0.6.6)
14
+ jets (0.6.7)
15
15
  actionpack (>= 5.2.1)
16
16
  actionview (>= 5.2.1)
17
17
  activerecord (>= 5.2.1)
@@ -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
@@ -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
 
@@ -1,30 +1,32 @@
1
- class Pascalize
2
- class << self
3
- # Specialized pascalize that will not pascalize keys under the
4
- # Variables part of the hash structure.
5
- # Based on: https://stackoverflow.com/questions/8706930/converting-nested-hash-keys-from-camelcase-to-snake-case-in-ruby
6
- def pascalize(value, parent_key=nil)
7
- case value
8
- when Array
9
- value.map { |v| pascalize(v) }
10
- when Hash
11
- initializer = value.map do |k, v|
12
- new_key = pascal_key(k, parent_key)
13
- [new_key, pascalize(v, new_key)]
14
- end
15
- Hash[initializer]
16
- else
17
- value
18
- end
19
- end
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
- def pascal_key(k, parent_key=nil)
22
- if parent_key == "Variables" # do not pascalize keys anything under Variables
23
- k
24
- else
25
- k = k.to_s.camelize
26
- k.slice(0,1).capitalize + k.slice(1..-1) # capitalize first letter only
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
@@ -15,7 +15,7 @@ class Jets::Rule::Task < Jets::Lambda::Task
15
15
  end
16
16
 
17
17
  def config_rule_properties
18
- props = Pascalize.pascalize(@config_rule)
18
+ props = Jets::Pascalize.pascalize(@config_rule)
19
19
  props = config_rule_defaults.merge(props)
20
20
  props
21
21
  end
data/lib/jets/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Jets
2
- VERSION = "0.6.6"
2
+ VERSION = "0.6.7"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jets
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.6
4
+ version: 0.6.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tung Nguyen