Module: Track

Defined in:
lib/track.rb,
lib/track/routes.rb,
lib/track/version.rb,
lib/track/route_map.rb,
lib/track/controller.rb,
lib/track/filter_map.rb,
lib/track/application.rb

Defined Under Namespace

Classes: Application, Controller, FilterMap, RouteMap, Routes

Constant Summary collapse

VERSION =
'0.4.0'
@@responses =
{
  :routing_error => [404, { 'Content-Type' => 'text/plain'}, ['Route not found']],
  :not_found     => [404, { 'Content-Type' => 'text/plain'}, ['Resource not found']]
}
@@env =
ENV['RACK_ENV'].to_sym.freeze
@@config =
nil
@@root =
nil
@@plugins =
[]

Class Method Summary collapse

Class Method Details

.[](key) ⇒ Object



25
26
27
# File 'lib/track.rb', line 25

def [](key)
  @@config[key.to_s]
end

.boot!(root) ⇒ Object



18
19
20
21
22
23
# File 'lib/track.rb', line 18

def boot!(root)
  @@root   = root
  @@config = load_config_file!(:config)
  boot_plugins!
  Routes.load! File.join(root, 'config', 'routes')
end

.boot_plugins!Object



61
62
63
# File 'lib/track.rb', line 61

def boot_plugins!
  @@plugins.each { |plugin| plugin.boot! }
end

.configObject



29
30
31
# File 'lib/track.rb', line 29

def config
  @@config
end

.envObject



33
34
35
# File 'lib/track.rb', line 33

def env
  @@env
end

.env?(e) ⇒ Boolean

Returns:

  • (Boolean)


37
38
39
# File 'lib/track.rb', line 37

def env?(e)
  @@env == e.to_sym
end

.load_config_file!(filename) ⇒ Object



57
58
59
# File 'lib/track.rb', line 57

def load_config_file!(filename)
  YAML.load(File.open(File.join(root, 'config', "#{filename}.yml")))[env.to_s]
end

.plugin(plugin) ⇒ Object



49
50
51
# File 'lib/track.rb', line 49

def plugin(plugin)
  @@plugins << plugin
end

.responsesObject



53
54
55
# File 'lib/track.rb', line 53

def responses
  @@responses
end

.rootObject



41
42
43
# File 'lib/track.rb', line 41

def root
  @@root
end

.versionObject



45
46
47
# File 'lib/track.rb', line 45

def version
  VERSION
end