rtomayko / wink

NO LONGER MAINTAINED

This URL has Read+Write access

wink / wink
100755 58 lines (42 sloc) 1.605 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/usr/bin/env ruby
 
# if this is the initial run, setup the load path and grab a mutex
if ! defined?(Sinatra)
  root_dir = File.dirname(__FILE__)
  $:.unshift "#{root_dir}/rack/lib" if File.directory?("#{root_dir}/rack")
  $:.unshift "#{root_dir}/sinatra/lib" if File.directory?("#{root_dir}/sinatra")
  $:.unshift "#{root_dir}/lib"
  $:.unshift "#{root_dir}"
end
 
require 'rubygems'
require 'wink'
 
Wink.run! 'wink.conf' unless reloading?
 
 
# Reloading =================================================================
 
if development?
 
  unless reloading?
 
    # this is the initial load of this file. set our UNLOADING constant
    # to an array of names to remove before each reload.
    UNLOAD = %w[Entry Article Bookmark Comment Tag Tagging]
 
  else
 
    # remove all constants that we redefine in wink.rb
    UNLOAD.each do |const_name|
      begin
        klass = Object.const_get(const_name)
        klass.destroy! if klass.respond_to?(:destroy!)
        Object.send :remove_const, const_name
      rescue => boom
        STDERR.puts "error unloading constant: #{const_name}"
      end
    end
 
    Wink.send :remove_const, 'VERSION'
 
    # We also remove DataMapper's schema cache and subclass tracking since it keeps
    # references to the class objects we've removed above. This ensures that old
    # class objects can be GC'd.
    # DataMapper::Database[:default].adapter.instance_variable_set(:@schema, nil)
    # DataMapper::Persistence.subclasses.clear
 
    # reload all wink sources.
    load 'wink.rb'
    load 'wink.conf'
    load 'wink/models.rb'
    load 'wink/web.rb'
 
  end
 
end