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