Skip to content

Commit

Permalink
Use RuboCop default hash syntax.
Browse files Browse the repository at this point in the history
  • Loading branch information
MikeMcQuaid committed Mar 7, 2024
1 parent 672cb6c commit 6489329
Show file tree
Hide file tree
Showing 11 changed files with 18 additions and 18 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Manage background services using the daemon manager `launchctl` on macOS or `sys

## Usage

See [the `brew services` section of the `man brew` output](https://docs.brew.sh/Manpage#services-subcommand) or `brew services --help`.
See [the `brew services` section of the `man brew` output](https://docs.brew.sh/Manpage#services-subcommand) or `brew services --help`.
To specify a service file use `brew services <command> <formula> --file=<file>`.


Expand Down
2 changes: 1 addition & 1 deletion lib/service/commands/info.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def run(targets, verbose:, json:)
end

output.each do |hash|
puts output(hash, verbose: verbose)
puts output(hash, verbose:)
end
end

Expand Down
2 changes: 1 addition & 1 deletion lib/service/commands/kill.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ module Kill

def run(targets, verbose:)
ServicesCli.check(targets) &&
ServicesCli.kill(targets, verbose: verbose)
ServicesCli.kill(targets, verbose:)
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/service/commands/list.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def print_table(formulae)
status += formula[:exit_code].to_s if formula[:status] == :error
file = formula[:file].to_s.gsub(Dir.home, "~").presence if formula[:loaded]

{ name: formula[:name], status: status, user: formula[:user], file: file }
{ name: formula[:name], status:, user: formula[:user], file: }
end

longest_name = [*services.map { |service| service[:name].length }, 4].max
Expand Down
6 changes: 3 additions & 3 deletions lib/service/commands/restart.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ def run(targets, verbose:)
# group not-started services with started ones for restart
started << service
end
ServicesCli.stop([service], verbose: verbose) if service.loaded?
ServicesCli.stop([service], verbose:) if service.loaded?
end

ServicesCli.run(ran, verbose: verbose) if ran.present?
ServicesCli.start(started, verbose: verbose) if started.present?
ServicesCli.run(ran, verbose:) if ran.present?
ServicesCli.start(started, verbose:) if started.present?
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/service/commands/run.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ module Run

def run(targets, verbose:)
ServicesCli.check(targets) &&
ServicesCli.run(targets, verbose: verbose)
ServicesCli.run(targets, verbose:)
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/service/commands/start.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ module Start

def run(targets, custom_plist, verbose:)
ServicesCli.check(targets) &&
ServicesCli.start(targets, custom_plist, verbose: verbose)
ServicesCli.start(targets, custom_plist, verbose:)
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/service/commands/stop.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ module Stop

def run(targets, verbose:, no_wait:)
ServicesCli.check(targets) &&
ServicesCli.stop(targets, verbose: verbose, no_wait: no_wait)
ServicesCli.stop(targets, verbose:, no_wait:)
end
end
end
Expand Down
8 changes: 4 additions & 4 deletions lib/service/formula_wrapper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -168,13 +168,13 @@ def exit_code

def to_hash
hash = {
name: name,
service_name: service_name,
name:,
service_name:,
running: pid?,
loaded: loaded?(cached: true),
schedulable: timed?,
pid: pid,
exit_code: exit_code,
pid:,
exit_code:,
user: owner,
status: status_symbol,
file: service_file_present? ? dest : service_file,
Expand Down
4 changes: 2 additions & 2 deletions lib/service/services_cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -283,12 +283,12 @@ def service_load(service, enable:)

if System.launchctl?
file = enable ? service.dest : service.service_file
launchctl_load(service, file: file, enable: enable)
launchctl_load(service, file:, enable:)
elsif System.systemctl?
# Systemctl loads based upon location so only install service
# file when it is not installed. Used with the `run` command.
install_service_file(service, nil) unless service.dest.exist?
systemd_load(service, enable: enable)
systemd_load(service, enable:)
end

function = enable ? "started" : "ran"
Expand Down
4 changes: 2 additions & 2 deletions spec/homebrew/commands/list_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@

it "prints an error code" do
file = Pathname.new("/tmp/file.file")
formula = { name: "a", user: "u", file: file, status: :error, exit_code: 256, loaded: true }
formula = { name: "a", user: "u", file:, status: :error, exit_code: 256, loaded: true }
expected_output = "<BOLD>Name Status User File<RESET>\na <RED>error <RESET>256 u /tmp/file.file\n"
expect do
described_class.print_table([formula])
Expand Down Expand Up @@ -102,7 +102,7 @@

it "includes an exit code" do
file = Pathname.new("/tmp/file.file")
formula = { name: "a", user: "u", file: file, status: :error, exit_code: 256, loaded: true }
formula = { name: "a", user: "u", file:, status: :error, exit_code: 256, loaded: true }
filtered_formula = formula.slice(*described_class::JSON_FIELDS)
expected_output = "#{JSON.pretty_generate([filtered_formula])}\n"
expect do
Expand Down

0 comments on commit 6489329

Please sign in to comment.