ops_team 1.11.0 → 1.13.0

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: 58e624e071ff1192e4f1d53d3a76135f0cb93feb43730531012944c245109a5f
4
- data.tar.gz: 55a945d92fc66f60ff5dce922a734d93e3ec74973d97505357efb1c57d0d7a76
3
+ metadata.gz: 8c5f694faa0c40cbd2f850fe45fb7eb35012d3359bf815e95984198366ddac6d
4
+ data.tar.gz: 4d9e6178368112d8a55869162b4371ec715a9168bfb9c0b2fca08e0025d7d1e6
5
5
  SHA512:
6
- metadata.gz: a1b19fb48de6a17dc8430bd09855ae94483117562ab6c725870abcacf72df86dad737ffb4cdbfe1b0d1c1290acf27c466194c39b88f6b98b833cfe2b61a5b43b
7
- data.tar.gz: fbae4f1f500e1d9ef96a1befc963111bfc28a32d3c7da2bc5e0c1a4a8e8e9ad2c5308eb3c3adaa58b3c55b5ce6e9f59e47482cb5e5e6c629a32dd74d35c7b14d
6
+ metadata.gz: 1bf4567b067db9a9041628384e3b09c096b6ece2caada9749c449a29e2e772197e52f5ee8413155e47a8faeb3bc68134f9f4ef86d7aa1f26d4b3111cbe21b0c1
7
+ data.tar.gz: 59eb6746612f1f7209ea93b086be4556274fbda04d2e7372b2ce8583bc1eea9d86b7a0c795d6d137a6278c3c4a716faa67ee3c69ab2ab1cd155d2b7ec5c097b5
data/bin/ops CHANGED
@@ -3,7 +3,6 @@
3
3
 
4
4
  require 'optparse'
5
5
 
6
-
7
6
  def usage
8
7
  puts "Usage: ops [-f|--file <ops_yml>] action [<action args>"
9
8
  puts " ops_yml: the config file to load instead of './ops.yml'"
data/lib/action.rb CHANGED
@@ -26,7 +26,13 @@ class Action
26
26
  end
27
27
 
28
28
  def alias
29
- @config["alias"]
29
+ @config["alias"] || @config["aliases"]&.first
30
+ end
31
+
32
+ def aliases
33
+ return [@config["alias"]].compact unless @config["aliases"]
34
+
35
+ ([@config["alias"]] + @config["aliases"]).compact
30
36
  end
31
37
 
32
38
  def command
data/lib/action_list.rb CHANGED
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'action'
4
+
3
5
  class ActionList
4
6
  class UnknownActionError < StandardError; end
5
7
 
@@ -40,7 +42,16 @@ class ActionList
40
42
  action = Action.new(name, config, @args)
41
43
 
42
44
  @actions[name] = action
43
- @aliases[action.alias] = action
45
+ action.aliases.each do |aliaz|
46
+ check_duplicate_alias(name, aliaz)
47
+ @aliases[aliaz] = action
48
+ end
44
49
  end
45
50
  end
51
+
52
+ def check_duplicate_alias(name, aliaz)
53
+ return if @aliases[aliaz].nil?
54
+
55
+ Output.warn("Duplicate alias '#{aliaz}' detected in action '#{name}'.")
56
+ end
46
57
  end
@@ -23,6 +23,8 @@ module Builtins
23
23
  end
24
24
 
25
25
  Process.detach(subprocess)
26
+
27
+ true
26
28
  end
27
29
 
28
30
  private
data/lib/builtins/help.rb CHANGED
@@ -17,23 +17,24 @@ module Builtins
17
17
  end
18
18
 
19
19
  def run
20
- Output.out("Builtins:")
21
- Output.out(" #{builtins.join("\n ")}")
22
- Output.out("")
23
- Output.out("Forwards:")
24
- Output.out(" #{forwards.join("\n ")}")
25
- Output.out("")
26
- Output.out("Actions:")
27
- Output.out(" #{actions.join("\n ")}")
20
+ list("Builtins", builtins) if builtins.any?
21
+ list("Forwards", forwards) if forwards.any?
22
+ list("Actions", actions) if actions.any?
28
23
 
29
24
  true
30
25
  end
31
26
 
32
27
  private
33
28
 
29
+ def list(name, items)
30
+ Output.out("#{name}:")
31
+ Output.out(" #{items.join("\n ")}")
32
+ Output.out("")
33
+ end
34
+
34
35
  def forwards
35
36
  Forwards.new(@config).forwards.map do |name, dir|
36
- format("%<name>-#{NAME_WIDTH}s %<desc>s" , name: name.yellow, desc: "#{dir}")
37
+ format("%<name>-#{NAME_WIDTH}s %<desc>s", name: name.yellow, desc: dir.to_s)
37
38
  end
38
39
  end
39
40
 
@@ -18,7 +18,7 @@ module Builtins
18
18
 
19
19
  @dependency_set.map do |type, names|
20
20
  dependencies_for(type, names)
21
- end.flatten
21
+ end.flatten.compact
22
22
  end
23
23
 
24
24
  def dependencies_for(type, names)
@@ -7,7 +7,7 @@ require 'dependency'
7
7
  module Dependencies
8
8
  class Apk < Dependency
9
9
  def met?
10
- execute("apk info | grep -q #{name}")
10
+ execute("apk info | grep -q '^#{name}'$")
11
11
  end
12
12
 
13
13
  def meet
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'English'
4
+
5
+ require 'dependency'
6
+ require 'options'
7
+
8
+ module Dependencies
9
+ class Pip < Dependency
10
+ DEFAULT_PIP = "python3 -m pip"
11
+
12
+ def met?
13
+ execute("#{pip} show #{name}")
14
+ end
15
+
16
+ def meet
17
+ execute("#{pip} install #{name}")
18
+ end
19
+
20
+ def unmeet
21
+ # do nothing; we don't want to uninstall packages and reinstall them every time
22
+ true
23
+ end
24
+
25
+ def should_meet?
26
+ true
27
+ end
28
+
29
+ private
30
+
31
+ def pip
32
+ Options.get("pip.command") || DEFAULT_PIP
33
+ end
34
+ end
35
+ end
data/lib/hook_handler.rb CHANGED
@@ -4,6 +4,7 @@ require 'output'
4
4
 
5
5
  class HookHandler
6
6
  class HookConfigError < StandardError; end
7
+
7
8
  class HookExecError < StandardError; end
8
9
 
9
10
  def initialize(config)
data/lib/ops.rb CHANGED
@@ -101,13 +101,11 @@ class Ops
101
101
  end
102
102
 
103
103
  def config
104
- @config ||= begin
105
- if config_file_exists?
106
- parsed_config_contents
107
- else
108
- Output.warn("File '#{@config_file}' does not exist.") unless @action_name == "init"
109
- {}
110
- end
104
+ @config ||= if config_file_exists?
105
+ parsed_config_contents
106
+ else
107
+ Output.warn("File '#{@config_file}' does not exist.") unless @action_name == "init"
108
+ {}
111
109
  end
112
110
  end
113
111
 
data/lib/secrets.rb CHANGED
@@ -43,9 +43,7 @@ class Secrets < AppConfig
43
43
  end
44
44
 
45
45
  def file_contents
46
- @file_contents ||= begin
47
- @filename.match(/\.ejson$/) ? ejson_contents : super
48
- end
46
+ @file_contents ||= @filename.match(/\.ejson$/) ? ejson_contents : super
49
47
  end
50
48
 
51
49
  def ejson_contents
data/ops_team.gemspec CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = 'ops_team'
5
- s.version = '1.11.0'
5
+ s.version = '1.13.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: 1.11.0
4
+ version: 1.13.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - nickthecook@gmail.com
@@ -193,6 +193,7 @@ files:
193
193
  - lib/dependencies/docker.rb
194
194
  - lib/dependencies/gem.rb
195
195
  - lib/dependencies/helpers/apt_cache_policy.rb
196
+ - lib/dependencies/pip.rb
196
197
  - lib/dependencies/sshkey.rb
197
198
  - lib/dependencies/versioned_dependency.rb
198
199
  - lib/dependency.rb
@@ -228,7 +229,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
228
229
  - !ruby/object:Gem::Version
229
230
  version: '0'
230
231
  requirements: []
231
- rubygems_version: 3.2.22
232
+ rubygems_version: 3.2.15
232
233
  signing_key:
233
234
  specification_version: 4
234
235
  summary: ops_team handles basic automation for your project, driven by self-documenting