Sha256: 3024a10cb18200ffda7a75f32433b501d478c2df083ba17619867615da15d77e

Contents?: true

Size: 855 Bytes

Versions: 31

Compression:

Stored size: 855 Bytes

Contents

require 'json'
require 'open3'

require_relative "ruby_selector"
require_relative "gemfile_selector"

module SchemaDev
  class Executor

    attr_reader :ruby, :activerecord, :db, :error

    def initialize(ruby:, activerecord:, db:)
      @ruby_selector = RubySelector.command(ruby)
      @gemfile_selector = GemfileSelector.command(activerecord: activerecord, db: db)
    end

    def run(cmd, dry_run: false)
      fullcommand = ["/usr/bin/env", @gemfile_selector, @ruby_selector, cmd].compact.join(' ')
      puts "* #{fullcommand}"
      return true if dry_run

      @error = false
      Open3.popen2e(fullcommand) do |i, oe, t|
        oe.each {|line|
          puts line
          @error ||= (line =~ /(^Failed examples)|(rake aborted)|(LoadError)/)
        }
        @error ||= !t.value.success?
      end

      return !@error
    end
  end
end

Version data entries

31 entries across 31 versions & 1 rubygems

Version Path
schema_dev-4.0.0 lib/schema_dev/executor.rb
schema_dev-3.13.1 lib/schema_dev/executor.rb
schema_dev-3.13.0 lib/schema_dev/executor.rb
schema_dev-3.12.1 lib/schema_dev/executor.rb
schema_dev-3.12.0 lib/schema_dev/executor.rb
schema_dev-3.11.2 lib/schema_dev/executor.rb
schema_dev-3.11.1 lib/schema_dev/executor.rb
schema_dev-3.11.0 lib/schema_dev/executor.rb
schema_dev-3.10.1 lib/schema_dev/executor.rb
schema_dev-3.10.0 lib/schema_dev/executor.rb
schema_dev-3.9.0 lib/schema_dev/executor.rb
schema_dev-3.8.1 lib/schema_dev/executor.rb
schema_dev-3.8.0 lib/schema_dev/executor.rb
schema_dev-3.7.1 lib/schema_dev/executor.rb
schema_dev-3.7.0 lib/schema_dev/executor.rb
schema_dev-3.6.2 lib/schema_dev/executor.rb
schema_dev-3.6.1 lib/schema_dev/executor.rb
schema_dev-3.6.0 lib/schema_dev/executor.rb
schema_dev-3.5.1 lib/schema_dev/executor.rb
schema_dev-3.5.0 lib/schema_dev/executor.rb