ops_team 0.11.0 → 0.12.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: 952f4e8174c60f623b0768fc6a35eb62524c1f574ea8d887c07023d423365d8e
4
- data.tar.gz: 9e8421e67c77535683fd7aae10d90c8a671ea3e58c37656a975f303092c8df06
3
+ metadata.gz: f4fd4661f8ea9e234bed8f61e205e625a232d301786557ce3c645519885c068a
4
+ data.tar.gz: af58d1ede9274d7a1aa884f036bc2dc6b93f7deff66307484bbcaae30806eea9
5
5
  SHA512:
6
- metadata.gz: 8e3c9bb627b2f8570cca8a3dd60f8e176138dcf01b9417889bcf50e2a24cc25759f5cf0492784bbc28e779fe6d201f570e0992fcb1a8261cab9d09f2f4d54e40
7
- data.tar.gz: 4c89388eb2bf7669cb7d4ddc588424911f56d04a5f6c72921e9fb2729caa0c95aa7cd2efac3b7040842d8976c367364eb881e0e4e672583b3c923d97b291d297
6
+ metadata.gz: bc505145b87e405a8a714196966ed2652bfd341fa8deec285c12ad6aa5fb07e01eb4797b888bc7ea5b253d90987b335e4fb6d45a5650af09b23fc74bac3086ed
7
+ data.tar.gz: 1227db2ce9be14ba4ee5bb1be55750fa6acbe92678a847b9d88a4e19bae6e465909bfa268b1700a73142946f4e0b751a69834630f8e6571860a6b8900403a8da
@@ -1,13 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "rubygems"
4
-
5
3
  require "output"
4
+ require "version"
6
5
 
7
6
  module Builtins
8
7
  class Version < Builtin
9
- GEMSPEC_FILE = "#{__dir__}/../../ops_team.gemspec"
10
-
11
8
  class << self
12
9
  def description
13
10
  "prints the version of ops that is running"
@@ -15,18 +12,7 @@ module Builtins
15
12
  end
16
13
 
17
14
  def run
18
- unless gemspec
19
- Output.error("Unable to load gemspec at '#{GEMSPEC_FILE}")
20
- return false
21
- end
22
-
23
- Output.out(gemspec.version)
24
- end
25
-
26
- private
27
-
28
- def gemspec
29
- @gemspec ||= Gem::Specification.load(GEMSPEC_FILE)
15
+ Output.out(::Version.version)
30
16
  end
31
17
  end
32
18
  end
data/lib/ops.rb CHANGED
@@ -3,12 +3,14 @@
3
3
 
4
4
  require 'yaml'
5
5
  require 'require_all'
6
+ require "rubygems"
6
7
 
7
8
  require 'hook_handler'
8
9
  require 'action'
9
10
  require 'output'
10
11
  require 'options'
11
12
  require 'environment'
13
+ require 'version'
12
14
  require_rel "builtins"
13
15
 
14
16
  # executes commands based on local `ops.yml`
@@ -20,6 +22,7 @@ class Ops
20
22
  INVALID_SYNTAX_EXIT_CODE = 64
21
23
  UNKNOWN_ACTION_EXIT_CODE = 65
22
24
  ERROR_LOADING_APP_CONFIG_EXIT_CODE = 66
25
+ MIN_VERSION_NOT_MET_EXIT_CODE = 67
23
26
 
24
27
  class << self
25
28
  def project_name
@@ -35,7 +38,9 @@ class Ops
35
38
  end
36
39
 
37
40
  def run
41
+ # "return" is here to allow specs to stub "exit"
38
42
  return exit(INVALID_SYNTAX_EXIT_CODE) unless syntax_valid?
43
+ return exit(MIN_VERSION_NOT_MET_EXIT_CODE) unless min_version_met?
39
44
 
40
45
  run_action
41
46
  rescue UnknownActionError => e
@@ -54,6 +59,21 @@ class Ops
54
59
  end
55
60
  end
56
61
 
62
+ def min_version_met?
63
+ return true unless min_version
64
+
65
+ if Version.min_version_met?(min_version)
66
+ true
67
+ else
68
+ Output.error("ops.yml specifies minimum version of #{min_version}, but ops version is #{Version.version}")
69
+ false
70
+ end
71
+ end
72
+
73
+ def min_version
74
+ config["min_version"]
75
+ end
76
+
57
77
  def run_action
58
78
  do_before_run_action
59
79
 
@@ -0,0 +1,38 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "rubygems"
4
+
5
+ class Version
6
+ GEMSPEC_FILE = "#{__dir__}/../ops_team.gemspec"
7
+
8
+ class << self
9
+ # these class methods exist because I don't want to have to call `Version.new.version` elsewhere
10
+ def version
11
+ new.send(:version)
12
+ end
13
+
14
+ def min_version_met?(min_version)
15
+ new.send(:min_version_met?, min_version)
16
+ end
17
+ end
18
+
19
+ private
20
+
21
+ # these instance methods exist so that I don't have to clear class variables between tests
22
+ def version
23
+ unless gemspec
24
+ Output.error("Unable to load gemspec at '#{GEMSPEC_FILE}")
25
+ return nil
26
+ end
27
+
28
+ gemspec.version
29
+ end
30
+
31
+ def min_version_met?(min_version)
32
+ Gem::Version.new(version) >= Gem::Version.new(min_version)
33
+ end
34
+
35
+ def gemspec
36
+ @gemspec ||= Gem::Specification.load(GEMSPEC_FILE)
37
+ end
38
+ end
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = 'ops_team'
5
- s.version = '0.11.0'
5
+ s.version = '0.12.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.11.0
4
+ version: 0.12.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - nickthecook@gmail.com
@@ -176,6 +176,7 @@ files:
176
176
  - lib/options.rb
177
177
  - lib/output.rb
178
178
  - lib/secrets.rb
179
+ - lib/version.rb
179
180
  - loader.rb
180
181
  - ops_team.gemspec
181
182
  homepage: https://github.com/nickthecook/ops