Sha256: a5d5ca4d167b0dbd1b5a8a822365ee4133a8650d850a57d8f6700af774930ad8

Contents?: true

Size: 879 Bytes

Versions: 58

Compression:

Stored size: 879 Bytes

Contents

require 'fileutils'

module Jets
  class Turbo
    autoload :DatabaseYaml, 'jets/turbo/database_yaml'
    autoload :Rail, 'jets/turbo/rail'

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

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

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

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

    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
  end
end

Version data entries

58 entries across 58 versions & 2 rubygems

Version Path
jets-1.9.5 lib/jets/turbo.rb
jets-1.9.4 lib/jets/turbo.rb
jets-1.9.3 lib/jets/turbo.rb
jets-1.9.2 lib/jets/turbo.rb
jets-1.9.1 lib/jets/turbo.rb
jets-1.9.0 lib/jets/turbo.rb
jets-1.8.14 lib/jets/turbo.rb
jets-1.8.13 lib/jets/turbo.rb
jets-1.8.12 lib/jets/turbo.rb
jets-1.8.11 lib/jets/turbo.rb
jets-1.8.10 lib/jets/turbo.rb
jets-1.8.9 lib/jets/turbo.rb
jets-1.8.8 lib/jets/turbo.rb
jets-1.8.7 lib/jets/turbo.rb
jets-1.8.6 lib/jets/turbo.rb
jets-1.8.5 lib/jets/turbo.rb
jets-1.8.4 lib/jets/turbo.rb
jets-1.8.3 lib/jets/turbo.rb
jets-1.8.2 lib/jets/turbo.rb
jets-1.8.1 lib/jets/turbo.rb