ops_team 0.8.10 → 0.9.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: caa9b859d0dac66be5cc981ed872b591a6c174a5c70dabdf145d415681960831
4
- data.tar.gz: '08beac67a93906cb88db284977d1a10863820de5fd73369fb782f530cc8ec601'
3
+ metadata.gz: a811c1178ce7f125d006e4a3839191446cf758bf24dd5b68d10e6778b4aa2927
4
+ data.tar.gz: 4b46a9a22a19f533d244c4442ab8c4bbb30479e04c09d4f40f65993faa7f4ea1
5
5
  SHA512:
6
- metadata.gz: 472f261d6d94bc4024576b2a322fe69bd10b53b5892efbcc89027a825723901c9a1aede0cc393cd8fae372dba49bdeb95c703b912f4d83ecf6711de8f3541caa
7
- data.tar.gz: 2a3a3ae0d383b40bec9cfaa79d705520f46b885f510aaab3833e763114a9c10a8b90af5a6c6285942e53057508643da93ad32f629fc4812819e24e44969ba750
6
+ metadata.gz: 14117ab9417d99efc20ea08a0497504acdc7486704be02b96f65fe7da0719447dace894e8ee733261e9fd73b5cafe81199527aa37e4977cd818434e6517465be
7
+ data.tar.gz: 179c07999a87d8f43710ab22f1ffda3dd7a5776e56640324c1a4e175df36607fe904e0b2c15901e8c5e89eaba3a1a216157a6fb518e5aca6f64120061bb6dbc5
@@ -1,6 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class Builtin
4
+ attr_reader :args, :config
5
+
4
6
  class << self
5
7
  def description
6
8
  "no description"
@@ -0,0 +1,52 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'open3'
4
+
5
+ require 'builtin'
6
+
7
+ module Builtins
8
+ class Background < Builtin
9
+ DEFAULT_SHELL = "bash"
10
+ DEFAULT_LOG_FILE_PREFIX = "/tmp/ops_bglog_"
11
+
12
+ class << self
13
+ def description
14
+ "runs the given command in a background session"
15
+ end
16
+ end
17
+
18
+ def run
19
+ subprocess = fork do
20
+ run_ops(args)
21
+ end
22
+
23
+ Process.detach(subprocess)
24
+ end
25
+
26
+ private
27
+
28
+ def run_ops(args)
29
+ Output.warn("Running '#{args.join(' ')}' with stderr and stdout redirected to '#{log_file}'")
30
+ $stdout.sync = $stderr.sync = true
31
+ $stdout.reopen(log_file, "w")
32
+ $stderr.reopen($stdout)
33
+
34
+ Ops.new(args).run
35
+ end
36
+
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
+ def shell
46
+ Options.get("background.shell") || DEFAULT_SHELL
47
+ end
48
+ end
49
+
50
+ # set an alias
51
+ Bg = Background
52
+ end
@@ -57,8 +57,7 @@ module Dependencies
57
57
  end
58
58
 
59
59
  def key_comment
60
- # the current directory is usually named for the project
61
- File.basename(::Dir.pwd)
60
+ Ops.project_name
62
61
  end
63
62
 
64
63
  def dir_name
data/lib/ops.rb CHANGED
@@ -19,6 +19,12 @@ class Ops
19
19
  INVALID_SYNTAX_EXIT_CODE = 64
20
20
  UNKNOWN_ACTION_EXIT_CODE = 65
21
21
 
22
+ class << self
23
+ def project_name
24
+ File.basename(::Dir.pwd)
25
+ end
26
+ end
27
+
22
28
  def initialize(argv)
23
29
  @action_name = argv[0]
24
30
  @args = argv[1..-1]
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = 'ops_team'
5
- s.version = '0.8.10'
5
+ s.version = '0.9.0'
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.8.10
4
+ version: 0.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - nickthecook@gmail.com
@@ -148,6 +148,7 @@ files:
148
148
  - lib/action.rb
149
149
  - lib/app_config.rb
150
150
  - lib/builtin.rb
151
+ - lib/builtins/background.rb
151
152
  - lib/builtins/down.rb
152
153
  - lib/builtins/env.rb
153
154
  - lib/builtins/exec.rb