Sha256: 54b677765b6d91307e960f5c8975438beb5f90540da2bfbcd0dd4f3c02fd1523
Contents?: true
Size: 863 Bytes
Versions: 2
Compression:
Stored size: 863 Bytes
Contents
require 'json' require_relative "ruby_selector" require_relative "gemfile_selector" module SchemaDev class Executor attr_reader :ruby, :rails, :db, :error def initialize(ruby:, rails:, db: nil) @ruby_selector = RubySelector.command(ruby) @gemfile_selector = GemfileSelector.command(rails: rails, db: db) @dev_env = "SCHEMA_DEV_DB=#{db.inspect}" end def run(cmd, dry_run: false) fullcommand = ["/usr/bin/env", @dev_env, @gemfile_selector, @ruby_selector, cmd].compact.join(' ') puts "* #{fullcommand}" return true if dry_run Tempfile.open('SchemaDev') do |file| @error = !system(%Q[ (#{fullcommand}) 2>& 1 | tee #{file.path} ]) file.rewind @error ||= file.readlines.grep(/(^Failed examples)|(rake aborted)|(LoadError)/).any? end return !@error end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
schema_dev-0.0.3 | lib/schema_dev/executor.rb |
schema_dev-0.0.2 | lib/schema_dev/executor.rb |