Class: Gemika::Matrix
- Inherits:
-
Object
- Object
- Gemika::Matrix
- Defined in:
- lib/gemika/matrix.rb
Constant Summary collapse
- COLOR_HEAD =
"\e[44;97m"- COLOR_WARNING =
"\e[33m"- COLOR_SUCCESS =
"\e[32m"- COLOR_FAILURE =
"\e[31m"- COLOR_RESET =
"\e[0m"
Class Method Summary collapse
Instance Method Summary collapse
- #each(&block) ⇒ Object
-
#initialize(options) ⇒ Matrix
constructor
A new instance of Matrix.
Constructor Details
#initialize(options) ⇒ Matrix
Returns a new instance of Matrix.
12 13 14 15 16 |
# File 'lib/gemika/matrix.rb', line 12 def initialize() @rows = .fetch(:rows) @results = {} @all_passed = nil end |
Class Method Details
.from_travis_yml ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/gemika/matrix.rb', line 39 def self.from_travis_yml travis_yml = YAML.load_file('.travis.yml') rubies = travis_yml.fetch('rvm') gemfiles = travis_yml.fetch('gemfile') = travis_yml.fetch('matrix', {}) excludes = .fetch('exclude', []) includes = .fetch('include', []) rows = [] rubies.each do |ruby| gemfiles.each do |gemfile| entry = { 'rvm' => ruby, 'gemfile' => gemfile } rows << entry unless excludes.include?(entry) end end rows += includes new(:rows => rows) end |
Instance Method Details
#each(&block) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/gemika/matrix.rb', line 18 def each(&block) @all_passed = true rows.each do |entry| gemfile = entry['gemfile'] if compatible?(entry) print_title gemfile ENV['BUNDLE_GEMFILE'] = gemfile gemfile_passed = block.call @all_passed &= gemfile_passed if gemfile_passed @results[entry] = tint('Success', COLOR_SUCCESS) else @results[entry] = tint('Failed', COLOR_FAILURE) end else @results[entry] = tint("Skipped", COLOR_WARNING) end end print_summary end |