Class: SchemaDev::Executor
- Inherits:
-
Object
- Object
- SchemaDev::Executor
- Defined in:
- lib/schema_dev/executor.rb
Instance Attribute Summary collapse
-
#db ⇒ Object
readonly
Returns the value of attribute db.
-
#error ⇒ Object
readonly
Returns the value of attribute error.
-
#rails ⇒ Object
readonly
Returns the value of attribute rails.
-
#ruby ⇒ Object
readonly
Returns the value of attribute ruby.
Instance Method Summary collapse
-
#initialize(ruby:, rails:, db:) ⇒ Executor
constructor
A new instance of Executor.
- #run(cmd, dry_run: false) ⇒ Object
Constructor Details
#initialize(ruby:, rails:, db:) ⇒ Executor
Returns a new instance of Executor.
12 13 14 15 |
# File 'lib/schema_dev/executor.rb', line 12 def initialize(ruby:, rails:, db:) @ruby_selector = RubySelector.command(ruby) @gemfile_selector = GemfileSelector.command(rails: rails, db: db) end |
Instance Attribute Details
#db ⇒ Object (readonly)
Returns the value of attribute db.
10 11 12 |
# File 'lib/schema_dev/executor.rb', line 10 def db @db end |
#error ⇒ Object (readonly)
Returns the value of attribute error.
10 11 12 |
# File 'lib/schema_dev/executor.rb', line 10 def error @error end |
#rails ⇒ Object (readonly)
Returns the value of attribute rails.
10 11 12 |
# File 'lib/schema_dev/executor.rb', line 10 def rails @rails end |
#ruby ⇒ Object (readonly)
Returns the value of attribute ruby.
10 11 12 |
# File 'lib/schema_dev/executor.rb', line 10 def ruby @ruby end |
Instance Method Details
#run(cmd, dry_run: false) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/schema_dev/executor.rb', line 17 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 |