Class: Jets::Turbo

Inherits:
Object
  • Object
show all
Extended by:
Memoist
Defined in:
lib/jets/turbo.rb,
lib/jets/turbo/rails.rb,
lib/jets/turbo/database_yaml.rb

Defined Under Namespace

Classes: DatabaseYaml, Rails

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.afterburner?Boolean

Relies on the cached side-effect since Jets afterburner will switch Jets.root and the result will be different

Returns:

  • (Boolean)


10
11
12
# File 'lib/jets/turbo.rb', line 10

def afterburner?
  new.rails?
end

Instance Method Details

#chargeObject

Turbo charge mode



17
18
19
20
21
22
23
24
25
26
27
# File 'lib/jets/turbo.rb', line 17

def charge
  framework = detect
  case framework
  when :jets
    # do nothing
  when :rails
    Rails.new.setup
  else
    # should never get here
  end
end

#config_ru_contains?(value) ⇒ Boolean

Returns:

  • (Boolean)


47
48
49
50
51
52
53
54
# File 'lib/jets/turbo.rb', line 47

def config_ru_contains?(value)
  root = ENV["JETS_ROOT"] || Dir.pwd # Jets.root is not yet available
  config_ru = "#{root}/config.ru"
  return false unless File.exist?(config_ru)

  lines = ::IO.readlines(config_ru)
  !!lines.detect { |l| l.include?(value) }
end

#detectObject



29
30
31
32
33
34
35
36
37
# File 'lib/jets/turbo.rb', line 29

def detect
  if rails?
    :rails
  elsif jets?
    :jets
  else
    :unknown_framework
  end
end

#jets?Boolean

Returns:

  • (Boolean)


43
44
45
# File 'lib/jets/turbo.rb', line 43

def jets?
  config_ru_contains?('run Jets.application')
end

#rails?Boolean

Returns:

  • (Boolean)


39
40
41
# File 'lib/jets/turbo.rb', line 39

def rails?
  config_ru_contains?('run Rails.application')
end