Created
June 4, 2010 00:56
-
-
Save achiurizo/424755 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# /Library/Ruby/Gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb in const_missing | |
# | |
98. parent.send :const_missing, const_name | |
99. end | |
100. rescue NameError => e | |
101. # Make sure that the name we are missing is the one that caused the error | |
102. parent_qualified_name = Dependencies.qualified_name_for parent, const_name | |
103. raise unless e.missing_name? parent_qualified_name | |
104. qualified_name = Dependencies.qualified_name_for self, const_name | |
105. raise NameError.new("uninitialized constant #{qualified_name}").copy_blame!(e) | |
106. end | |
107. end | |
108. end | |
109. end | |
110. | |
111. # Object includes this module | |
112. module Loadable #:nodoc: | |
# /Library/Ruby/Gems/1.8/gems/http_router-0.1.4/lib/http_router.rb in reset! | |
# | |
42. end | |
43. | |
44. def redirect_trailing_slash? | |
45. @redirect_trailing_slash | |
46. end | |
47. | |
48. def reset! | |
49. @root = Root.new(self) | |
50. @routes.clear | |
51. @named_routes.clear | |
52. end | |
53. | |
54. def default(app) | |
55. @default_app = app | |
56. end | |
# /Library/Ruby/Gems/1.8/gems/http_router-0.1.4/lib/http_router.rb in initialize | |
# | |
29. @options = options | |
30. @default_app = options && options[:default_app] || proc{|env| ::Rack::Response.new("Not Found", 404).finish } | |
31. @ignore_trailing_slash = options && options.key?(:ignore_trailing_slash) ? options[:ignore_trailing_slash] : true | |
32. @redirect_trailing_slash = options && options.key?(:redirect_trailing_slash) ? options[:redirect_trailing_slash] : false | |
33. @routes = [] | |
34. @named_routes = {} | |
35. @init_block = block | |
36. reset! | |
37. instance_eval(&block) if block | |
38. end | |
39. | |
40. def ignore_trailing_slash? | |
41. @ignore_trailing_slash | |
42. end | |
43. | |
# /Library/Ruby/Gems/1.8/gems/padrino-core-0.9.10/lib/padrino-core/application/routing.rb in new | |
# | |
106. # ==== Examples | |
107. # | |
108. # router.add('/greedy/{!:greed,.*}') | |
109. # router.recognize('/simple') | |
110. # | |
111. def router | |
112. unless @router | |
113. @router = HttpRouter.new | |
114. end | |
115. block_given? ? yield(@router) : @router | |
116. end | |
117. alias :urls :router | |
118. | |
119. ## | |
120. # Instance method for url generation like: | |
# /Library/Ruby/Gems/1.8/gems/padrino-core-0.9.10/lib/padrino-core/application/routing.rb in router | |
# | |
106. # ==== Examples | |
107. # | |
108. # router.add('/greedy/{!:greed,.*}') | |
109. # router.recognize('/simple') | |
110. # | |
111. def router | |
112. unless @router | |
113. @router = HttpRouter.new | |
114. end | |
115. block_given? ? yield(@router) : @router | |
116. end | |
117. alias :urls :router | |
118. | |
119. ## | |
120. # Instance method for url generation like: | |
# /Library/Ruby/Gems/1.8/gems/padrino-core-0.9.10/lib/padrino-core/application/routing.rb in route! | |
# | |
397. end | |
398. | |
399. private | |
400. ## | |
401. # Compatibility with http_router | |
402. # | |
403. def route!(base=self.class, pass_block=nil) | |
404. if base.router and match = base.router.recognize(@request) | |
405. if !match.matched? | |
406. route_eval { | |
407. match.headers.each{|k,v| response[k] = v} | |
408. status match.status | |
409. } | |
410. elsif match | |
411. @block_params = match.params | |
# /Library/Ruby/Gems/1.8/gems/padrino-core-0.9.10/lib/padrino-core/application/routing.rb in route! | |
# | |
428. end | |
429. end | |
430. end | |
431. end | |
432. | |
433. # Run routes defined in superclass. | |
434. if base.superclass.respond_to?(:router) | |
435. route! base.superclass, pass_block | |
436. return | |
437. end | |
438. | |
439. route_eval(&pass_block) if pass_block | |
440. | |
441. route_missing | |
442. end | |
# /Library/Ruby/Gems/1.8/gems/sinatra-1.0/lib/sinatra/base.rb in dispatch! | |
# | |
594. res | |
595. end | |
596. | |
597. # Dispatch a request with error handling. | |
598. def dispatch! | |
599. static! if settings.static? && (request.get? || request.head?) | |
600. before_filter! | |
601. route! | |
602. rescue NotFound => boom | |
603. handle_not_found!(boom) | |
604. rescue ::Exception => boom | |
605. handle_exception!(boom) | |
606. ensure | |
607. after_filter! unless env['sinatra.static_file'] | |
608. end | |
# /Library/Ruby/Gems/1.8/gems/sinatra-1.0/lib/sinatra/base.rb in call! | |
# | |
404. def call!(env) | |
405. @env = env | |
406. @request = Request.new(env) | |
407. @response = Response.new | |
408. @params = indifferent_params(@request.params) | |
409. @template_cache.clear if settings.reload_templates | |
410. | |
411. invoke { dispatch! } | |
412. invoke { error_block!(response.status) } | |
413. | |
414. status, header, body = @response.finish | |
415. | |
416. # Never produce a body on HEAD requests. Do retain the Content-Length | |
417. # unless it's "0", in which case we assume it was calculated erroneously | |
418. # for a manual HEAD response and remove it entirely. | |
# /Library/Ruby/Gems/1.8/gems/sinatra-1.0/lib/sinatra/base.rb in instance_eval | |
# | |
559. | |
560. def indifferent_hash | |
561. Hash.new {|hash,key| hash[key.to_s] if Symbol === key } | |
562. end | |
563. | |
564. # Run the block with 'throw :halt' support and apply result to the response. | |
565. def invoke(&block) | |
566. res = catch(:halt) { instance_eval(&block) } | |
567. return if res.nil? | |
568. | |
569. case | |
570. when res.respond_to?(:to_str) | |
571. @response.body = [res] | |
572. when res.respond_to?(:to_ary) | |
573. res = res.to_ary | |
# /Library/Ruby/Gems/1.8/gems/sinatra-1.0/lib/sinatra/base.rb in invoke | |
# | |
559. | |
560. def indifferent_hash | |
561. Hash.new {|hash,key| hash[key.to_s] if Symbol === key } | |
562. end | |
563. | |
564. # Run the block with 'throw :halt' support and apply result to the response. | |
565. def invoke(&block) | |
566. res = catch(:halt) { instance_eval(&block) } | |
567. return if res.nil? | |
568. | |
569. case | |
570. when res.respond_to?(:to_str) | |
571. @response.body = [res] | |
572. when res.respond_to?(:to_ary) | |
573. res = res.to_ary | |
# /Library/Ruby/Gems/1.8/gems/sinatra-1.0/lib/sinatra/base.rb in catch | |
# | |
559. | |
560. def indifferent_hash | |
561. Hash.new {|hash,key| hash[key.to_s] if Symbol === key } | |
562. end | |
563. | |
564. # Run the block with 'throw :halt' support and apply result to the response. | |
565. def invoke(&block) | |
566. res = catch(:halt) { instance_eval(&block) } | |
567. return if res.nil? | |
568. | |
569. case | |
570. when res.respond_to?(:to_str) | |
571. @response.body = [res] | |
572. when res.respond_to?(:to_ary) | |
573. res = res.to_ary | |
# /Library/Ruby/Gems/1.8/gems/sinatra-1.0/lib/sinatra/base.rb in invoke | |
# | |
559. | |
560. def indifferent_hash | |
561. Hash.new {|hash,key| hash[key.to_s] if Symbol === key } | |
562. end | |
563. | |
564. # Run the block with 'throw :halt' support and apply result to the response. | |
565. def invoke(&block) | |
566. res = catch(:halt) { instance_eval(&block) } | |
567. return if res.nil? | |
568. | |
569. case | |
570. when res.respond_to?(:to_str) | |
571. @response.body = [res] | |
572. when res.respond_to?(:to_ary) | |
573. res = res.to_ary | |
# /Library/Ruby/Gems/1.8/gems/sinatra-1.0/lib/sinatra/base.rb in call! | |
# | |
404. def call!(env) | |
405. @env = env | |
406. @request = Request.new(env) | |
407. @response = Response.new | |
408. @params = indifferent_params(@request.params) | |
409. @template_cache.clear if settings.reload_templates | |
410. | |
411. invoke { dispatch! } | |
412. invoke { error_block!(response.status) } | |
413. | |
414. status, header, body = @response.finish | |
415. | |
416. # Never produce a body on HEAD requests. Do retain the Content-Length | |
417. # unless it's "0", in which case we assume it was calculated erroneously | |
418. # for a manual HEAD response and remove it entirely. | |
# /Library/Ruby/Gems/1.8/gems/sinatra-1.0/lib/sinatra/base.rb in call | |
# | |
392. @app = app | |
393. @template_cache = Tilt::Cache.new | |
394. yield self if block_given? | |
395. end | |
396. | |
397. # Rack call interface. | |
398. def call(env) | |
399. dup.call!(env) | |
400. end | |
401. | |
402. attr_accessor :env, :request, :response, :params | |
403. | |
404. def call!(env) | |
405. @env = env | |
406. @request = Request.new(env) | |
# /Library/Ruby/Gems/1.8/gems/rack-1.1.0/lib/rack/showexceptions.rb in call | |
# | |
17. | |
18. def initialize(app) | |
19. @app = app | |
20. @template = ERB.new(TEMPLATE) | |
21. end | |
22. | |
23. def call(env) | |
24. @app.call(env) | |
25. rescue StandardError, LoadError, SyntaxError => e | |
26. backtrace = pretty(env, e) | |
27. [500, | |
28. {"Content-Type" => "text/html", | |
29. "Content-Length" => backtrace.join.size.to_s}, | |
30. backtrace] | |
31. end | |
# /Library/Ruby/Gems/1.8/gems/rack-1.1.0/lib/rack/methodoverride.rb in call | |
# | |
17. method = method.to_s.upcase | |
18. if HTTP_METHODS.include?(method) | |
19. env["rack.methodoverride.original_method"] = env["REQUEST_METHOD"] | |
20. env["REQUEST_METHOD"] = method | |
21. end | |
22. end | |
23. | |
24. @app.call(env) | |
25. end | |
26. end | |
27. end | |
# /Library/Ruby/Gems/1.8/gems/rack-1.1.0/lib/rack/session/cookie.rb in call | |
# | |
30. @default_options = {:domain => nil, | |
31. :path => "/", | |
32. :expire_after => nil}.merge(options) | |
33. end | |
34. | |
35. def call(env) | |
36. load_session(env) | |
37. status, headers, body = @app.call(env) | |
38. commit_session(env, status, headers, body) | |
39. end | |
40. | |
41. private | |
42. | |
43. def load_session(env) | |
44. request = Rack::Request.new(env) | |
# /Library/Ruby/Gems/1.8/gems/sinatra-1.0/lib/sinatra/base.rb in call | |
# | |
972. middleware.each { |c,a,b| builder.use(c, *a, &b) } | |
973. | |
974. builder.run super | |
975. builder.to_app | |
976. end | |
977. | |
978. def call(env) | |
979. synchronize { prototype.call(env) } | |
980. end | |
981. | |
982. private | |
983. def detect_rack_handler | |
984. servers = Array(self.server) | |
985. servers.each do |server_name| | |
986. begin | |
# /Library/Ruby/Gems/1.8/gems/sinatra-1.0/lib/sinatra/base.rb in synchronize | |
# | |
998. end | |
999. | |
1000. @@mutex = Mutex.new | |
1001. def synchronize(&block) | |
1002. if lock? | |
1003. @@mutex.synchronize(&block) | |
1004. else | |
1005. yield | |
1006. end | |
1007. end | |
1008. | |
1009. def metadef(message, &block) | |
1010. (class << self; self; end). | |
1011. send :define_method, message, &block | |
1012. end | |
# /Library/Ruby/Gems/1.8/gems/sinatra-1.0/lib/sinatra/base.rb in call | |
# | |
972. middleware.each { |c,a,b| builder.use(c, *a, &b) } | |
973. | |
974. builder.run super | |
975. builder.to_app | |
976. end | |
977. | |
978. def call(env) | |
979. synchronize { prototype.call(env) } | |
980. end | |
981. | |
982. private | |
983. def detect_rack_handler | |
984. servers = Array(self.server) | |
985. servers.each do |server_name| | |
986. begin | |
# /Library/Ruby/Gems/1.8/gems/padrino-core-0.9.10/lib/padrino-core/router.rb in call | |
# | |
64. @mapping.each do |host, path, match, app| | |
65. next unless host.nil? || hHost =~ host | |
66. next unless rPath =~ match && rest = $1 | |
67. next unless rest.empty? || rest[0] == ?/ | |
68. | |
69. rest = "/" if rest.empty? | |
70. | |
71. return app.call( | |
72. env.merge( | |
73. 'SCRIPT_NAME' => (script_name + path), | |
74. 'PATH_INFO' => rest)) | |
75. end | |
76. [404, {"Content-Type" => "text/plain", "X-Cascade" => "pass"}, ["Not Found: #{rPath}"]] | |
77. end | |
78. end | |
# /Library/Ruby/Gems/1.8/gems/padrino-core-0.9.10/lib/padrino-core/router.rb in each | |
# | |
57. sort! | |
58. end | |
59. | |
60. def call(env) | |
61. rPath = env["PATH_INFO"].to_s | |
62. script_name = env['SCRIPT_NAME'] | |
63. hHost, sName, sPort = env.values_at('HTTP_HOST','SERVER_NAME','SERVER_PORT') | |
64. @mapping.each do |host, path, match, app| | |
65. next unless host.nil? || hHost =~ host | |
66. next unless rPath =~ match && rest = $1 | |
67. next unless rest.empty? || rest[0] == ?/ | |
68. | |
69. rest = "/" if rest.empty? | |
70. | |
71. return app.call( | |
# /Library/Ruby/Gems/1.8/gems/padrino-core-0.9.10/lib/padrino-core/router.rb in call | |
# | |
57. sort! | |
58. end | |
59. | |
60. def call(env) | |
61. rPath = env["PATH_INFO"].to_s | |
62. script_name = env['SCRIPT_NAME'] | |
63. hHost, sName, sPort = env.values_at('HTTP_HOST','SERVER_NAME','SERVER_PORT') | |
64. @mapping.each do |host, path, match, app| |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment