Skip to content

Instantly share code, notes, and snippets.

@drusellers
Created August 6, 2010 01:34
Show Gist options
  • Save drusellers/510682 to your computer and use it in GitHub Desktop.
Save drusellers/510682 to your computer and use it in GitHub Desktop.
# /home/drusellers/dev/gemcutter/app/models/download.rb in most_downloaded_today
#
20.
21. def self.for(what)
22. $redis[key(what)].to_i
23. end
24.
25. def self.most_downloaded_today
26. items = $redis.zrevrange(TODAY_KEY, 0, 4, :with_scores => true)
27. items.in_groups_of(2).collect do |full_name, downloads|
28. version = Version.find_by_full_name(full_name)
29.
30. [version, downloads.to_i]
31. end
32. end
33.
34. def self.key(what)
# /home/drusellers/dev/gemcutter/app/controllers/home_controller.rb in index
#
1. class HomeController < ApplicationController
2. def index
3. @rubygems_count = Rubygem.total_count
4. @downloads_count = Download.count
5. @latest = Rubygem.latest
6. @downloaded = Download.most_downloaded_today
7. @updated = Version.updated
8. end
9. end
# /home/drusellers/dev/gemcutter/vendor/bundler_gems/gems/actionpack-3.0.0.beta4/lib/action_controller/metal/implicit_render.rb in send_action
#
1. module ActionController
2. module ImplicitRender
3. def send_action(*)
4. ret = super
5. default_render unless response_body
6. ret
7. end
8.
9. def default_render
10. render
11. end
# /home/drusellers/dev/gemcutter/vendor/bundler_gems/gems/actionpack-3.0.0.beta4/lib/action_controller/metal/implicit_render.rb in send_action
#
1. module ActionController
2. module ImplicitRender
3. def send_action(*)
4. ret = super
5. default_render unless response_body
6. ret
7. end
8.
9. def default_render
10. render
11. end
# /home/drusellers/dev/gemcutter/vendor/bundler_gems/gems/actionpack-3.0.0.beta4/lib/abstract_controller/base.rb in process_action
#
138. self.class.action_methods.include?(name)
139. end
140.
141. # Call the action. Override this in a subclass to modify the
142. # behavior around processing an action. This, and not #process,
143. # is the intended way to override action dispatching.
144. def process_action(method_name, *args)
145. send_action(method_name, *args)
146. end
147.
148. # Actually call the method associated with the action. Override
149. # this method if you wish to change how action methods are called,
150. # not to add additional behavior around it. For example, you would
151. # override #send_action if you want to inject arguments into the
152. # method.
# /home/drusellers/dev/gemcutter/vendor/bundler_gems/gems/actionpack-3.0.0.beta4/lib/action_controller/metal/rendering.rb in process_action
#
4.
5. include ActionController::RackDelegation
6. include AbstractController::Rendering
7.
8. # Before processing, set the request formats in current controller formats.
9. def process_action(*) #:nodoc:
10. self.formats = request.formats.map { |x| x.to_sym }
11. super
12. end
13.
14. # Check for double render errors and set the content_type after rendering.
15. def render(*args) #:nodoc:
16. raise ::AbstractController::DoubleRenderError if response_body
17. super
18. self.content_type ||= Mime[formats.first].to_s
# /home/drusellers/dev/gemcutter/vendor/bundler_gems/gems/actionpack-3.0.0.beta4/lib/abstract_controller/callbacks.rb in process_action
#
11. define_callbacks :process_action, :terminator => "response_body"
12. end
13.
14. # Override AbstractController::Base's process_action to run the
15. # process_action callbacks around the normal behavior.
16. def process_action(method_name)
17. run_callbacks(:process_action, method_name) do
18. super
19. end
20. end
21.
22. module ClassMethods
23. # If :only or :except are used, convert the options into the
24. # primitive form (:per_key) used by ActiveSupport::Callbacks.
25. # The basic idea is that :only => :index gets converted to
# /home/drusellers/dev/gemcutter/vendor/bundler_gems/gems/activesupport-3.0.0.beta4/lib/active_support/callbacks.rb in _run__738958071__process_action__199225275__callbacks
#
421. #
422. def __create_keyed_callback(name, kind, object, &blk) #:nodoc:
423. @_keyed_callbacks ||= {}
424. @_keyed_callbacks[name] ||= begin
425. str = send("_#{kind}_callbacks").compile(name, object)
426. class_eval "def #{name}() #{str} end", __FILE__, __LINE__
427. true
428. end
429. end
430.
431. # This is used internally to append, prepend and skip callbacks to the
432. # CallbackChain.
433. #
434. def __update_callbacks(name, filters = [], block = nil) #:nodoc:
435. send("_update_#{name}_superclass_callbacks")
# /home/drusellers/dev/gemcutter/vendor/bundler_gems/gems/activesupport-3.0.0.beta4/lib/active_support/callbacks.rb in send
#
401. if key
402. name = "_run__\#{self.class.name.hash.abs}__#{symbol}__\#{key.hash.abs}__callbacks"
403.
404. unless respond_to?(name)
405. self.class.__create_keyed_callback(name, :#{symbol}, self, &blk)
406. end
407.
408. send(name, &blk)
409. else
410. #{body}
411. end
412. end
413. private :_run_#{symbol}_callbacks
414. RUBY_EVAL
415. end
# /home/drusellers/dev/gemcutter/vendor/bundler_gems/gems/activesupport-3.0.0.beta4/lib/active_support/callbacks.rb in _run_process_action_callbacks
#
401. if key
402. name = "_run__\#{self.class.name.hash.abs}__#{symbol}__\#{key.hash.abs}__callbacks"
403.
404. unless respond_to?(name)
405. self.class.__create_keyed_callback(name, :#{symbol}, self, &blk)
406. end
407.
408. send(name, &blk)
409. else
410. #{body}
411. end
412. end
413. private :_run_#{symbol}_callbacks
414. RUBY_EVAL
415. end
# /home/drusellers/dev/gemcutter/vendor/bundler_gems/gems/activesupport-3.0.0.beta4/lib/active_support/callbacks.rb in send
#
81. # - save
82. # saved
83. #
84. module Callbacks
85. extend Concern
86.
87. def run_callbacks(kind, *args, &block)
88. send("_run_#{kind}_callbacks", *args, &block)
89. end
90.
91. class Callback
92. @@_callback_sequence = 0
93.
94. attr_accessor :chain, :filter, :kind, :options, :per_key, :klass, :raw_filter
95.
# /home/drusellers/dev/gemcutter/vendor/bundler_gems/gems/activesupport-3.0.0.beta4/lib/active_support/callbacks.rb in run_callbacks
#
81. # - save
82. # saved
83. #
84. module Callbacks
85. extend Concern
86.
87. def run_callbacks(kind, *args, &block)
88. send("_run_#{kind}_callbacks", *args, &block)
89. end
90.
91. class Callback
92. @@_callback_sequence = 0
93.
94. attr_accessor :chain, :filter, :kind, :options, :per_key, :klass, :raw_filter
95.
# /home/drusellers/dev/gemcutter/vendor/bundler_gems/gems/actionpack-3.0.0.beta4/lib/abstract_controller/callbacks.rb in process_action
#
10. included do
11. define_callbacks :process_action, :terminator => "response_body"
12. end
13.
14. # Override AbstractController::Base's process_action to run the
15. # process_action callbacks around the normal behavior.
16. def process_action(method_name)
17. run_callbacks(:process_action, method_name) do
18. super
19. end
20. end
21.
22. module ClassMethods
23. # If :only or :except are used, convert the options into the
24. # primitive form (:per_key) used by ActiveSupport::Callbacks.
# /home/drusellers/dev/gemcutter/vendor/bundler_gems/gems/actionpack-3.0.0.beta4/lib/action_controller/metal/instrumentation.rb in process_action
#
22. :method => request.method,
23. :path => (request.fullpath rescue "unknown")
24. }
25.
26. ActiveSupport::Notifications.instrument("start_processing.action_controller", raw_payload.dup)
27.
28. ActiveSupport::Notifications.instrument("process_action.action_controller", raw_payload) do |payload|
29. result = super
30. payload[:status] = response.status
31. append_info_to_payload(payload)
32. result
33. end
34. end
35.
36. def render(*args)
# /home/drusellers/dev/gemcutter/vendor/bundler_gems/gems/activesupport-3.0.0.beta4/lib/active_support/notifications/instrumenter.rb in instrument
#
13.
14. # Instrument the given block by measuring the time taken to execute it
15. # and publish it. Notice that events get sent even if an error occurs
16. # in the passed-in block
17. def instrument(name, payload={})
18. time = Time.now
19. begin
20. yield(payload) if block_given?
21. rescue Exception => e
22. payload[:exception] = [e.class.name, e.message]
23. raise e
24. ensure
25. @notifier.publish(name, time, Time.now, @id, payload)
26. end
27. end
# /home/drusellers/dev/gemcutter/vendor/bundler_gems/gems/activesupport-3.0.0.beta4/lib/active_support/notifications.rb in __send__
#
41. autoload :Instrumenter, 'active_support/notifications/instrumenter'
42. autoload :Event, 'active_support/notifications/instrumenter'
43. autoload :Fanout, 'active_support/notifications/fanout'
44.
45. class << self
46. attr_writer :notifier
47. delegate :publish, :subscribe, :unsubscribe, :to => :notifier
48. delegate :instrument, :to => :instrumenter
49.
50. def notifier
51. @notifier ||= Notifier.new
52. end
53.
54. def instrumenter
55. Thread.current[:"instrumentation_#{notifier.object_id}"] ||= Instrumenter.new(notifier)
# /home/drusellers/dev/gemcutter/vendor/bundler_gems/gems/activesupport-3.0.0.beta4/lib/active_support/notifications.rb in instrument
#
41. autoload :Instrumenter, 'active_support/notifications/instrumenter'
42. autoload :Event, 'active_support/notifications/instrumenter'
43. autoload :Fanout, 'active_support/notifications/fanout'
44.
45. class << self
46. attr_writer :notifier
47. delegate :publish, :subscribe, :unsubscribe, :to => :notifier
48. delegate :instrument, :to => :instrumenter
49.
50. def notifier
51. @notifier ||= Notifier.new
52. end
53.
54. def instrumenter
55. Thread.current[:"instrumentation_#{notifier.object_id}"] ||= Instrumenter.new(notifier)
# /home/drusellers/dev/gemcutter/vendor/bundler_gems/gems/actionpack-3.0.0.beta4/lib/action_controller/metal/instrumentation.rb in process_action
#
21. :formats => request.formats.map(&:to_sym),
22. :method => request.method,
23. :path => (request.fullpath rescue "unknown")
24. }
25.
26. ActiveSupport::Notifications.instrument("start_processing.action_controller", raw_payload.dup)
27.
28. ActiveSupport::Notifications.instrument("process_action.action_controller", raw_payload) do |payload|
29. result = super
30. payload[:status] = response.status
31. append_info_to_payload(payload)
32. result
33. end
34. end
35.
# /home/drusellers/dev/gemcutter/vendor/bundler_gems/gems/actionpack-3.0.0.beta4/lib/action_controller/metal/rescue.rb in process_action
#
1. module ActionController #:nodoc:
2. module Rescue
3. extend ActiveSupport::Concern
4. include ActiveSupport::Rescuable
5.
6. private
7. def process_action(*args)
8. super
9. rescue Exception => exception
10. rescue_with_handler(exception) || raise(exception)
11. end
12. end
13. end
# /home/drusellers/dev/gemcutter/vendor/bundler_gems/gems/actionpack-3.0.0.beta4/lib/abstract_controller/base.rb in process
#
107.
108. unless action_name = method_for_action(action_name)
109. raise ActionNotFound, "The action '#{action}' could not be found"
110. end
111.
112. @_response_body = nil
113.
114. process_action(action_name, *args)
115. end
116.
117. # Delegates to the class' #controller_path
118. def controller_path
119. self.class.controller_path
120. end
121.
# /home/drusellers/dev/gemcutter/vendor/bundler_gems/gems/actionpack-3.0.0.beta4/lib/abstract_controller/rendering.rb in process
#
33. extend ActiveSupport::Concern
34.
35. include AbstractController::ViewPaths
36.
37. # Overwrite process to setup I18n proxy.
38. def process(*) #:nodoc:
39. old_config, I18n.config = I18n.config, I18nProxy.new(I18n.config, lookup_context)
40. super
41. ensure
42. I18n.config = old_config
43. end
44.
45. module ClassMethods
46. def view_context_class
47. @view_context_class ||= begin
# /home/drusellers/dev/gemcutter/vendor/bundler_gems/gems/actionpack-3.0.0.beta4/lib/action_controller/metal.rb in dispatch
#
119. end
120.
121. # :api: private
122. def dispatch(name, request)
123. @_request = request
124. @_env = request.env
125. @_env['action_controller.instance'] = self
126. process(name)
127. to_a
128. end
129.
130. # :api: private
131. def to_a
132. response ? response.to_a : [status, headers, response_body]
133. end
# /home/drusellers/dev/gemcutter/vendor/bundler_gems/gems/actionpack-3.0.0.beta4/lib/action_controller/metal/rack_delegation.rb in dispatch
#
7.
8. delegate :headers, :status=, :location=, :content_type=,
9. :status, :location, :content_type, :to => "@_response"
10.
11. def dispatch(action, request, response = ActionDispatch::Response.new)
12. @_response ||= response
13. @_response.request ||= request
14. super(action, request)
15. end
16.
17. def params
18. @_params ||= @_request.parameters
19. end
20.
21. def response_body=(body)
# /home/drusellers/dev/gemcutter/vendor/bundler_gems/gems/actionpack-3.0.0.beta4/lib/action_controller/metal.rb in nil
#
159. # ==== Parameters
160. # action<#to_s>:: An action name
161. #
162. # ==== Returns
163. # Proc:: A rack application
164. def self.action(name, klass = ActionDispatch::Request)
165. middleware_stack.build(name.to_s) do |env|
166. new.dispatch(name, klass.new(env))
167. end
168. end
169. end
170. end
# /home/drusellers/dev/gemcutter/vendor/bundler_gems/gems/actionpack-3.0.0.beta4/lib/action_dispatch/routing/route_set.rb in call
#
20. prepare_params!(params)
21.
22. # Just raise undefined constant errors if a controller was specified as default.
23. unless controller = controller(params, @defaults.key?(:controller))
24. return [404, {'X-Cascade' => 'pass'}, []]
25. end
26.
27. controller.action(params[:action]).call(env)
28. end
29.
30. def prepare_params!(params)
31. merge_default_action!(params)
32. split_glob_param!(params) if @glob_param
33. end
34.
# /home/drusellers/dev/gemcutter/vendor/bundler_gems/gems/actionpack-3.0.0.beta4/lib/action_dispatch/routing/route_set.rb in call
#
20. prepare_params!(params)
21.
22. # Just raise undefined constant errors if a controller was specified as default.
23. unless controller = controller(params, @defaults.key?(:controller))
24. return [404, {'X-Cascade' => 'pass'}, []]
25. end
26.
27. controller.action(params[:action]).call(env)
28. end
29.
30. def prepare_params!(params)
31. merge_default_action!(params)
32. split_glob_param!(params) if @glob_param
33. end
34.
# /home/drusellers/dev/gemcutter/vendor/bundler_gems/gems/rack-mount-0.6.9/lib/rack/mount/route_set.rb in call
#
141. params.each { |k, v| params[k] = Utils.unescape_uri(v) if v.is_a?(String) }
142.
143. if route.prefix?
144. env[Prefix::KEY] = matches[:path_info].to_s
145. end
146.
147. env[@parameters_key] = params
148. result = route.app.call(env)
149. return result unless result[1][X_CASCADE] == PASS
150. end
151.
152. request || [404, {'Content-Type' => 'text/html', 'X-Cascade' => 'pass'}, ['Not Found']]
153. end
154.
155. # Generates a url from Rack env and identifiers or significant keys.
# /home/drusellers/dev/gemcutter/vendor/bundler_gems/gems/rack-mount-0.6.9/lib/rack/mount/code_generation.rb in recognize
#
82. instance_eval(<<-RUBY, __FILE__, __LINE__)
83. def recognize(obj)
84. cache = {}
85. container = @recognition_graph[#{keys}]
86. optimize_container_iterator(container) unless container.respond_to?(:optimized_each)
87.
88. if block_given?
89. container.optimized_each(obj) do |route, matches, params|
90. yield route, matches, params
91. end
92. else
93. container.optimized_each(obj) do |route, matches, params|
94. return route, matches, params
95. end
96. end
# /home/drusellers/dev/gemcutter/vendor/bundler_gems/gems/rack-mount-0.6.9/lib/rack/mount/code_generation.rb in optimized_each
#
59. }
60.
61. container.instance_eval(<<-RUBY, __FILE__, __LINE__)
62. def optimized_each(obj)
63. #{body.join("\n")}
64. nil
65. end
66. RUBY
67. end
68.
69. def optimize_recognize!
70. keys = @recognition_keys.map { |key|
71. if key.respond_to?(:call_source)
72. key.call_source(:cache, :obj)
73. else
# /home/drusellers/dev/gemcutter/vendor/bundler_gems/gems/rack-mount-0.6.9/lib/rack/mount/code_generation.rb in recognize
#
81.
82. instance_eval(<<-RUBY, __FILE__, __LINE__)
83. def recognize(obj)
84. cache = {}
85. container = @recognition_graph[#{keys}]
86. optimize_container_iterator(container) unless container.respond_to?(:optimized_each)
87.
88. if block_given?
89. container.optimized_each(obj) do |route, matches, params|
90. yield route, matches, params
91. end
92. else
93. container.optimized_each(obj) do |route, matches, params|
94. return route, matches, params
95. end
# /home/drusellers/dev/gemcutter/vendor/bundler_gems/gems/rack-mount-0.6.9/lib/rack/mount/route_set.rb in call
#
132. def call(env)
133. raise 'route set not finalized' unless @recognition_graph
134.
135. env[PATH_INFO] = Utils.normalize_path(env[PATH_INFO])
136.
137. request = nil
138. req = @request_class.new(env)
139. recognize(req) do |route, matches, params|
140. # TODO: We only want to unescape params from uri related methods
141. params.each { |k, v| params[k] = Utils.unescape_uri(v) if v.is_a?(String) }
142.
143. if route.prefix?
144. env[Prefix::KEY] = matches[:path_info].to_s
145. end
146.
# /home/drusellers/dev/gemcutter/vendor/bundler_gems/gems/actionpack-3.0.0.beta4/lib/action_dispatch/routing/route_set.rb in call
#
450. rewritten_url << "##{Rack::Utils.escape(options[:anchor].to_param.to_s)}" if options[:anchor]
451.
452. rewritten_url
453. end
454.
455. def call(env)
456. finalize!
457. @set.call(env)
458. end
459.
460. def recognize_path(path, environment = {})
461. method = (environment[:method] || "GET").to_s.upcase
462. path = Rack::Mount::Utils.normalize_path(path)
463.
464. begin
# /home/drusellers/dev/gemcutter/vendor/bundler_gems/gems/sinatra-1.0/lib/sinatra/base.rb in forward
#
443. def pass(&block)
444. throw :pass, block
445. end
446.
447. # Forward the request to the downstream app -- middleware only.
448. def forward
449. fail "downstream app not set" unless @app.respond_to? :call
450. status, headers, body = @app.call(@request.env)
451. @response.status = status
452. @response.body = body
453. @response.headers.merge! headers
454. nil
455. end
456.
457. private
# /home/drusellers/dev/gemcutter/vendor/bundler_gems/gems/sinatra-1.0/lib/sinatra/base.rb in route_missing
#
524. # No matching route was found or all routes passed. The default
525. # implementation is to forward the request downstream when running
526. # as middleware (@app is non-nil); when no downstream app is set, raise
527. # a NotFound exception. Subclasses can override this method to perform
528. # custom route miss logic.
529. def route_missing
530. if @app
531. forward
532. else
533. raise NotFound
534. end
535. end
536.
537. # Attempt to serve static files from public directory. Throws :halt when
538. # a matching file is found, returns nil otherwise.
# /home/drusellers/dev/gemcutter/vendor/bundler_gems/gems/sinatra-1.0/lib/sinatra/base.rb in route!
#
509. if base.superclass.respond_to?(:routes)
510. route! base.superclass, pass_block
511. return
512. end
513.
514. route_eval(&pass_block) if pass_block
515.
516. route_missing
517. end
518.
519. # Run a route block and throw :halt with the result.
520. def route_eval(&block)
521. throw :halt, instance_eval(&block)
522. end
523.
# /home/drusellers/dev/gemcutter/vendor/bundler_gems/gems/sinatra-1.0/lib/sinatra/base.rb in route!
#
503. end
504.
505. @params = original_params
506. end
507.
508. # Run routes defined in superclass.
509. if base.superclass.respond_to?(:routes)
510. route! base.superclass, pass_block
511. return
512. end
513.
514. route_eval(&pass_block) if pass_block
515.
516. route_missing
517. end
# /home/drusellers/dev/gemcutter/vendor/bundler_gems/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
# /home/drusellers/dev/gemcutter/vendor/bundler_gems/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.
# /home/drusellers/dev/gemcutter/vendor/bundler_gems/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
# /home/drusellers/dev/gemcutter/vendor/bundler_gems/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
# /home/drusellers/dev/gemcutter/vendor/bundler_gems/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
# /home/drusellers/dev/gemcutter/vendor/bundler_gems/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
# /home/drusellers/dev/gemcutter/vendor/bundler_gems/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.
# /home/drusellers/dev/gemcutter/vendor/bundler_gems/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)
# /usr/lib/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
# /home/drusellers/dev/gemcutter/vendor/bundler_gems/gems/actionpack-3.0.0.beta4/lib/action_dispatch/middleware/head.rb in call
#
7. def call(env)
8. if env["REQUEST_METHOD"] == "HEAD"
9. env["REQUEST_METHOD"] = "GET"
10. env["rack.methodoverride.original_method"] = "HEAD"
11. status, headers, body = @app.call(env)
12. [status, headers, []]
13. else
14. @app.call(env)
15. end
16. end
17. end
18. end
# /usr/lib/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
# /home/drusellers/dev/gemcutter/vendor/bundler_gems/gems/actionpack-3.0.0.beta4/lib/action_dispatch/middleware/params_parser.rb in call
#
14. end
15.
16. def call(env)
17. if params = parse_formatted_parameters(env)
18. env["action_dispatch.request.request_parameters"] = params
19. end
20.
21. @app.call(env)
22. end
23.
24. private
25. def parse_formatted_parameters(env)
26. request = Request.new(env)
27.
28. return false if request.content_length.zero?
# /home/drusellers/dev/gemcutter/vendor/bundler_gems/gems/actionpack-3.0.0.beta4/lib/action_dispatch/middleware/flash.rb in call
#
170. end
171.
172. def call(env)
173. if (session = env['rack.session']) && (flash = session['flash'])
174. flash.sweep
175. end
176.
177. @app.call(env)
178. ensure
179. if (session = env['rack.session']) && session.key?('flash') && session['flash'].empty?
180. session.delete('flash')
181. end
182. end
183. end
184. end
# /home/drusellers/dev/gemcutter/vendor/bundler_gems/gems/actionpack-3.0.0.beta4/lib/action_dispatch/middleware/session/abstract_store.rb in call
#
99. @key = @default_options.delete(:key).freeze
100. @cookie_only = @default_options.delete(:cookie_only)
101. ensure_session_key!
102. end
103.
104. def call(env)
105. prepare!(env)
106. response = @app.call(env)
107.
108. session_data = env[ENV_SESSION_KEY]
109. options = env[ENV_SESSION_OPTIONS_KEY]
110.
111. if !session_data.is_a?(AbstractStore::SessionHash) || session_data.send(:loaded?) || options[:expire_after]
112. session_data.send(:load!) if session_data.is_a?(AbstractStore::SessionHash) && !session_data.send(:loaded?)
113.
# /home/drusellers/dev/gemcutter/vendor/bundler_gems/gems/actionpack-3.0.0.beta4/lib/action_dispatch/middleware/cookies.rb in call
#
228. end
229.
230. def initialize(app)
231. @app = app
232. end
233.
234. def call(env)
235. status, headers, body = @app.call(env)
236.
237. if cookie_jar = env['action_dispatch.cookies']
238. cookie_jar.write(headers)
239. if headers[HTTP_HEADER].respond_to?(:join)
240. headers[HTTP_HEADER] = headers[HTTP_HEADER].join("\n")
241. end
242. end
# /home/drusellers/dev/gemcutter/vendor/bundler_gems/gems/activerecord-3.0.0.beta4/lib/active_record/query_cache.rb in call
#
24.
25. def initialize(app)
26. @app = app
27. end
28.
29. def call(env)
30. ActiveRecord::Base.cache do
31. @app.call(env)
32. end
33. end
34. end
35. end
# /home/drusellers/dev/gemcutter/vendor/bundler_gems/gems/activerecord-3.0.0.beta4/lib/active_record/connection_adapters/abstract/query_cache.rb in cache
#
21. end
22.
23. attr_reader :query_cache, :query_cache_enabled
24.
25. # Enable the query cache within the block.
26. def cache
27. old, @query_cache_enabled = @query_cache_enabled, true
28. yield
29. ensure
30. clear_query_cache
31. @query_cache_enabled = old
32. end
33.
34. # Disable the query cache within the block.
35. def uncached
# /home/drusellers/dev/gemcutter/vendor/bundler_gems/gems/activerecord-3.0.0.beta4/lib/active_record/query_cache.rb in cache
#
4. class QueryCache
5. module ClassMethods
6. # Enable the query cache within the block if Active Record is configured.
7. def cache(&block)
8. if ActiveRecord::Base.configurations.blank?
9. yield
10. else
11. connection.cache(&block)
12. end
13. end
14.
15. # Disable the query cache within the block if Active Record is configured.
16. def uncached(&block)
17. if ActiveRecord::Base.configurations.blank?
18. yield
# /home/drusellers/dev/gemcutter/vendor/bundler_gems/gems/activerecord-3.0.0.beta4/lib/active_record/query_cache.rb in call
#
23. end
24.
25. def initialize(app)
26. @app = app
27. end
28.
29. def call(env)
30. ActiveRecord::Base.cache do
31. @app.call(env)
32. end
33. end
34. end
35. end
# /home/drusellers/dev/gemcutter/vendor/bundler_gems/gems/activerecord-3.0.0.beta4/lib/active_record/connection_adapters/abstract/connection_pool.rb in call
#
358.
359. class ConnectionManagement
360. def initialize(app)
361. @app = app
362. end
363.
364. def call(env)
365. @app.call(env)
366. ensure
367. # Don't return connection (and perform implicit rollback) if
368. # this request is a part of integration test
369. unless env.key?("rack.test")
370. ActiveRecord::Base.clear_active_connections!
371. end
372. end
# /home/drusellers/dev/gemcutter/vendor/bundler_gems/gems/actionpack-3.0.0.beta4/lib/action_dispatch/middleware/callbacks.rb in call
#
39. @app, @prepare_each_request = app, prepare_each_request
40. run_callbacks(:prepare)
41. end
42.
43. def call(env)
44. run_callbacks(:call) do
45. run_callbacks(:prepare) if @prepare_each_request
46. @app.call(env)
47. end
48. end
49. end
50. end
# /home/drusellers/dev/gemcutter/vendor/bundler_gems/gems/activesupport-3.0.0.beta4/lib/active_support/callbacks.rb in _run_call_callbacks
#
407.
408. send(name, &blk)
409. else
410. #{body}
411. end
412. end
413. private :_run_#{symbol}_callbacks
414. RUBY_EVAL
415. end
416. end
417.
418. # This is called the first time a callback is called with a particular
419. # key. It creates a new callback method for the key, calculating
420. # which callbacks can be omitted because of per_key conditions.
421. #
# /home/drusellers/dev/gemcutter/vendor/bundler_gems/gems/activesupport-3.0.0.beta4/lib/active_support/callbacks.rb in send
#
81. # - save
82. # saved
83. #
84. module Callbacks
85. extend Concern
86.
87. def run_callbacks(kind, *args, &block)
88. send("_run_#{kind}_callbacks", *args, &block)
89. end
90.
91. class Callback
92. @@_callback_sequence = 0
93.
94. attr_accessor :chain, :filter, :kind, :options, :per_key, :klass, :raw_filter
95.
# /home/drusellers/dev/gemcutter/vendor/bundler_gems/gems/activesupport-3.0.0.beta4/lib/active_support/callbacks.rb in run_callbacks
#
81. # - save
82. # saved
83. #
84. module Callbacks
85. extend Concern
86.
87. def run_callbacks(kind, *args, &block)
88. send("_run_#{kind}_callbacks", *args, &block)
89. end
90.
91. class Callback
92. @@_callback_sequence = 0
93.
94. attr_accessor :chain, :filter, :kind, :options, :per_key, :klass, :raw_filter
95.
# /home/drusellers/dev/gemcutter/vendor/bundler_gems/gems/actionpack-3.0.0.beta4/lib/action_dispatch/middleware/callbacks.rb in call
#
37.
38. def initialize(app, prepare_each_request = false)
39. @app, @prepare_each_request = app, prepare_each_request
40. run_callbacks(:prepare)
41. end
42.
43. def call(env)
44. run_callbacks(:call) do
45. run_callbacks(:prepare) if @prepare_each_request
46. @app.call(env)
47. end
48. end
49. end
50. end
# /usr/lib/ruby/gems/1.8/gems/rack-1.1.0/lib/rack/sendfile.rb in call
#
98.
99. def initialize(app, variation=nil)
100. @app = app
101. @variation = variation
102. end
103.
104. def call(env)
105. status, headers, body = @app.call(env)
106. if body.respond_to?(:to_path)
107. case type = variation(env)
108. when 'X-Accel-Redirect'
109. path = F.expand_path(body.to_path)
110. if url = map_accel_path(env, path)
111. headers[type] = url
112. body = []
# /home/drusellers/dev/gemcutter/vendor/bundler_gems/gems/actionpack-3.0.0.beta4/lib/action_dispatch/middleware/remote_ip.rb in call
#
41. regex = '(^127\.0\.0\.1$|^(10|172\.(1[6-9]|2[0-9]|30|31)|192\.168)\.)'
42. regex << "|(#{trusted_proxies})" if trusted_proxies
43. @trusted_proxies = Regexp.new(regex, "i")
44. end
45.
46. def call(env)
47. env["action_dispatch.remote_ip"] = RemoteIpGetter.new(env, @check_ip_spoofing, @trusted_proxies)
48. @app.call(env)
49. end
50. end
51. end
# /home/drusellers/dev/gemcutter/vendor/bundler_gems/gems/actionpack-3.0.0.beta4/lib/action_dispatch/middleware/show_exceptions.rb in call
#
41.
42. def initialize(app, consider_all_requests_local = false)
43. @app = app
44. @consider_all_requests_local = consider_all_requests_local
45. end
46.
47. def call(env)
48. status, headers, body = @app.call(env)
49.
50. # Only this middleware cares about RoutingError. So, let's just raise
51. # it here.
52. # TODO: refactor this middleware to handle the X-Cascade scenario without
53. # having to raise an exception.
54. if headers['X-Cascade'] == 'pass'
55. raise ActionController::RoutingError, "No route matches #{env['PATH_INFO'].inspect}"
# /home/drusellers/dev/gemcutter/vendor/bundler_gems/gems/railties-3.0.0.beta4/lib/rails/rack/logger.rb in call
#
7. class Logger < Rails::LogSubscriber
8. def initialize(app)
9. @app = app
10. end
11.
12. def call(env)
13. before_dispatch(env)
14. @app.call(env)
15. ensure
16. after_dispatch(env)
17. end
18.
19. protected
20.
21. def before_dispatch(env)
# /usr/lib/ruby/gems/1.8/gems/rack-1.1.0/lib/rack/runtime.rb in call
#
10. @app = app
11. @header_name = "X-Runtime"
12. @header_name << "-#{name}" if name
13. end
14.
15. def call(env)
16. start_time = Time.now
17. status, headers, body = @app.call(env)
18. request_time = Time.now - start_time
19.
20. if !headers.has_key?(@header_name)
21. headers[@header_name] = "%0.6f" % request_time
22. end
23.
24. [status, headers, body]
# /home/drusellers/dev/gemcutter/vendor/bundler_gems/gems/activesupport-3.0.0.beta4/lib/active_support/cache/strategy/local_cache.rb in call
#
65.
66. def initialize(app)
67. @app = app
68. end
69.
70. def call(env)
71. Thread.current[:#{thread_local_key}] = LocalStore.new
72. @app.call(env)
73. ensure
74. Thread.current[:#{thread_local_key}] = nil
75. end
76. EOS
77. klass
78. end
79. end
# /usr/lib/ruby/gems/1.8/gems/rack-1.1.0/lib/rack/lock.rb in call
#
4.
5. def initialize(app, lock = Mutex.new)
6. @app, @lock = app, lock
7. end
8.
9. def call(env)
10. old, env[FLAG] = env[FLAG], false
11. @lock.synchronize { @app.call(env) }
12. ensure
13. env[FLAG] = old
14. end
15. end
16. end
# /usr/lib/ruby/gems/1.8/gems/rack-1.1.0/lib/rack/lock.rb in synchronize
#
4.
5. def initialize(app, lock = Mutex.new)
6. @app, @lock = app, lock
7. end
8.
9. def call(env)
10. old, env[FLAG] = env[FLAG], false
11. @lock.synchronize { @app.call(env) }
12. ensure
13. env[FLAG] = old
14. end
15. end
16. end
# /usr/lib/ruby/gems/1.8/gems/rack-1.1.0/lib/rack/lock.rb in call
#
4.
5. def initialize(app, lock = Mutex.new)
6. @app, @lock = app, lock
7. end
8.
9. def call(env)
10. old, env[FLAG] = env[FLAG], false
11. @lock.synchronize { @app.call(env) }
12. ensure
13. env[FLAG] = old
14. end
15. end
16. end
# /home/drusellers/dev/gemcutter/vendor/bundler_gems/gems/actionpack-3.0.0.beta4/lib/action_dispatch/middleware/static.rb in call
#
23. if file_exist?(cached_path)
24. env['PATH_INFO'] = cached_path
25. return @file_server.call(env)
26. end
27. end
28. end
29.
30. @app.call(env)
31. end
32.
33. private
34. def file_exist?(path)
35. full_path = File.join(@file_server.root, ::Rack::Utils.unescape(path))
36. File.file?(full_path) && File.readable?(full_path)
37. end
# /home/drusellers/dev/gemcutter/vendor/bundler_gems/gems/railties-3.0.0.beta4/lib/rails/application.rb in call
#
138. @app ||= begin
139. config.middleware = config.middleware.merge_into(default_middleware_stack)
140. config.middleware.build(routes)
141. end
142. end
143.
144. def call(env)
145. app.call(env.reverse_merge!(env_defaults))
146. end
147.
148. def env_defaults
149. @env_defaults ||= {
150. "action_dispatch.parameter_filter" => config.filter_parameters,
151. "action_dispatch.secret_token" => config.secret_token
152. }
# /home/drusellers/dev/gemcutter/vendor/bundler_gems/gems/railties-3.0.0.beta4/lib/rails/application.rb in send
#
74. def respond_to?(*args)
75. super || instance.respond_to?(*args)
76. end
77.
78. protected
79.
80. def method_missing(*args, &block)
81. instance.send(*args, &block)
82. end
83. end
84.
85. delegate :middleware, :to => :config
86.
87. def add_lib_to_load_paths!
88. path = config.root.join('lib').to_s
# /home/drusellers/dev/gemcutter/vendor/bundler_gems/gems/railties-3.0.0.beta4/lib/rails/application.rb in method_missing
#
74. def respond_to?(*args)
75. super || instance.respond_to?(*args)
76. end
77.
78. protected
79.
80. def method_missing(*args, &block)
81. instance.send(*args, &block)
82. end
83. end
84.
85. delegate :middleware, :to => :config
86.
87. def add_lib_to_load_paths!
88. path = config.root.join('lib').to_s
# /home/drusellers/dev/gemcutter/vendor/bundler_gems/gems/railties-3.0.0.beta4/lib/rails/rack/log_tailer.rb in call
#
8. @cursor = ::File.size(path)
9. @last_checked = Time.now.to_f
10.
11. @file = ::File.open(path, 'r')
12. end
13.
14. def call(env)
15. response = @app.call(env)
16. tail!
17. response
18. end
19.
20. def tail!
21. @file.seek @cursor
22.
# /usr/lib/ruby/gems/1.8/gems/rack-1.1.0/lib/rack/content_length.rb in call
#
6. include Rack::Utils
7.
8. def initialize(app)
9. @app = app
10. end
11.
12. def call(env)
13. status, headers, body = @app.call(env)
14. headers = HeaderHash.new(headers)
15.
16. if !STATUS_WITH_NO_ENTITY_BODY.include?(status) &&
17. !headers['Content-Length'] &&
18. !headers['Transfer-Encoding'] &&
19. (body.respond_to?(:to_ary) || body.respond_to?(:to_str))
20.
# /usr/lib/ruby/gems/1.8/gems/rack-1.1.0/lib/rack/handler/webrick.rb in service
#
41. env["QUERY_STRING"] ||= ""
42. env["REQUEST_PATH"] ||= "/"
43. unless env["PATH_INFO"] == ""
44. path, n = req.request_uri.path, env["SCRIPT_NAME"].length
45. env["PATH_INFO"] = path[n, path.length-n]
46. end
47.
48. status, headers, body = @app.call(env)
49. begin
50. res.status = status.to_i
51. headers.each { |k, vs|
52. if k.downcase == "set-cookie"
53. res.cookies.concat vs.split("\n")
54. else
55. vs.split("\n").each { |v|
# /usr/lib/ruby/1.8/webrick/httpserver.rb in service
#
97.
98. servlet, options, script_name, path_info = search_servlet(req.path)
99. raise HTTPStatus::NotFound, "`#{req.path}' not found." unless servlet
100. req.script_name = script_name
101. req.path_info = path_info
102. si = servlet.get_instance(self, *options)
103. @logger.debug(format("%s is invoked.", si.class.name))
104. si.service(req, res)
105. end
106.
107. def do_OPTIONS(req, res)
108. res["allow"] = "GET,HEAD,POST,OPTIONS"
109. end
110.
111. def mount(dir, servlet, *options)
# /usr/lib/ruby/1.8/webrick/httpserver.rb in run
#
58. res.request_uri = req.request_uri
59. res.request_http_version = req.http_version
60. res.keep_alive = req.keep_alive?
61. server = lookup_server(req) || self
62. if callback = server[:RequestCallback] || server[:RequestHandler]
63. callback.call(req, res)
64. end
65. server.service(req, res)
66. rescue HTTPStatus::EOFError, HTTPStatus::RequestTimeout => ex
67. res.set_error(ex)
68. rescue HTTPStatus::Error => ex
69. @logger.error(ex.message)
70. res.set_error(ex)
71. rescue HTTPStatus::Status => ex
72. res.status = ex.code
# /usr/lib/ruby/1.8/webrick/server.rb in start_thread
#
166. addr = sock.peeraddr
167. @logger.debug "accept: #{addr[3]}:#{addr[1]}"
168. rescue SocketError
169. @logger.debug "accept: <address unknown>"
170. raise
171. end
172. call_callback(:AcceptCallback, sock)
173. block ? block.call(sock) : run(sock)
174. rescue Errno::ENOTCONN
175. @logger.debug "Errno::ENOTCONN raised"
176. rescue ServerError => ex
177. msg = "#{ex.class}: #{ex.message}\n\t#{ex.backtrace[0]}"
178. @logger.error msg
179. rescue Exception => ex
180. @logger.error ex
# /usr/lib/ruby/1.8/webrick/server.rb in start
#
155. msg = "#{ex.class}: #{ex.message}\n\t#{ex.backtrace[0]}"
156. @logger.error msg
157. end
158. return sock
159. end
160.
161. def start_thread(sock, &block)
162. Thread.start{
163. begin
164. Thread.current[:WEBrickSocket] = sock
165. begin
166. addr = sock.peeraddr
167. @logger.debug "accept: #{addr[3]}:#{addr[1]}"
168. rescue SocketError
169. @logger.debug "accept: <address unknown>"
# /usr/lib/ruby/1.8/webrick/server.rb in start_thread
#
155. msg = "#{ex.class}: #{ex.message}\n\t#{ex.backtrace[0]}"
156. @logger.error msg
157. end
158. return sock
159. end
160.
161. def start_thread(sock, &block)
162. Thread.start{
163. begin
164. Thread.current[:WEBrickSocket] = sock
165. begin
166. addr = sock.peeraddr
167. @logger.debug "accept: #{addr[3]}:#{addr[1]}"
168. rescue SocketError
169. @logger.debug "accept: <address unknown>"
# /usr/lib/ruby/1.8/webrick/server.rb in start
#
88. @status = :Running
89. while @status == :Running
90. begin
91. if svrs = IO.select(@listeners, nil, nil, 2.0)
92. svrs[0].each{|svr|
93. @tokens.pop # blocks while no token is there.
94. if sock = accept_client(svr)
95. th = start_thread(sock, &block)
96. th[:WEBrickThread] = true
97. thgroup.add(th)
98. else
99. @tokens.push(nil)
100. end
101. }
102. end
# /usr/lib/ruby/1.8/webrick/server.rb in each
#
85. call_callback(:StartCallback)
86.
87. thgroup = ThreadGroup.new
88. @status = :Running
89. while @status == :Running
90. begin
91. if svrs = IO.select(@listeners, nil, nil, 2.0)
92. svrs[0].each{|svr|
93. @tokens.pop # blocks while no token is there.
94. if sock = accept_client(svr)
95. th = start_thread(sock, &block)
96. th[:WEBrickThread] = true
97. thgroup.add(th)
98. else
99. @tokens.push(nil)
# /usr/lib/ruby/1.8/webrick/server.rb in start
#
85. call_callback(:StartCallback)
86.
87. thgroup = ThreadGroup.new
88. @status = :Running
89. while @status == :Running
90. begin
91. if svrs = IO.select(@listeners, nil, nil, 2.0)
92. svrs[0].each{|svr|
93. @tokens.pop # blocks while no token is there.
94. if sock = accept_client(svr)
95. th = start_thread(sock, &block)
96. th[:WEBrickThread] = true
97. thgroup.add(th)
98. else
99. @tokens.push(nil)
# /usr/lib/ruby/1.8/webrick/server.rb in start
#
16.
17. module WEBrick
18.
19. class ServerError < StandardError; end
20.
21. class SimpleServer
22. def SimpleServer.start
23. yield
24. end
25. end
26.
27. class Daemon
28. def Daemon.start
29. exit!(0) if fork
30. Process::setsid
# /usr/lib/ruby/1.8/webrick/server.rb in start
#
75. @listeners += Utils::create_listeners(address, port, @logger)
76. end
77.
78. def start(&block)
79. raise ServerError, "already started." if @status != :Stop
80. server_type = @config[:ServerType] || SimpleServer
81.
82. server_type.start{
83. @logger.info \
84. "#{self.class}#start: pid=#{$$} port=#{@config[:Port]}"
85. call_callback(:StartCallback)
86.
87. thgroup = ThreadGroup.new
88. @status = :Running
89. while @status == :Running
# /usr/lib/ruby/gems/1.8/gems/rack-1.1.0/lib/rack/handler/webrick.rb in run
#
7. class WEBrick < ::WEBrick::HTTPServlet::AbstractServlet
8. def self.run(app, options={})
9. options[:BindAddress] = options.delete(:Host) if options[:Host]
10. server = ::WEBrick::HTTPServer.new(options)
11. server.mount "/", Rack::Handler::WEBrick, app
12. trap(:INT) { server.shutdown }
13. yield server if block_given?
14. server.start
15. end
16.
17. def initialize(server, app)
18. super server
19. @app = Rack::ContentLength.new(app)
20. end
21.
# /usr/lib/ruby/gems/1.8/gems/rack-1.1.0/lib/rack/server.rb in start
#
148.
149. if library = options[:require]
150. require library
151. end
152.
153. daemonize_app if options[:daemonize]
154. write_pid if options[:pid]
155. server.run wrapped_app, options
156. end
157.
158. def server
159. @_server ||= Rack::Handler.get(options[:server]) || Rack::Handler.default
160. end
161.
162. private
# /home/drusellers/dev/gemcutter/vendor/bundler_gems/gems/railties-3.0.0.beta4/lib/rails/commands/server.rb in start
#
55. puts "=> Ctrl-C to shutdown server" unless options[:daemonize]
56.
57. #Create required tmp directories if not found
58. %w(cache pids sessions sockets).each do |dir_to_make|
59. FileUtils.mkdir_p(Rails.root.join('tmp', dir_to_make))
60. end
61.
62. super
63. ensure
64. # The '-h' option calls exit before @options is set.
65. # If we call 'options' with it unset, we get double help banners.
66. puts 'Exiting' unless @options && options[:daemonize]
67. end
68.
69. def middleware
# /home/drusellers/dev/gemcutter/vendor/bundler_gems/gems/railties-3.0.0.beta4/lib/rails/commands.rb in nil
#
23. Rails::Console.start(Rails::Application)
24.
25. when 'server'
26. require 'rails/commands/server'
27. Rails::Server.new.tap { |server|
28. require APP_PATH
29. Dir.chdir(Rails::Application.root)
30. server.start
31. }
32.
33. when 'dbconsole'
34. require 'rails/commands/dbconsole'
35. require APP_PATH
36. Rails::DBConsole.start(Rails::Application)
37.
# /home/drusellers/dev/gemcutter/vendor/bundler_gems/gems/railties-3.0.0.beta4/lib/rails/commands.rb in tap
#
20. require 'rails/commands/console'
21. require APP_PATH
22. Rails::Application.require_environment!
23. Rails::Console.start(Rails::Application)
24.
25. when 'server'
26. require 'rails/commands/server'
27. Rails::Server.new.tap { |server|
28. require APP_PATH
29. Dir.chdir(Rails::Application.root)
30. server.start
31. }
32.
33. when 'dbconsole'
34. require 'rails/commands/dbconsole'
# /home/drusellers/dev/gemcutter/vendor/bundler_gems/gems/railties-3.0.0.beta4/lib/rails/commands.rb in nil
#
20. require 'rails/commands/console'
21. require APP_PATH
22. Rails::Application.require_environment!
23. Rails::Console.start(Rails::Application)
24.
25. when 'server'
26. require 'rails/commands/server'
27. Rails::Server.new.tap { |server|
28. require APP_PATH
29. Dir.chdir(Rails::Application.root)
30. server.start
31. }
32.
33. when 'dbconsole'
34. require 'rails/commands/dbconsole'
# script/rails in require
#
1. #!/usr/bin/env ruby
2. # This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
3.
4. APP_PATH = File.expand_path('../../config/application', __FILE__)
5. require File.expand_path('../../config/boot', __FILE__)
6. require 'rails/commands'
# script/rails in nil
#
1. #!/usr/bin/env ruby
2. # This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
3.
4. APP_PATH = File.expand_path('../../config/application', __FILE__)
5. require File.expand_path('../../config/boot', __FILE__)
6. require 'rails/commands'
@drusellers
Copy link
Author

/home/drusellers/dev/gemcutter/app/models/download.rb in most_downloaded_today

  1. def self.for(what)
  2. $redis[key(what)].to_i
  3. end
    24.
  4. def self.most_downloaded_today
  5. items = $redis.zrevrange(TODAY_KEY, 0, 4, :with_scores => true)
  6. items.in_groups_of(2).collect do |full_name, downloads|
  7. version = Version.find_by_full_name(full_name)
    29.
  8. [version, downloads.to_i]
  9. end
  10. end
    33.
  11. def self.key(what)

/home/drusellers/dev/gemcutter/app/controllers/home_controller.rb in index

  1. class HomeController < ApplicationController
  2. def index
  3. @rubygems_count = Rubygem.total_count
  4. @downloads_count = Download.count
  5. @latest = Rubygem.latest
  6. @Downloaded = Download.most_downloaded_today
  7. @Updated = Version.updated
  8. end
  9. end

/home/drusellers/dev/gemcutter/vendor/bundler_gems/gems/actionpack-3.0.0.beta4/lib/action_controller/metal/implicit_render.rb in send_action

  1. module ActionController
  2. module ImplicitRender
  3. def send_action(*)
  4. ret = super
  5. default_render unless response_body
  6. ret
  7. end
    8.
  8. def default_render
    1. render
    2. end

/home/drusellers/dev/gemcutter/vendor/bundler_gems/gems/actionpack-3.0.0.beta4/lib/action_controller/metal/implicit_render.rb in send_action

  1. module ActionController
  2. module ImplicitRender
  3. def send_action(*)
  4. ret = super
  5. default_render unless response_body
  6. ret
  7. end
    8.
  8. def default_render
    1. render
    2. end

/home/drusellers/dev/gemcutter/vendor/bundler_gems/gems/actionpack-3.0.0.beta4/lib/abstract_controller/base.rb in process_action

  1. self.class.action_methods.include?(name)
  2. end
    140.
  3. Call the action. Override this in a subclass to modify the

  4. behavior around processing an action. This, and not #process,

  5. is the intended way to override action dispatching.

  6. def process_action(method_name, *args)
  7. send_action(method_name, *args)
  8. end
    147.
  9. Actually call the method associated with the action. Override

  10. this method if you wish to change how action methods are called,

  11. not to add additional behavior around it. For example, you would

  12. override #send_action if you want to inject arguments into the

  13. method.

/home/drusellers/dev/gemcutter/vendor/bundler_gems/gems/actionpack-3.0.0.beta4/lib/action_controller/metal/rendering.rb in process_action

  1. include ActionController::RackDelegation
  2. include AbstractController::Rendering
    7.
  3. Before processing, set the request formats in current controller formats.

  4. def process_action(*) #:nodoc:
    1. self.formats = request.formats.map { |x| x.to_sym }
    2. super
    3. end
      13.
    4. Check for double render errors and set the content_type after rendering.

    5. def render(*args) #:nodoc:
    6. raise ::AbstractController::DoubleRenderError if response_body
    7. super
    8. self.content_type ||= Mime[formats.first].to_s

/home/drusellers/dev/gemcutter/vendor/bundler_gems/gems/actionpack-3.0.0.beta4/lib/abstract_controller/callbacks.rb in process_action

  1. define_callbacks :process_action, :terminator => "response_body"
  2. end
    13.
  3. Override AbstractController::Base's process_action to run the

  4. process_action callbacks around the normal behavior.

  5. def process_action(method_name)
  6. run_callbacks(:process_action, method_name) do
  7. super
  8. end
  9. end
    21.
  10. module ClassMethods
  11. If :only or :except are used, convert the options into the

  12. primitive form (:per_key) used by ActiveSupport::Callbacks.

  13. The basic idea is that :only => :index gets converted to

/home/drusellers/dev/gemcutter/vendor/bundler_gems/gems/activesupport-3.0.0.beta4/lib/active_support/callbacks.rb in _run__738958071__process_action__199225275__callbacks

  1. def __create_keyed_callback(name, kind, object, &blk) #:nodoc:
  2. @_keyed_callbacks ||= {}
  3. @_keyed_callbacks[name] ||= begin
  4. str = send("_#{kind}_callbacks").compile(name, object)
  5. class_eval "def #{name}() #{str} end", FILE, LINE
  6. true
  7. end
  8. end
    430.
  9. This is used internally to append, prepend and skip callbacks to the

  10. CallbackChain.

  11. def __update_callbacks(name, filters = [], block = nil) #:nodoc:
  12. send("update#{name}_superclass_callbacks")

/home/drusellers/dev/gemcutter/vendor/bundler_gems/gems/activesupport-3.0.0.beta4/lib/active_support/callbacks.rb in send

  1. if key
  2. name = "run_#{self.class.name.hash.abs}#{symbol}#{key.hash.abs}__callbacks"
    403.
  3. unless respond_to?(name)
  4. self.class.__create_keyed_callback(name, :#{symbol}, self, &blk)
  5. end
    407.
  6. send(name, &blk)
  7. else
  8. #{body}
  9. end
  10. end
  11. private :run#{symbol}_callbacks
  12. RUBY_EVAL
  13. end

/home/drusellers/dev/gemcutter/vendor/bundler_gems/gems/activesupport-3.0.0.beta4/lib/active_support/callbacks.rb in _run_process_action_callbacks

  1. if key
  2. name = "run_#{self.class.name.hash.abs}#{symbol}#{key.hash.abs}__callbacks"
    403.
  3. unless respond_to?(name)
  4. self.class.__create_keyed_callback(name, :#{symbol}, self, &blk)
  5. end
    407.
  6. send(name, &blk)
  7. else
  8. #{body}
  9. end
  10. end
  11. private :run#{symbol}_callbacks
  12. RUBY_EVAL
  13. end

/home/drusellers/dev/gemcutter/vendor/bundler_gems/gems/activesupport-3.0.0.beta4/lib/active_support/callbacks.rb in send

  1. - save

  2. saved

  3. module Callbacks
  4. extend Concern
    86.
  5. def run_callbacks(kind, *args, &block)
  6. send("run#{kind}_callbacks", *args, &block)
  7. end
    90.
  8. class Callback
  9. @@_callback_sequence = 0
    93.
  10. attr_accessor :chain, :filter, :kind, :options, :per_key, :klass, :raw_filter
    95.

/home/drusellers/dev/gemcutter/vendor/bundler_gems/gems/activesupport-3.0.0.beta4/lib/active_support/callbacks.rb in run_callbacks

  1. - save

  2. saved

  3. module Callbacks
  4. extend Concern
    86.
  5. def run_callbacks(kind, *args, &block)
  6. send("run#{kind}_callbacks", *args, &block)
  7. end
    90.
  8. class Callback
  9. @@_callback_sequence = 0
    93.
  10. attr_accessor :chain, :filter, :kind, :options, :per_key, :klass, :raw_filter
    95.

/home/drusellers/dev/gemcutter/vendor/bundler_gems/gems/actionpack-3.0.0.beta4/lib/abstract_controller/callbacks.rb in process_action

  1. included do
  2. define_callbacks :process_action, :terminator => "response_body"
  3. end
    13.
  4. Override AbstractController::Base's process_action to run the

  5. process_action callbacks around the normal behavior.

  6. def process_action(method_name)
  7. run_callbacks(:process_action, method_name) do
  8. super
  9. end
  10. end
    21.
  11. module ClassMethods
  12. If :only or :except are used, convert the options into the

  13. primitive form (:per_key) used by ActiveSupport::Callbacks.

/home/drusellers/dev/gemcutter/vendor/bundler_gems/gems/actionpack-3.0.0.beta4/lib/action_controller/metal/instrumentation.rb in process_action

  1. :method => request.method,
  2. :path => (request.fullpath rescue "unknown")
  3. }
    25.
  4. ActiveSupport::Notifications.instrument("start_processing.action_controller", raw_payload.dup)
    27.
  5. ActiveSupport::Notifications.instrument("process_action.action_controller", raw_payload) do |payload|
  6. result = super
  7. payload[:status] = response.status
  8. append_info_to_payload(payload)
  9. result
  10. end
  11. end
    35.
  12. def render(*args)

/home/drusellers/dev/gemcutter/vendor/bundler_gems/gems/activesupport-3.0.0.beta4/lib/active_support/notifications/instrumenter.rb in instrument

  1. Instrument the given block by measuring the time taken to execute it

  2. and publish it. Notice that events get sent even if an error occurs

  3. in the passed-in block

  4. def instrument(name, payload={})
  5. time = Time.now
  6. begin
  7. yield(payload) if block_given?
  8. rescue Exception => e
  9. payload[:exception] = [e.class.name, e.message]
  10. raise e
  11. ensure
  12. @notifier.publish(name, time, Time.now, @id, payload)
  13. end
  14. end

/home/drusellers/dev/gemcutter/vendor/bundler_gems/gems/activesupport-3.0.0.beta4/lib/active_support/notifications.rb in send

  1. autoload :Instrumenter, 'active_support/notifications/instrumenter'

  2. autoload :Event, 'active_support/notifications/instrumenter'

  3. autoload :Fanout, 'active_support/notifications/fanout'
    44.

  4. class << self

  5. attr_writer :notifier

  6. delegate :publish, :subscribe, :unsubscribe, :to => :notifier

  7. delegate :instrument, :to => :instrumenter

  8. def notifier

  9. @Notifier ||= Notifier.new

  10. end
    53.

  11. def instrumenter

  12. Thread.current[:"instrumentation_#{notifier.object_id}"] ||= Instrumenter.new(notifier)

/home/drusellers/dev/gemcutter/vendor/bundler_gems/gems/activesupport-3.0.0.beta4/lib/active_support/notifications.rb in instrument

  1. autoload :Instrumenter, 'active_support/notifications/instrumenter'

  2. autoload :Event, 'active_support/notifications/instrumenter'

  3. autoload :Fanout, 'active_support/notifications/fanout'
    44.

  4. class << self

  5. attr_writer :notifier

  6. delegate :publish, :subscribe, :unsubscribe, :to => :notifier

  7. delegate :instrument, :to => :instrumenter

  8. def notifier

  9. @Notifier ||= Notifier.new

  10. end
    53.

  11. def instrumenter

  12. Thread.current[:"instrumentation_#{notifier.object_id}"] ||= Instrumenter.new(notifier)

/home/drusellers/dev/gemcutter/vendor/bundler_gems/gems/actionpack-3.0.0.beta4/lib/action_controller/metal/instrumentation.rb in process_action

  1. :formats => request.formats.map(&:to_sym),
  2. :method => request.method,
  3. :path => (request.fullpath rescue "unknown")
  4. }
    25.
  5. ActiveSupport::Notifications.instrument("start_processing.action_controller", raw_payload.dup)
    27.
  6. ActiveSupport::Notifications.instrument("process_action.action_controller", raw_payload) do |payload|
  7. result = super
  8. payload[:status] = response.status
  9. append_info_to_payload(payload)
  10. result
  11. end
  12. end
    35.

/home/drusellers/dev/gemcutter/vendor/bundler_gems/gems/actionpack-3.0.0.beta4/lib/action_controller/metal/rescue.rb in process_action

  1. module ActionController #:nodoc:
  2. module Rescue
  3. extend ActiveSupport::Concern
  4. include ActiveSupport::Rescuable
    5.
  5. private
  6. def process_action(*args)
  7. super
  8. rescue Exception => exception
    1. rescue_with_handler(exception) || raise(exception)
    2. end
    3. end
    4. end

/home/drusellers/dev/gemcutter/vendor/bundler_gems/gems/actionpack-3.0.0.beta4/lib/abstract_controller/base.rb in process

  1. unless action_name = method_for_action(action_name)
  2. raise ActionNotFound, "The action '#{action}' could not be found"
  3. end
    111.
  4. @_response_body = nil
    113.
  5. process_action(action_name, *args)
  6. end
    116.
  7. Delegates to the class' #controller_path

  8. def controller_path
  9. self.class.controller_path
  10. end
    121.

/home/drusellers/dev/gemcutter/vendor/bundler_gems/gems/actionpack-3.0.0.beta4/lib/abstract_controller/rendering.rb in process

  1. extend ActiveSupport::Concern
    34.
  2. include AbstractController::ViewPaths
    36.
  3. Overwrite process to setup I18n proxy.

  4. def process(*) #:nodoc:
  5. old_config, I18n.config = I18n.config, I18nProxy.new(I18n.config, lookup_context)
  6. super
  7. ensure
  8. I18n.config = old_config
  9. end
    44.
  10. module ClassMethods
  11. def view_context_class
  12. @view_context_class ||= begin

/home/drusellers/dev/gemcutter/vendor/bundler_gems/gems/actionpack-3.0.0.beta4/lib/action_controller/metal.rb in dispatch

  1. end
    120.
  2. :api: private

  3. def dispatch(name, request)
  4. @_request = request
  5. @_env = request.env
  6. @_env['action_controller.instance'] = self
  7. process(name)
  8. to_a
  9. end
    129.
  10. :api: private

  11. def to_a
  12. response ? response.to_a : [status, headers, response_body]
  13. end

/home/drusellers/dev/gemcutter/vendor/bundler_gems/gems/actionpack-3.0.0.beta4/lib/action_controller/metal/rack_delegation.rb in dispatch

  1. delegate :headers, :status=, :location=, :content_type=,
  2. :status, :location, :content_type, :to => "@_response"
    10.
    1. def dispatch(action, request, response = ActionDispatch::Response.new)
    2. @_response ||= response
    3. @_response.request ||= request
    4. super(action, request)
    5. end
      16.
    6. def params
    7. @_params ||= @_request.parameters
    8. end
      20.
    9. def response_body=(body)

/home/drusellers/dev/gemcutter/vendor/bundler_gems/gems/actionpack-3.0.0.beta4/lib/action_controller/metal.rb in nil

  1. ==== Parameters

  2. action<#to_s>:: An action name

  3. ==== Returns

  4. Proc:: A rack application

  5. def self.action(name, klass = ActionDispatch::Request)
  6. middleware_stack.build(name.to_s) do |env|
  7. new.dispatch(name, klass.new(env))
  8. end
  9. end
  10. end
  11. end

/home/drusellers/dev/gemcutter/vendor/bundler_gems/gems/actionpack-3.0.0.beta4/lib/action_dispatch/routing/route_set.rb in call

  1. prepare_params!(params)
    21.
  2. Just raise undefined constant errors if a controller was specified as default.

  3. unless controller = controller(params, @defaults.key?(:controller))
  4. return [404, {'X-Cascade' => 'pass'}, []]
  5. end
    26.
  6. controller.action(params[:action]).call(env)
  7. end
    29.
  8. def prepare_params!(params)
  9. merge_default_action!(params)
  10. split_glob_param!(params) if @glob_param
  11. end
    34.

/home/drusellers/dev/gemcutter/vendor/bundler_gems/gems/actionpack-3.0.0.beta4/lib/action_dispatch/routing/route_set.rb in call

  1. prepare_params!(params)
    21.
  2. Just raise undefined constant errors if a controller was specified as default.

  3. unless controller = controller(params, @defaults.key?(:controller))
  4. return [404, {'X-Cascade' => 'pass'}, []]
  5. end
    26.
  6. controller.action(params[:action]).call(env)
  7. end
    29.
  8. def prepare_params!(params)
  9. merge_default_action!(params)
  10. split_glob_param!(params) if @glob_param
  11. end
    34.

/home/drusellers/dev/gemcutter/vendor/bundler_gems/gems/rack-mount-0.6.9/lib/rack/mount/route_set.rb in call

  1. params.each { |k, v| params[k] = Utils.unescape_uri(v) if v.is_a?(String) }
    142.
  2. if route.prefix?
  3. env[Prefix::KEY] = matches[:path_info].to_s
  4. end
    146.
  5. env[@parameters_key] = params
  6. result = route.app.call(env)
  7. return result unless result[1][X_CASCADE] == PASS
  8. end
    151.
  9. request || [404, {'Content-Type' => 'text/html', 'X-Cascade' => 'pass'}, ['Not Found']]
  10. end
    154.
  11. Generates a url from Rack env and identifiers or significant keys.

/home/drusellers/dev/gemcutter/vendor/bundler_gems/gems/rack-mount-0.6.9/lib/rack/mount/code_generation.rb in recognize

  1. instance_eval(<<-RUBY, FILE, LINE)
  2. def recognize(obj)
  3. cache = {}
  4. container = @recognition_graph[#{keys}]
  5. optimize_container_iterator(container) unless container.respond_to?(:optimized_each)
    87.
  6. if block_given?
  7. container.optimized_each(obj) do |route, matches, params|
  8. yield route, matches, params
  9. end
  10. else
  11. container.optimized_each(obj) do |route, matches, params|
  12. return route, matches, params
  13. end
  14. end

/home/drusellers/dev/gemcutter/vendor/bundler_gems/gems/rack-mount-0.6.9/lib/rack/mount/code_generation.rb in optimized_each

  1. }
    60.
  2. container.instance_eval(<<-RUBY, FILE, LINE)
  3. def optimized_each(obj)
  4. #{body.join("\n")}
  5. nil
  6. end
  7. RUBY
  8. end
    68.
  9. def optimize_recognize!
  10. keys = @recognition_keys.map { |key|
  11. if key.respond_to?(:call_source)
  12. key.call_source(:cache, :obj)
  13. else

/home/drusellers/dev/gemcutter/vendor/bundler_gems/gems/rack-mount-0.6.9/lib/rack/mount/code_generation.rb in recognize

  1. instance_eval(<<-RUBY, FILE, LINE)
  2. def recognize(obj)
  3. cache = {}
  4. container = @recognition_graph[#{keys}]
  5. optimize_container_iterator(container) unless container.respond_to?(:optimized_each)
    87.
  6. if block_given?
  7. container.optimized_each(obj) do |route, matches, params|
  8. yield route, matches, params
  9. end
  10. else
  11. container.optimized_each(obj) do |route, matches, params|
  12. return route, matches, params
  13. end

/home/drusellers/dev/gemcutter/vendor/bundler_gems/gems/rack-mount-0.6.9/lib/rack/mount/route_set.rb in call

  1. def call(env)
  2. raise 'route set not finalized' unless @recognition_graph
    134.
  3. env[PATH_INFO] = Utils.normalize_path(env[PATH_INFO])
    136.
  4. request = nil
  5. req = @request_class.new(env)
  6. recognize(req) do |route, matches, params|
  7. TODO: We only want to unescape params from uri related methods

  8. params.each { |k, v| params[k] = Utils.unescape_uri(v) if v.is_a?(String) }
    142.
  9. if route.prefix?
  10. env[Prefix::KEY] = matches[:path_info].to_s
  11. end
    146.

/home/drusellers/dev/gemcutter/vendor/bundler_gems/gems/actionpack-3.0.0.beta4/lib/action_dispatch/routing/route_set.rb in call

  1. rewritten_url << "##{Rack::Utils.escape(options[:anchor].to_param.to_s)}" if options[:anchor]
    451.
  2. rewritten_url
  3. end
    454.
  4. def call(env)
  5. finalize!
  6. @set.call(env)
  7. end
    459.
  8. def recognize_path(path, environment = {})
  9. method = (environment[:method] || "GET").to_s.upcase
  10. path = Rack::Mount::Utils.normalize_path(path)
    463.
  11. begin

/home/drusellers/dev/gemcutter/vendor/bundler_gems/gems/sinatra-1.0/lib/sinatra/base.rb in forward

  1. def pass(&block)
  2. throw :pass, block
  3. end
    446.
  4. Forward the request to the downstream app -- middleware only.

  5. def forward
  6. fail "downstream app not set" unless @app.respond_to? :call
  7. status, headers, body = @app.call(@request.env)
  8. @response.status = status
  9. @response.body = body
  10. @response.headers.merge! headers
  11. nil
  12. end
    456.
  13. private

/home/drusellers/dev/gemcutter/vendor/bundler_gems/gems/sinatra-1.0/lib/sinatra/base.rb in route_missing

  1. No matching route was found or all routes passed. The default

  2. implementation is to forward the request downstream when running

  3. as middleware (@app is non-nil); when no downstream app is set, raise

  4. a NotFound exception. Subclasses can override this method to perform

  5. custom route miss logic.

  6. def route_missing
  7. if @app
  8. forward
  9. else
  10. raise NotFound
  11. end
  12. end
    536.
  13. Attempt to serve static files from public directory. Throws :halt when

  14. a matching file is found, returns nil otherwise.

/home/drusellers/dev/gemcutter/vendor/bundler_gems/gems/sinatra-1.0/lib/sinatra/base.rb in route!

  1. if base.superclass.respond_to?(:routes)
  2. route! base.superclass, pass_block
  3. return
  4. end
    513.
  5. route_eval(&pass_block) if pass_block
    515.
  6. route_missing
  7. end
    518.
  8. Run a route block and throw :halt with the result.

  9. def route_eval(&block)
  10. throw :halt, instance_eval(&block)
  11. end
    523.

/home/drusellers/dev/gemcutter/vendor/bundler_gems/gems/sinatra-1.0/lib/sinatra/base.rb in route!

  1. end
    504.
  2. @params = original_params
  3. end
    507.
  4. Run routes defined in superclass.

  5. if base.superclass.respond_to?(:routes)
  6. route! base.superclass, pass_block
  7. return
  8. end
    513.
  9. route_eval(&pass_block) if pass_block
    515.
  10. route_missing
  11. end

/home/drusellers/dev/gemcutter/vendor/bundler_gems/gems/sinatra-1.0/lib/sinatra/base.rb in dispatch!

  1. res
  2. end
    596.
  3. Dispatch a request with error handling.

  4. def dispatch!
  5. static! if settings.static? && (request.get? || request.head?)
  6. before_filter!
  7. route!
  8. rescue NotFound => boom
  9. handle_not_found!(boom)
  10. rescue ::Exception => boom
  11. handle_exception!(boom)
  12. ensure
  13. after_filter! unless env['sinatra.static_file']
  14. end

/home/drusellers/dev/gemcutter/vendor/bundler_gems/gems/sinatra-1.0/lib/sinatra/base.rb in call!

  1. def call!(env)
  2. @env = env
  3. @request = Request.new(env)
  4. @response = Response.new
  5. @params = indifferent_params(@request.params)
  6. @template_cache.clear if settings.reload_templates
    410.
  7. invoke { dispatch! }
  8. invoke { error_block!(response.status) }
    413.
  9. status, header, body = @response.finish
    415.
  10. Never produce a body on HEAD requests. Do retain the Content-Length

  11. unless it's "0", in which case we assume it was calculated erroneously

  12. for a manual HEAD response and remove it entirely.

/home/drusellers/dev/gemcutter/vendor/bundler_gems/gems/sinatra-1.0/lib/sinatra/base.rb in instance_eval

  1. def indifferent_hash
  2. Hash.new {|hash,key| hash[key.to_s] if Symbol === key }
  3. end
    563.
  4. Run the block with 'throw :halt' support and apply result to the response.

  5. def invoke(&block)
  6. res = catch(:halt) { instance_eval(&block) }
  7. return if res.nil?
    568.
  8. case
  9. when res.respond_to?(:to_str)
  10. @response.body = [res]
  11. when res.respond_to?(:to_ary)
  12. res = res.to_ary

/home/drusellers/dev/gemcutter/vendor/bundler_gems/gems/sinatra-1.0/lib/sinatra/base.rb in invoke

  1. def indifferent_hash
  2. Hash.new {|hash,key| hash[key.to_s] if Symbol === key }
  3. end
    563.
  4. Run the block with 'throw :halt' support and apply result to the response.

  5. def invoke(&block)
  6. res = catch(:halt) { instance_eval(&block) }
  7. return if res.nil?
    568.
  8. case
  9. when res.respond_to?(:to_str)
  10. @response.body = [res]
  11. when res.respond_to?(:to_ary)
  12. res = res.to_ary

/home/drusellers/dev/gemcutter/vendor/bundler_gems/gems/sinatra-1.0/lib/sinatra/base.rb in catch

  1. def indifferent_hash
  2. Hash.new {|hash,key| hash[key.to_s] if Symbol === key }
  3. end
    563.
  4. Run the block with 'throw :halt' support and apply result to the response.

  5. def invoke(&block)
  6. res = catch(:halt) { instance_eval(&block) }
  7. return if res.nil?
    568.
  8. case
  9. when res.respond_to?(:to_str)
  10. @response.body = [res]
  11. when res.respond_to?(:to_ary)
  12. res = res.to_ary

/home/drusellers/dev/gemcutter/vendor/bundler_gems/gems/sinatra-1.0/lib/sinatra/base.rb in invoke

  1. def indifferent_hash
  2. Hash.new {|hash,key| hash[key.to_s] if Symbol === key }
  3. end
    563.
  4. Run the block with 'throw :halt' support and apply result to the response.

  5. def invoke(&block)
  6. res = catch(:halt) { instance_eval(&block) }
  7. return if res.nil?
    568.
  8. case
  9. when res.respond_to?(:to_str)
  10. @response.body = [res]
  11. when res.respond_to?(:to_ary)
  12. res = res.to_ary

/home/drusellers/dev/gemcutter/vendor/bundler_gems/gems/sinatra-1.0/lib/sinatra/base.rb in call!

  1. def call!(env)
  2. @env = env
  3. @request = Request.new(env)
  4. @response = Response.new
  5. @params = indifferent_params(@request.params)
  6. @template_cache.clear if settings.reload_templates
    410.
  7. invoke { dispatch! }
  8. invoke { error_block!(response.status) }
    413.
  9. status, header, body = @response.finish
    415.
  10. Never produce a body on HEAD requests. Do retain the Content-Length

  11. unless it's "0", in which case we assume it was calculated erroneously

  12. for a manual HEAD response and remove it entirely.

/home/drusellers/dev/gemcutter/vendor/bundler_gems/gems/sinatra-1.0/lib/sinatra/base.rb in call

  1. @app = app
  2. @template_cache = Tilt::Cache.new
  3. yield self if block_given?
  4. end
    396.
  5. Rack call interface.

  6. def call(env)
  7. dup.call!(env)
  8. end
    401.
  9. attr_accessor :env, :request, :response, :params
    403.
  10. def call!(env)
  11. @env = env
  12. @request = Request.new(env)

/usr/lib/ruby/gems/1.8/gems/rack-1.1.0/lib/rack/showexceptions.rb in call

  1. def initialize(app)
  2. @app = app
  3. @template = ERB.new(TEMPLATE)
  4. end
    22.
  5. def call(env)
  6. @app.call(env)
  7. rescue StandardError, LoadError, SyntaxError => e
  8. backtrace = pretty(env, e)
  9. [500,
  10. {"Content-Type" => "text/html",
  11. "Content-Length" => backtrace.join.size.to_s},
  12. backtrace]
  13. end

/home/drusellers/dev/gemcutter/vendor/bundler_gems/gems/actionpack-3.0.0.beta4/lib/action_dispatch/middleware/head.rb in call

  1. def call(env)
  2. if env["REQUEST_METHOD"] == "HEAD"
  3. env["REQUEST_METHOD"] = "GET"
    1. env["rack.methodoverride.original_method"] = "HEAD"
    2. status, headers, body = @app.call(env)
    3. [status, headers, []]
    4. else
    5. @app.call(env)
    6. end
    7. end
    8. end
    9. end

/usr/lib/ruby/gems/1.8/gems/rack-1.1.0/lib/rack/methodoverride.rb in call

  1. method = method.to_s.upcase
  2. if HTTP_METHODS.include?(method)
  3. env["rack.methodoverride.original_method"] = env["REQUEST_METHOD"]
  4. env["REQUEST_METHOD"] = method
  5. end
  6. end
    23.
  7. @app.call(env)
  8. end
  9. end
  10. end

/home/drusellers/dev/gemcutter/vendor/bundler_gems/gems/actionpack-3.0.0.beta4/lib/action_dispatch/middleware/params_parser.rb in call

  1. end
    15.
  2. def call(env)
  3. if params = parse_formatted_parameters(env)
  4. env["action_dispatch.request.request_parameters"] = params
  5. end
    20.
  6. @app.call(env)
  7. end
    23.
  8. private
  9. def parse_formatted_parameters(env)
  10. request = Request.new(env)
    27.
  11. return false if request.content_length.zero?

/home/drusellers/dev/gemcutter/vendor/bundler_gems/gems/actionpack-3.0.0.beta4/lib/action_dispatch/middleware/flash.rb in call

  1. end
    171.
  2. def call(env)
  3. if (session = env['rack.session']) && (flash = session['flash'])
  4. flash.sweep
  5. end
    176.
  6. @app.call(env)
  7. ensure
  8. if (session = env['rack.session']) && session.key?('flash') && session['flash'].empty?
  9. session.delete('flash')
  10. end
  11. end
  12. end
  13. end

/home/drusellers/dev/gemcutter/vendor/bundler_gems/gems/actionpack-3.0.0.beta4/lib/action_dispatch/middleware/session/abstract_store.rb in call

  1. @key = @default_options.delete(:key).freeze
    1. @cookie_only = @default_options.delete(:cookie_only)

    2. ensure_session_key!

    3. end
      103.

    4. def call(env)

    5. prepare!(env)

    6. response = @app.call(env)

    7. session_data = env[ENV_SESSION_KEY]

    8. options = env[ENV_SESSION_OPTIONS_KEY]

    9. if !session_data.is_a?(AbstractStore::SessionHash) || session_data.send(:loaded?) || options[:expire_after]

    10. session_data.send(:load!) if session_data.is_a?(AbstractStore::SessionHash) && !session_data.send(:loaded?)

/home/drusellers/dev/gemcutter/vendor/bundler_gems/gems/actionpack-3.0.0.beta4/lib/action_dispatch/middleware/cookies.rb in call

  1. end
    229.

  2. def initialize(app)

  3. @app = app

  4. end
    233.

  5. def call(env)

  6. status, headers, body = @app.call(env)

  7. if cookie_jar = env['action_dispatch.cookies']

  8. cookie_jar.write(headers)

  9. if headers[HTTP_HEADER].respond_to?(:join)

  10. headers[HTTP_HEADER] = headers[HTTP_HEADER].join("\n")

  11. end

  12. end

/home/drusellers/dev/gemcutter/vendor/bundler_gems/gems/activerecord-3.0.0.beta4/lib/active_record/query_cache.rb in call

  1. def initialize(app)
  2. @app = app
  3. end
    28.
  4. def call(env)
  5. ActiveRecord::Base.cache do
  6. @app.call(env)
  7. end
  8. end
  9. end
  10. end

/home/drusellers/dev/gemcutter/vendor/bundler_gems/gems/activerecord-3.0.0.beta4/lib/active_record/connection_adapters/abstract/query_cache.rb in cache

  1. end
    22.
  2. attr_reader :query_cache, :query_cache_enabled
    24.
  3. Enable the query cache within the block.

  4. def cache
  5. old, @query_cache_enabled = @query_cache_enabled, true
  6. yield
  7. ensure
  8. clear_query_cache
  9. @query_cache_enabled = old
  10. end
    33.
  11. Disable the query cache within the block.

  12. def uncached

/home/drusellers/dev/gemcutter/vendor/bundler_gems/gems/activerecord-3.0.0.beta4/lib/active_record/query_cache.rb in cache

  1. class QueryCache
  2. module ClassMethods
  3. Enable the query cache within the block if Active Record is configured.

  4. def cache(&block)
  5. if ActiveRecord::Base.configurations.blank?
  6. yield
    1. else
    2. connection.cache(&block)
    3. end
    4. end
      14.
    5. Disable the query cache within the block if Active Record is configured.

    6. def uncached(&block)
    7. if ActiveRecord::Base.configurations.blank?
    8. yield

/home/drusellers/dev/gemcutter/vendor/bundler_gems/gems/activerecord-3.0.0.beta4/lib/active_record/query_cache.rb in call

  1. end
    24.
  2. def initialize(app)
  3. @app = app
  4. end
    28.
  5. def call(env)
  6. ActiveRecord::Base.cache do
  7. @app.call(env)
  8. end
  9. end
  10. end
  11. end

/home/drusellers/dev/gemcutter/vendor/bundler_gems/gems/activerecord-3.0.0.beta4/lib/active_record/connection_adapters/abstract/connection_pool.rb in call

  1. class ConnectionManagement
  2. def initialize(app)
  3. @app = app
  4. end
    363.
  5. def call(env)
  6. @app.call(env)
  7. ensure
  8. Don't return connection (and perform implicit rollback) if

  9. this request is a part of integration test

  10. unless env.key?("rack.test")
  11. ActiveRecord::Base.clear_active_connections!
  12. end
  13. end

/home/drusellers/dev/gemcutter/vendor/bundler_gems/gems/actionpack-3.0.0.beta4/lib/action_dispatch/middleware/callbacks.rb in call

  1. @app, @prepare_each_request = app, prepare_each_request
  2. run_callbacks(:prepare)
  3. end
    42.
  4. def call(env)
  5. run_callbacks(:call) do
  6. run_callbacks(:prepare) if @prepare_each_request
  7. @app.call(env)
  8. end
  9. end
  10. end
  11. end

/home/drusellers/dev/gemcutter/vendor/bundler_gems/gems/activesupport-3.0.0.beta4/lib/active_support/callbacks.rb in _run_call_callbacks

  1. send(name, &blk)
  2. else
  3. #{body}
  4. end
  5. end
  6. private :run#{symbol}_callbacks
  7. RUBY_EVAL
  8. end
  9. end
    417.
  10. This is called the first time a callback is called with a particular

  11. key. It creates a new callback method for the key, calculating

  12. which callbacks can be omitted because of per_key conditions.

/home/drusellers/dev/gemcutter/vendor/bundler_gems/gems/activesupport-3.0.0.beta4/lib/active_support/callbacks.rb in send

  1. - save

  2. saved

  3. module Callbacks
  4. extend Concern
    86.
  5. def run_callbacks(kind, *args, &block)
  6. send("run#{kind}_callbacks", *args, &block)
  7. end
    90.
  8. class Callback
  9. @@_callback_sequence = 0
    93.
  10. attr_accessor :chain, :filter, :kind, :options, :per_key, :klass, :raw_filter
    95.

/home/drusellers/dev/gemcutter/vendor/bundler_gems/gems/activesupport-3.0.0.beta4/lib/active_support/callbacks.rb in run_callbacks

  1. - save

  2. saved

  3. module Callbacks
  4. extend Concern
    86.
  5. def run_callbacks(kind, *args, &block)
  6. send("run#{kind}_callbacks", *args, &block)
  7. end
    90.
  8. class Callback
  9. @@_callback_sequence = 0
    93.
  10. attr_accessor :chain, :filter, :kind, :options, :per_key, :klass, :raw_filter
    95.

/home/drusellers/dev/gemcutter/vendor/bundler_gems/gems/actionpack-3.0.0.beta4/lib/action_dispatch/middleware/callbacks.rb in call

  1. def initialize(app, prepare_each_request = false)
  2. @app, @prepare_each_request = app, prepare_each_request
  3. run_callbacks(:prepare)
  4. end
    42.
  5. def call(env)
  6. run_callbacks(:call) do
  7. run_callbacks(:prepare) if @prepare_each_request
  8. @app.call(env)
  9. end
  10. end
  11. end
  12. end

/usr/lib/ruby/gems/1.8/gems/rack-1.1.0/lib/rack/sendfile.rb in call

  1. def initialize(app, variation=nil)
    1. @app = app
    2. @variation = variation
    3. end
      103.
    4. def call(env)
    5. status, headers, body = @app.call(env)
    6. if body.respond_to?(:to_path)
    7. case type = variation(env)
    8. when 'X-Accel-Redirect'
    9. path = F.expand_path(body.to_path)
    10. if url = map_accel_path(env, path)
    11. headers[type] = url
    12. body = []

/home/drusellers/dev/gemcutter/vendor/bundler_gems/gems/actionpack-3.0.0.beta4/lib/action_dispatch/middleware/remote_ip.rb in call

  1. regex = '(^127.0.0.1$|^(10|172.(1[6-9]|2[0-9]|30|31)|192.168).)'
  2. regex << "|(#{trusted_proxies})" if trusted_proxies
  3. @trusted_proxies = Regexp.new(regex, "i")
  4. end
    45.
  5. def call(env)
  6. env["action_dispatch.remote_ip"] = RemoteIpGetter.new(env, @check_ip_spoofing, @trusted_proxies)
  7. @app.call(env)
  8. end
  9. end
  10. end

/home/drusellers/dev/gemcutter/vendor/bundler_gems/gems/actionpack-3.0.0.beta4/lib/action_dispatch/middleware/show_exceptions.rb in call

  1. def initialize(app, consider_all_requests_local = false)

  2. @app = app

  3. @consider_all_requests_local = consider_all_requests_local

  4. end
    46.

  5. def call(env)

  6. status, headers, body = @app.call(env)

  7. Only this middleware cares about RoutingError. So, let's just raise

  8. it here.

  9. TODO: refactor this middleware to handle the X-Cascade scenario without

  10. having to raise an exception.

  11. if headers['X-Cascade'] == 'pass'

  12. raise ActionController::RoutingError, "No route matches #{env['PATH_INFO'].inspect}"

/home/drusellers/dev/gemcutter/vendor/bundler_gems/gems/railties-3.0.0.beta4/lib/rails/rack/logger.rb in call

  1. class Logger < Rails::LogSubscriber
  2. def initialize(app)
  3. @app = app
    1. end
      11.
    2. def call(env)
    3. before_dispatch(env)
    4. @app.call(env)
    5. ensure
    6. after_dispatch(env)
    7. end
      18.
    8. protected
      20.
    9. def before_dispatch(env)

/usr/lib/ruby/gems/1.8/gems/rack-1.1.0/lib/rack/runtime.rb in call

  1. @app = app
  2. @header_name = "X-Runtime"
  3. @header_name << "-#{name}" if name
  4. end
    14.
  5. def call(env)
  6. start_time = Time.now
  7. status, headers, body = @app.call(env)
  8. request_time = Time.now - start_time
    19.
  9. if !headers.has_key?(@header_name)
  10. headers[@header_name] = "%0.6f" % request_time
  11. end
    23.
  12. [status, headers, body]

/home/drusellers/dev/gemcutter/vendor/bundler_gems/gems/activesupport-3.0.0.beta4/lib/active_support/cache/strategy/local_cache.rb in call

  1. def initialize(app)
  2. @app = app
  3. end
    69.
  4. def call(env)
  5. Thread.current[:#{thread_local_key}] = LocalStore.new
  6. @app.call(env)
  7. ensure
  8. Thread.current[:#{thread_local_key}] = nil
  9. end
  10. EOS
  11. klass
  12. end
  13. end

/usr/lib/ruby/gems/1.8/gems/rack-1.1.0/lib/rack/lock.rb in call

  1. def initialize(app, lock = Mutex.new)
  2. @app, @lock = app, lock
  3. end
    8.
  4. def call(env)
    1. old, env[FLAG] = env[FLAG], false
    2. @lock.synchronize { @app.call(env) }
    3. ensure
    4. env[FLAG] = old
    5. end
    6. end
    7. end

/usr/lib/ruby/gems/1.8/gems/rack-1.1.0/lib/rack/lock.rb in synchronize

  1. def initialize(app, lock = Mutex.new)
  2. @app, @lock = app, lock
  3. end
    8.
  4. def call(env)
    1. old, env[FLAG] = env[FLAG], false
    2. @lock.synchronize { @app.call(env) }
    3. ensure
    4. env[FLAG] = old
    5. end
    6. end
    7. end

/usr/lib/ruby/gems/1.8/gems/rack-1.1.0/lib/rack/lock.rb in call

  1. def initialize(app, lock = Mutex.new)
  2. @app, @lock = app, lock
  3. end
    8.
  4. def call(env)
    1. old, env[FLAG] = env[FLAG], false
    2. @lock.synchronize { @app.call(env) }
    3. ensure
    4. env[FLAG] = old
    5. end
    6. end
    7. end

/home/drusellers/dev/gemcutter/vendor/bundler_gems/gems/actionpack-3.0.0.beta4/lib/action_dispatch/middleware/static.rb in call

  1. if file_exist?(cached_path)
  2. env['PATH_INFO'] = cached_path
  3. return @file_server.call(env)
  4. end
  5. end
  6. end
    29.
  7. @app.call(env)
  8. end
    32.
  9. private
  10. def file_exist?(path)
  11. full_path = File.join(@file_server.root, ::Rack::Utils.unescape(path))
  12. File.file?(full_path) && File.readable?(full_path)
  13. end

/home/drusellers/dev/gemcutter/vendor/bundler_gems/gems/railties-3.0.0.beta4/lib/rails/application.rb in call

  1. @app ||= begin
  2. config.middleware = config.middleware.merge_into(default_middleware_stack)
  3. config.middleware.build(routes)
  4. end
  5. end
    143.
  6. def call(env)
  7. app.call(env.reverse_merge!(env_defaults))
  8. end
    147.
  9. def env_defaults
  10. @env_defaults ||= {
  11. "action_dispatch.parameter_filter" => config.filter_parameters,
  12. "action_dispatch.secret_token" => config.secret_token
  13. }

/home/drusellers/dev/gemcutter/vendor/bundler_gems/gems/railties-3.0.0.beta4/lib/rails/application.rb in send

  1. def respond_to?(*args)
  2. super || instance.respond_to?(*args)
  3. end
    77.
  4. protected
    79.
  5. def method_missing(*args, &block)
  6. instance.send(*args, &block)
  7. end
  8. end
    84.
  9. delegate :middleware, :to => :config
    86.
  10. def add_lib_to_load_paths!
  11. path = config.root.join('lib').to_s

/home/drusellers/dev/gemcutter/vendor/bundler_gems/gems/railties-3.0.0.beta4/lib/rails/application.rb in method_missing

  1. def respond_to?(*args)
  2. super || instance.respond_to?(*args)
  3. end
    77.
  4. protected
    79.
  5. def method_missing(*args, &block)
  6. instance.send(*args, &block)
  7. end
  8. end
    84.
  9. delegate :middleware, :to => :config
    86.
  10. def add_lib_to_load_paths!
  11. path = config.root.join('lib').to_s

/home/drusellers/dev/gemcutter/vendor/bundler_gems/gems/railties-3.0.0.beta4/lib/rails/rack/log_tailer.rb in call

  1. @cursor = ::File.size(path)
  2. @last_checked = Time.now.to_f
    10.
    1. @file = ::File.open(path, 'r')
    2. end
      13.
    3. def call(env)
    4. response = @app.call(env)
    5. tail!
    6. response
    7. end
      19.
    8. def tail!
    9. @file.seek @cursor
      22.

/usr/lib/ruby/gems/1.8/gems/rack-1.1.0/lib/rack/content_length.rb in call

  1. include Rack::Utils
    7.
  2. def initialize(app)
  3. @app = app
    1. end
      11.
    2. def call(env)
    3. status, headers, body = @app.call(env)
    4. headers = HeaderHash.new(headers)
      15.
    5. if !STATUS_WITH_NO_ENTITY_BODY.include?(status) &&
    6. !headers['Content-Length'] &&
    7. !headers['Transfer-Encoding'] &&
    8. (body.respond_to?(:to_ary) || body.respond_to?(:to_str))
      20.

/usr/lib/ruby/gems/1.8/gems/rack-1.1.0/lib/rack/handler/webrick.rb in service

  1. env["QUERY_STRING"] ||= ""
  2. env["REQUEST_PATH"] ||= "/"
  3. unless env["PATH_INFO"] == ""
  4. path, n = req.request_uri.path, env["SCRIPT_NAME"].length
  5. env["PATH_INFO"] = path[n, path.length-n]
  6. end
    47.
  7. status, headers, body = @app.call(env)
  8. begin
  9. res.status = status.to_i
  10. headers.each { |k, vs|
  11. if k.downcase == "set-cookie"
  12. res.cookies.concat vs.split("\n")
  13. else
  14. vs.split("\n").each { |v|

/usr/lib/ruby/1.8/webrick/httpserver.rb in service

  1. servlet, options, script_name, path_info = search_servlet(req.path)
  2. raise HTTPStatus::NotFound, "`#{req.path}' not found." unless servlet
    1. req.script_name = script_name
    2. req.path_info = path_info
    3. si = servlet.get_instance(self, *options)
    4. @logger.debug(format("%s is invoked.", si.class.name))
    5. si.service(req, res)
    6. end
      106.
    7. def do_OPTIONS(req, res)
    8. res["allow"] = "GET,HEAD,POST,OPTIONS"
    9. end
      110.
    10. def mount(dir, servlet, *options)

/usr/lib/ruby/1.8/webrick/httpserver.rb in run

  1. res.request_uri = req.request_uri
  2. res.request_http_version = req.http_version
  3. res.keep_alive = req.keep_alive?
  4. server = lookup_server(req) || self
  5. if callback = server[:RequestCallback] || server[:RequestHandler]
  6. callback.call(req, res)
  7. end
  8. server.service(req, res)
  9. rescue HTTPStatus::EOFError, HTTPStatus::RequestTimeout => ex
  10. res.set_error(ex)
  11. rescue HTTPStatus::Error => ex
  12. @logger.error(ex.message)
  13. res.set_error(ex)
  14. rescue HTTPStatus::Status => ex
  15. res.status = ex.code

/usr/lib/ruby/1.8/webrick/server.rb in start_thread

  1. addr = sock.peeraddr
  2. @logger.debug "accept: #{addr[3]}:#{addr[1]}"
  3. rescue SocketError
  4. @logger.debug "accept: "
  5. raise
  6. end
  7. call_callback(:AcceptCallback, sock)
  8. block ? block.call(sock) : run(sock)
  9. rescue Errno::ENOTCONN
  10. @logger.debug "Errno::ENOTCONN raised"
  11. rescue ServerError => ex
  12. msg = "#{ex.class}: #{ex.message}\n\t#{ex.backtrace[0]}"
  13. @logger.error msg
  14. rescue Exception => ex
  15. @logger.error ex

/usr/lib/ruby/1.8/webrick/server.rb in start

  1. msg = "#{ex.class}: #{ex.message}\n\t#{ex.backtrace[0]}"
  2. @logger.error msg
  3. end
  4. return sock
  5. end
    160.
  6. def start_thread(sock, &block)
  7. Thread.start{
  8. begin
  9. Thread.current[:WEBrickSocket] = sock
  10. begin
  11. addr = sock.peeraddr
  12. @logger.debug "accept: #{addr[3]}:#{addr[1]}"
  13. rescue SocketError
  14. @logger.debug "accept: "

/usr/lib/ruby/1.8/webrick/server.rb in start_thread

  1. msg = "#{ex.class}: #{ex.message}\n\t#{ex.backtrace[0]}"
  2. @logger.error msg
  3. end
  4. return sock
  5. end
    160.
  6. def start_thread(sock, &block)
  7. Thread.start{
  8. begin
  9. Thread.current[:WEBrickSocket] = sock
  10. begin
  11. addr = sock.peeraddr
  12. @logger.debug "accept: #{addr[3]}:#{addr[1]}"
  13. rescue SocketError
  14. @logger.debug "accept: "

/usr/lib/ruby/1.8/webrick/server.rb in start

  1. @status = :Running
  2. while @status == :Running
  3. begin
  4. if svrs = IO.select(@listeners, nil, nil, 2.0)
  5. svrs[0].each{|svr|
  6. @tokens.pop # blocks while no token is there.
  7. if sock = accept_client(svr)
  8. th = start_thread(sock, &block)
  9. th[:WEBrickThread] = true
  10. thgroup.add(th)
  11. else
  12. @tokens.push(nil)
    1. end
    2. }
    3. end

/usr/lib/ruby/1.8/webrick/server.rb in each

  1. call_callback(:StartCallback)
    86.
  2. thgroup = ThreadGroup.new
  3. @status = :Running
  4. while @status == :Running
  5. begin
  6. if svrs = IO.select(@listeners, nil, nil, 2.0)
  7. svrs[0].each{|svr|
  8. @tokens.pop # blocks while no token is there.
  9. if sock = accept_client(svr)
  10. th = start_thread(sock, &block)
  11. th[:WEBrickThread] = true
  12. thgroup.add(th)
  13. else
  14. @tokens.push(nil)

/usr/lib/ruby/1.8/webrick/server.rb in start

  1. call_callback(:StartCallback)
    86.
  2. thgroup = ThreadGroup.new
  3. @status = :Running
  4. while @status == :Running
  5. begin
  6. if svrs = IO.select(@listeners, nil, nil, 2.0)
  7. svrs[0].each{|svr|
  8. @tokens.pop # blocks while no token is there.
  9. if sock = accept_client(svr)
  10. th = start_thread(sock, &block)
  11. th[:WEBrickThread] = true
  12. thgroup.add(th)
  13. else
  14. @tokens.push(nil)

/usr/lib/ruby/1.8/webrick/server.rb in start

  1. module WEBrick
    18.
  2. class ServerError < StandardError; end
    20.
  3. class SimpleServer
  4. def SimpleServer.start
  5. yield
  6. end
  7. end
    26.
  8. class Daemon
  9. def Daemon.start
  10. exit!(0) if fork
  11. Process::setsid

/usr/lib/ruby/1.8/webrick/server.rb in start

  1. @listeners += Utils::create_listeners(address, port, @logger)
  2. end
    77.
  3. def start(&block)
  4. raise ServerError, "already started." if @status != :Stop
  5. server_type = @config[:ServerType] || SimpleServer
    81.
  6. server_type.start{
  7. @logger.info \
  8. "#{self.class}#start: pid=#{$$} port=#{@config[:Port]}"
  9. call_callback(:StartCallback)
    86.
  10. thgroup = ThreadGroup.new
  11. @status = :Running
  12. while @status == :Running

/usr/lib/ruby/gems/1.8/gems/rack-1.1.0/lib/rack/handler/webrick.rb in run

  1. class WEBrick < ::WEBrick::HTTPServlet::AbstractServlet
  2. def self.run(app, options={})
  3. options[:BindAddress] = options.delete(:Host) if options[:Host]
    1. server = ::WEBrick::HTTPServer.new(options)
    2. server.mount "/", Rack::Handler::WEBrick, app
    3. trap(:INT) { server.shutdown }
    4. yield server if block_given?
    5. server.start
    6. end
      16.
    7. def initialize(server, app)
    8. super server
    9. @app = Rack::ContentLength.new(app)
    10. end
      21.

/usr/lib/ruby/gems/1.8/gems/rack-1.1.0/lib/rack/server.rb in start

  1. if library = options[:require]
  2. require library
  3. end
    152.
  4. daemonize_app if options[:daemonize]
  5. write_pid if options[:pid]
  6. server.run wrapped_app, options
  7. end
    157.
  8. def server
  9. @_server ||= Rack::Handler.get(options[:server]) || Rack::Handler.default
  10. end
    161.
  11. private

/home/drusellers/dev/gemcutter/vendor/bundler_gems/gems/railties-3.0.0.beta4/lib/rails/commands/server.rb in start

  1. puts "=> Ctrl-C to shutdown server" unless options[:daemonize]
    56.
  2. #Create required tmp directories if not found
  3. %w(cache pids sessions sockets).each do |dir_to_make|
  4. FileUtils.mkdir_p(Rails.root.join('tmp', dir_to_make))
  5. end
    61.
  6. super
  7. ensure
  8. The '-h' option calls exit before @options is set.

  9. If we call 'options' with it unset, we get double help banners.

  10. puts 'Exiting' unless @options && options[:daemonize]
  11. end
    68.
  12. def middleware

/home/drusellers/dev/gemcutter/vendor/bundler_gems/gems/railties-3.0.0.beta4/lib/rails/commands.rb in nil

  1. Rails::Console.start(Rails::Application)
    24.
  2. when 'server'
  3. require 'rails/commands/server'
  4. Rails::Server.new.tap { |server|
  5. require APP_PATH
  6. Dir.chdir(Rails::Application.root)
  7. server.start
  8. }
    32.
  9. when 'dbconsole'
  10. require 'rails/commands/dbconsole'
  11. require APP_PATH
  12. Rails::DBConsole.start(Rails::Application)
    37.

/home/drusellers/dev/gemcutter/vendor/bundler_gems/gems/railties-3.0.0.beta4/lib/rails/commands.rb in tap

  1. require 'rails/commands/console'
  2. require APP_PATH
  3. Rails::Application.require_environment!
  4. Rails::Console.start(Rails::Application)
    24.
  5. when 'server'
  6. require 'rails/commands/server'
  7. Rails::Server.new.tap { |server|
  8. require APP_PATH
  9. Dir.chdir(Rails::Application.root)
  10. server.start
  11. }
    32.
  12. when 'dbconsole'
  13. require 'rails/commands/dbconsole'

/home/drusellers/dev/gemcutter/vendor/bundler_gems/gems/railties-3.0.0.beta4/lib/rails/commands.rb in nil

  1. require 'rails/commands/console'
  2. require APP_PATH
  3. Rails::Application.require_environment!
  4. Rails::Console.start(Rails::Application)
    24.
  5. when 'server'
  6. require 'rails/commands/server'
  7. Rails::Server.new.tap { |server|
  8. require APP_PATH
  9. Dir.chdir(Rails::Application.root)
  10. server.start
  11. }
    32.
  12. when 'dbconsole'
  13. require 'rails/commands/dbconsole'

script/rails in require

  1. #!/usr/bin/env ruby
  2. This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.

  3. APP_PATH = File.expand_path('../../config/application', FILE)
  4. require File.expand_path('../../config/boot', FILE)
  5. require 'rails/commands'

script/rails in nil

  1. #!/usr/bin/env ruby
  2. This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.

  3. APP_PATH = File.expand_path('../../config/application', FILE)
  4. require File.expand_path('../../config/boot', FILE)
  5. require 'rails/commands'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment