Skip to content

Commit

Permalink
whitespace fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
copiousfreetime committed May 3, 2024
1 parent 9ca065a commit f317776
Show file tree
Hide file tree
Showing 17 changed files with 19 additions and 23 deletions.
5 changes: 3 additions & 2 deletions lib/launchy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
# application class
#
module Launchy

class << self
#
# Launch an application for the given uri string
Expand Down Expand Up @@ -73,6 +72,7 @@ def string_to_uri(s)
Launchy.log "URI parsing pass 2 : #{s} -> #{uri.to_hash}"
end
raise Launchy::ArgumentError, "Invalid URI given: #{s.inspect}" unless uri

return uri
end

Expand Down Expand Up @@ -142,7 +142,8 @@ def path=(path)
@path = path
end

private
private

def to_bool(arg)
if arg.is_a? String
arg == "true"
Expand Down
2 changes: 2 additions & 0 deletions lib/launchy/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class << self
def handling(uri)
klass = find_child(:handles?, uri)
return klass if klass

raise ApplicationNotFoundError, "No application found to handle '#{uri}'"
end

Expand All @@ -32,6 +33,7 @@ def handling(uri)
def for_name(name)
klass = find_child(:has_name?, name)
return klass if klass

raise ApplicationNotFoundError, "No application found named '#{name}'"
end

Expand Down
1 change: 1 addition & 0 deletions lib/launchy/applications/browser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ def app_list

def browser_env
return [] unless ENV["BROWSER"]

browser_env = ENV["BROWSER"].split(File::PATH_SEPARATOR)
browser_env.flatten!
browser_env.delete_if { |b| b.nil? || (b.strip.size == 0) }
Expand Down
1 change: 1 addition & 0 deletions lib/launchy/argv.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ module Launchy
#
class Argv
attr_reader :argv

def initialize(*args)
@argv = args.flatten
end
Expand Down
4 changes: 1 addition & 3 deletions lib/launchy/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ module Launchy
# Internal: Command line interface for Launchy
#
class Cli

attr_reader :options

def initialize
@options = {}
end
Expand Down Expand Up @@ -39,7 +39,6 @@ def parser
@options[:host_os] = os
end


op.separator ""
op.separator "Standard Options:"

Expand All @@ -52,7 +51,6 @@ def parser
$stdout.puts "Launchy version #{Launchy::VERSION}"
exit 0
end

end
end
# rubocop:enable Metrics/MethodLength
Expand Down
1 change: 1 addition & 0 deletions lib/launchy/descendant_tracker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ module Launchy
module DescendantTracker
def inherited(klass)
return unless klass.instance_of?(Class)

self.children << klass
end

Expand Down
3 changes: 0 additions & 3 deletions lib/launchy/detect/host_os.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ module Launchy::Detect
# Internal: Determine the host operating system that Launchy is running on
#
class HostOs

attr_reader :host_os
alias to_s host_os
alias to_str host_os
Expand All @@ -30,7 +29,5 @@ def default_host_os
def override_host_os
Launchy.host_os
end

end

end
12 changes: 8 additions & 4 deletions lib/launchy/detect/host_os_family.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ class NotFoundError < Launchy::Error; end
extend ::Launchy::DescendantTracker

class << self

def detect(host_os = HostOs.new)
found = find_child(:matches?, host_os)
return found.new(host_os) if found

raise NotFoundError, "Unknown OS family for host os '#{host_os}'. #{Launchy.bug_report_message}"
end

Expand All @@ -27,16 +27,16 @@ def nix?() self == Nix; end
def cygwin?() self == Cygwin; end
end


attr_reader :host_os

def initialize(host_os = HostOs.new)
@host_os = host_os
end

def windows?() self.class.windows?; end
def darwin?() self.class.darwin?; end
def nix?() self.class.nix?; end
def cygwin?() self.class.cygwin?; end
def nix?() self.class.nix?; end
def cygwin?() self.class.cygwin?; end

#---------------------------
# All known host os families
Expand All @@ -46,6 +46,7 @@ class Windows < HostOsFamily
def self.matching_regex
/(mingw|mswin|msys|windows)/i
end

def app_list(app) app.windows_app_list; end
end

Expand All @@ -54,6 +55,7 @@ class Darwin < HostOsFamily
def self.matching_regex
/(darwin|mac os)/i
end

def app_list(app) app.darwin_app_list; end
end

Expand All @@ -62,6 +64,7 @@ class Nix < HostOsFamily
def self.matching_regex
/(linux|bsd|aix|solaris|sunos|dragonfly)/i
end

def app_list(app) app.nix_app_list; end
end

Expand All @@ -70,6 +73,7 @@ class Cygwin < HostOsFamily
def self.matching_regex
/cygwin/i
end

def app_list(app) app.cygwin_app_list; end
end
end
Expand Down
1 change: 0 additions & 1 deletion lib/launchy/detect/nix_desktop_environment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,5 @@ def self.browser
::Launchy::Argv.new
end
end

end
end
1 change: 1 addition & 0 deletions lib/launchy/runner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ module Launchy
class Runner
def run(cmd, *args)
raise Launchy::CommandNotFoundError, "No command found to run with args '#{args.join(' ')}'. If this is unexpected, #{Launchy.bug_report_message}" unless cmd

if Launchy.dry_run? then
$stdout.puts dry_run(cmd, *args)
else
Expand Down
1 change: 0 additions & 1 deletion lib/launchy/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ module Launchy

# Internal: Version number of Launchy
module Version

MAJOR = Integer(VERSION.split(".")[0])
MINOR = Integer(VERSION.split(".")[1])
PATCH = Integer(VERSION.split(".")[2])
Expand Down
2 changes: 1 addition & 1 deletion spec/applications/browser_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"darwin" => "darwin_app_list",
"cygwin" => "cygwin_app_list",
"linux" => "nix_app_list",
}.each do |host_os, called_method|
}.each do |host_os, called_method|
it "when host_os is '#{host_os}' the '#{called_method}' method is called" do
Launchy.host_os = host_os
browser = Launchy::Application::Browser.new
Expand Down
1 change: 0 additions & 1 deletion spec/cli_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
require "spec_helper"

describe Launchy::Cli do

before do
@old_stderr = $stderr
$stderr = StringIO.new
Expand Down
3 changes: 0 additions & 3 deletions spec/detect/host_os_family_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
require "yaml"

describe Launchy::Detect::HostOsFamily do

before do
Launchy.reset_global_options
end
Expand Down Expand Up @@ -36,9 +35,7 @@
ENV.delete("LAUNCHY_HOST_OS")
end


it "does not find an os of 'dos'" do
_(lambda { Launchy::Detect::HostOsFamily.detect("dos") }).must_raise Launchy::Detect::HostOsFamily::NotFoundError
end

end
2 changes: 0 additions & 2 deletions spec/detect/host_os_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
require "spec_helper"

describe Launchy::Detect::HostOs do

it "uses the defult host os from ruby's config" do
_(Launchy::Detect::HostOs.new.host_os).must_equal RbConfig::CONFIG["host_os"]
end
Expand All @@ -17,5 +16,4 @@
_(Launchy::Detect::HostOs.new.host_os).must_equal "fake-os-2"
ENV.delete("LAUNCHY_HOST_OS")
end

end
1 change: 0 additions & 1 deletion spec/detect/nix_desktop_environment_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
require "spec_helper"

describe Launchy::Detect::NixDesktopEnvironment do

before do
Launchy.reset_global_options
end
Expand Down
1 change: 0 additions & 1 deletion spec/launchy_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
require "mock_application"

describe Launchy do

before do
Launchy.reset_global_options
@stderr = $stderr
Expand Down

0 comments on commit f317776

Please sign in to comment.