slack_notifier 1.0.1 → 1.0.2

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,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 682923ee0b54ce851b8234a8aefdb7ccf8cb6e0a
4
- data.tar.gz: 240a006122a8a38dc12a136eb2f7299a08dc314d
3
+ metadata.gz: b39e490e10572679410cf3d0dacae361f173c551
4
+ data.tar.gz: a2480ed868a522013dd9d2330bf880749c912264
5
5
  SHA512:
6
- metadata.gz: 32abcba21e799e9fab0a28e3e8ec9cb27292ced15ce0612fa0551efef6dcf15929249fc57cd97733431c306ab36823981250217bb3d96afb0e0227857887d004
7
- data.tar.gz: 5f2cbf36c1f9a1983389e7640f8d8a0fc3a4bbe4f607dba3a7536da1de3e90ae52678a0ac4299d9f609d43bfce0cf282110595e0a2f55ffe2738042a33c82183
6
+ metadata.gz: 71ce891181ab7716e49f2ed94518776012d5c5ea3d1f153543a99a7241088c99b1793cd2316df888afa78788f4e4c7854330103cd6d878ae14a288460f95d252
7
+ data.tar.gz: db65701ef8feb87a7c00f90e913bfd4bfea145a04f22312b5a9f92efeb6597305afc8fdbdb91b36fa83e84889b3172b286c48b05dea2eaf86432e6ea4ffadb17
data/.gitignore CHANGED
@@ -42,9 +42,9 @@ build-iPhoneSimulator/
42
42
 
43
43
  # for a library or gem, you might want to ignore these files since the code is
44
44
  # intended to run in multiple environments; otherwise, check them in:
45
- # Gemfile.lock
46
- # .ruby-version
47
- # .ruby-gemset
45
+ Gemfile.lock
46
+ .ruby-version
47
+ .ruby-gemset
48
48
 
49
49
  # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
50
50
  .rvmrc
data/.travis.yml ADDED
@@ -0,0 +1,7 @@
1
+ language: ruby
2
+ sudo: false
3
+ rvm:
4
+ - 2.2.7
5
+ - 2.3.4
6
+ - 2.4.1
7
+ - ruby-head
data/README.md CHANGED
@@ -1,7 +1,12 @@
1
+ [![Gem Version](https://img.shields.io/gem/v/slack_notifier.svg)](https://rubygems.org/gems/slack_notifier)
2
+ [![Master](https://travis-ci.org/FindHotel/ruby_slack_notifier.svg?branch=master)](https://travis-ci.org/FindHotel/ruby_slack_notifier)
3
+
1
4
  # SlackNotifier
2
5
 
3
6
  Simple Ruby gem for sending messages to Slack
4
7
 
8
+ <img width="800" alt="slack notifier" src="https://user-images.githubusercontent.com/6284234/27587063-3037ceba-5b43-11e7-82a6-fbe2c13952f2.png">
9
+
5
10
  ## Installation
6
11
 
7
12
  Add this line to your application's Gemfile:
@@ -44,7 +49,9 @@ SlackNotifier::Message.send(
44
49
  channel: 'errors',
45
50
  nickname: 'Bugs',
46
51
  text: ex.message,
47
- report: ex.backtrace
52
+ icon_emoji: ':bug:',
53
+ report: ex.backtrace,
54
+ report_color: '#D3D3D3'
48
55
  )
49
56
  ```
50
57
 
@@ -1,9 +1,11 @@
1
1
  module SlackNotifier
2
2
  class Message
3
- def self.send(text:, channel: nil, nickname: nil, icon_emoji: nil, icon_url: nil, report: nil)
3
+ def self.send(text:, channel: nil, nickname: nil, icon_emoji: nil, report: nil, report_color: nil)
4
4
  channel ||= Config.default_channel
5
5
  nickname ||= Config.default_nickname
6
- new(text, channel, nickname, icon_emoji, icon_url, report).tap(&:deliver)
6
+ icon = icon_emoji || Config.default_icon_emoji
7
+ report_color = report_color || Config.default_report_color
8
+ new(text, channel, nickname, icon, report, report_color).tap(&:deliver)
7
9
  rescue => ex
8
10
  raise ex if Config.raise_delivery_errors
9
11
  puts ex.message
@@ -33,42 +35,18 @@ module SlackNotifier
33
35
 
34
36
  private
35
37
 
36
- def initialize(message, channel, nickname, icon, icon_ur, report)
38
+ def initialize(message, channel, nickname, icon, report, report_color)
37
39
  @message = message
38
40
  @channel = channel
39
41
  @nickname = nickname
40
- @created_at = Time.now
42
+ @icon_emoji = icon
41
43
  @report = report
42
-
43
- set_icon(icon, icon_ur)
44
+ @report_color = report_color
45
+ @created_at = Time.now
44
46
  end
45
47
 
46
48
  def icon_param
47
- @icon_emoji ? { icon_emoji: @icon_emoji } : { icon_url: @icon_url }
48
- end
49
-
50
- def set_icon(icon_emoji, icon_url)
51
- if no_icon?(icon_emoji, icon_url)
52
- @icon_emoji = Config.default_icon_emoji
53
- end
54
-
55
- if more_than_one_icon?(icon_emoji, icon_url)
56
- fail 'Please specify either an icon_emoji or an icon_url'
57
- end
58
-
59
- if icon_emoji
60
- @icon_emoji = icon_emoji
61
- else
62
- @icon_url = icon_url
63
- end
64
- end
65
-
66
- def no_icon?(icon_emoji, icon_url)
67
- icon_emoji.nil? && icon_url.nil?
68
- end
69
-
70
- def more_than_one_icon?(icon_emoji, icon_url)
71
- !icon_emoji.nil? && !icon_url.nil?
49
+ { icon_emoji: @icon_emoji }
72
50
  end
73
51
 
74
52
  def compose_attachment
@@ -76,7 +54,7 @@ module SlackNotifier
76
54
  attachments: [
77
55
  {
78
56
  title: Config.default_report_title,
79
- color: Config.default_report_color,
57
+ color: @report_color,
80
58
  text: key_value_pairs_to_s(@report)
81
59
  }
82
60
  ]
@@ -84,7 +62,7 @@ module SlackNotifier
84
62
  end
85
63
 
86
64
  def key_value_pairs_to_s(hash)
87
- hash.map { |k, v| "#{k}: #{v}" }.join("\n")
65
+ hash.map { |k, v| "#{k.to_s.gsub(/_/, ' ').titleize}: #{v}" }.join("\n")
88
66
  end
89
67
  end
90
68
  end
@@ -1,3 +1,3 @@
1
1
  module SlackNotifier
2
- VERSION = '1.0.1'
2
+ VERSION = '1.0.2'
3
3
  end
@@ -1,4 +1,5 @@
1
1
  require 'json'
2
+ require 'titleize'
2
3
  require 'slack_notifier/config'
3
4
  require 'slack_notifier/message'
4
5
  require 'slack_notifier/version'
@@ -12,13 +12,16 @@ Gem::Specification.new do |spec|
12
12
  spec.summary = %q{Simple Ruby gem for sending messages to Slack}
13
13
  spec.description = %q{Simple Ruby gem for sending messages to Slack}
14
14
  spec.homepage = "https://github.com/FindHotel/ruby_slack_notifier"
15
+ spec.license = "MIT"
15
16
 
16
17
  spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
17
18
  spec.bindir = "exe"
18
19
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
19
20
  spec.require_paths = ["lib"]
20
21
 
21
- spec.add_development_dependency "bundler", "~> 1.12"
22
- spec.add_development_dependency "rake", "~> 10.0"
23
- spec.add_development_dependency "rspec", "~> 3.0"
22
+ spec.add_runtime_dependency 'titleize', '~> 1.4'
23
+
24
+ spec.add_development_dependency 'bundler', '~> 1.12'
25
+ spec.add_development_dependency 'rake', '~> 10.0'
26
+ spec.add_development_dependency 'rspec', '~> 3.0'
24
27
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: slack_notifier
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Elod Peter
@@ -11,6 +11,20 @@ bindir: exe
11
11
  cert_chain: []
12
12
  date: 2017-06-27 00:00:00.000000000 Z
13
13
  dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: titleize
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - "~>"
19
+ - !ruby/object:Gem::Version
20
+ version: '1.4'
21
+ type: :runtime
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - "~>"
26
+ - !ruby/object:Gem::Version
27
+ version: '1.4'
14
28
  - !ruby/object:Gem::Dependency
15
29
  name: bundler
16
30
  requirement: !ruby/object:Gem::Requirement
@@ -63,8 +77,8 @@ extra_rdoc_files: []
63
77
  files:
64
78
  - ".gitignore"
65
79
  - ".rspec"
80
+ - ".travis.yml"
66
81
  - Gemfile
67
- - Gemfile.lock
68
82
  - LICENSE
69
83
  - README.md
70
84
  - Rakefile
@@ -76,7 +90,8 @@ files:
76
90
  - lib/slack_notifier/version.rb
77
91
  - slack_notifier.gemspec
78
92
  homepage: https://github.com/FindHotel/ruby_slack_notifier
79
- licenses: []
93
+ licenses:
94
+ - MIT
80
95
  metadata: {}
81
96
  post_install_message:
82
97
  rdoc_options: []
data/Gemfile.lock DELETED
@@ -1,35 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- slack_notifier (1.0.0)
5
-
6
- GEM
7
- remote: https://rubygems.org/
8
- specs:
9
- diff-lcs (1.3)
10
- rake (10.5.0)
11
- rspec (3.6.0)
12
- rspec-core (~> 3.6.0)
13
- rspec-expectations (~> 3.6.0)
14
- rspec-mocks (~> 3.6.0)
15
- rspec-core (3.6.0)
16
- rspec-support (~> 3.6.0)
17
- rspec-expectations (3.6.0)
18
- diff-lcs (>= 1.2.0, < 2.0)
19
- rspec-support (~> 3.6.0)
20
- rspec-mocks (3.6.0)
21
- diff-lcs (>= 1.2.0, < 2.0)
22
- rspec-support (~> 3.6.0)
23
- rspec-support (3.6.0)
24
-
25
- PLATFORMS
26
- ruby
27
-
28
- DEPENDENCIES
29
- bundler (~> 1.12)
30
- rake (~> 10.0)
31
- rspec (~> 3.0)
32
- slack_notifier!
33
-
34
- BUNDLED WITH
35
- 1.15.1