Class: Jets::Turbo

Inherits:
Object
  • Object
show all
Defined in:
lib/jets/turbo.rb,
lib/jets/turbo/rail.rb,
lib/jets/turbo/database_yaml.rb

Defined Under Namespace

Classes: DatabaseYaml, Rail

Instance Method Summary collapse

Instance Method Details

#chargeObject

Turbo charge mode



9
10
11
12
13
14
15
16
17
18
19
# File 'lib/jets/turbo.rb', line 9

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

#config_ru_contains?(value) ⇒ Boolean

Returns:

  • (Boolean)


39
40
41
42
43
44
45
# File 'lib/jets/turbo.rb', line 39

def config_ru_contains?(value)
  config_ru = "#{Dir.pwd}/config.ru"
  return false unless File.exist?(config_ru)

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

#detectObject



21
22
23
24
25
26
27
28
29
# File 'lib/jets/turbo.rb', line 21

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

#jets?Boolean

Returns:

  • (Boolean)


35
36
37
# File 'lib/jets/turbo.rb', line 35

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

#rails?Boolean

Returns:

  • (Boolean)


31
32
33
# File 'lib/jets/turbo.rb', line 31

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