stack_tracy 0.1.8 → 0.1.9

Sign up to get free protection for your applications and to get access to all the features.
data/.travis.yml ADDED
@@ -0,0 +1,8 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.9.3
4
+ - 1.9.2
5
+ - 1.8.7
6
+ - ree
7
+ before_script:
8
+ - cd ~/builds/archan937/stack_tracy/ext/stack_tracy && ruby extconf.rb && make
data/CHANGELOG.rdoc CHANGED
@@ -1,5 +1,9 @@
1
1
  = StackTracy CHANGELOG
2
2
 
3
+ == Version 0.1.9 (September 17, 2012)
4
+
5
+ * Made StackTracy compatible with Ruby 1.8.7 and REE
6
+
3
7
  == Version 0.1.8 (August 30, 2012)
4
8
 
5
9
  * Corrected index.html.erb regarding a possible nil value error
data/Gemfile CHANGED
@@ -14,4 +14,5 @@ group :gem_test do
14
14
  gem "minitest"
15
15
  gem "mocha"
16
16
  gem "pry"
17
+ gem "rake"
17
18
  end
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # StackTracy
1
+ # StackTracy [![Build Status](https://secure.travis-ci.org/archan937/stack_tracy.png)](http://travis-ci.org/archan937/stack_tracy)
2
2
 
3
3
  Investigate and detect slow methods within the stack trace of your Ruby (optionally Sinatra) application
4
4
 
@@ -399,7 +399,7 @@ The StackTracy repo is provided with `script/console` which you can use for deve
399
399
  Run the following command in your console:
400
400
 
401
401
  $ script/console
402
- Loading development environment (StackTracy 0.1.8)
402
+ Loading development environment (StackTracy 0.1.9)
403
403
  [1] pry(main)> stack_tracy :print do
404
404
  [1] pry(main)* puts "testing"
405
405
  [1] pry(main)* end
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.8
1
+ 0.1.9
@@ -6,6 +6,13 @@
6
6
  #include <time.h>
7
7
  #include <string.h>
8
8
 
9
+ #ifndef RUBY_VM
10
+ #include <node.h>
11
+ typedef rb_event_t rb_event_flag_t;
12
+ #define rb_sourcefile() (node ? node->nd_file : 0)
13
+ #define rb_sourceline() (node ? nd_line(node) : 0)
14
+ #endif
15
+
9
16
  typedef struct event_info_t {
10
17
  rb_event_flag_t event;
11
18
  const char *file;
data/lib/stack_tracy.rb CHANGED
@@ -1,5 +1,5 @@
1
+ require RUBY_VERSION == "1.8.7" ? "fastercsv" : "csv"
1
2
  require "erb"
2
- require "csv"
3
3
  require "tmpdir"
4
4
  require "securerandom"
5
5
  require "rich/support/core/string/colorize"
@@ -14,7 +14,7 @@ module StackTracy
14
14
  extend self
15
15
 
16
16
  PRESETS = {
17
- :core => "Array BasicObject Enumerable Fixnum Float Hash IO Integer Kernel Module Mutex Numeric Object Rational String Symbol Thread Time",
17
+ :core => "Array #{"BasicObject " unless RUBY_VERSION == "1.8.7"}Enumerable Fixnum Float Hash IO Integer Kernel Module #{"Mutex " unless RUBY_VERSION == "1.8.7"}Numeric Object Rational String Symbol Thread Time",
18
18
  :active_record => "ActiveRecord::Base",
19
19
  :data_mapper => "DataMapper::Resource"
20
20
  }
@@ -74,7 +74,7 @@ module StackTracy
74
74
  File.expand_path(path).tap do |path|
75
75
  bool = dump_source_location.nil? ? @options[:dump_source_location] : dump_source_location
76
76
  keys = [:event, (:file if bool), (:line if bool), :singleton, :object, :method, :nsec, :time, :call, :depth, :duration]
77
- CSV.open(path, "w", :col_sep => ";") do |file|
77
+ (RUBY_VERSION == "1.8.7" ? FasterCSV : CSV).open(path, "w", :col_sep => ";") do |file|
78
78
  file << keys
79
79
  select(only).each do |event|
80
80
  file << event.values_at(*keys)
@@ -7,7 +7,7 @@ module StackTracy
7
7
  attr_reader :event, :file, :line, :singleton, :object, :method, :nsec
8
8
 
9
9
  def self.to_hashes(csv)
10
- CSV.parse(csv.force_encoding("ISO-8859-1").encode("utf-8", replace: nil), :headers => true, :col_sep => ";").collect do |row|
10
+ CSV.parse(csv.force_encoding("ISO-8859-1").encode("utf-8", {:replace => nil}), :headers => true, :col_sep => ";").collect do |row|
11
11
  {
12
12
  :event => row[0] , :file => row[1] , :line => row[2].to_i, :singleton => row[3] == "true", :object => row[4] , :method => row[5],
13
13
  :nsec => row[6].to_f, :time => row[7].to_f, :call => row[8] , :depth => row[9].to_i , :duration => row[10].to_f
@@ -1,7 +1,7 @@
1
1
  module StackTracy #:nodoc:
2
2
  MAJOR = 0
3
3
  MINOR = 1
4
- TINY = 8
4
+ TINY = 9
5
5
 
6
6
  VERSION = [MAJOR, MINOR, TINY].join(".")
7
7
  end
data/stack_tracy.gemspec CHANGED
@@ -13,9 +13,10 @@ Gem::Specification.new do |gem|
13
13
  gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
14
14
  gem.name = "stack_tracy"
15
15
  gem.require_paths = ["lib"]
16
- gem.version = "0.1.8"
16
+ gem.version = "0.1.9"
17
17
 
18
18
  gem.add_dependency "rich_support", "~> 0.1.2"
19
19
  gem.add_dependency "launchy", "2.1.0"
20
20
  gem.add_dependency "thor"
21
+ gem.add_dependency "fastercsv"
21
22
  end
@@ -11,6 +11,14 @@ module Unit
11
11
  end
12
12
  end
13
13
 
14
+ def correct(array)
15
+ if RUBY_VERSION == "1.8.7"
16
+ array.delete_if{|x| x[:call] == "IO#puts"}
17
+ array.each{|x| x[:depth] -= 1 if x[:depth] && x[:call] == "IO#write"}
18
+ end
19
+ array
20
+ end
21
+
14
22
  it "should respond to methods as expected" do
15
23
  assert StackTracy.respond_to?(:config)
16
24
  assert StackTracy.respond_to?(:start)
@@ -25,7 +33,7 @@ module Unit
25
33
  it "should be configurable" do
26
34
  StackTracy.config do |c|
27
35
  assert_equal true, c.is_a?(Struct)
28
- assert_equal [:dump_dir, :dump_source_location, :limit, :threshold, :messages_only, :slows_only, :only, :exclude], c.members
36
+ assert_equal %w(dump_dir dump_source_location limit threshold messages_only slows_only only exclude), c.members.collect(&:to_s)
29
37
  c.only = "Kernel"
30
38
  c.exclude = ["IO", "String"]
31
39
  end
@@ -36,10 +44,17 @@ module Unit
36
44
  assert_equal({:only => "Paul", :exclude => "Foo"}, StackTracy.send(:merge_options, {"only" => "Paul", "exclude" => "Foo"}))
37
45
  assert_equal({:only => nil, :exclude => nil}, StackTracy.send(:merge_options, {:only => nil, :exclude => nil}))
38
46
 
39
- assert_equal(
40
- "Array BasicObject Enumerable Fixnum Float Foo Hash IO Integer Kernel Module Mutex Numeric Object Rational String Symbol Thread Time",
41
- StackTracy.send(:mod_names, [:core, "Foo"])
42
- )
47
+ if RUBY_VERSION == "1.8.7"
48
+ assert_equal(
49
+ "Array Enumerable Fixnum Float Foo Hash IO Integer Kernel Module Numeric Object Rational String Symbol Thread Time",
50
+ StackTracy.send(:mod_names, [:core, "Foo"]).strip
51
+ )
52
+ else
53
+ assert_equal(
54
+ "Array BasicObject Enumerable Fixnum Float Foo Hash IO Integer Kernel Module Mutex Numeric Object Rational String Symbol Thread Time",
55
+ StackTracy.send(:mod_names, [:core, "Foo"])
56
+ )
57
+ end
43
58
 
44
59
  assert_equal(
45
60
  "ActiveRecord::Base",
@@ -59,7 +74,7 @@ module Unit
59
74
  file, line = __FILE__, __LINE__ - 2
60
75
  st = File.expand_path("../../../lib/stack_tracy.rb", __FILE__)
61
76
 
62
- assert_equal [
77
+ assert_equal correct([
63
78
  {:event => "c-call" , :file => file, :line => line, :singleton => false, :object => Kernel , :method => "puts" , :call => "Kernel#puts" },
64
79
  {:event => "c-call" , :file => file, :line => line, :singleton => false, :object => IO , :method => "puts" , :call => "IO#puts" },
65
80
  {:event => "c-call" , :file => file, :line => line, :singleton => false, :object => IO , :method => "write", :call => "IO#write" },
@@ -70,7 +85,7 @@ module Unit
70
85
  {:event => "c-return", :file => file, :line => line, :singleton => false, :object => Kernel , :method => "puts" , :call => "Kernel#puts" },
71
86
  {:event => "call" , :file => st , :line => 35 , :singleton => false, :object => StackTracy, :method => "stop" , :call => "StackTracy#stop" },
72
87
  {:event => "c-call" , :file => st , :line => 36 , :singleton => 0 , :object => StackTracy, :method => "_stop", :call => "StackTracy._stop"}
73
- ], StackTracy.stack_trace.collect{ |event_info|
88
+ ]), StackTracy.stack_trace.collect{ |event_info|
74
89
  event_info.to_hash.tap do |hash|
75
90
  assert hash.delete(:nsec)
76
91
  hash.delete(:time)
@@ -116,12 +131,12 @@ module Unit
116
131
  end
117
132
  file, line = __FILE__, __LINE__ - 2
118
133
 
119
- assert_equal [
134
+ assert_equal correct([
120
135
  {:event => "c-call" , :file => file, :line => line, :singleton => false, :object => Kernel, :method => "puts" , :call => "Kernel#puts", :depth => 0},
121
136
  {:event => "c-call" , :file => file, :line => line, :singleton => false, :object => IO , :method => "puts" , :call => "IO#puts" , :depth => 1},
122
137
  {:event => "c-call" , :file => file, :line => line, :singleton => false, :object => IO , :method => "write", :call => "IO#write" , :depth => 2},
123
138
  {:event => "c-call" , :file => file, :line => line, :singleton => false, :object => IO , :method => "write", :call => "IO#write" , :depth => 2}
124
- ], StackTracy.select.collect{ |event_info|
139
+ ]), StackTracy.select.collect{ |event_info|
125
140
  event_info.to_hash.tap do |hash|
126
141
  assert hash.delete(:nsec)
127
142
  assert hash.delete(:duration)
@@ -213,12 +228,12 @@ module Unit
213
228
  end
214
229
  file, line = __FILE__, __LINE__ - 2
215
230
 
216
- assert_equal [
231
+ assert_equal correct([
217
232
  {:event => "c-call", :file => file, :line => line, :singleton => false, :object => Kernel, :method => "puts" , :call => "Kernel#puts", :depth => 0},
218
233
  {:event => "c-call", :file => file, :line => line, :singleton => false, :object => IO , :method => "puts" , :call => "IO#puts" , :depth => 1},
219
234
  {:event => "c-call", :file => file, :line => line, :singleton => false, :object => IO , :method => "write", :call => "IO#write" , :depth => 2},
220
235
  {:event => "c-call", :file => file, :line => line, :singleton => false, :object => IO , :method => "write", :call => "IO#write" , :depth => 2}
221
- ], StackTracy.select("*").collect{ |event_info|
236
+ ]), StackTracy.select("*").collect{ |event_info|
222
237
  event_info.to_hash.tap do |hash|
223
238
  assert hash.delete(:nsec)
224
239
  assert hash.delete(:duration)
@@ -236,11 +251,11 @@ module Unit
236
251
  end
237
252
  }
238
253
 
239
- assert_equal [
254
+ assert_equal correct([
240
255
  {:event => "c-call", :file => file, :line => line, :singleton => false, :object => IO, :method => "puts" , :call => "IO#puts" , :depth => 0},
241
256
  {:event => "c-call", :file => file, :line => line, :singleton => false, :object => IO, :method => "write", :call => "IO#write", :depth => 1},
242
257
  {:event => "c-call", :file => file, :line => line, :singleton => false, :object => IO, :method => "write", :call => "IO#write", :depth => 1}
243
- ], StackTracy.select("IO").collect{ |event_info|
258
+ ]), StackTracy.select("IO").collect{ |event_info|
244
259
  event_info.to_hash.tap do |hash|
245
260
  assert hash.delete(:nsec)
246
261
  assert hash.delete(:duration)
@@ -248,11 +263,11 @@ module Unit
248
263
  end
249
264
  }
250
265
 
251
- assert_equal [
266
+ assert_equal correct([
252
267
  {:event => "c-call", :file => file, :line => line, :singleton => false, :object => IO, :method => "puts" , :call => "IO#puts" , :depth => 0},
253
268
  {:event => "c-call", :file => file, :line => line, :singleton => false, :object => IO, :method => "write", :call => "IO#write", :depth => 1},
254
269
  {:event => "c-call", :file => file, :line => line, :singleton => false, :object => IO, :method => "write", :call => "IO#write", :depth => 1}
255
- ], StackTracy.select("IO*").collect{ |event_info|
270
+ ]), StackTracy.select("IO*").collect{ |event_info|
256
271
  event_info.to_hash.tap do |hash|
257
272
  assert hash.delete(:nsec)
258
273
  assert hash.delete(:duration)
@@ -265,11 +280,11 @@ module Unit
265
280
  event_info.to_hash
266
281
  }
267
282
 
268
- assert_equal [
283
+ assert_equal correct([
269
284
  {:event => "c-call", :file => file, :line => line, :singleton => false, :object => IO, :method => "puts" , :call => "IO#puts" , :depth => 0},
270
285
  {:event => "c-call", :file => file, :line => line, :singleton => false, :object => IO, :method => "write", :call => "IO#write", :depth => 1},
271
286
  {:event => "c-call", :file => file, :line => line, :singleton => false, :object => IO, :method => "write", :call => "IO#write", :depth => 1}
272
- ], StackTracy.select("IO#").collect{ |event_info|
287
+ ]), StackTracy.select("IO#").collect{ |event_info|
273
288
  event_info.to_hash.tap do |hash|
274
289
  assert hash.delete(:nsec)
275
290
  assert hash.delete(:duration)
@@ -299,10 +314,10 @@ module Unit
299
314
  end
300
315
  }
301
316
 
302
- assert_equal [
317
+ assert_equal correct([
303
318
  {:event => "c-call", :file => file, :line => line, :singleton => false, :object => Kernel, :method => "puts", :call => "Kernel#puts", :depth => 0},
304
319
  {:event => "c-call", :file => file, :line => line, :singleton => false, :object => IO , :method => "puts", :call => "IO#puts" , :depth => 1}
305
- ], StackTracy.select("*#puts").collect{ |event_info|
320
+ ]), StackTracy.select("*#puts").collect{ |event_info|
306
321
  event_info.to_hash.tap do |hash|
307
322
  assert hash.delete(:nsec)
308
323
  assert hash.delete(:duration)
@@ -22,7 +22,7 @@ StackTracy = (function() {
22
22
  });
23
23
 
24
24
  return {
25
- version: "0.1.8",
25
+ version: "0.1.9",
26
26
  sort: function(section, column) {
27
27
  sortation[section][column] = sortation[section][column] == "asc" ? "desc" : "asc";
28
28
  $("#" + section + ">.body>div").tsort("span:eq(" + column + ")[abbr]", {
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: stack_tracy
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.1.8
5
+ version: 0.1.9
6
6
  platform: ruby
7
7
  authors:
8
8
  - Paul Engel
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2012-08-30 00:00:00 Z
13
+ date: 2012-09-16 00:00:00 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rich_support
@@ -45,6 +45,17 @@ dependencies:
45
45
  version: "0"
46
46
  type: :runtime
47
47
  version_requirements: *id003
48
+ - !ruby/object:Gem::Dependency
49
+ name: fastercsv
50
+ prerelease: false
51
+ requirement: &id004 !ruby/object:Gem::Requirement
52
+ none: false
53
+ requirements:
54
+ - - ">="
55
+ - !ruby/object:Gem::Version
56
+ version: "0"
57
+ type: :runtime
58
+ version_requirements: *id004
48
59
  description: Investigate and detect slow methods within the stack trace of your Ruby (optionally Sinatra) application
49
60
  email:
50
61
  - paul.engel@holder.nl
@@ -56,6 +67,7 @@ extra_rdoc_files: []
56
67
 
57
68
  files:
58
69
  - .gitignore
70
+ - .travis.yml
59
71
  - CHANGELOG.rdoc
60
72
  - Gemfile
61
73
  - MIT-LICENSE