Sha256: affb3f4a3472f3b2b1de5b4521d079311dc3305a38e4b0f8a9d23aaf54bbbde8

Contents?: true

Size: 1.74 KB

Versions: 3

Compression:

Stored size: 1.74 KB

Contents

require 'logger'
require 'active_support/dependencies'
require 'memoist'

module Jets::Core
  extend Memoist

  # Calling application triggers load of configs.
  # Jets' the default config/application.rb is loaded,
  # then the project's config/application.rb is loaded.
  @@application = nil
  def application
    return @@application if @@application

    @@application = Jets::Application.new
    @@application.setup!
    @@application
  end
  # For some reason memoize doesnt work with application, think there's
  # some circular dependency issue. Figure this out later.

  def config
    application.config
  end

  # Load all application base classes and project classes
  def boot
    Jets::Booter.boot!
  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)
  end
  memoize :root

  def env
    env = ENV['JETS_ENV'] || 'development'
    ENV['RAILS_ENV'] = ENV['RACK_ENV'] = env
    ActiveSupport::StringInquirer.new(env)
  end
  memoize :env

  def build_root
    "/tmp/jets/#{config.project_name}".freeze
  end
  memoize :build_root

  def logger
    Logger.new($stderr)
  end
  memoize :logger

  def webpacker?
    Gem.loaded_specs.keys.include?("webpacker")
  end
  memoize :webpacker?

  def load_tasks
    Jets::Commands::RakeTasks.load!
  end

  def version
    Jets::VERSION
  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
jets-0.5.2 lib/jets/core.rb
jets-0.5.1 lib/jets/core.rb
jets-0.5.0 lib/jets/core.rb