Class: Ossy::Engine::Rubocop::Run
- Inherits:
-
CLI::Commands::Core
- Object
- Dry::CLI::Command
- CLI::Commands::Core
- Ossy::Engine::Rubocop::Run
- Defined in:
- lib/ossy/engine/rubocop/run.rb
Instance Method Summary collapse
Instance Method Details
#call(path:, format: "json", args: []) ⇒ Object
99 100 101 102 103 104 105 106 107 108 |
# File 'lib/ossy/engine/rubocop/run.rb', line 99 def call(path:, format: "json", args: []) extra_opts = args.join(" ") result, output = exec("rubocop #{path} --format #{format} #{extra_opts}".strip) case format when "json" then Result.build(JSON.parse(output)) else [result, output] end end |
#exec(cmd, opts = {}) ⇒ Object
110 111 112 113 114 |
# File 'lib/ossy/engine/rubocop/run.rb', line 110 def exec(cmd, opts = {}) Open3.popen3(cmd, opts) do |_stdin, stdout, _stderr, wait_thr| [wait_thr.value, stdout.read] end end |