slack-notifier 1.2.0 → 1.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 381988fd2d67aa541bc06565270991713da8f7d0
4
- data.tar.gz: 36d7e7196a763ef4b07eb698f0f072eccba597ef
3
+ metadata.gz: b724540f4fb01a3f48950fee034eda3af6b3fb4a
4
+ data.tar.gz: a56880a665af231f4ce81d5bead28f7db048abdf
5
5
  SHA512:
6
- metadata.gz: 2109923737e8d0f772b2aa54100b363c79f8d1d51d016bb2207634de817cbbc2e4673d7a944f486712a9f46667bddd6059a975e46781c98d6504449f61d9ed82
7
- data.tar.gz: 358d437fa6484dd9ff544a12fd84d87534038a348b989bacce57ac8a6b085c363304029e473467517150e06ad682759bb9fb1b7ab90b42383f30729434056df2
6
+ metadata.gz: d843ebf95f96255e4c4fc470876ab1937af610b0a94805ebd0acd02673e508ed8c63772dd9ebff22773daa5c693f42daa5d55f20a34d3b436d151d7a67ad0252
7
+ data.tar.gz: 78f341412567858fca8ff81bb1f5fc9e222d4cc6b734de43c6a1781fcc552e9a3c7147f9733e76b71768ee25a8f2ef5271b774c83dcc449866bc410564c5a1b2
@@ -11,7 +11,11 @@ module Slack
11
11
  end
12
12
 
13
13
  def initialize string
14
- @orig = fix_encoding string
14
+ @orig = if string.respond_to? :scrub
15
+ string.scrub
16
+ else
17
+ string
18
+ end
15
19
  end
16
20
 
17
21
  def formatted
@@ -24,17 +28,17 @@ module Slack
24
28
  text = Regexp.last_match[1]
25
29
  slack_link link, text
26
30
  end
31
+
32
+ rescue => e
33
+ if RUBY_VERSION < '2.1' && e.message.include?('invalid byte sequence')
34
+ raise e, "#{e.message}. Consider including the 'string-scrub' gem to strip invalid characters"
35
+ else
36
+ raise e
37
+ end
27
38
  end
28
39
 
29
40
  private
30
41
 
31
- def fix_encoding string
32
- string.encode 'UTF-8',
33
- 'binary',
34
- :invalid => :replace,
35
- :undef => :replace
36
- end
37
-
38
42
  def slack_link link, text=nil
39
43
  out = "<#{link}"
40
44
  out << "|#{text}" if text && !text.empty?
@@ -1,5 +1,5 @@
1
1
  module Slack
2
2
  class Notifier
3
- VERSION = "1.2.0"
3
+ VERSION = "1.2.1"
4
4
  end
5
5
  end
@@ -1,5 +1,6 @@
1
+ # encoding: utf-8
1
2
  require_relative '../../lib/slack-notifier'
2
3
 
3
4
  notifier = Slack::Notifier.new ENV['SLACK_WEBHOOK_URL'], username: 'notifier'
4
5
  puts "testing with ruby #{RUBY_VERSION}"
5
- notifier.ping "hello from notifier test script on ruby: #{RUBY_VERSION}"
6
+ notifier.ping "hello/こんにちは from notifier test script on ruby: #{RUBY_VERSION}\225"
@@ -1,3 +1,4 @@
1
+ # encoding: utf-8
1
2
  require 'spec_helper'
2
3
 
3
4
  describe Slack::Notifier::LinkFormatter do
@@ -37,15 +38,24 @@ describe Slack::Notifier::LinkFormatter do
37
38
  expect( formatted ).to include("<http://example2.com|this2>")
38
39
  end
39
40
 
40
- it "handles invalid unicode sequences" do
41
- expect {
42
- described_class.format("This sequence is invalid: \255")
43
- }.not_to raise_error
41
+ if "".respond_to? :scrub
42
+ context "when on ruby 2.1+ or have string-scrub installed" do
43
+ it "handles invalid unicode sequences" do
44
+ expect {
45
+ described_class.format("This sequence is invalid: \255")
46
+ }.not_to raise_error
47
+ end
48
+
49
+ it "replaces invalid unicode sequences with the unicode replacement character" do
50
+ formatted = described_class.format("\255")
51
+ expect(formatted).to eq "\uFFFD"
52
+ end
53
+ end
44
54
  end
45
55
 
46
- it "replaces invalid unicode sequences with the unicode replacement character" do
47
- formatted = described_class.format("\255")
48
- expect(formatted).to eq "\uFFFD"
56
+ it "doesn't replace valid Japanese" do
57
+ formatted = described_class.format("こんにちは")
58
+ expect(formatted).to eq "こんにちは"
49
59
  end
50
60
 
51
61
  end
@@ -10,4 +10,4 @@ RSpec.configure do |config|
10
10
  mocks.verify_doubled_constant_names = true
11
11
  mocks.verify_partial_doubles = true
12
12
  end
13
- end
13
+ end
metadata CHANGED
@@ -1,16 +1,16 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: slack-notifier
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Steven Sloan
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-04-27 00:00:00.000000000 Z
11
+ date: 2015-05-18 00:00:00.000000000 Z
12
12
  dependencies: []
13
- description: " A slim ruby wrapper for posting to slack webhooks "
13
+ description: ' A slim ruby wrapper for posting to slack webhooks '
14
14
  email:
15
15
  - stevenosloan@gmail.com
16
16
  executables: []
@@ -36,17 +36,17 @@ require_paths:
36
36
  - lib
37
37
  required_ruby_version: !ruby/object:Gem::Requirement
38
38
  requirements:
39
- - - ">="
39
+ - - '>='
40
40
  - !ruby/object:Gem::Version
41
41
  version: '0'
42
42
  required_rubygems_version: !ruby/object:Gem::Requirement
43
43
  requirements:
44
- - - ">="
44
+ - - '>='
45
45
  - !ruby/object:Gem::Version
46
46
  version: '0'
47
47
  requirements: []
48
48
  rubyforge_project:
49
- rubygems_version: 2.2.2
49
+ rubygems_version: 2.4.5
50
50
  signing_key:
51
51
  specification_version: 4
52
52
  summary: A slim ruby wrapper for posting to slack webhooks