Module: Razor
- Defined in:
- lib/razor.rb,
lib/version.rb,
lib/razor/view.rb,
lib/razor/renderer.rb,
lib/razor/generable.rb,
lib/razor/rake/ftp_push.rb,
lib/razor/rake/git_generate.rb
Defined Under Namespace
Modules: Rake
Classes: Directory, Generable, GenerableFile, Page, RegularFile, Renderer, Script, Site, StyleSheet, View, ViewFile
Constant Summary
collapse
- Version =
'0.5.2'
Class Method Summary
collapse
Class Method Details
.create(name) ⇒ Object
11
12
13
|
# File 'lib/razor.rb', line 11
def self.create(name)
Dir.mkdir name
end
|
.generate(options, *args) ⇒ Object
15
16
17
18
19
20
21
22
23
|
# File 'lib/razor.rb', line 15
def self.generate(options, *args)
if options[:url_base]
args << options[:url_base]
end
@src = args[0]
site = Site.new(*args)
FileUtils.rm_r(dest) rescue nil
site.generate
end
|
.http_request(src, url) ⇒ Object
56
57
58
59
60
61
|
# File 'lib/razor.rb', line 56
def self.http_request(src, url)
url = url[1..-1].sub(/\/+/, '/')
site = Site.new(src, '')
file = site.http(url)
file and file.request
end
|
.load(path) ⇒ Object
52
53
54
|
# File 'lib/razor.rb', line 52
def self.load(path)
super File.join(@src, path)
end
|
.server(port, src) ⇒ Object
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
|
# File 'lib/razor.rb', line 25
def self.server(port, src)
require 'rack'
@src = src
port = (port and port.to_i or 3300)
on_request = lambda do |env|
page = http_request src, env['PATH_INFO']
if page
[
200,
{ 'Content-Type' =>
Rack::Mime.mime_type(page.dest_ext) },
[ page.contents ]
]
else
[
404,
{ 'Content-Type' => 'text/html' },
[ 'Page Not Found' ]
]
end
end
Rack::Handler::WEBrick.run(on_request, :Port => port) { |server|
trap(:INT) { server.stop }
trap(:TERM) { server.stop }
}
end
|