class Snowglobe::ProjectCommandRunner

Attributes

fs[R]

Public Class Methods

new(fs) click to toggle source
# File lib/snowglobe/project_command_runner.rb, line 3
def initialize(fs)
  @fs = fs
end

Public Instance Methods

run(*args, **options, &block) click to toggle source
# File lib/snowglobe/project_command_runner.rb, line 56
def run(*args, **options, &block)
  CommandRunner.run(
    *args,
    directory: fs.project_directory,
    **options,
    &block
  )
end
run!(*args, **options, &block) click to toggle source
# File lib/snowglobe/project_command_runner.rb, line 47
def run!(*args, **options, &block)
  CommandRunner.run!(
    *args,
    directory: fs.project_directory,
    **options,
    &block
  )
end
run_migrations!() click to toggle source
# File lib/snowglobe/project_command_runner.rb, line 7
def run_migrations!
  run_rake_tasks!(["db:drop", "db:create", "db:migrate"])
end
run_n_unit_test_suite() click to toggle source
# File lib/snowglobe/project_command_runner.rb, line 15
def run_n_unit_test_suite
  run_rake_tasks("test", env: { TESTOPTS: "-v" })
end
run_n_unit_tests(*paths) click to toggle source
# File lib/snowglobe/project_command_runner.rb, line 11
def run_n_unit_tests(*paths)
  run_command_within_bundle("ruby -I lib -I test", *paths)
end
run_rake_tasks(*tasks) click to toggle source
# File lib/snowglobe/project_command_runner.rb, line 28
def run_rake_tasks(*tasks)
  options = tasks.last.is_a?(Hash) ? tasks.pop : {}
  args = ["bundle", "exec", "rake", *tasks, "--trace"] + [options]
  run(*args)
end
run_rake_tasks!(*args, **options, &block) click to toggle source
# File lib/snowglobe/project_command_runner.rb, line 19
def run_rake_tasks!(*args, **options, &block)
  run_rake_tasks(
    *args,
    **options,
    run_successfully: true,
    &block
  )
end
run_within_bundle(*args) { |runner| ... } click to toggle source
# File lib/snowglobe/project_command_runner.rb, line 34
def run_within_bundle(*args)
  run(*args) do |runner|
    runner.command_prefix = "bundle exec"
    runner.env["BUNDLE_GEMFILE"] = fs.find_in_project("Gemfile").to_s

    runner.around_command do |run_command|
      Bundler.with_clean_env(&run_command)
    end

    yield runner if block_given?
  end
end