### Home Classes Methods

### In Files

- lib/ramaze/setup.rb

### Parent

Object

### Methods

- ::new
- #gem
- #install_gem
- #run
- #setup
- #setup_gem
- #temp_argv

### Class/Module Index

Quicksearch

- Ramaze
- Ramaze::App
- Ramaze::AppGraph
- Ramaze::Bin
- Ramaze::Bin::Console
- Ramaze::Bin::Create
- Ramaze::Bin::Helper
- Ramaze::Bin::Restart
- Ramaze::Bin::Runner
- Ramaze::Bin::Start
- Ramaze::Bin::Status
- Ramaze::Bin::Stop
- Ramaze::Cache
- Ramaze::Cache::LRU
- Ramaze::Cache::LocalMemCache
- Ramaze::Cache::MemCache
- Ramaze::Cache::Redis
- Ramaze::Cache::Sequel
- Ramaze::Controller
- Ramaze::CoreExtensions
- Ramaze::CoreExtensions::Array
- Ramaze::CoreExtensions::Binding
- Ramaze::CoreExtensions::Kernel
- Ramaze::CoreExtensions::Numeric
- Ramaze::CoreExtensions::Object
- Ramaze::CoreExtensions::Proc
- Ramaze::CoreExtensions::String
- Ramaze::Current
- Ramaze::DefaultController
- Ramaze::Dictionary
- Ramaze::Fiber
- Ramaze::Files
- Ramaze::GemSetup
- Ramaze::Gestalt
- Ramaze::Helper
- Ramaze::Helper::Auth
- Ramaze::Helper::Bench
- Ramaze::Helper::BlueForm
- Ramaze::Helper::BlueForm::Form
- Ramaze::Helper::CSRF
- Ramaze::Helper::Cache
- Ramaze::Helper::Cache::SingletonMethods
- Ramaze::Helper::Disqus
- Ramaze::Helper::Email
- Ramaze::Helper::Erector
- Ramaze::Helper::Flash
- Ramaze::Helper::Formatting
- Ramaze::Helper::Gestalt
- Ramaze::Helper::Gravatar
- Ramaze::Helper::Identity
- Ramaze::Helper::Layout
- Ramaze::Helper::Layout::SingletonMethods
- Ramaze::Helper::Link
- Ramaze::Helper::Localize
- Ramaze::Helper::Localize::Dictionary
- Ramaze::Helper::Localize::Parser
- Ramaze::Helper::Markaby
- Ramaze::Helper::Maruku
- Ramaze::Helper::Paginate
- Ramaze::Helper::Paginate::Paginator
- Ramaze::Helper::Paginate::Paginator::ArrayPager
- Ramaze::Helper::Paginate::Paginator::DataMapperPager
- Ramaze::Helper::Remarkably
- Ramaze::Helper::RequestAccessor
- Ramaze::Helper::SendFile
- Ramaze::Helper::SimpleCaptcha
- Ramaze::Helper::Stack
- Ramaze::Helper::Thread
- Ramaze::Helper::Ultraviolet
- Ramaze::Helper::Upload
- Ramaze::Helper::Upload::ClassMethods
- Ramaze::Helper::Upload::UploadedFile
- Ramaze::Helper::UserHelper
- Ramaze::Helper::UserHelper::Wrapper
- Ramaze::Helper::XHTML
- Ramaze::LRUHash
- Ramaze::Logger
- Ramaze::Logger::Analogger
- Ramaze::Logger::Growl
- Ramaze::Logger::Informer
- Ramaze::Logger::Knotify
- Ramaze::Logger::LogHub
- Ramaze::Logger::Logger
- Ramaze::Logger::RotatingInformer
- Ramaze::Logger::Syslog
- Ramaze::Logger::Xosd
- Ramaze::Logging
- Ramaze::MiddlewareCompiler
- Ramaze::Plugin
- Ramaze::Reloader
- Ramaze::Reloader::Hooks
- Ramaze::Reloader::WatchInotify
- Ramaze::Reloader::WatchStat
- Ramaze::Request
- Ramaze::Response
- Ramaze::SpecLogger
- Ramaze::Struct
- Ramaze::View
- Ramaze::View::Erector
- Ramaze::View::Erubis
- Ramaze::View::Ezamar
- Ramaze::View::Gestalt
- Ramaze::View::Haml
- Ramaze::View::Liquid
- Ramaze::View::Liquid::Tag
- Ramaze::View::Lokar
- Ramaze::View::Mustache
- Ramaze::View::Mustache::RamazeContext
- Ramaze::View::Nagoro
- Ramaze::View::Remarkably
- Ramaze::View::Sass
- Ramaze::View::Slippers
- Ramaze::View::Tagz
- Ramaze::View::Tagz::Methods
- Ramaze::View::Tenjin
- Nagoro
- Nagoro::Pipe
- Nagoro::Pipe::RenderPartial
- Bacon
- Bacon::PrettyOutput
- Erector
- Erector::Widget
- Rack
- Rack::RouteExceptions
- Tenjin
- Tenjin::Template
- BlankSlate
- Controller
- Fiber
- FiberError
- MainController
- Object
- OrderedSet
- Thread

No matching classes.

# Ramaze::GemSetup

Class responsible for installing and loading all the gems.

@author Michael Fellinger (manveru) @since 19-05-2009

### Public Class Methods

new(options = {}, &block) click to toggle source

Creates a new instance of the class and saves the parameters that were set.

@author Michael Fellinger (manveru) @since 19-05-2009 @param [Hash] options Hash containing various options to pass to the

    GemSetup class.

@option options :verbose When set to true Ramaze will log

    various actions such as messages about the installation process.

@yield block

    # File lib/ramaze/setup.rb, line 45
    def initialize(options = {}, &block)
      @gems = []
      @options = options.dup
      @verbose = @options.delete(:verbose)

      run(&block)
    end

### Public Instance Methods

gem(name, version = nil, options = {}) click to toggle source

Adds the given gem to the list of required gems.

@example

    gem('json', '>=1.5.1')

@author Michael Fellinger (manveru) @since 19-05-2009 @param [String] name The name of the gem to load. @param [String] version The version of the gem. @param [Hash] options Additional options to use when loading the gem. @option options :lib The name to load the gem as.

    # File lib/ramaze/setup.rb, line 80
    def gem(name, version = nil, options = {})
      if version.respond_to?(:merge!)
        options = version
      else
        options[:version] = version
      end

      @gems << [name, options]
    end

install_gem(name, options) click to toggle source

Tell Rubygems to install a gem.

@author Michael Fellinger (manveru) @since 19-05-2009 @param [String] name The name of the gem to activate. @param [Hash] options The options to use for installing the gem.

    # File lib/ramaze/setup.rb, line 135
    def install_gem(name, options)
      installer = Gem::DependencyInstaller.new(options)

      temp_argv(options[:extconf]) do
        log "Installing gem #{name}"
        installer.install(name, options[:version])
      end
    end

run(&block) click to toggle source

Executes the data inside the block, loading all the gems and optionally installing them.

@author Michael Fellinger (manveru) @since 19-05-2009 @param [Proc] block A block containing all the calls to gem().

    # File lib/ramaze/setup.rb, line 61
    def run(&block)
      return unless block_given?
      instance_eval(&block)
      setup
    end

setup() click to toggle source

Tries to install all the gems.

@author Michael Fellinger (manveru) @since 19-05-2009

    # File lib/ramaze/setup.rb, line 96
    def setup
      require 'rubygems'
      require 'rubygems/dependency_installer'

      @gems.each do |name, options|
        setup_gem(name, options)
      end
    end

setup_gem(name, options) click to toggle source

First try to activate, install and try to activate again if activation fails the first time.

@author Michael Fellinger (manveru) @since 19-05-2009 @param [String] name The name of the gem to activate. @param [Hash] options The options from GemSetup#initialize.

    # File lib/ramaze/setup.rb, line 114
    def setup_gem(name, options)
      version  = [options[:version]].compact
      lib_name = options[:lib] || name

      log "Activating gem #{name}"

      activate(name, lib_name, *version)
    # Gem not installed yet
    rescue Gem::LoadError
      install_gem(name, options)
      activate(name, lib_name, *version)
    end

temp_argv(extconf) click to toggle source

Prepare ARGV for rubygems installer

@author Michael Fellinger (manveru) @since 19-05-2009 @param [String] extconf

    # File lib/ramaze/setup.rb, line 151
    def temp_argv(extconf)
      if extconf ||= @options[:extconf]
        old_argv = ARGV.clone
        ARGV.replace(extconf.split(' '))
      end

      yield

    ensure
      ARGV.replace(old_argv) if extconf
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.