job_notifier 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/Gemfile.lock +5 -3
- data/job_notifier.gemspec +1 -0
- data/lib/job_notifier/engine.rb +4 -1
- data/lib/job_notifier/logger.rb +45 -0
- data/lib/job_notifier/version.rb +1 -1
- data/lib/job_notifier.rb +1 -0
- data/spec/dummy/db/development.sqlite3 +0 -0
- data/spec/dummy/log/development.log +5367 -0
- data/spec/dummy/log/test.log +252 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/-G/-GveclH2c4AJ0F2uL6co5BAB_tYM95Ku5Ck3fg3Hc6k.cache +0 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/1e/1eDUwogv1wCqFvnsIm_nhSx2jnLqUGtI1xUJIN-l16g.cache +1 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/5L/5Lly_CA8DZvPhQV2jDQx-Y6P_y3Ygra9t5jfSlGhHDA.cache +0 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/89/89w7NaV6lPBAfZVdfkmopJFJuwUm7gXiVPcZxt565_E.cache +0 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/8R/8Rx8sm5uy1PHQglr12AuNYr8bXFcaESzsmKDAOSZ76k.cache +0 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/Cs/CsgITdnoK8_gEUOO-VFmXXdSp3U2e2JCyNXec6FRZlY.cache +0 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/DS/DSOLSc6A5RVSmvM415eEWAWG_AgOvZcLZOXQjsXyWQA.cache +0 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/ER/ERIhhkC0nBZDXqlDn0mXHrkrs_GPOxP7F7a70kUtx3I.cache +1 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/GS/GSYOC-pszNtwHt4c-Lo8Gue-MGEdNNGQIQJw2nS_gS0.cache +0 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/Lp/Lpdy5sEQ64fxZUmoCW1U2JZRcigvKHbQ_LhbqLUMows.cache +1 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/O9/O9QU90Fu7AqBAB31SsXiSSwuDAA-WRMTvQf_oS5rXS8.cache +0 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/OI/OI6uxGcnsKavdWTtwDAasU3wPx8QXhzBgV0X2n1KjMQ.cache +0 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/X2/X2hdh6kt8wzxqAt-enHhmKCBxAzHrv82UUBRYaG3_fs.cache +1 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/bn/bncSCdc2AfNDJzvmfZMH3E-IEVGZu6iUd5EC0WkH-Z0.cache +0 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/fZ/fZ9H_KjFoFfW7FqMB1A4cSa3EsXC8dX7v-VQJYRSJHk.cache +1 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/hR/hRdK8r2hDS-C0wYY8IRTGZJKznSdPVeFYaR5vJKEHi0.cache +1 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/jd/jd1N2ahKVxbKWIgy09_CJVy7UyoEqkmHOiZeB691RtY.cache +0 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/mD/mDGzXQ81u8HQycpxMCOGh1g6rLHg9RBajq3DdbFlL4E.cache +1 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/mw/mwRbfLO1vJxbKQ-k3bYvRwMykL_yMbxVo5l_aGXnPyQ.cache +0 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/nz/nzhBOc_BmoyFakEF2EOQ4a0aghloLMYCrlnQP0rHVLs.cache +1 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/o7/o7zQ6QY0zgMOeEjO3uYYhX-zJWxp-WqDQZ-7HPFVZVE.cache +0 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/ow/ow19PYQOyFHSeyFWRX-yfLKh637sPoryvuY3SMv_Kvk.cache +1 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/p9/p9Wt8VP4Z8vR35WPKdPKAv4_wiNuBEcttWollOUhp9k.cache +1 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/sG/sGhULBDomUtPteRueTXoAM65_WaXLQMJh-NZa__WCe4.cache +2 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/tb/tbTtIqrR3Pv_YkUZQPuwIqe5M9bDI4_g6w2GTdmAF3M.cache +0 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/zC/zCAHudpoDDHfDk7BvKD3-nDfRPr2_Wl_r5pGbKrXKAI.cache +0 -0
- data/spec/dummy/tmp/pids/server.pid +1 -1
- metadata +63 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c8937d5be6261a37e48eb27ab905ad9b93eb196c
|
4
|
+
data.tar.gz: b72d27da476103948cc7da671edbd3c5deb583ff
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3570373e7c9bd76cc1508e6a494f7429d00fee041e33a4cc37a1c6a1843d481b3095b96afde0272e7c572774e4c1b8e808a58a5b7aefcdc06fa8f499d95dd065
|
7
|
+
data.tar.gz: f7fd01921da169626cf55b57149dfcabe68b5010210e7b5e064a6644eda05db5539451773f81fa87651c12607834095f85dfb0104918ba477acf619b8bd0cf21
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,12 @@
|
|
2
2
|
All notable changes to this project will be documented in this file.
|
3
3
|
This project adheres to [Semantic Versioning](http://semver.org/).
|
4
4
|
|
5
|
+
### v1.1.0
|
6
|
+
|
7
|
+
#### Added
|
8
|
+
|
9
|
+
- Replace Rails::Rack::Logger class with custom logger to avoid noisy logs.
|
10
|
+
|
5
11
|
### v1.0.0
|
6
12
|
|
7
13
|
#### Added
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
job_notifier (1.
|
4
|
+
job_notifier (1.1.0)
|
5
|
+
colorize (~> 0.7, >= 0.7.7)
|
5
6
|
enumerize (~> 1.0.0, ~> 1.0)
|
6
7
|
rails (~> 4.2, >= 4.2.0)
|
7
8
|
|
@@ -46,6 +47,7 @@ GEM
|
|
46
47
|
arel (6.0.3)
|
47
48
|
builder (3.2.2)
|
48
49
|
coderay (1.1.1)
|
50
|
+
colorize (0.8.1)
|
49
51
|
concurrent-ruby (1.0.2)
|
50
52
|
diff-lcs (1.2.5)
|
51
53
|
enumerize (1.0.0)
|
@@ -122,10 +124,10 @@ GEM
|
|
122
124
|
rspec-support (~> 3.4.0)
|
123
125
|
rspec-support (3.4.1)
|
124
126
|
slop (3.6.0)
|
125
|
-
sprockets (3.6.
|
127
|
+
sprockets (3.6.3)
|
126
128
|
concurrent-ruby (~> 1.0)
|
127
129
|
rack (> 1, < 3)
|
128
|
-
sprockets-rails (3.
|
130
|
+
sprockets-rails (3.1.1)
|
129
131
|
actionpack (>= 4.0)
|
130
132
|
activesupport (>= 4.0)
|
131
133
|
sprockets (>= 3.0.0)
|
data/job_notifier.gemspec
CHANGED
@@ -19,6 +19,7 @@ Gem::Specification.new do |s|
|
|
19
19
|
|
20
20
|
s.add_dependency "rails", "~> 4.2", ">= 4.2.0"
|
21
21
|
s.add_dependency "enumerize", "~> 1.0", "~> 1.0.0"
|
22
|
+
s.add_dependency "colorize", "~> 0.7", ">= 0.7.7"
|
22
23
|
|
23
24
|
s.add_development_dependency "pry"
|
24
25
|
s.add_development_dependency "sqlite3"
|
data/lib/job_notifier/engine.rb
CHANGED
@@ -14,10 +14,13 @@ module JobNotifier
|
|
14
14
|
require_relative "./notifier"
|
15
15
|
require_relative "./identifier"
|
16
16
|
require_relative "./adapters"
|
17
|
+
require_relative "./logger"
|
17
18
|
|
18
19
|
ActiveSupport.on_load :action_controller do
|
19
|
-
helper
|
20
|
+
helper(JobNotifier::ApplicationHelper)
|
20
21
|
end
|
22
|
+
|
23
|
+
Rails.application.middleware.swap(Rails::Rack::Logger, JobNotifier::Logger)
|
21
24
|
end
|
22
25
|
end
|
23
26
|
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
module JobNotifier
|
2
|
+
class Logger < Rails::Rack::Logger
|
3
|
+
def initialize(app, opts = {})
|
4
|
+
@app = app
|
5
|
+
@opts = opts
|
6
|
+
super
|
7
|
+
end
|
8
|
+
|
9
|
+
def call(env)
|
10
|
+
if env["PATH_INFO"] =~ %r{\/job_notifier\/\w+\/jobs\/\w+.json}
|
11
|
+
Rails.logger.silence do
|
12
|
+
response = @app.call(env)
|
13
|
+
log_jobs_info(response[2])
|
14
|
+
return response
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
super(env)
|
19
|
+
end
|
20
|
+
|
21
|
+
def log_jobs_info(response)
|
22
|
+
response.each do |resp|
|
23
|
+
next if resp.blank?
|
24
|
+
result = JSON.parse(resp)
|
25
|
+
next if result.blank?
|
26
|
+
puts build_log_msg(result)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def build_log_msg(result)
|
31
|
+
msg = ["[#{DateTime.now.strftime('%Y-%m-%d %H:%M:%S')}] UNNOTIFIED JOBS".light_blue]
|
32
|
+
grouped_jobs = result.group_by { |job| job["status"].to_sym }
|
33
|
+
load_job_status_msg(grouped_jobs, msg, :pending, :yellow)
|
34
|
+
load_job_status_msg(grouped_jobs, msg, :finished, :green)
|
35
|
+
load_job_status_msg(grouped_jobs, msg, :failed, :red)
|
36
|
+
msg.join(" ")
|
37
|
+
end
|
38
|
+
|
39
|
+
def load_job_status_msg(grouped_jobs, msg, status, color)
|
40
|
+
if grouped_jobs.has_key?(status)
|
41
|
+
msg << "#{status.to_s.capitalize}: #{grouped_jobs[status].count}".send(color)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
data/lib/job_notifier/version.rb
CHANGED
data/lib/job_notifier.rb
CHANGED
Binary file
|