lib/jets/core.rb in jets-0.10.4 vs lib/jets/core.rb in jets-1.0.0

- old
+ new

@@ -32,19 +32,10 @@ end # Ensures trailing slash # Useful for appending a './' in front of a path or leaving it alone. # Returns: '/path/with/trailing/slash/' or './' - # @@root = nil - # def root - # return @@root if @@root - # @@root = ENV['JETS_ROOT'].to_s - # @@root = '.' if @@root == '' - # @@root = "#{@@root}/" unless @@root.ends_with?('/') - # @@root = Pathname.new(@@root) - # end - def root root = ENV['JETS_ROOT'].to_s root = '.' if root == '' root = "#{root}/" unless root.ends_with?('/') Pathname.new(root) @@ -105,19 +96,22 @@ end end # Skip these paths because eager loading doesnt work for them. def skip_eager_load_paths?(path) - path =~ %r{/templates/} || - path =~ %r{/version} || - path =~ %r{/rails_overrides} || - path =~ %r{/default/application} || - path =~ %r{/internal/app} || - path =~ %r{/webpacker} || path =~ %r{/cli} || path =~ %r{/core_ext} || - path =~ %r{/jets/stack} + path =~ %r{/default/application} || + path =~ %r{/functions} || + path =~ %r{/internal/app} || + path =~ %r{/jets/stack} || + path =~ %r{/rackup_wrappers} || + path =~ %r{/rails_overrides} || + path =~ %r{/reconfigure_rails} || + path =~ %r{/templates/} || + path =~ %r{/version} || + path =~ %r{/webpacker} end def class_mappings(class_name) map = { "Jets::Io" => "Jets::IO", @@ -127,11 +121,11 @@ # Eager load user's application def eager_load_app Dir.glob("#{Jets.root}app/**/*.rb").select do |path| next if !File.file?(path) or path =~ %r{/javascript/} or path =~ %r{/views/} - next if path.include?('app/shared/functions') + next if path.include?('app/functions') || path.include?('app/shared/functions') class_name = path .sub(/\.rb$/,'') # remove .rb .sub(%{^\./},'') # remove ./ .sub(Jets.root.to_s,'') @@ -161,9 +155,17 @@ def prewarm_count @@prewarm_count end def project_namespace - [config.project_name, config.short_env, config.env_extra].compact.join('-') + [config.project_name, config.short_env, config.env_extra].compact.join('-').gsub('_','-') end + def rack? + path = "#{Jets.root}rack" + File.exist?(path) || File.symlink?(path) + end + + def lazy_load? + config.ruby.lazy_load + end end