Class: Bike
- Inherits:
-
Object
show all
- Defined in:
- lib/bike.rb
Overview
- Author
-
Akira FUNAI
- Copyright
-
Copyright © 2009 Akira FUNAI
Defined Under Namespace
Modules: Error, I18n, Meta, Parser, Path, REX, Response, Set
Classes: Checkbox, Field, File, Img, Password, Radio, Select, Storage, Text, Textarea, Workflow
Class Method Summary
collapse
Instance Method Summary
collapse
Class Method Details
.[](name) ⇒ Object
32
33
34
35
|
# File 'lib/bike.rb', line 32
def self.[](name)
@config ||= {}
@config[name]
end
|
.base ⇒ Object
61
62
63
|
# File 'lib/bike.rb', line 61
def self.base
self.current[:base]
end
|
.client ⇒ Object
49
50
51
|
# File 'lib/bike.rb', line 49
def self.client
self.session[:client] ||= 'nobody'
end
|
.client=(id) ⇒ Object
53
54
55
|
# File 'lib/bike.rb', line 53
def self.client=(id)
self.session[:client] = id
end
|
.config(config) ⇒ Object
28
29
30
|
# File 'lib/bike.rb', line 28
def self.config(config)
@config = config
end
|
.current ⇒ Object
37
38
39
|
# File 'lib/bike.rb', line 37
def self.current
Thread.current
end
|
.libdir ⇒ Object
69
70
71
|
# File 'lib/bike.rb', line 69
def self.libdir
::File.dirname __FILE__
end
|
.session ⇒ Object
41
42
43
|
# File 'lib/bike.rb', line 41
def self.session
self.current[:session] || ($fake_session ||= {})
end
|
.static(env) ⇒ Object
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
|
# File 'lib/bike.rb', line 73
def self.static(env)
@static ||= Rack::Directory.new Bike['skin_dir']
response = @static.call env
if response.first == 404
until ::File.readable? ::File.join(
Bike['skin_dir'],
env['PATH_INFO'].sub(%r{(/#{Bike::REX::DIR_STATIC}/).*}, '\\1')
)
env['PATH_INFO'].sub!(%r{/[^/]+(?=/#{Bike::REX::DIR_STATIC}/)}, '') || break
end
@static.call env
else
response
end
end
|
.token ⇒ Object
57
58
59
|
# File 'lib/bike.rb', line 57
def self.token
self.session[:token] ||= rand(36 ** 32).to_s(36)
end
|
.transaction ⇒ Object
45
46
47
|
# File 'lib/bike.rb', line 45
def self.transaction
self.session[:transaction] ||= {}
end
|
.uri ⇒ Object
65
66
67
|
# File 'lib/bike.rb', line 65
def self.uri
self.current[:uri]
end
|