stackprof-local 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 8f8fd54db60e2e426abf0db78d9608b3bdf585b6
4
+ data.tar.gz: 459fabb83878576063767797e3eebf6b9fd57967
5
+ SHA512:
6
+ metadata.gz: 01f70ae8bc2a92e540e92250beca18b0d17f1d1b7b0f309bce2b542edd03dccb443826f1a275739e058edf70da61e0d3494c05d967b5f1bc8770113e4d8a7d6f
7
+ data.tar.gz: 548cc93a366b28c1e9e76e306c6c7e468af3f67135d624a1635a434605f9ef9c27145e335a2ea779c1b2372e3df30fb058c7a821d2b913e6004eeb7436f5a7fc
data/.gitignore ADDED
@@ -0,0 +1,14 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.bundle
11
+ *.so
12
+ *.o
13
+ *.a
14
+ mkmf.log
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in stackprof-local.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Strech (Sergey Fedorov)
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,102 @@
1
+ # [stackprof](https://github.com/tmm1/stackprof)-local
2
+
3
+ This gem inpired by two awesome gems:
4
+ [stackprof](https://github.com/tmm1/stackprof) & [stackprof-remote](https://github.com/quirkey/stackprof-remote).
5
+
6
+ Unfortunately it's not always comfortable to read dumps on production machine.
7
+ And you want to copy dump on your local machine and read'em carefully in quiet place.
8
+
9
+ So, what happend if you do so? Something like this:
10
+
11
+ ```bash
12
+ $ stackprof --method Middleware::Runner#call tmp/stackprof/stackprof-wall-14962-1412161559.dump
13
+ Middleware::Runner#call (/home/user/project/shared/bundle/ruby/2.1.0/gems/middleware-0.1.0/lib/middleware/runner.rb:27)
14
+ samples: 0 self (0.0%) / 6123 total (70.7%)
15
+ callers:
16
+ 6123 ( 100.0%) Middleware::Builder#call
17
+ callees (6123 total):
18
+ 6089 ( 99.4%) ThinkingSphinx::Middlewares::StaleIdFilter#call
19
+ 34 ( 0.6%) ThinkingSphinx::Middlewares::SphinxQL#call
20
+ code:
21
+ /Users/me/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/stackprof-0.2.7/lib/stackprof/report.rb:347:in `readlines':
22
+ No such file or directory @ rb_sysopen - /home/user/project/shared/bundle/ruby/2.1.0/gems/middleware-0.1.0/lib/middleware/runner.rb (Errno::ENOENT)
23
+ from /Users/me/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/stackprof-0.2.7/lib/stackprof/report.rb:347:in `source_display'
24
+ from /Users/me/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/stackprof-0.2.7/lib/stackprof/report.rb:265:in `block in print_method'
25
+ from /Users/me/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/stackprof-0.2.7/lib/stackprof/report.rb:238:in `each'
26
+ from /Users/me/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/stackprof-0.2.7/lib/stackprof/report.rb:238:in `print_method'
27
+ from /Users/me/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/stackprof-0.2.7/bin/stackprof:62:in `<top (required)>'
28
+ from /Users/me/.rbenv/versions/2.1.2/bin/stackprof:23:in `load'
29
+ from /Users/me/.rbenv/versions/2.1.2/bin/stackprof:23:in `<main>'
30
+ ```
31
+
32
+ Because dump was made on another machine with another gems path and project path.
33
+
34
+ ## Usage
35
+
36
+ Project specific configuration options stored in project root folder in `.stackprof-local` file,
37
+ and it's looks like `.rspec` configuration file
38
+
39
+ ```
40
+ $ cat /path/to/project/.stackprof-local
41
+ --remote-gems /home/user/project/shared/bundle/ruby/2.1.0/gems
42
+ --remote-project /home/user/project/releases/20141001101534
43
+ --local-gems /Users/me/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems
44
+ --local-project /Users/me/Development/project
45
+ ```
46
+
47
+ stackprof-local provides an interactive pry-based [cli-utility](https://github.com/quirkey/stackprof-remote#cli)
48
+ taken from stackprof-remote
49
+
50
+ ```
51
+ $ stackprof-local-cli tmp/stackprof/stackprof-wall-14962-1412161559.dump
52
+ stackprof> method Middleware::Runner#call
53
+ Middleware::Runner#call (/home/user/project/shared/bundle/ruby/2.1.0/gems/middleware-0.1.0/lib/middleware/runner.rb:27)
54
+ samples: 0 self (0.0%) / 6123 total (70.7%)
55
+ callers:
56
+ 6123 ( 100.0%) Middleware::Builder#call
57
+ callees (6123 total):
58
+ 6089 ( 99.4%) ThinkingSphinx::Middlewares::StaleIdFilter#call
59
+ 34 ( 0.6%) ThinkingSphinx::Middlewares::SphinxQL#call
60
+ code:
61
+ | 1 | module Middleware
62
+ | 2 | # This is a basic runner for middleware stacks. This runner does
63
+ | 3 | # the default expected behavior of running the middleware stacks
64
+ | 4 | # in order, then reversing the order.
65
+ | 5 | class Runner
66
+ | 6 | # A middleware which does nothing
67
+ | 7 | EMPTY_MIDDLEWARE = lambda { |env| }
68
+ | 8 |
69
+ | 9 | # Build a new middleware runner with the given middleware
70
+ | 10 | # stack.
71
+ ...
72
+ ```
73
+
74
+ All of configuration options are available as cli arguments and will override file defined options
75
+
76
+ ```
77
+ $ stackprof-local-cli --remote-gems '/path/to/gems' tmp/stackprof/stackprof-wall-14962-1412161559.dump
78
+ ```
79
+
80
+ ## Installation
81
+
82
+ Add this line to your application's Gemfile:
83
+
84
+ ```ruby
85
+ gem 'stackprof-local'
86
+ ```
87
+
88
+ And then execute:
89
+
90
+ $ bundle
91
+
92
+ Or install it yourself as:
93
+
94
+ $ gem install stackprof-local
95
+
96
+ ## Contributing
97
+
98
+ 1. Fork it ( https://github.com/Strech/stackprof-local/fork )
99
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
100
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
101
+ 4. Push to the branch (`git push origin my-new-feature`)
102
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "stackprof/cli"
4
+ require "stackprof/local"
5
+
6
+ StackProf::Local.configure(ARGV)
7
+ StackProf::CLI.start(ARGV.shift)
@@ -0,0 +1,33 @@
1
+ require "stackprof/local/version"
2
+ require "stackprof/local/configuration"
3
+ require "stackprof/local/source_display"
4
+
5
+ module StackProf
6
+ module Local
7
+ extend self
8
+
9
+ attr_reader :configuration
10
+
11
+ def configure(args)
12
+ @configuration = Configuration.new(args)
13
+ end
14
+
15
+ def localize(file)
16
+ if file.include?(configuration.remote_gems)
17
+ to_local_gems(file)
18
+ else
19
+ to_local_project(file)
20
+ end
21
+ end
22
+
23
+ private
24
+
25
+ def to_local_gems(file)
26
+ file.sub(configuration.remote_gems, configuration.local_gems)
27
+ end
28
+
29
+ def to_local_project(file)
30
+ file.sub(configuration.remote_project, configuration.local_project)
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,40 @@
1
+ require 'erb'
2
+ require 'optparse'
3
+ require 'shellwords'
4
+
5
+ module StackProf
6
+ module Local
7
+ class Configuration
8
+ OPTIONS_FILE = ".stackprof-local".freeze
9
+ ERB_EOUTVAR = "-".freeze
10
+
11
+ attr_reader :local_gems, :local_project
12
+ attr_reader :remote_gems, :remote_project
13
+
14
+ def initialize(args)
15
+ parser.parse!(args_from_options_file)
16
+ parser.parse!(args)
17
+ end
18
+
19
+ private
20
+
21
+ def parser
22
+ OptionParser.new do |parser|
23
+ parser.on('--remote-gems PATH', String) { |path| @remote_gems = path }
24
+ parser.on('--remote-project PATH', String) { |path| @remote_project = path }
25
+ parser.on('--local-gems PATH', String) { |path| @local_gems = path }
26
+ parser.on('--local-project PATH', String) { |path| @local_project = path }
27
+ end
28
+ end
29
+
30
+ def args_from_options_file
31
+ return [] unless File.exist?(OPTIONS_FILE)
32
+ options_file_as_erb_string(OPTIONS_FILE).split(/\n+/).flat_map(&:shellsplit)
33
+ end
34
+
35
+ def options_file_as_erb_string(path)
36
+ ERB.new(File.read(path), nil, ERB_EOUTVAR).result(binding)
37
+ end
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,13 @@
1
+ require "stackprof/report"
2
+
3
+ module StackProf
4
+ module Local
5
+ module SourceDisplay
6
+ def source_display(f, file, lines, range = nil)
7
+ super(f, Local.localize(file), lines, range = nil)
8
+ end
9
+ end
10
+ end
11
+ end
12
+
13
+ StackProf::Report.prepend(StackProf::Local::SourceDisplay)
@@ -0,0 +1,5 @@
1
+ module Stackprof
2
+ module Local
3
+ VERSION = "0.0.1".freeze
4
+ end
5
+ end
@@ -0,0 +1,26 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'stackprof/local/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "stackprof-local"
8
+ spec.version = Stackprof::Local::VERSION
9
+ spec.authors = ["Strech (Sergey Fedorov)"]
10
+ spec.email = ["strech_ftf@mail.ru"]
11
+ spec.summary = "Read stackprof dumps localy"
12
+ spec.description = "Allow read stackprof dump from remote machine on your local machine"
13
+ spec.homepage = "https://github.com/Strech/stackprof-local"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_dependency "stackprof", "= 0.2.7"
22
+ spec.add_dependency "stackprof-remote", "~> 0.0.5"
23
+
24
+ spec.add_development_dependency "bundler", "~> 1.7"
25
+ spec.add_development_dependency "rake", "~> 10.0"
26
+ end
metadata ADDED
@@ -0,0 +1,112 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: stackprof-local
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Strech (Sergey Fedorov)
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-10-02 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: stackprof
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '='
18
+ - !ruby/object:Gem::Version
19
+ version: 0.2.7
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '='
25
+ - !ruby/object:Gem::Version
26
+ version: 0.2.7
27
+ - !ruby/object:Gem::Dependency
28
+ name: stackprof-remote
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 0.0.5
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 0.0.5
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.7'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.7'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '10.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '10.0'
69
+ description: Allow read stackprof dump from remote machine on your local machine
70
+ email:
71
+ - strech_ftf@mail.ru
72
+ executables:
73
+ - stackprof-local-cli
74
+ extensions: []
75
+ extra_rdoc_files: []
76
+ files:
77
+ - ".gitignore"
78
+ - Gemfile
79
+ - LICENSE.txt
80
+ - README.md
81
+ - Rakefile
82
+ - bin/stackprof-local-cli
83
+ - lib/stackprof/local.rb
84
+ - lib/stackprof/local/configuration.rb
85
+ - lib/stackprof/local/source_display.rb
86
+ - lib/stackprof/local/version.rb
87
+ - stackprof-local.gemspec
88
+ homepage: https://github.com/Strech/stackprof-local
89
+ licenses:
90
+ - MIT
91
+ metadata: {}
92
+ post_install_message:
93
+ rdoc_options: []
94
+ require_paths:
95
+ - lib
96
+ required_ruby_version: !ruby/object:Gem::Requirement
97
+ requirements:
98
+ - - ">="
99
+ - !ruby/object:Gem::Version
100
+ version: '0'
101
+ required_rubygems_version: !ruby/object:Gem::Requirement
102
+ requirements:
103
+ - - ">="
104
+ - !ruby/object:Gem::Version
105
+ version: '0'
106
+ requirements: []
107
+ rubyforge_project:
108
+ rubygems_version: 2.2.2
109
+ signing_key:
110
+ specification_version: 4
111
+ summary: Read stackprof dumps localy
112
+ test_files: []