Class: Terraspace::Cloud::Ci
- Inherits:
-
Object
- Object
- Terraspace::Cloud::Ci
- Defined in:
- lib/terraspace/cloud/ci.rb
Class Method Summary collapse
- .detect ⇒ Object
-
.interface_class(meta) ⇒ Object
IE: TerraspaceCiGithub::Interface.
- .match?(v, env_value) ⇒ Boolean
- .register(data) ⇒ Object
Class Method Details
.detect ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/terraspace/cloud/ci.rb', line 20 def detect detected = .find do |data| env_key = data[:env_key] # IE: ENV['GITHUB_ACTIONS'] env_value = data[:env_value] # IE: "string" or /pattern/ if env_value v = ENV[env_key] v && match?(v, env_value) else ENV[env_key] # only env_key end end interface_class(detected) if detected end |
.interface_class(meta) ⇒ Object
IE: TerraspaceCiGithub::Interface
35 36 37 |
# File 'lib/terraspace/cloud/ci.rb', line 35 def interface_class() "terraspace_ci_#{[:name]}::Interface".classify.constantize end |
.match?(v, env_value) ⇒ Boolean
39 40 41 42 43 44 45 46 |
# File 'lib/terraspace/cloud/ci.rb', line 39 def match?(v, env_value) case v when String v == env_value when Regexp v.match(env_value) end end |
.register(data) ⇒ Object
14 15 16 17 18 |
# File 'lib/terraspace/cloud/ci.rb', line 14 def register(data) self. << data unless .find do |m| m[:name] == data[:name] end end |