public
Rubygem
Description: JSON Web App Framework
Homepage: http://halcyon.rubyforge.org/
Clone URL: git://github.com/mtodd/halcyon.git
Click here to lend your support to: halcyon and make a donation at www.pledgie.com !
halcyon / lib / halcyon.rb
100644 87 lines (68 sloc) 2.253 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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
$:.unshift File.dirname(__FILE__)
 
%w(rubygems rack extlib merb-core/vendor/facets merb-core/dispatch/router json uri).each {|dep|require dep}
 
# Provides global values, like the root of the current application directory,
# the current logger, the application name, and the framework version.
#
# Examples
# Halcyon.app #=> AppName
# Halcyon.root #=> Dir.pwd
# Halcyon.config #=> {:allow_from => :all, :logging => {...}, ...}
# Halcyon.paths #=> {:config => Halcyon.root/'config', ...}
# Halcyon.logger #=> #<Logger>
# Halcyon.version #=> "0.5.2"
#
module Halcyon
  
  VERSION = [0,5,5] unless defined?(Halcyon::VERSION)
  
  autoload :Application, 'halcyon/application'
  autoload :Client, 'halcyon/client'
  autoload :Config, 'halcyon/config'
  autoload :Controller, 'halcyon/controller'
  autoload :Exceptions, 'halcyon/exceptions'
  autoload :Logging, 'halcyon/logging'
  autoload :Runner, 'halcyon/runner'
  
  include Config::Helpers
  
  class << self
    
    attr_accessor :logger
    attr_writer :config
    
    def version
      VERSION.join('.')
    end
    
    # The default <tt>root</tt> setting, overwritten by a configuration helper.
    # This is so that the paths can be loaded when first booting the app.
    # This won't be necessary for certain cases where the paths the root is
    # manually configured, but for all other cases it can cause problems.
    #
    def root
      Dir.pwd
    end
    
    # Configuration accessor which creates a configuration object when
    # necessary.
    #
    def config
      @config ||= Halcyon::Config.new
    end
    
    # Tests for Windows platform (to compensate for numerous Windows-specific
    # bugs and oddities.)
    #
    # Returns Boolean:is_windows
    #
    def windows?
      RUBY_PLATFORM =~ /mswin/
    end
    
    # Tests for Linux platform.
    #
    # Returns Boolean:is_linux
    #
    def linux?
      RUBY_PLATFORM =~ /linux/
    end
    
  end
  
end
 
# Include the klass#logger and klass.logger accessor methods into Object.
Object.send(:include, Halcyon::Logging::Helpers)
 
# The server-interface framework.
#
module Rack
  
  autoload :JSONP, 'rack/jsonp'
  autoload :PostBodyContentTypeParsers, 'rack/post_body_content_type_parsers'
  
end