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.5.5 lib/jets/turbo.rb
jets-1.5.4 lib/jets/turbo.rb
jets-1.5.3 lib/jets/turbo.rb
jets-1.5.2 lib/jets/turbo.rb
jets-1.5.1 lib/jets/turbo.rb
jets-1.5.0 lib/jets/turbo.rb
jets-1.4.11 lib/jets/turbo.rb
jets-1.4.10 lib/jets/turbo.rb
jets-1.4.9 lib/jets/turbo.rb
jets-1.4.8 lib/jets/turbo.rb
jets-1.4.7 lib/jets/turbo.rb
jets-1.4.6 lib/jets/turbo.rb
jets-1.4.5 lib/jets/turbo.rb
jets-1.4.4 lib/jets/turbo.rb
jets-1.4.3 lib/jets/turbo.rb
jets-1.4.2 lib/jets/turbo.rb
jets-1.4.1 lib/jets/turbo.rb
jets-1.4.0 lib/jets/turbo.rb