squash_ruby 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/lib/squash/ruby.rb +58 -9
  2. metadata +32 -18
data/lib/squash/ruby.rb CHANGED
@@ -351,7 +351,11 @@ module Squash
351
351
  environment_data.merge(top_level_user_data).merge(
352
352
  'class_name' => exception.class.to_s,
353
353
  'message' => exception.to_s,
354
- 'backtraces' => [["Active Thread/Fiber", true, prepare_backtrace(exception.backtrace)]],
354
+ 'backtraces' => [{
355
+ 'name' => "Active Thread/Fiber",
356
+ 'faulted' => true,
357
+ 'backtrace' => prepare_backtrace(exception.backtrace)
358
+ }],
355
359
  'occurred_at' => occurred,
356
360
  'revision' => current_revision,
357
361
 
@@ -365,7 +369,11 @@ module Squash
365
369
  'parent_exceptions' => parents.nil? ? nil : parents.map do |parent|
366
370
  {'class_name' => parent.class.to_s,
367
371
  'message' => parent.to_s,
368
- 'backtraces' => [["Active Thread/Fiber", true, prepare_backtrace(parent.backtrace)]],
372
+ 'backtraces' => [{
373
+ 'name' => "Active Thread/Fiber",
374
+ 'faulted' => true,
375
+ 'backtrace' => prepare_backtrace(parent.backtrace)
376
+ }],
369
377
  'association' => 'original_exception',
370
378
  'ivars' => instance_variable_hash(parent)}
371
379
  end
@@ -377,7 +385,13 @@ module Squash
377
385
  bt.map do |element|
378
386
  if element =~ /^((?:[a-z0-9_$]+\.)*(?:[a-z0-9_$]+))\.(\w+)\((\w+.java):(\d+)\)$/i
379
387
  # special JRuby backtrace element of the form "org.jruby.RubyHash$27.visit(RubyHash.java:1646)"
380
- ['_JAVA_', $3, $4.to_i, $2, $1]
388
+ {
389
+ 'type' => 'obfuscated',
390
+ 'file' => $3,
391
+ 'line' => $4.to_i,
392
+ 'symbol' => $2,
393
+ 'class' => $1
394
+ }
381
395
  else
382
396
  if element.include?(' at ')
383
397
  method, fileline = element.split(' at ')
@@ -399,11 +413,21 @@ module Squash
399
413
 
400
414
  # it could still be a java backtrace, even if it's not the special format
401
415
  if file[-5, 5] == '.java'
402
- ['_JAVA_', file.split('/').last, line, method, file.sub(/\.java$/, '').gsub('/', '.')]
416
+ {
417
+ 'type' => 'obfuscated',
418
+ 'file' => file.split('/').last,
419
+ 'line' => line,
420
+ 'symbol' => method,
421
+ 'class' => file.sub(/\.java$/, '').gsub('/', '.')
422
+ }
403
423
  else
404
424
  # ok now we're sure it's a ruby backtrace
405
425
  file.slice! 0, configuration(:project_root).length + 1 if file[0, configuration(:project_root).length + 1] == configuration(:project_root) + '/'
406
- [file, line, method]
426
+ {
427
+ 'file' => file,
428
+ 'line' => line,
429
+ 'symbol' => method
430
+ }
407
431
  end
408
432
  end
409
433
  end
@@ -419,7 +443,11 @@ module Squash
419
443
  method = $1
420
444
  end
421
445
  method = nil if method && method.empty?
422
- [file, line, method]
446
+ {
447
+ 'file' => file,
448
+ 'line' => line,
449
+ 'symbol' => method
450
+ }
423
451
  end
424
452
  end
425
453
  end
@@ -433,12 +461,14 @@ module Squash
433
461
  instance.map { |i| valueify(i) }
434
462
  else
435
463
  filtered = value_filter(instance)
464
+ yaml = begin filtered.to_yaml; rescue Exception; nil end
465
+ json = begin filtered.to_json; rescue Exception; nil end
436
466
  {
437
467
  'language' => 'ruby',
438
468
  'class_name' => filtered.class.to_s,
439
469
  'inspect' => filtered.inspect,
440
- 'yaml' => (filtered.to_yaml rescue nil),
441
- 'json' => (filtered.to_json rescue nil),
470
+ 'yaml' => yaml,
471
+ 'json' => json,
442
472
  'to_s' => (filtered.to_s rescue nil)
443
473
  }
444
474
  end
@@ -506,7 +536,26 @@ module Squash
506
536
  head_file = File.join(configuration(:repository_root), '.git', 'HEAD')
507
537
  if File.exist?(head_file)
508
538
  rev = File.read(head_file).chomp.strip
509
- rev = File.read(File.join(configuration(:repository_root), '.git', $1)).chomp.strip if rev =~ /^ref: (.+?)$/
539
+ if rev =~ /^ref: (.+?)$/
540
+ rev = nil # in case we need to shell
541
+ ref = $1
542
+ ref_file = File.join(configuration(:repository_root), '.git', ref)
543
+ if File.exist?(ref_file)
544
+ rev = File.read(ref_file).chomp.strip
545
+ elsif File.exist?(File.join(configuration(:repository_root), '.git', 'packed-refs'))
546
+ revs = File.join(configuration(:repository_root), '.git', 'packed-refs')
547
+ File.open(revs) do |f|
548
+ f.each_line do |line|
549
+ next if line[0, 1] == '#'
550
+ next if line[0, 1] == '^'
551
+ next unless line.chomp[-(ref.length)..-1] == ref
552
+ rev = line[0, 40]
553
+ break
554
+ end
555
+ end
556
+ end
557
+ end
558
+ rev ||= `git rev-parse #{ref}`.strip # shell as a last resort
510
559
  rev
511
560
  else
512
561
  raise "You must set the :revision_file configuration if the code is not running in a Git checkout"
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: squash_ruby
3
3
  version: !ruby/object:Gem::Version
4
- hash: 23
4
+ hash: 21
5
5
  prerelease:
6
6
  segments:
7
7
  - 1
8
8
  - 0
9
- - 0
10
- version: 1.0.0
9
+ - 1
10
+ version: 1.0.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Tim Morgan
@@ -15,10 +15,9 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2012-12-07 00:00:00 Z
18
+ date: 2013-01-25 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
- prerelease: false
22
21
  requirement: &id001 !ruby/object:Gem::Requirement
23
22
  none: false
24
23
  requirements:
@@ -28,11 +27,11 @@ dependencies:
28
27
  segments:
29
28
  - 0
30
29
  version: "0"
31
- type: :runtime
32
- name: json
33
30
  version_requirements: *id001
34
- - !ruby/object:Gem::Dependency
31
+ name: json
35
32
  prerelease: false
33
+ type: :runtime
34
+ - !ruby/object:Gem::Dependency
36
35
  requirement: &id002 !ruby/object:Gem::Requirement
37
36
  none: false
38
37
  requirements:
@@ -42,11 +41,11 @@ dependencies:
42
41
  segments:
43
42
  - 0
44
43
  version: "0"
45
- type: :development
46
- name: rspec
47
44
  version_requirements: *id002
48
- - !ruby/object:Gem::Dependency
45
+ name: rspec
49
46
  prerelease: false
47
+ type: :development
48
+ - !ruby/object:Gem::Dependency
50
49
  requirement: &id003 !ruby/object:Gem::Requirement
51
50
  none: false
52
51
  requirements:
@@ -56,11 +55,11 @@ dependencies:
56
55
  segments:
57
56
  - 0
58
57
  version: "0"
59
- type: :development
60
- name: yard
61
58
  version_requirements: *id003
62
- - !ruby/object:Gem::Dependency
59
+ name: fakefs
63
60
  prerelease: false
61
+ type: :development
62
+ - !ruby/object:Gem::Dependency
64
63
  requirement: &id004 !ruby/object:Gem::Requirement
65
64
  none: false
66
65
  requirements:
@@ -70,11 +69,11 @@ dependencies:
70
69
  segments:
71
70
  - 0
72
71
  version: "0"
73
- type: :development
74
- name: redcarpet
75
72
  version_requirements: *id004
76
- - !ruby/object:Gem::Dependency
73
+ name: yard
77
74
  prerelease: false
75
+ type: :development
76
+ - !ruby/object:Gem::Dependency
78
77
  requirement: &id005 !ruby/object:Gem::Requirement
79
78
  none: false
80
79
  requirements:
@@ -84,9 +83,24 @@ dependencies:
84
83
  segments:
85
84
  - 0
86
85
  version: "0"
86
+ version_requirements: *id005
87
+ name: redcarpet
88
+ prerelease: false
87
89
  type: :development
90
+ - !ruby/object:Gem::Dependency
91
+ requirement: &id006 !ruby/object:Gem::Requirement
92
+ none: false
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ hash: 3
97
+ segments:
98
+ - 0
99
+ version: "0"
100
+ version_requirements: *id006
88
101
  name: jeweler
89
- version_requirements: *id005
102
+ prerelease: false
103
+ type: :development
90
104
  description: This client library records Ruby exceptions to Squash.
91
105
  email: tim@squareup.com
92
106
  executables: []