HornsAndHooves-slackiq 1.2.0 → 1.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,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 62df624090d1e75604db7bbeed49cd4ba4f0ce71a65fa5daae87f0542a4cf873
4
- data.tar.gz: c68080713af81feda7f82eb32de41be002fce8d36556bcedc459bec9bf55522a
3
+ metadata.gz: 4d33511bc1da33236ea8a6b3c03b4d1e2a26305fbc55d9d8db48cd71644c713c
4
+ data.tar.gz: da45ca5736a952f4f75bced5cfc5c1f3f4858ad7d1a0edb383558785458308c2
5
5
  SHA512:
6
- metadata.gz: a9eace127b91ddbf98a3e314a4a3aefdb941e8d997726d762545c3627fbdc30b6bb7c1e9f92c099b788e84d2db6a1fa83a83f4eda355baa29bbb1ed1f6b721ea
7
- data.tar.gz: b9eb40323fbc169e25569d33560a10ec8697f4483627da2b665403fb5a747465c28313c1b4d030b045d2a1498e4cf1845006ff9303dc800b2093526ce3d6df51
6
+ metadata.gz: ebe7cbb7a607f79063c21f549ce0a2680ab8c3d96f0da08b00c65110a37aa3eb17228ac21ffc133933d53bb037e3f94b3afd718122e43462e5bd5251b01fdede
7
+ data.tar.gz: a1907bad4728a9f07d581901a2e3e57b60e8ddd1079a9d631cc84c5e503db42d90dbfde4936b937261ee878062274d276b4ed6b9e5105cea3cc34502238f7df4
data/Gemfile CHANGED
@@ -1,7 +1,6 @@
1
- source 'https://rubygems.org'
1
+ source "https://rubygems.org"
2
2
 
3
3
  # Specify your gem's dependencies in slackiq.gemspec
4
4
  gemspec
5
5
 
6
6
  gem "sidekiq"
7
- gem "gemfury"
@@ -1,28 +1,27 @@
1
1
  # -*- encoding: utf-8 -*-
2
2
 
3
- lib = File.expand_path('../lib', __FILE__)
3
+ lib = File.expand_path("../lib", __FILE__)
4
4
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
- require 'slackiq/version'
5
+ require "slackiq/version"
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "HornsAndHooves-slackiq"
9
9
  s.version = Slackiq::VERSION
10
10
  s.authors = ["HornsAndHooves", "Peter Maneykowski"]
11
- s.email = ['maneyko@integracredit.com']
12
- s.summary = 'HornsAndHooves: Slack and Sidekiq Pro integration'
11
+ s.email = ["maneyko@integracredit.com"]
12
+ s.summary = "HornsAndHooves: Slack and Sidekiq Pro integration"
13
13
  s.description = "Slackiq (by HornsAndHooves) integrates Slack and Sidekiq so that you can "\
14
14
  "have vital information about your Sidekiq jobs sent directly to your team's Slack."
15
- s.homepage = 'https://github.com/HornsAndHooves/slackiq'
16
- s.license = 'MIT'
15
+ s.homepage = "https://github.com/HornsAndHooves/slackiq"
16
+ s.license = "MIT"
17
17
 
18
18
  s.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
19
19
  s.bindir = "exe"
20
20
  s.executables = s.files.grep(%r{^exe/}) { |f| File.basename(f) }
21
21
  s.require_paths = ["lib"]
22
22
 
23
- s.add_dependency 'httparty'
23
+ s.add_dependency "httparty"
24
24
  s.add_development_dependency "bundler"
25
25
  s.add_development_dependency "rake"
26
26
  s.add_development_dependency "rspec"
27
- s.add_development_dependency "rspec-sidekiq"
28
27
  end
data/README.md CHANGED
@@ -10,7 +10,7 @@ Slackiq (pronounced *slack-kick*) integrates [Slack](https://slack.com/) and [Si
10
10
  Add this line to your Gemfile:
11
11
 
12
12
  ```ruby
13
- gem 'slackiq'
13
+ gem "slackiq"
14
14
  ```
15
15
 
16
16
  Then run:
@@ -26,8 +26,8 @@ First, set up any number of Slack Incoming Webhooks [from your Slack](https://sl
26
26
  Then, you only need to call the `configure` method when your application launches to configure all of the webhooks to which you want to post. If you're using Rails, create an initializer at `config/initializers/slackiq.rb`. Here's an example:
27
27
 
28
28
  ```ruby
29
- Slackiq.configure( web_scrapes: 'https://hooks.slack.com/services/HA298HF2/ALSKF2451/lknsaHHA2323KKDKND',
30
- data_processing: 'https://hooks.slack.com/services/HA298HF2/ALSKF2451/H24dLKAHD22423')
29
+ Slackiq.configure( web_scrapes: "https://hooks.slack.com/services/HA298HF2/ALSKF2451/lknsaHHA2323KKDKND",
30
+ data_processing: "https://hooks.slack.com/services/HA298HF2/ALSKF2451/H24dLKAHD22423")
31
31
  ```
32
32
 
33
33
  `:web_scrapes` and `data_processing` are examples of keys. Use whatever keys you want.
@@ -57,7 +57,7 @@ class WebScraper
57
57
  # Scrape the first 100 URLs in the database
58
58
  def scrape_100
59
59
  batch = Sidekiq::Batch.new
60
- batch.description = 'Scrape the first 100 URLs!'
60
+ batch.description = "Scrape the first 100 URLs!"
61
61
  batch.on(:complete, self)
62
62
 
63
63
  batch.jobs do
@@ -72,22 +72,22 @@ class WebScraper
72
72
  end
73
73
 
74
74
  def on_complete(status, options)
75
- Slackiq.notify(webhook_name: :web_scrapes, status: status, title: 'Scrape Completed!',
76
- 'Total URLs in DB' => URL.count.to_s,
77
- 'Servers' => "#{Server.active_count} active, #{Server.inactive_count} inactive")
75
+ Slackiq.notify(webhook_name: :web_scrapes, status: status, title: "Scrape Completed!",
76
+ "Total URLs in DB" => URL.count.to_s,
77
+ "Servers" => "#{Server.active_count} active, #{Server.inactive_count} inactive")
78
78
  end
79
79
 
80
80
  end
81
81
  ```
82
82
 
83
- Note that in this case, `'Total URLs in DB'` and `'Servers'` are custom fields that will also appear in Slack!
83
+ Note that in this case, `"Total URLs in DB"` and `"Servers"` are custom fields that will also appear in Slack!
84
84
 
85
85
  ### Want to send a message to Slack that isn't Sidekiq-related?
86
86
 
87
87
  No prob. Just:
88
88
 
89
89
  ```ruby
90
- Slackiq.message('Server 5 is overloaded!', webhook_name: :data_processing)
90
+ Slackiq.message("Server 5 is overloaded!", webhook_name: :data_processing)
91
91
  ```
92
92
 
93
93
  ## Contributing
data/Rakefile CHANGED
@@ -1,8 +1,7 @@
1
1
  require "bundler/gem_tasks"
2
- require "gemfury/tasks"
3
2
 
4
3
  task :console do
5
4
  exec "irb -r slackiq -I ./lib"
6
5
  end
7
6
 
8
- task c: :console
7
+ task c: :console
@@ -1,13 +1,12 @@
1
- require 'slackiq/version'
1
+ require "slackiq/version"
2
2
 
3
- require 'net/http'
4
- require 'json'
5
- require 'httparty'
3
+ require "net/http"
4
+ require "json"
5
+ require "httparty"
6
6
 
7
- require 'slackiq/time_helper'
8
- require 'slackiq/sidekiq_status'
7
+ require "slackiq/time_helper"
9
8
 
10
- require 'active_support' # For Hash#except
9
+ require "active_support" # For Hash#except
11
10
 
12
11
  module Slackiq
13
12
 
@@ -16,7 +15,7 @@ module Slackiq
16
15
  # Configure all of the webhook URLs you're going to use
17
16
  # @author Jason Lew
18
17
  def configure(webhook_urls={})
19
- raise 'Argument must be a Hash' unless webhook_urls.class == Hash
18
+ raise "Argument must be a Hash" unless webhook_urls.class == Hash
20
19
  @@webhook_urls = webhook_urls
21
20
  end
22
21
 
@@ -48,7 +47,7 @@ module Slackiq
48
47
  if created_at
49
48
  time_now = Time.now
50
49
  duration = Slackiq::TimeHelper.elapsed_time_humanized(created_at, time_now)
51
- time_now_title = (status.complete? ? 'Completed' : 'Now')
50
+ time_now_title = (status.complete? ? "Completed" : "Now")
52
51
  end
53
52
 
54
53
  total_jobs = status.total
@@ -67,44 +66,44 @@ module Slackiq
67
66
 
68
67
  fields += [
69
68
  {
70
- 'title' => 'Created',
71
- 'value' => Slackiq::TimeHelper.format(created_at),
72
- 'short' => true
69
+ title: "Created",
70
+ value: Slackiq::TimeHelper.format(created_at),
71
+ short: true
73
72
  },
74
73
  {
75
- 'title' => time_now_title,
76
- 'value' => Slackiq::TimeHelper.format(time_now),
77
- 'short' => true
74
+ title: time_now_title,
75
+ value: Slackiq::TimeHelper.format(time_now),
76
+ short: true
78
77
  },
79
78
  {
80
- 'title' => "Duration",
81
- 'value' => duration,
82
- 'short' => true
79
+ title: "Duration",
80
+ value: duration,
81
+ short: true
83
82
  },
84
83
  {
85
- 'title' => "Total Jobs",
86
- 'value' => total_jobs,
87
- 'short' => true
84
+ title: "Total Jobs",
85
+ value: total_jobs,
86
+ short: true
88
87
  },
89
88
  {
90
- 'title' => "Jobs Run",
91
- 'value' => jobs_run,
92
- 'short' => true
89
+ title: "Jobs Run",
90
+ value: jobs_run,
91
+ short: true
93
92
  },
94
93
  {
95
- 'title' => "Completion %",
96
- 'value' => "#{completion_percentage}%",
97
- 'short' => true
94
+ title: "Completion %",
95
+ value: "#{completion_percentage}%",
96
+ short: true
98
97
  },
99
98
  {
100
- 'title' => "Failures",
101
- 'value' => status.failures,
102
- 'short' => true
99
+ title: "Failures",
100
+ value: status.failures,
101
+ short: true
103
102
  },
104
103
  {
105
- 'title' => "Failure %",
106
- 'value' => "#{failure_percentage}%",
107
- 'short' => true
104
+ title: "Failure %",
105
+ value: "#{failure_percentage}%",
106
+ short: true
108
107
  },
109
108
  ]
110
109
  end
@@ -112,19 +111,19 @@ module Slackiq
112
111
  # Add extra fields
113
112
  fields += extra_fields.map do |title, value|
114
113
  {
115
- 'title' => title,
116
- 'value' => value,
117
- 'short' => false
114
+ title: title,
115
+ value: value,
116
+ short: false
118
117
  }
119
118
  end
120
119
 
121
120
  attachments = [
122
121
  {
123
- 'fallback' => title,
124
- 'color' => color,
125
- 'title' => title,
126
- 'text' => description,
127
- 'fields' => fields,
122
+ fallback: title,
123
+ color: color,
124
+ title: title,
125
+ text: description,
126
+ fields: fields,
128
127
  }
129
128
  ]
130
129
 
@@ -137,20 +136,20 @@ module Slackiq
137
136
  # @author Jason Lew
138
137
  def message(text, options)
139
138
  url = @@webhook_urls[options[:webhook_name]]
140
- body = { 'text' => text }.to_json
139
+ body = { text: text }.to_json
141
140
  HTTParty.post(url, body: body)
142
141
  end
143
142
 
144
143
  private
145
144
  def color_for(status)
146
145
  if status.total == 0
147
- '#FBBD08' # yellow
146
+ "#FBBD08" # yellow
148
147
  elsif status.failures > 0
149
- '#FF0000' # red
148
+ "#FF0000" # red
150
149
  elsif status.failures == 0
151
- '#1C9513' # green
150
+ "#1C9513" # green
152
151
  else
153
- '#FBBD08' # yellow
152
+ "#FBBD08" # yellow
154
153
  end
155
154
  end
156
155
  end
@@ -1,4 +1,4 @@
1
- require 'date'
1
+ require "date"
2
2
 
3
3
  module Slackiq
4
4
  module TimeHelper
@@ -26,11 +26,11 @@ module Slackiq
26
26
  "#{n.to_i}#{name}"
27
27
  end
28
28
  end
29
- }.compact.reverse.join(' ')
29
+ }.compact.reverse.join(" ")
30
30
  end
31
31
 
32
32
  def format(time)
33
- time.strftime('%D @ %r').gsub('PM', 'pm').gsub('AM', 'am')
33
+ time.strftime("%D @ %r").gsub("PM", "pm").gsub("AM", "am")
34
34
  end
35
35
  end
36
36
  end
@@ -1,3 +1,3 @@
1
1
  module Slackiq
2
- VERSION = "1.2.0"
2
+ VERSION = "1.2.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: HornsAndHooves-slackiq
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
  - HornsAndHooves
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2020-03-31 00:00:00.000000000 Z
12
+ date: 2020-04-03 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: httparty
@@ -67,20 +67,6 @@ dependencies:
67
67
  - - ">="
68
68
  - !ruby/object:Gem::Version
69
69
  version: '0'
70
- - !ruby/object:Gem::Dependency
71
- name: rspec-sidekiq
72
- requirement: !ruby/object:Gem::Requirement
73
- requirements:
74
- - - ">="
75
- - !ruby/object:Gem::Version
76
- version: '0'
77
- type: :development
78
- prerelease: false
79
- version_requirements: !ruby/object:Gem::Requirement
80
- requirements:
81
- - - ">="
82
- - !ruby/object:Gem::Version
83
- version: '0'
84
70
  description: Slackiq (by HornsAndHooves) integrates Slack and Sidekiq so that you
85
71
  can have vital information about your Sidekiq jobs sent directly to your team's
86
72
  Slack.
@@ -100,7 +86,6 @@ files:
100
86
  - bin/console
101
87
  - bin/setup
102
88
  - lib/slackiq.rb
103
- - lib/slackiq/sidekiq_status.rb
104
89
  - lib/slackiq/time_helper.rb
105
90
  - lib/slackiq/version.rb
106
91
  homepage: https://github.com/HornsAndHooves/slackiq
@@ -122,8 +107,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
122
107
  - !ruby/object:Gem::Version
123
108
  version: '0'
124
109
  requirements: []
125
- rubyforge_project:
126
- rubygems_version: 2.7.9
110
+ rubygems_version: 3.0.6
127
111
  signing_key:
128
112
  specification_version: 4
129
113
  summary: 'HornsAndHooves: Slack and Sidekiq Pro integration'
@@ -1,24 +0,0 @@
1
- # RSpec::Sidekiq::Batch::Status does not support batch failures.
2
- # Here, FailureStatus and SuccessStatus circumvent this problem.
3
-
4
- if defined?(RSpec)
5
- require 'rspec-sidekiq'
6
-
7
- module RSpec
8
- module Sidekiq
9
- class Batch
10
- class FailureStatus < NullStatus
11
- def failures
12
- 1
13
- end
14
- end
15
-
16
- class SuccessStatus < NullStatus
17
- def failures
18
- 0
19
- end
20
- end
21
- end
22
- end
23
- end
24
- end