dogcatcher 0.2.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- ZDkyOTc3ZmMyOWNhYTMyYzc1YTJlODI2OWEzZjgwNGI4ZGYzZjI5Mw==
4
+ NDJlNGE0ZDAzYTUwMmU4Yjk2ODZhM2MzMmExNDIyNzAwZTUwZTE2NA==
5
5
  data.tar.gz: !binary |-
6
- MzIyMDAzNzlkMDA0MTZjODhjMTdlOWYzYjU4ZTJjZDE3ZmU4ZmU4ZQ==
6
+ MmYyYTM5NTE2ZmJmOWIxNTk5OTAzM2M4NTcxMjdlYzhmZmEyNGVlZQ==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- NzdlZWE1MGVjYzllMWFjNmE4ZTY2MWFlNTFkNWMyYWNkNzVjODcxMDM3M2Zi
10
- ZjdhZWFiMDdjZWFiYTU2OGYyMTU1YzYyYTQ1YTc1OTJiY2JjMDFiOTZmZmMw
11
- OWQzNGM0ODNhZGM2YjYzYjEwZGE2YTkzMjNjZWExZWEyOTg3YzU=
9
+ YWRiMTg1NDM4MjAyZmUxN2ZiYjkzNzA1NjM4MzAzZmU5OTI3NGQwOTFhNTIy
10
+ ZDMxZTBkYmMwYjAyZWI0NjM4MDY2MDRhODllOGFmNDM1NzYxNmIzZDE0ZGEx
11
+ ZjEyZTY3NWUyNDIyOWRhNjU1MDM1NDRhZDljZDM0NmU5ZWY3MTc=
12
12
  data.tar.gz: !binary |-
13
- NzJlMjQyMWQwMmUyYzhjODUxOGU0NWFhZWI0NzgxNGE0N2M3YzVmY2U2ZDVi
14
- ZGQ5ZmI3OTNjYjU0MjdhZDA3NmJlMjY3MjBjYzgzNjM1OGZkOTkyMDZmYzAx
15
- YmJlMDc0ODFkMjdiYTU1NWEyNGM4YjQwMWNiZTNlMmI3MzZmNzY=
13
+ YzFlZmUyMTUxYWYwNWViOTRjOTNjZTAyYTQ1ZjU2OGY4ZjI4YzE0ZDMwZWI5
14
+ OTZjYjEyNzgyNGI2YzBlMzY5NGQzNzQwMDkwNzVlODliMTMxNjc0ZTBiY2Q1
15
+ YTdhODBmNmViZGI3NTQ4NTk2Yjk0NzcxNzU3ZTRlZWE4NTEwNmE=
@@ -16,8 +16,15 @@ module Dogcatcher
16
16
  #
17
17
  # @param [String] str text to include in the code block
18
18
  # @param [String] language of the code block
19
- def code_block(str, language = nil)
20
- @result << ['```', language, "\n", str, "\n```\n"]
19
+ # @param [FixNum] max_len Length at which to truncate the content of the
20
+ # code block. Length includes block backticks and language. Negative
21
+ # numbers disable the maximum length.
22
+ def code_block(str, language = nil, max_len = -1)
23
+ if max_len > 0
24
+ max_len -= code_block_builder('', language).length # Subtract markdown overhead
25
+ str = str[0..max_len-1] if str.length > max_len
26
+ end
27
+ @result << code_block_builder(str, language)
21
28
  end
22
29
 
23
30
  # Gets the result string formatted in Markdown.
@@ -26,5 +33,11 @@ module Dogcatcher
26
33
  def result
27
34
  ['%%%', "\n", *@result, "\n", '%%%'].join('')
28
35
  end
36
+
37
+ private
38
+
39
+ def code_block_builder(str, language)
40
+ ['```', language, "\n", str, "\n```\n"].join('')
41
+ end
29
42
  end
30
43
  end
@@ -1,5 +1,7 @@
1
1
  module Dogcatcher
2
2
  class Notice
3
+ MAX_MESSAGE_SIZE = 4000
4
+
3
5
  # Name of the source that caught the exception
4
6
  attr_accessor :notifier
5
7
 
@@ -27,7 +29,8 @@ module Dogcatcher
27
29
  backtrace = @config.backtrace_cleaner.clean(exception.backtrace)
28
30
  markdown = Markdown.new
29
31
  metadata.each { |key, value| markdown.bullet("#{key}: #{value}") }
30
- markdown.code_block(backtrace.join("\n"))
32
+ max_block_size = MAX_MESSAGE_SIZE - markdown.result.length - 10
33
+ markdown.code_block(backtrace.join("\n"), 'text', max_block_size)
31
34
  markdown.result
32
35
  end
33
36
 
@@ -1,3 +1,3 @@
1
1
  module Dogcatcher
2
- VERSION = '0.2.0'.freeze
2
+ VERSION = '0.2.1'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dogcatcher
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ben Vidulich
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-04-26 00:00:00.000000000 Z
11
+ date: 2016-05-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler