Module: Goat

Includes:
Log
Defined in:
lib/goat.rb,
lib/goat/dom.rb,
lib/goat/common.rb,
lib/goat/static.rb,
lib/goat/state-srv.rb,
lib/goat/net-common.rb,
lib/goat/notifications.rb

Defined Under Namespace

Modules: AppHelpers, DOMTools, FlashHelper, HTMLHelpers, JSONMessages, Log, NotificationCenter, StateSrvClient Classes: App, BasicApp, Channel, ChannelPusher, Component, ComponentSkeleton, ComponentUpdate, Config, DOMDistiller, ERBRunner, ExpansionHelper, HTMLString, Halt, IndifferentHash, NoStateSrvConnectionError, NotFoundError, Page, PageCanvas, ReqHandler, StateSrvConnection, Static, UpdateDispatcher

Class Method Summary collapse

Methods included from Log

lockpath, log, log_message, logf, logname, logpath, tai64n

Class Method Details

.announce_launch(svc) ⇒ Object



9
10
11
# File 'lib/goat/common.rb', line 9

def self.announce_launch(svc)
  $stderr.puts "#{Time.now.to_s} #{svc} #{Goat.version} starting..."
end

.configObject



120
# File 'lib/goat.rb', line 120

def self.config; @config; end

.configure(&blk) ⇒ Object



122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
# File 'lib/goat.rb', line 122

def self.configure(&blk)
  @config = Config.new

  blk.call(@config)

  load_all('components')
  load_all('pages')

  # disabled for now
  #if p = Goat.setting(:press)
  #  Goat::Static.press = p
  #end

  if @config[:debug]
    if defined?(Thin)
      Thin::Logging.debug = true
    end
  end

  Goat::StateSrvClient.schedule
  Goat::NotificationCenter.schedule
  UpdateDispatcher.enable
end

.goat_path(f) ⇒ Object



71
# File 'lib/goat.rb', line 71

def self.goat_path(f); File.join(File.dirname(__FILE__), 'goat', f); end

.load_all(dir_fragment) ⇒ Object



113
114
115
116
117
118
# File 'lib/goat.rb', line 113

def self.load_all(dir_fragment)
  dir = File.join(Goat.config.get!(:root), dir_fragment)
  if File.directory?(dir)
    Dir.entries(dir).select{|f| f =~ /\.rb$/}.each {|f| require(File.join(dir, f))}
  end
end

.logd(msg) ⇒ Object



4
# File 'lib/goat/net-common.rb', line 4

def self.logd(msg); Goat::Log.log(:debug, msg); end

.loge(msg) ⇒ Object



6
# File 'lib/goat/net-common.rb', line 6

def self.loge(msg); Goat::Log.log(:error, msg); end

.logw(msg) ⇒ Object



5
# File 'lib/goat/net-common.rb', line 5

def self.logw(msg); Goat::Log.log(:warn, msg); end

.rack_builder(app, opts = {}) ⇒ Object



146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
# File 'lib/goat.rb', line 146

def self.rack_builder(app, opts={})
  defaults = {:logger => Rack::CommonLogger}
  opts = defaults.merge(opts)

  Rack::Builder.new do
    if cookies = Goat.config[:cookies]
      use Rack::Session::Cookie, cookies
    end

    use opts[:logger]

    if static = Goat.config[:static]
      use Rack::Static, :urls => static.fetch(:urls), :root => static.fetch(:root)
    end

    use Rack::Flash if defined?(Rack::Flash) # TODO hack

    run app
  end
end

.rpc_handlersObject



710
# File 'lib/goat.rb', line 710

def self.rpc_handlers; @rpc_handlers ||= {}; end

.run_app(app, opts = {}) ⇒ Object



167
168
169
170
# File 'lib/goat.rb', line 167

def self.run_app(app, opts={})
  builder = rack_builder(app, opts)
  Rack::Handler::Thin.run(builder.to_app)
end

.versionObject



4
5
6
7
# File 'lib/goat/common.rb', line 4

def self.version
  specpath = File.join(File.dirname(__FILE__), '../../goat.gemspec')
  Gem::Specification.load(specpath).version.to_s
end