ops_team 0.9.0 → 0.9.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 +4 -4
- data/lib/builtin.rb +10 -0
- data/lib/builtins/background.rb +12 -12
- data/lib/builtins/background_log.rb +27 -0
- data/lib/ops.rb +1 -5
- data/lib/output.rb +2 -0
- data/ops_team.gemspec +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 70498a1ccc87cf4bf2ddd7ad29028785f02d8dc5a6c8ea44f181a1db5d8e8fea
|
4
|
+
data.tar.gz: e43c220a41cf3956c14bc077ead9abf64f5502960ad46c6c49915a3a51a4b76d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: be7def6a15311c5bed82a39b898a22d9aaeacd7058abecd1cdea47cef341439b78af9c9271cccf8ecdf5f9445c6be1d8fb76d44650a18654e0b22dd69b64dbd7
|
7
|
+
data.tar.gz: ad1cb8908108aae55c985b8b513421ad4669143a40a79db2fa064c1f4b07615b82fc736af36d766432204f459bd0cc467af8fa8743b8ff3c03b5af9aa4f259b5
|
data/lib/builtin.rb
CHANGED
@@ -7,6 +7,16 @@ class Builtin
|
|
7
7
|
def description
|
8
8
|
"no description"
|
9
9
|
end
|
10
|
+
|
11
|
+
def class_for(name:)
|
12
|
+
Builtins.const_get(builtin_class_name_for(name: name), false)
|
13
|
+
end
|
14
|
+
|
15
|
+
private
|
16
|
+
|
17
|
+
def builtin_class_name_for(name:)
|
18
|
+
name.capitalize.to_sym
|
19
|
+
end
|
10
20
|
end
|
11
21
|
|
12
22
|
def initialize(args, config)
|
data/lib/builtins/background.rb
CHANGED
@@ -1,7 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require 'open3'
|
4
|
-
|
5
3
|
require 'builtin'
|
6
4
|
|
7
5
|
module Builtins
|
@@ -13,6 +11,16 @@ module Builtins
|
|
13
11
|
def description
|
14
12
|
"runs the given command in a background session"
|
15
13
|
end
|
14
|
+
|
15
|
+
def log_filename
|
16
|
+
"#{log_filename_prefix}#{Ops.project_name}"
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
def log_filename_prefix
|
22
|
+
Options.get("background.log_filename_prefix") || DEFAULT_LOG_FILE_PREFIX
|
23
|
+
end
|
16
24
|
end
|
17
25
|
|
18
26
|
def run
|
@@ -26,22 +34,14 @@ module Builtins
|
|
26
34
|
private
|
27
35
|
|
28
36
|
def run_ops(args)
|
29
|
-
Output.warn("Running '#{args.join(' ')}' with stderr and stdout redirected to '#{
|
37
|
+
Output.warn("Running '#{args.join(' ')}' with stderr and stdout redirected to '#{Background.log_filename}'")
|
30
38
|
$stdout.sync = $stderr.sync = true
|
31
|
-
$stdout.reopen(
|
39
|
+
$stdout.reopen(Background.log_filename, "w")
|
32
40
|
$stderr.reopen($stdout)
|
33
41
|
|
34
42
|
Ops.new(args).run
|
35
43
|
end
|
36
44
|
|
37
|
-
def log_file
|
38
|
-
@log_file ||= "#{log_file_prefix}#{Ops.project_name}"
|
39
|
-
end
|
40
|
-
|
41
|
-
def log_file_prefix
|
42
|
-
Options.get("background.log_file_prefix") || DEFAULT_LOG_FILE_PREFIX
|
43
|
-
end
|
44
|
-
|
45
45
|
def shell
|
46
46
|
Options.get("background.shell") || DEFAULT_SHELL
|
47
47
|
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'builtin'
|
4
|
+
require 'builtins/background'
|
5
|
+
|
6
|
+
module Builtins
|
7
|
+
class BackgroundLog < Builtin
|
8
|
+
class << self
|
9
|
+
def description
|
10
|
+
"displays the log from the current or most recent background task from this project"
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def run
|
15
|
+
unless File.exist?(Background.log_filename)
|
16
|
+
Output.warn("No background log found at '#{Background.log_filename}'.")
|
17
|
+
return 0
|
18
|
+
end
|
19
|
+
|
20
|
+
Output.notice("Displaying background log '#{Background.log_filename}'...")
|
21
|
+
exec("tail #{args.join(' ')} '#{Background.log_filename}'")
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
# set an alias
|
26
|
+
Bglog = BackgroundLog
|
27
|
+
end
|
data/lib/ops.rb
CHANGED
@@ -64,16 +64,12 @@ class Ops
|
|
64
64
|
end
|
65
65
|
|
66
66
|
def builtin
|
67
|
-
@builtin ||=
|
67
|
+
@builtin ||= Builtin.class_for(name: @action_name).new(@args, config)
|
68
68
|
rescue NameError
|
69
69
|
# this means there isn't a builtin with that name in that module
|
70
70
|
nil
|
71
71
|
end
|
72
72
|
|
73
|
-
def builtin_class_name
|
74
|
-
@action_name.capitalize.to_sym
|
75
|
-
end
|
76
|
-
|
77
73
|
def action
|
78
74
|
return actions[@action_name] if actions[@action_name]
|
79
75
|
return aliases[@action_name] if aliases[@action_name]
|
data/lib/output.rb
CHANGED
data/ops_team.gemspec
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ops_team
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- nickthecook@gmail.com
|
@@ -149,6 +149,7 @@ files:
|
|
149
149
|
- lib/app_config.rb
|
150
150
|
- lib/builtin.rb
|
151
151
|
- lib/builtins/background.rb
|
152
|
+
- lib/builtins/background_log.rb
|
152
153
|
- lib/builtins/down.rb
|
153
154
|
- lib/builtins/env.rb
|
154
155
|
- lib/builtins/exec.rb
|