Top Level Namespace
Defined Under Namespace
Modules: CodeButler, Enumerable, Kernel, Rack, Sinatra
Classes: Array, Class, Fixnum, Hash, NilClass, Proc, String, Symbol
Instance Method Summary
collapse
-
#before(&b) ⇒ Object
-
#configures(*envs, &b) ⇒ Object
(also: #configure)
-
#delete(path, options = {}, &b) ⇒ Object
-
#error(type = Sinatra::ServerError, options = {}, &b) ⇒ Object
-
#get(path, options = {}, &b) ⇒ Object
-
#helpers(&b) ⇒ Object
-
#layout(name = :layout, &b) ⇒ Object
-
#mime(ext, type) ⇒ Object
-
#not_found(options = {}, &b) ⇒ Object
-
#post(path, options = {}, &b) ⇒ Object
-
#put(path, options = {}, &b) ⇒ Object
-
#set_options(opts) ⇒ Object
-
#template(name, &b) ⇒ Object
-
#use_in_file_templates! ⇒ Object
Instance Method Details
#before(&b) ⇒ Object
883
884
885
|
# File 'lib/codebutler/sinatra.rb', line 883
def before(&b)
Sinatra.application.define_filter(:before, &b)
end
|
922
923
924
925
926
|
# File 'lib/codebutler/sinatra.rb', line 922
def configures(*envs, &b)
yield if !Sinatra.application.reloading &&
(envs.include?(Sinatra.application.options.env) ||
envs.empty?)
end
|
#delete(path, options = {}, &b) ⇒ Object
879
880
881
|
# File 'lib/codebutler/sinatra.rb', line 879
def delete(path, options ={}, &b)
Sinatra.application.define_event(:delete, path, options, &b)
end
|
#error(type = Sinatra::ServerError, options = {}, &b) ⇒ Object
#get(path, options = {}, &b) ⇒ Object
867
868
869
|
# File 'lib/codebutler/sinatra.rb', line 867
def get(path, options ={}, &b)
Sinatra.application.define_event(:get, path, options, &b)
end
|
#helpers(&b) ⇒ Object
887
888
889
|
# File 'lib/codebutler/sinatra.rb', line 887
def helpers(&b)
Sinatra::EventContext.class_eval(&b)
end
|
#layout(name = :layout, &b) ⇒ Object
899
900
901
|
# File 'lib/codebutler/sinatra.rb', line 899
def layout(name = :layout, &b)
Sinatra.application.define_template(name, &b)
end
|
#mime(ext, type) ⇒ Object
934
935
936
|
# File 'lib/codebutler/sinatra.rb', line 934
def mime(ext, type)
Rack::File::MIME_TYPES[ext.to_s] = type
end
|
#not_found(options = {}, &b) ⇒ Object
#post(path, options = {}, &b) ⇒ Object
871
872
873
|
# File 'lib/codebutler/sinatra.rb', line 871
def post(path, options ={}, &b)
Sinatra.application.define_event(:post, path, options, &b)
end
|
#put(path, options = {}, &b) ⇒ Object
875
876
877
|
# File 'lib/codebutler/sinatra.rb', line 875
def put(path, options ={}, &b)
Sinatra.application.define_event(:put, path, options, &b)
end
|
#set_options(opts) ⇒ Object
#template(name, &b) ⇒ Object
903
904
905
|
# File 'lib/codebutler/sinatra.rb', line 903
def template(name, &b)
Sinatra.application.define_template(name, &b)
end
|
#use_in_file_templates! ⇒ Object
907
908
909
910
911
912
913
914
915
916
917
918
919
920
|
# File 'lib/codebutler/sinatra.rb', line 907
def use_in_file_templates!
require 'stringio'
templates = IO.read(caller.first.split(':').first).split('__FILE__').last
data = StringIO.new(templates)
current_template = nil
data.each do |line|
if line =~ /^##\s?(.*)/
current_template = $1.to_sym
Sinatra.application.templates[current_template] = ''
elsif current_template
Sinatra.application.templates[current_template] << line
end
end
end
|