job_log 0.1.0

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: afebb08666fc1e6cbc4c592b03c34385b3c162af
4
+ data.tar.gz: 1b0eff7bb3900094d59479ccb417a7ce35f52512
5
+ SHA512:
6
+ metadata.gz: 244a4bbde478842d84dc7a48b25fad2d584d08318a894fb812591a26d3ecd9a39f61a5fa20986a4349df3a6b588903e6f682065dc3065ef74dce540299714ccd
7
+ data.tar.gz: fc6bf3f57ecb082797d849800c81a7c8daf470e90f9e934584174525854fd9c042f3f57c075430d3f109ffbac1be940e6dd93fad27495e0560e45c7129b26382
Binary file
Binary file
@@ -0,0 +1,60 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # file: job_log.rb
4
+
5
+ require 'sps-sub'
6
+ require 'dynarex'
7
+
8
+
9
+ class JobLog
10
+
11
+ def initialize(dxfilepath='joblog.xml', host: 'sps2', port: 59100)
12
+
13
+ @dxfilepath = dxfilepath
14
+ @sps = SPSSub.new host: host, port: port
15
+
16
+ @dx = if File.exists? dxfilepath then
17
+ Dynarex.new(dxfilepath)
18
+ else
19
+ Dynarex.new 'jobs/job(title, desc, started, ended, status, tags)'
20
+ end
21
+ end
22
+
23
+ def listen
24
+
25
+ topics = %w(started done aborted).map {|x| "log/+/#{x}/+"}.join(' | ')
26
+ @sps.subscribe(topic: topics) do |msg, topic|
27
+
28
+ title = topic[/(?<=log\/)\w+/]
29
+
30
+ case topic
31
+ when /\/started\//
32
+
33
+ desc, raw_tags = msg.split(/(?= +#)/,2)
34
+ tags = raw_tags.scan(/(?<=#)\w+/).join ' '
35
+ @dx.create title: title, started: Time.now.to_s, desc: desc, tags: tags
36
+
37
+ when /\/done\//
38
+
39
+ r = @dx.find_by_title title
40
+ r.ended = Time.now.to_s if r
41
+ r.status = 'success'
42
+
43
+ when /\/aborted\//
44
+
45
+ r = @dx.find_by_title title
46
+ r.ended = Time.now.to_s if r
47
+ r.status = msg
48
+ end
49
+
50
+ # write the entry to file
51
+ @dx.save @dxfilepath
52
+ end
53
+ end
54
+ end
55
+
56
+
57
+ if __FILE__ == $0 then
58
+ jl = JobLog.new
59
+ jl.listen
60
+ end
metadata ADDED
@@ -0,0 +1,107 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: job_log
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - James Robertson
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain:
11
+ - |
12
+ -----BEGIN CERTIFICATE-----
13
+ MIIDljCCAn6gAwIBAgIBATANBgkqhkiG9w0BAQUFADBIMRIwEAYDVQQDDAlnZW1t
14
+ YXN0ZXIxHjAcBgoJkiaJk/IsZAEZFg5qYW1lc3JvYmVydHNvbjESMBAGCgmSJomT
15
+ 8ixkARkWAmV1MB4XDTE3MTAzMDExNDAzOVoXDTE4MTAzMDExNDAzOVowSDESMBAG
16
+ A1UEAwwJZ2VtbWFzdGVyMR4wHAYKCZImiZPyLGQBGRYOamFtZXNyb2JlcnRzb24x
17
+ EjAQBgoJkiaJk/IsZAEZFgJldTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoC
18
+ ggEBAKt1737THWDNIPvI+wXur6QKFsLPDiJW9Gtf1+VOO7WV6i6ZkFrOrlFTcYRK
19
+ 9XgC8mhVQSOfGPlo4vrqN83le7zTqPLkrGzn0lr2gD89sii4O2KlGPQOFxE73ZcB
20
+ cau2ZFsn/BTZymwF7FXAoE1NV3gyD92u0l2rRh9neYK4w+vewZmWNfxbqbgfljtS
21
+ +VJ5wN9X7PbdL/ivYn/vO90+rrET8TJZb44G33yGMn29xKnnX7uuw0NcVNs6SJl7
22
+ 5YDjRz6aWluHcucZBktYxkf/9w6/iAjYwdh5zU7jRUHzG4G6P+vhbBQqfXskw+Lq
23
+ OTFGvszar7G6VkkA9t+hQZvXI70CAwEAAaOBijCBhzAJBgNVHRMEAjAAMAsGA1Ud
24
+ DwQEAwIEsDAdBgNVHQ4EFgQUlbFfeiff0GMCrHHXyfskZ7lZqRYwJgYDVR0RBB8w
25
+ HYEbZ2VtbWFzdGVyQGphbWVzcm9iZXJ0c29uLmV1MCYGA1UdEgQfMB2BG2dlbW1h
26
+ c3RlckBqYW1lc3JvYmVydHNvbi5ldTANBgkqhkiG9w0BAQUFAAOCAQEAbSEarO+7
27
+ Sp5dFaejyCE+0V/wCQ3+hbOGAM8is3WeKElpax60CaUvkj9B7dqNXFIOsh5R7+Q9
28
+ hvbVIbEf/j2iCgI7MhLkEb1NoWBsiLDo8sBndqg0e+/s7SVkjI6dwJK+adzCYSjQ
29
+ bitUQ2W+TankC/JBe06l7Qki3ri50yVthDp5VPF6gujenQTqxiWeDksvMJvBGxp4
30
+ wE0bA5t1O2r3Ko6gnBx13SCjLwjIAIYvJQoQedcdo5yxWVnzyToS+dygE8SbJhJT
31
+ KYWcqZKgA8qLVcunQeGtvoh4RH26oqZ3L64D91kqO8nVPEQxIgeqIrgYiuVYdwO9
32
+ WRRQX/+XSywNEQ==
33
+ -----END CERTIFICATE-----
34
+ date: 2017-10-30 00:00:00.000000000 Z
35
+ dependencies:
36
+ - !ruby/object:Gem::Dependency
37
+ name: dynarex
38
+ requirement: !ruby/object:Gem::Requirement
39
+ requirements:
40
+ - - "~>"
41
+ - !ruby/object:Gem::Version
42
+ version: '1.7'
43
+ - - ">="
44
+ - !ruby/object:Gem::Version
45
+ version: 1.7.26
46
+ type: :runtime
47
+ prerelease: false
48
+ version_requirements: !ruby/object:Gem::Requirement
49
+ requirements:
50
+ - - "~>"
51
+ - !ruby/object:Gem::Version
52
+ version: '1.7'
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ version: 1.7.26
56
+ - !ruby/object:Gem::Dependency
57
+ name: sps-sub
58
+ requirement: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - "~>"
61
+ - !ruby/object:Gem::Version
62
+ version: '0.3'
63
+ - - ">="
64
+ - !ruby/object:Gem::Version
65
+ version: 0.3.6
66
+ type: :runtime
67
+ prerelease: false
68
+ version_requirements: !ruby/object:Gem::Requirement
69
+ requirements:
70
+ - - "~>"
71
+ - !ruby/object:Gem::Version
72
+ version: '0.3'
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: 0.3.6
76
+ description:
77
+ email: james@jamesrobertson.eu
78
+ executables: []
79
+ extensions: []
80
+ extra_rdoc_files: []
81
+ files:
82
+ - lib/job_log.rb
83
+ homepage: https://github.com/jrobertson/job_log
84
+ licenses:
85
+ - MIT
86
+ metadata: {}
87
+ post_install_message:
88
+ rdoc_options: []
89
+ require_paths:
90
+ - lib
91
+ required_ruby_version: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - ">="
94
+ - !ruby/object:Gem::Version
95
+ version: '0'
96
+ required_rubygems_version: !ruby/object:Gem::Requirement
97
+ requirements:
98
+ - - ">="
99
+ - !ruby/object:Gem::Version
100
+ version: '0'
101
+ requirements: []
102
+ rubyforge_project:
103
+ rubygems_version: 2.6.13
104
+ signing_key:
105
+ specification_version: 4
106
+ summary: Logs the start and end of a job by subscribing to the SPS topic log.
107
+ test_files: []
@@ -0,0 +1,2 @@
1
+ cy��K��;���/!����:/�#��%��#81\�r%:�:�㽺� 2�6���̵�x'E�¬��95]��1�%r2J#�$���-��W^KQ�3S��]m�e�H����_�!(뛊�.��&E\ ĝ�U��!l<��A�彛�����m��yS8�{'}�/"�\�{���#��m�+C �}9�y�x� ���j9�e'?u��}��B
2
+ -��o���I%/C�UՃ.�LI�v��n���oȗPn�^'/��=