Module: Pry::Stackprofiler
- Defined in:
- lib/pry-stackprofiler.rb
Class Method Summary collapse
Class Method Details
.profile(opts = {}, &blk) ⇒ Object
19 20 21 22 23 24 25 |
# File 'lib/pry-stackprofiler.rb', line 19 def profile opts={}, &blk # todo: pass through options perhaps? opts.merge!({mode: :wall, raw: true}) @last_profile = StackProfx.run(opts) { blk.call } @blk_obj_id = RubyVM::InstructionSequence::of(blk).object_id @needs_send = true end |
.try_send ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/pry-stackprofiler.rb', line 27 def try_send return unless @needs_send @needs_send = false pry_file = Pry.line_buffer.join @last_profile[:files] = {'(pry)' => pry_file} @last_profile[:suggested_rebase] = @blk_obj_id url = URI::parse ui_url headers = {'Content-Type' => 'application/x-ruby-marshal'} req = Net::HTTP::Post.new(url.to_s, headers) req.body = Marshal.dump @last_profile response = Net::HTTP.new(url.host, url.port).start {|http| http.request(req) } end |
.ui_url ⇒ Object
43 44 45 |
# File 'lib/pry-stackprofiler.rb', line 43 def ui_url Pry.config.pry_stackprofiler_ui_url ||= ENV['PRY_STACKPROFILER_UI_URL'] end |