Sha256: db0f66b1752c7e69afeb6bdba6684332087cf10a1d553830995c17d0f38d1ff9

Contents?: true

Size: 1.05 KB

Versions: 15

Compression:

Stored size: 1.05 KB

Contents

module Ramaze
  def self.setup(start = true, &block)
    SetupEnvironment.new(&block) if block_given?
    self.start if start
  end

  class SetupEnvironment
    # FIXME:
    # * This is weird, class scope includes Global, yet it's skipped
    #   by Ruby on the lookup only because it's not in the scope of the block
    #   at the point of creation, shouldn't instance_eval take the binding of
    #   the SetupEnvironment instance in acocunt?

    def initialize(&block)
      instance_eval(&block)
    end

    # Shortcut for Ramaze::Gems::gem
    def gem(*args)
      require 'ramaze/contrib/gems'
      Ramaze::Gems::gem(*args)
      Ramaze::Gems::setup
    end

    # Shortcut if you don't need specific versions but tons of gems
    def gems(*args)
      args.each{|g| gem(g) }
    end

    def global(hash = nil)
      if hash
        Global.merge!(hash)
      else
        Global
      end
    end
    alias option global
  end
end

__END__
Usage example:

Ramaze.setup do
  gem 'json'

  option :middleware => true
  global.adapter = :thin
  option.port = 7000
end

Version data entries

15 entries across 15 versions & 4 rubygems

Version Path
Pistos-ramaze-2008.09 lib/ramaze/setup.rb
Pistos-ramaze-2008.12 lib/ramaze/setup.rb
Pistos-ramaze-2009.01 lib/ramaze/setup.rb
Pistos-ramaze-2009.02 lib/ramaze/setup.rb
manveru-ramaze-2008.08 lib/ramaze/setup.rb
manveru-ramaze-2008.09 lib/ramaze/setup.rb
manveru-ramaze-2008.10 lib/ramaze/setup.rb
manveru-ramaze-2008.12 lib/ramaze/setup.rb
manveru-ramaze-2009.01 lib/ramaze/setup.rb
ptomato-ramaze-2009.02.1 lib/ramaze/setup.rb
ptomato-ramaze-2009.02 lib/ramaze/setup.rb
ramaze-2008.11 lib/ramaze/setup.rb
ramaze-2009.01 lib/ramaze/setup.rb
ramaze-2009.03 lib/ramaze/setup.rb
ramaze-2009.02 lib/ramaze/setup.rb