Sha256: b054e580fb067d688793e0c6d90d5731f1dfcddd007ab5138c09c557349b6b9a

Contents?: true

Size: 1.7 KB

Versions: 17

Compression:

Stored size: 1.7 KB

Contents

# Do not change this file!
#
# This was mainly copied (but modified a little bit) from the rails framework
# initializers, but made less picky about gem loading.

APPLICATION_ROOT = File.expand_path("#{File.dirname(__FILE__)}/..") unless defined?(APPLICATION_ROOT)

module RuGUI
  class << self
    def boot!
      unless booted?
        preinitialize
        pick_boot.run
      end
    end

    def booted?
      defined? RuGUI::Initializer
    end

    def pick_boot
      (vendor_rugui? ? VendorBoot : GemBoot).new
    end

    def vendor_rugui?
      File.exist?("#{APPLICATION_ROOT}/vendor/rugui")
    end

    def preinitialize
      load(preinitializer_path) if File.exist?(preinitializer_path)
    end

    def preinitializer_path
      "#{APPLICATION_ROOT}/config/preinitializer.rb"
    end
  end

  class Boot
    def run
      load_initializer
      RuGUI::Initializer.run(:set_load_path)
    end
  end

  class VendorBoot < Boot
    def load_initializer
      require "#{APPLICATION_ROOT}/vendor/rugui/lib/rugui/initializer"
    end
  end

  class GemBoot < Boot
    def load_initializer
      self.class.load_rubygems
      load_rugui
      require 'rugui/initializer'
    end

    def load_rugui
      require 'rugui'
    rescue Gem::LoadError
      $stderr.puts %(Missing the RuGUI gem. Please `gem install rugui`.)
      exit 1
    end

    class << self
      def rubygems_version
        Gem::RubyGemsVersion if defined? Gem::RubyGemsVersion
      end

      def load_rubygems
        require 'rubygems'
      rescue LoadError
        $stderr.puts %(RuGUI requires RubyGems. Please install RubyGems and try again: http://rubygems.rubyforge.org)
        exit 1
      end
    end
  end
end

# All that for this:
RuGUI.boot!

Version data entries

17 entries across 17 versions & 2 rubygems

Version Path
intelitiva-rugui-1.2.0 rugui_generators/rugui/templates/boot.rb
intelitiva-rugui-1.3.0 rugui_generators/rugui/templates/boot.rb
intelitiva-rugui-1.3.1 rugui_generators/rugui/templates/boot.rb
intelitiva-rugui-1.3.2 rugui_generators/rugui/templates/boot.rb
rugui-1.6.0 lib/rugui/generators/rugui/templates/config/boot.rb
rugui-1.5.4 lib/rugui/generators/rugui/templates/config/boot.rb
rugui-1.5.3 lib/rugui/generators/rugui/templates/config/boot.rb
rugui-1.5.2 lib/rugui/generators/rugui/templates/config/boot.rb
rugui-1.5.0 lib/rugui/generators/rugui/templates/config/boot.rb
rugui-1.4.3 lib/rugui/generators/rugui/templates/config/boot.rb
rugui-1.4.2 lib/rugui/generators/rugui/templates/config/boot.rb
rugui-1.4.0 lib/rugui/generators/rugui/templates/config/boot.rb
rugui-1.3.3 rugui_generators/rugui/templates/boot.rb
rugui-1.3.1 rugui_generators/rugui/templates/boot.rb
rugui-1.3.2 rugui_generators/rugui/templates/boot.rb
rugui-1.2.2 rugui_generators/rugui/templates/boot.rb
rugui-1.3.0 rugui_generators/rugui/templates/boot.rb