Sha256: abb219cd6c63076bb515af5b3344bb8abff74734d0cfa7d28506009d101a5c9c

Contents?: true

Size: 1.28 KB

Versions: 56

Compression:

Stored size: 1.28 KB

Contents

# frozen_string_literal: true

require_relative "../base"

module Neetob
  class CLI
    module Heroku
      class Execute < Base
        attr_accessor :apps, :command_to_execute, :should_run_in_rails_console, :sandbox

        def initialize(apps, command_to_execute, should_run_in_rails_console = false, sandbox = false)
          super()
          @apps = apps
          @command_to_execute = command_to_execute
          @should_run_in_rails_console = should_run_in_rails_console
          @sandbox = sandbox
        end

        def run
          matching_apps = find_all_matching_apps_or_repos(apps, :heroku, sandbox)
          rails_runner_command = "rails runner '#{command_to_execute}'"
          heroku_command = should_run_in_rails_console ? "run \"#{rails_runner_command}\"" : command_to_execute
          matching_apps.each do |app|
            ui.info("\n  Working on #{app}\n")
            output = `heroku #{heroku_command} -a #{app}`
            unless $?.success?
              ui.error("There is a problem in accessing the app with name \"#{app}\" in your account.")
              ui.error("Please check the specified app name and ensure you're authorized to view that app.")
              next
            end
            ui.success(output)
          end
        end
      end
    end
  end
end

Version data entries

56 entries across 56 versions & 1 rubygems

Version Path
neetob-0.4.10 lib/neetob/cli/heroku/execute.rb
neetob-0.4.9 lib/neetob/cli/heroku/execute.rb
neetob-0.4.8 lib/neetob/cli/heroku/execute.rb
neetob-0.4.7 lib/neetob/cli/heroku/execute.rb
neetob-0.4.6 lib/neetob/cli/heroku/execute.rb
neetob-0.4.5 lib/neetob/cli/heroku/execute.rb
neetob-0.4.4 lib/neetob/cli/heroku/execute.rb
neetob-0.4.3 lib/neetob/cli/heroku/execute.rb
neetob-0.4.2 lib/neetob/cli/heroku/execute.rb
neetob-0.4.1 lib/neetob/cli/heroku/execute.rb
neetob-0.4.0 lib/neetob/cli/heroku/execute.rb
neetob-0.3.2 lib/neetob/cli/heroku/execute.rb
neetob-0.3.1 lib/neetob/cli/heroku/execute.rb
neetob-0.3.0 lib/neetob/cli/heroku/execute.rb
neetob-0.2.7 lib/neetob/cli/heroku/execute.rb
neetob-0.2.6 lib/neetob/cli/heroku/execute.rb