Permalink
Browse files

Added tour_proxy; yardoc

  • Loading branch information...
1 parent 784675b commit b53025b0e087ed22147feff32b319194aca55bbd @dbrady committed Sep 23, 2010
Showing with 152 additions and 0 deletions.
  1. +8 −0 .yardoc/checksums
  2. BIN .yardoc/objects/File.dat
  3. BIN .yardoc/objects/File/here_c.dat
  4. BIN .yardoc/objects/Runner.dat
  5. BIN .yardoc/objects/Runner/host_i.dat
  6. BIN .yardoc/objects/Runner/initialize_i.dat
  7. BIN .yardoc/objects/Runner/log_i.dat
  8. BIN .yardoc/objects/Runner/number_i.dat
  9. BIN .yardoc/objects/Runner/run_tourists_i.dat
  10. BIN .yardoc/objects/Runner/runner_id_i.dat
  11. BIN .yardoc/objects/Runner/runner_type_i.dat
  12. BIN .yardoc/objects/Runner/tour_limited_to_i.dat
  13. BIN .yardoc/objects/Runner/tourists_i.dat
  14. BIN .yardoc/objects/TOURBUS_LIB_PATH.dat
  15. BIN .yardoc/objects/TourBus.dat
  16. BIN .yardoc/objects/TourBus/benchmarks_i.dat
  17. BIN .yardoc/objects/TourBus/concurrency_i.dat
  18. BIN .yardoc/objects/TourBus/errors_i.dat
  19. BIN .yardoc/objects/TourBus/fails_i.dat
  20. BIN .yardoc/objects/TourBus/host_i.dat
  21. BIN .yardoc/objects/TourBus/initialize_i.dat
  22. BIN .yardoc/objects/TourBus/log_i.dat
  23. BIN .yardoc/objects/TourBus/next_runner_id_i.dat
  24. BIN .yardoc/objects/TourBus/number_i.dat
  25. BIN .yardoc/objects/TourBus/passes_i.dat
  26. BIN .yardoc/objects/TourBus/run_i.dat
  27. BIN .yardoc/objects/TourBus/runners_i.dat
  28. BIN .yardoc/objects/TourBus/runs_i.dat
  29. BIN .yardoc/objects/TourBus/tests_i.dat
  30. BIN .yardoc/objects/TourBus/total_runs_i.dat
  31. BIN .yardoc/objects/TourBus/tourists_i.dat
  32. BIN .yardoc/objects/TourBus/update_benchmarks_i.dat
  33. BIN .yardoc/objects/TourBus/update_stats_i.dat
  34. BIN .yardoc/objects/TourBusException.dat
  35. BIN .yardoc/objects/TourProxy.dat
  36. BIN .yardoc/objects/TourProxy/dump_request_i.dat
  37. BIN .yardoc/objects/TourProxy/dump_response_i.dat
  38. BIN .yardoc/objects/TourProxy/initialize_i.dat
  39. BIN .yardoc/objects/TourProxy/log_request_as_webrat_i.dat
  40. BIN .yardoc/objects/TourProxy/run_server_21_c.dat
  41. BIN .yardoc/objects/TourProxy/shutdown_i.dat
  42. BIN .yardoc/objects/TourProxy/start_i.dat
  43. BIN .yardoc/objects/TourRat.dat
  44. BIN .yardoc/objects/TourRat/ClassMethods.dat
  45. BIN .yardoc/objects/TourRat/InstanceMethods.dat
  46. BIN .yardoc/objects/TourRat/included_c.dat
  47. BIN .yardoc/objects/TourWatch.dat
  48. BIN .yardoc/objects/TourWatch/bargraph_i.dat
  49. BIN .yardoc/objects/TourWatch/fields_i.dat
  50. BIN .yardoc/objects/TourWatch/fields_linux_i.dat
  51. BIN .yardoc/objects/TourWatch/fields_mac_i.dat
  52. BIN .yardoc/objects/TourWatch/initialize_i.dat
  53. BIN .yardoc/objects/TourWatch/log_i.dat
  54. BIN .yardoc/objects/TourWatch/processes_i.dat
  55. BIN .yardoc/objects/TourWatch/run_i.dat
  56. BIN .yardoc/objects/TourWatch/stats_i.dat
  57. BIN .yardoc/objects/TourWatch/top_linux_i.dat
  58. BIN .yardoc/objects/TourWatch/top_mac_i.dat
  59. BIN .yardoc/objects/Tourist.dat
  60. BIN .yardoc/objects/Tourist/after_tours_i.dat
  61. BIN .yardoc/objects/Tourist/before_tours_i.dat
  62. BIN .yardoc/objects/Tourist/host_i.dat
  63. BIN .yardoc/objects/Tourist/initialize_i.dat
  64. BIN .yardoc/objects/Tourist/log_i.dat
  65. BIN .yardoc/objects/Tourist/make_tourist_c.dat
  66. BIN .yardoc/objects/Tourist/number_i.dat
  67. BIN .yardoc/objects/Tourist/run_tour_i.dat
  68. BIN .yardoc/objects/Tourist/session_i.dat
  69. BIN .yardoc/objects/Tourist/setup_i.dat
  70. BIN .yardoc/objects/Tourist/teardown_i.dat
  71. BIN .yardoc/objects/Tourist/tour_type_i.dat
  72. BIN .yardoc/objects/Tourist/tourist_3F_c.dat
  73. BIN .yardoc/objects/Tourist/tourist_id_i.dat
  74. BIN .yardoc/objects/Tourist/tourists_c.dat
  75. BIN .yardoc/objects/Tourist/tours_c.dat
  76. BIN .yardoc/objects/Tourist/tours_i.dat
  77. BIN .yardoc/objects/Tourist/wait_i.dat
  78. BIN .yardoc/objects/WebratError.dat
  79. BIN .yardoc/objects/require_all_files_in_folder_i.dat
  80. BIN .yardoc/objects/root.dat
  81. BIN .yardoc/proxy_types
  82. +10 −0 bin/tourproxy
  83. +11 −0 lib/file.rb
  84. +82 −0 lib/tour_proxy.rb
  85. +19 −0 spec/lib/tourproxy_spec.rb
  86. +22 −0 spec/spec_helper.rb
View
@@ -0,0 +1,8 @@
+lib/tour_rat.rb 0499f31e2256d338ed68dd385b9b48b397a33e1b
+lib/tourist.rb 795cdf5075cd728d4e1665705335fcd099a246d6
+lib/tour_watch.rb cdcbd2189992948dd9b769bd0b947feabe228834
+lib/tour_proxy.rb 7635591d97ddf885d70f8e2dc02d20f4d8ac758f
+lib/runner.rb df2672b86c3350e0db38cb10a750bc5e1227778e
+lib/file.rb 97d45fcd028220b74be47a7af3deb3432ad48f1d
+lib/tour_bus.rb 5b787c820bd8bd2656d65b2eec576167f7a47ec4
+lib/common.rb c61e96662d25eabc72ae81caa96b5c19c489cd7e
View
Binary file not shown.
Binary file not shown.
View
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
View
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
View
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
View
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
View
Binary file not shown.
View
Binary file not shown.
View
@@ -0,0 +1,10 @@
+#!/usr/bin/env ruby
+# This proxy logger logs x-amf traffic, and is stolen with gratitude from http://altentee.com/2008/performance-testing-flex-remoting-amf-with-jmeter/
+
+require File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib', 'tour_proxy'))
+
+options = {}
+
+proxy = TourProxy.new options
+trap "INT" do proxy.shutdown end
+proxy.start
View
@@ -0,0 +1,11 @@
+class File
+ # Hides all that lovely expand/join/dirname(__FILE__, path) crap
+ #
+ # E.g.: require File.here("../lib/pants")
+ #
+ # Splatty version for the OS Agnosts out there:
+ # require File.here(%w[.. lib pants])
+ def self.here(*args)
+ p = File.expand_path(File.join(File.dirname(caller.first.split(':')[0]), *args))
+ end
+end
View
@@ -0,0 +1,82 @@
+require 'webrick/httpproxy'
+require 'ruby-debug'
+
+class TourProxy
+ # Initialize the proxy object.
+ #
+ # @param [Hash] options list of options to configure the proxy.
+ # @option options [Fixnum] :port Port number to listen on
+ # @option options [Hash] :hostnames hostnames by name => url
+ # @option options [IO] :output_buffer IO object to write output to
+ def initialize(options={})
+ @server = nil
+ @output_buffer = options[:output_buffer] || STDOUT
+ @server = WEBrick::HTTPProxyServer.new(
+ :Port => options[:port] || 8080,
+ :RequestCallback => Proc.new do |req,res|
+ log_request_as_webrat(req)
+ # dump_request(req)
+ puts(("<" * 100) + " END CALLBACK")
+ end
+ )
+ end
+
+ def log_request_as_webrat(request)
+ return unless @output_buffer
+ puts "> log_request_as_webrat"
+ body = request.body
+ if body
+ items = body.split(/&/)
+ pairs = items.map{ |e| e.split(/=/,2)}
+ hash = Hash[pairs]
+ @output_buffer.puts "visit '#{request.request_uri}', :#{request.request_method.downcase}, #{hash.inspect}"
+ else
+ @output_buffer.puts "visit '#{request.request_uri}', :#{request.request_method.downcase}"
+ end
+ puts "< log_request_as_webrat"
+ end
+
+ # Dumps an HTTPRequest object
+ def dump_request(request)
+ return unless @output_buffer
+ puts "> dump_request"
+ terms = %w(request_uri request_line raw_header body)
+ longest = terms.map(&:size).max
+
+ @output_buffer.puts '-' * 80
+ @output_buffer.puts "Request:"
+ terms.each do |term|
+ @output_buffer.puts " %#{longest}s:" % [term] # , request.send(term).to_s.length]
+ end
+ @output_buffer.puts '-' * 80
+ @output_buffer.flush
+ puts "< dump_request"
+ end
+
+ # Dumps an HTTPResponse object
+ def dump_response(response)
+ return unless @output_buffer
+ puts "> dump_response"
+ terms = %w()
+ longest = terms.map(&:size).max
+
+ @output_buffer.puts '-' * 80
+ @output_buffer.puts "Response:"
+ terms.each do |term|
+ @output_buffer.puts " %#{longest}s: %s" % [term, response.send(term).to_s]
+ end
+ @output_buffer.puts '-' * 80
+ @output_buffer.flush
+ puts "< dump_response"
+ end
+
+ def start
+ @server.start
+ end
+
+ def shutdown
+ @server.shutdown
+ end
+end
+
+
View
@@ -0,0 +1,19 @@
+require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
+
+describe TourProxy do
+ it "should replace known hostnames"
+ # given a list of known hostnames,
+ # when I process a request matching a hosts,
+ # then the request uri should be rewritten with the variable's expansion
+
+ it "should emit AMF blobs"
+ it "should emit get/post blobs for unrecognized types"
+
+ # when doing an html get
+ # with no params
+ # it should log "visit 'url'"
+ # and should not log "visit 'url', :get" etc
+
+
+end
+
View
@@ -0,0 +1,22 @@
+# This file is copied to ~/spec when you run 'ruby script/generate rspec'
+# from the project root directory.
+require File.expand_path(File.join(File.dirname(__FILE__), '../lib/file'))
+require 'spec/autorun'
+require 'ruby-debug'
+# require File.here('../features/factories/fixjour_definitions')
+# require File.here('../test/bdrb_test_helper')
+
+# Requires all files in a folder relative to .. (project root).
+def require_all_files_in_folder(folder, extension = '*.rb')
+ for file in Dir[File.join(File.expand_path(File.dirname(__FILE__)), '..', folder, "**/#{extension}")]
+ require file
+ end
+end
+
+# Uncomment the next line to use webrat's matchers
+#require 'webrat/integrations/rspec-rails'
+
+# Requires supporting files with custom matchers and macros, etc,
+# in ./support/ and its subdirectories.
+require_all_files_in_folder "spec/support"
+require_all_files_in_folder "lib"

0 comments on commit b53025b

Please sign in to comment.