matrixeval 0.1.0 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,51 @@
1
+ module Matrixeval
2
+ class Variant
3
+ class << self
4
+ def default(key, vector)
5
+ self.new({"key" => key}, vector)
6
+ end
7
+ end
8
+
9
+ attr_reader :key, :env, :vector, :default, :container, :mounts
10
+
11
+ def initialize(config = {}, vector)
12
+ raise Error.new("Variant#key is missing") if config["key"].nil?
13
+
14
+ @vector = vector
15
+ @key = config["key"].to_s
16
+ @container = Container.new(config["container"])
17
+ @env = config["env"] || {}
18
+ @default = config["default"] || false
19
+ @mounts = config["mounts"] || []
20
+ end
21
+
22
+ def name
23
+ "#{vector.key}: #{key}"
24
+ end
25
+
26
+ def id
27
+ "#{vector.id}_#{key.to_s.gsub(/[^A-Za-z0-9]/,'_')}"
28
+ end
29
+
30
+ def docker_compose_service_name
31
+ id
32
+ end
33
+
34
+ def pathname
35
+ id
36
+ end
37
+
38
+ def default?
39
+ default
40
+ end
41
+
42
+ def match_command_options?(options)
43
+ options[vector.key] == key.to_s
44
+ end
45
+
46
+ def ==(variant)
47
+ vector.key == variant.vector.key &&
48
+ key == variant.key
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,38 @@
1
+ module Matrixeval
2
+ class Vector
3
+ attr_reader :key, :variants, :main
4
+
5
+ def initialize(key, config)
6
+ @key = key.to_s
7
+ @main = !!config["main"]
8
+ @variants = (config["variants"] || []).map do |variant_config|
9
+ _config = if variant_config.is_a?(Hash)
10
+ variant_config
11
+ else
12
+ { "key" => variant_config.to_s }
13
+ end
14
+
15
+ Variant.new(_config, self)
16
+ end
17
+ end
18
+
19
+ def main?
20
+ return main if Config.target.vector_key.nil?
21
+
22
+ Config.target.vector_key == key
23
+ end
24
+
25
+ def id
26
+ "#{key.to_s.gsub(/[^A-Za-z0-9]/,'_')}"
27
+ end
28
+
29
+ def default_variant
30
+ variant = variants.find(&:default?)
31
+ if variant.nil?
32
+ raise Error.new("Please set a default variant for matrix #{key}")
33
+ end
34
+
35
+ variant
36
+ end
37
+ end
38
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Matrixeval
4
- VERSION = "0.1.0"
4
+ VERSION = "0.4.0"
5
5
  end
data/lib/matrixeval.rb CHANGED
@@ -2,7 +2,50 @@
2
2
 
3
3
  require_relative "matrixeval/version"
4
4
 
5
+ require 'pathname'
6
+ require 'fileutils'
7
+ require 'optparse'
8
+
9
+ require 'matrixeval/docker_compose/extend_raw'
10
+ require 'matrixeval/docker_compose/extend'
11
+ require 'matrixeval/container'
12
+ require 'matrixeval/variant'
13
+ require 'matrixeval/vector'
14
+ require 'matrixeval/config'
15
+
16
+ require 'matrixeval/target'
17
+
18
+ require 'matrixeval/context'
19
+ require 'matrixeval/extra_mount_files'
20
+ require 'matrixeval/docker_compose'
21
+ require 'matrixeval/gitignore'
22
+
23
+ require 'matrixeval/command_line'
24
+ require 'matrixeval/runner'
25
+
5
26
  module Matrixeval
27
+
6
28
  class Error < StandardError; end
7
- # Your code goes here...
29
+
30
+ module_function
31
+ def start(argv)
32
+ Runner.start(argv)
33
+ end
34
+
35
+ def register_target(target_name, target_klass)
36
+ targets[target_name] = target_klass
37
+ end
38
+
39
+ def targets
40
+ @targets ||= {}
41
+ end
42
+
43
+ def working_dir
44
+ Pathname.new(Dir.getwd)
45
+ end
46
+
47
+ def root
48
+ Pathname.new("#{__dir__}/..")
49
+ end
50
+
8
51
  end
metadata CHANGED
@@ -1,19 +1,63 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: matrixeval
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hopper Gee
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-02-03 00:00:00.000000000 Z
12
- dependencies: []
11
+ date: 2022-02-26 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rainbow
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '3.1'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '3.1'
27
+ - !ruby/object:Gem::Dependency
28
+ name: concurrent-ruby
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: terminal-table
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
13
55
  description: MatrixEval
14
56
  email:
15
57
  - hopper.gee@hey.com
16
- executables: []
58
+ executables:
59
+ - matrixeval
60
+ - meval
17
61
  extensions: []
18
62
  extra_rdoc_files: []
19
63
  files:
@@ -25,7 +69,30 @@ files:
25
69
  - Rakefile
26
70
  - bin/console
27
71
  - bin/setup
72
+ - bin/test
73
+ - exe/matrixeval
74
+ - exe/meval
28
75
  - lib/matrixeval.rb
76
+ - lib/matrixeval/command_line.rb
77
+ - lib/matrixeval/command_line/parse_context_arguments.rb
78
+ - lib/matrixeval/command_line/parse_init_arguments.rb
79
+ - lib/matrixeval/config.rb
80
+ - lib/matrixeval/config/yaml.rb
81
+ - lib/matrixeval/container.rb
82
+ - lib/matrixeval/context.rb
83
+ - lib/matrixeval/context/build_docker_compose_extend.rb
84
+ - lib/matrixeval/context/find_by_command_options.rb
85
+ - lib/matrixeval/docker_compose.rb
86
+ - lib/matrixeval/docker_compose/extend.rb
87
+ - lib/matrixeval/docker_compose/extend_raw.rb
88
+ - lib/matrixeval/docker_compose/file.rb
89
+ - lib/matrixeval/extra_mount_files.rb
90
+ - lib/matrixeval/gitignore.rb
91
+ - lib/matrixeval/runner.rb
92
+ - lib/matrixeval/target.rb
93
+ - lib/matrixeval/templates/matrixeval.yml
94
+ - lib/matrixeval/variant.rb
95
+ - lib/matrixeval/vector.rb
29
96
  - lib/matrixeval/version.rb
30
97
  homepage: https://github.com/MatrixEval/matrixeval
31
98
  licenses:
@@ -42,7 +109,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
42
109
  requirements:
43
110
  - - ">="
44
111
  - !ruby/object:Gem::Version
45
- version: 2.6.0
112
+ version: 2.5.0
46
113
  required_rubygems_version: !ruby/object:Gem::Requirement
47
114
  requirements:
48
115
  - - ">="