-
Notifications
You must be signed in to change notification settings - Fork 1
/
piano
executable file
·64 lines (51 loc) · 1.69 KB
/
piano
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
#!/usr/bin/env ruby
$LOAD_PATH << File.expand_path("../../lib", __FILE__)
require 'piano'
require 'metafun/delegator'
unless ARGV.empty?
args = {}
ARGV.each do |arg|
if arg =~ /^\d+$/
args[:port] = arg
elsif arg =~ /^noetags$/
args[:etags] = :off
elsif arg == '-v'
puts Piano::VERSION
Process.exit!
elsif arg =~ /^views:/
matches = arg.match(/^views:(.+)$/)
args[:views] = matches[1]
elsif arg =~ /^public:/
matches = arg.match(/^public:(.+)$/)
args[:public] = matches[1]
elsif arg =~ /^[a-z]+$/
args[:environment] = arg.to_sym
end
end
end
if args
Piano::Base.port = args[:port] if args[:port]
Piano::Base.environment = args[:environment] if args[:environment]
Piano::Base.etags = args[:etags] if args[:etags]
Piano::Base.views = args[:views] if args[:views]
Piano::Base.public = args[:public] if args[:public]
end
self.extend Metafun::Delegator
self.delegate Piano::Base, :get, :patch, :put, :post, :delete,
:head, :options, :template, :fetch, :layout,
:before, :after, :error, :not_found,
:configure, :set, :mime_type, :enable,
:disable, :use, :development?, :test?,
:production?, :helpers, :settings, :play!
$LOAD_PATH << Dir.pwd + '/lib'
if File.exists?('Pianofile')
puts 'Pianofile found, loading...'
load 'Pianofile'
end
if File.directory?('controllers')
puts "'controllers' directory found, loading '.controller' files"
Piano::ControllerLoader.folder 'controllers'
end
require 'piano/routes'
puts "Starting Sinatra from Piano #{Piano::VERSION}"
Piano::Base.play!