ops_team 0.9.0 → 0.9.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a811c1178ce7f125d006e4a3839191446cf758bf24dd5b68d10e6778b4aa2927
4
- data.tar.gz: 4b46a9a22a19f533d244c4442ab8c4bbb30479e04c09d4f40f65993faa7f4ea1
3
+ metadata.gz: 70498a1ccc87cf4bf2ddd7ad29028785f02d8dc5a6c8ea44f181a1db5d8e8fea
4
+ data.tar.gz: e43c220a41cf3956c14bc077ead9abf64f5502960ad46c6c49915a3a51a4b76d
5
5
  SHA512:
6
- metadata.gz: 14117ab9417d99efc20ea08a0497504acdc7486704be02b96f65fe7da0719447dace894e8ee733261e9fd73b5cafe81199527aa37e4977cd818434e6517465be
7
- data.tar.gz: 179c07999a87d8f43710ab22f1ffda3dd7a5776e56640324c1a4e175df36607fe904e0b2c15901e8c5e89eaba3a1a216157a6fb518e5aca6f64120061bb6dbc5
6
+ metadata.gz: be7def6a15311c5bed82a39b898a22d9aaeacd7058abecd1cdea47cef341439b78af9c9271cccf8ecdf5f9445c6be1d8fb76d44650a18654e0b22dd69b64dbd7
7
+ data.tar.gz: ad1cb8908108aae55c985b8b513421ad4669143a40a79db2fa064c1f4b07615b82fc736af36d766432204f459bd0cc467af8fa8743b8ff3c03b5af9aa4f259b5
@@ -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)
@@ -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 '#{log_file}'")
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(log_file, "w")
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 ||= Builtins.const_get(builtin_class_name, false).new(@args, config)
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]
@@ -40,6 +40,8 @@ class Output
40
40
  @err.puts(msg.yellow)
41
41
  end
42
42
 
43
+ alias_method :notice, :warn
44
+
43
45
  def error(msg)
44
46
  @err.puts(msg.red)
45
47
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = 'ops_team'
5
- s.version = '0.9.0'
5
+ s.version = '0.9.1'
6
6
  s.authors = [
7
7
  'nickthecook@gmail.com'
8
8
  ]
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.0
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