From 7c6cb2fd2561541f869d43444ba144cf90bf8248 Mon Sep 17 00:00:00 2001 From: copiousfreetime Date: Wed, 26 Feb 2020 21:22:21 -0700 Subject: [PATCH 01/21] update to latest fixme --- tasks/default.rake | 6 +++--- tasks/this.rb | 8 +++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/tasks/default.rake b/tasks/default.rake index 80ee6ad..fef74b7 100644 --- a/tasks/default.rake +++ b/tasks/default.rake @@ -24,12 +24,12 @@ namespace :develop do File.open( "Gemfile", "w+" ) do |f| f.puts "# DO NOT EDIT - This file is automatically generated" f.puts "# Make changes to Manifest.txt and/or Rakefile and regenerate" - f.puts 'source "https://rubygems.org/"' + f.puts 'source "https://rubygems.org"' f.puts 'gemspec' end end end -desc "Boostrap development" +desc "Bootstrap development" task :develop => "develop:default" #------------------------------------------------------------------------------ @@ -38,7 +38,7 @@ task :develop => "develop:default" begin require 'rake/testtask' Rake::TestTask.new( :test ) do |t| - t.ruby_opts = %w[ -w -rubygems ] + t.ruby_opts = %w[ -w ] t.libs = %w[ lib spec test ] t.pattern = "{test,spec}/**/{test_*,*_spec}.rb" end diff --git a/tasks/this.rb b/tasks/this.rb index 6d713b1..67eb531 100644 --- a/tasks/this.rb +++ b/tasks/this.rb @@ -28,7 +28,7 @@ def initialize(&block) @exclude_from_manifest = Regexp.union(/\.(git|DS_Store)/, /^(doc|coverage|pkg|tmp|Gemfile(\.lock)?)/, /^[^\/]+\.gemspec/, - /\.(swp|jar|bundle|so|rvmrc|travis.yml)$/, + /\.(swp|jar|bundle|so|rvmrc|travis.yml|byebug_history)$/, /~$/) @gemspecs = Hash.new yield self if block_given? @@ -146,7 +146,7 @@ def core_gemspec spec.rdoc_options = [ "--main" , 'README.md', "--markup", "tomdoc" ] - spec.required_ruby_version = '>= 1.9.3' + spec.required_ruby_version = '>= 2.4.0' end end @@ -194,7 +194,9 @@ def description end def license - "ISC" + license_file = project_path("LICENSE") + line = license_file.readlines.first + line.split(/\s+/).first end # Internal: The path to the gemspec file From 72e1af52e2f88fa0ddeee444f6cab06d2574e40c Mon Sep 17 00:00:00 2001 From: copiousfreetime Date: Wed, 26 Feb 2020 21:22:31 -0700 Subject: [PATCH 02/21] add a .ruby_version --- .ruby_version | 1 + 1 file changed, 1 insertion(+) create mode 100644 .ruby_version diff --git a/.ruby_version b/.ruby_version new file mode 100644 index 0000000..7811505 --- /dev/null +++ b/.ruby_version @@ -0,0 +1 @@ +ruby 2.6.5 From 48a950c84bdf7672b28587ef7de9addfd8778b61 Mon Sep 17 00:00:00 2001 From: copiousfreetime Date: Wed, 26 Feb 2020 21:29:46 -0700 Subject: [PATCH 03/21] Add jeremymoritz and contributor --- CONTRIBUTING.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index aeab024..efbb709 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -50,6 +50,7 @@ easiest way to contribute. * [Cédric Félizard](https://github.com/infertux) * [Daniel Farina](https://github.com/fdr) * [Jack Turnbull](https://github.com/jackturnbull) +* [Jeremy Moritz](https://github.com/jeremymoritz) [GitHub Account]: https://github.com/signup/free "GitHub Signup" [GitHub Issues]: https://github.com/copiousfreetime/launchy/issues "Launchy Issues" From 437af88b8841edc7efe790763bae1fe51747f59b Mon Sep 17 00:00:00 2001 From: copiousfreetime Date: Wed, 26 Feb 2020 21:31:14 -0700 Subject: [PATCH 04/21] update contributing instructions to be accurate --- CONTRIBUTING.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index efbb709..49a3c41 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -27,9 +27,9 @@ easiest way to contribute. * Fork the [repo][]. * Create a new branch for your issue: `git checkout -b issue/my-issue` * Lovingly craft your contribution: - * `rake develop` to get started, or if you prefer bundler `rake develop:using_bundler && bundle`. - * `rake test` to run tests -* Make sure that `rake test` passes. It's important, I said it twice. + * `rake develop` to get started + * `bundle exec rake test` to run tests +* Make sure that `bundle exec rake test` passes. It's important, I said it twice. * Add yourself to the contributors section below. * Submit your [pull request][]. From b8baa2c7e03d56d72f388ba858c8ab8d4654279c Mon Sep 17 00:00:00 2001 From: copiousfreetime Date: Wed, 26 Feb 2020 21:31:36 -0700 Subject: [PATCH 05/21] add travis badge --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 07464b8..2e4855c 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ # launchy +[![Build Status](https://travis-ci.org/copiousfreetime/launchy.svg?branch=master)](https://travis-ci.org/copiousfreetime/launchy) + * [Homepage](https://github.com/copiousfreetime/launchy) * [Github Project](https://github.com/copiousfreetime/launchy) * email jeremy at hinegardner dot org From f5e9fe5450e734c559c3bbd3d4c169058379d0c6 Mon Sep 17 00:00:00 2001 From: copiousfreetime Date: Wed, 26 Feb 2020 21:31:44 -0700 Subject: [PATCH 06/21] reformat readme --- README.md | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 2e4855c..cc76d42 100644 --- a/README.md +++ b/README.md @@ -2,9 +2,9 @@ [![Build Status](https://travis-ci.org/copiousfreetime/launchy.svg?branch=master)](https://travis-ci.org/copiousfreetime/launchy) + * [Homepage](https://github.com/copiousfreetime/launchy) * [Github Project](https://github.com/copiousfreetime/launchy) -* email jeremy at hinegardner dot org ## DESCRIPTION @@ -22,7 +22,8 @@ Currently only launching a browser is supported. ## SYNOPSIS -You can use launchy on the commandline, within the Capybara and Rspec-rails testing environment, or via its API. +You can use launchy on the commandline, within the Capybara and Rspec-rails +testing environment, or via its API. ### Commandline @@ -32,11 +33,17 @@ There are additional command line options, use `launchy --help` to see them. ### Using the `BROWSER` environment variable -Launchy has a predefined set of common browsers on each platform that it attempts to use, and of course it is not exhaustive. As a fallbabck you can make use of the somewhat standard `BROWSER` environment variable. +Launchy has a predefined set of common browsers on each platform that it +attempts to use, and of course it is not exhaustive. As a fallbabck you can make +use of the somewhat standard `BROWSER` environment variable. -`BROWSER` works in a similar same way to `PATH`. It is a colon (`:`) separated list of commands to try. You can also put in a `%s` in the command and the URL you are attempting to open will be substituted there. +`BROWSER` works in a similar same way to `PATH`. It is a colon (`:`) separated +list of commands to try. You can also put in a `%s` in the command and the URL +you are attempting to open will be substituted there. -As an example if you set `BROWSER=/usr/local/bin/firefox-bin -new-tab '%s':/usr/local/bin/google-chrome-stable` and you call `Launchy.open("http://www.ruby-lang.org/")` then Launchy will try, in order: +As an example if you set `BROWSER=/usr/local/bin/firefox-bin -new-tab +'%s':/usr/local/bin/google-chrome-stable` and you call +`Launchy.open("http://www.ruby-lang.org/")` then Launchy will try, in order: * `/usr/local/bin/firefox-bin -new-tab 'http://www.ruby-lang.org'` * `/usr/local/bin/google-chrome-stable http://www.ruby-lang.org` @@ -49,16 +56,21 @@ Additional links on the use of `BROWSER` as an environment variable. ### Capybara Testing -First, install [Capybara](https://github.com/jnicklas/capybara) and [Rspec for Rails](https://github.com/rspec/rspec-rails). Capybara provides the following method: +First, install [Capybara](https://github.com/jnicklas/capybara) and [Rspec for +Rails](https://github.com/rspec/rspec-rails). Capybara provides the following +method: save_and_open_page -When inserted into your code at the place where you would like to open your program, and when rspec is run, Capybara displays this message: +When inserted into your code at the place where you would like to open your +program, and when rspec is run, Capybara displays this message: Page saved to /home/code/my_app_name/tmp/capybara/capybara-current-date-and-time.html with save_and_open_page. Please install the launchy gem to open page automatically. -With Launchy installed, when rspec is run again, it will launch an unstyled instance of the specific page. It can be especially useful when debugging errors in integration tests. For example: +With Launchy installed, when rspec is run again, it will launch an unstyled +instance of the specific page. It can be especially useful when debugging errors +in integration tests. For example: context "signin" do it "lets a user sign in" do From 7405eca867edc345a27fb2123490a3ee9136d554 Mon Sep 17 00:00:00 2001 From: copiousfreetime Date: Wed, 26 Feb 2020 21:37:52 -0700 Subject: [PATCH 07/21] add a .ruby-version file --- .ruby-version | 1 + .ruby_version | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) create mode 100644 .ruby-version delete mode 100644 .ruby_version diff --git a/.ruby-version b/.ruby-version new file mode 100644 index 0000000..57cf282 --- /dev/null +++ b/.ruby-version @@ -0,0 +1 @@ +2.6.5 diff --git a/.ruby_version b/.ruby_version deleted file mode 100644 index 7811505..0000000 --- a/.ruby_version +++ /dev/null @@ -1 +0,0 @@ -ruby 2.6.5 From cb7620f1f79cc950d45b56176a7f1e1c4f9370e1 Mon Sep 17 00:00:00 2001 From: copiousfreetime Date: Wed, 26 Feb 2020 21:40:47 -0700 Subject: [PATCH 08/21] removing .ruby-version --- .ruby-version | 1 - 1 file changed, 1 deletion(-) delete mode 100644 .ruby-version diff --git a/.ruby-version b/.ruby-version deleted file mode 100644 index 57cf282..0000000 --- a/.ruby-version +++ /dev/null @@ -1 +0,0 @@ -2.6.5 From 6521ee04e453917a32009d2129b38d9dfcb35bff Mon Sep 17 00:00:00 2001 From: copiousfreetime Date: Wed, 26 Feb 2020 21:41:58 -0700 Subject: [PATCH 09/21] update dependencies --- Gemfile | 2 +- Rakefile | 8 +++---- launchy.gemspec | 64 ++++++++++++++++++++++++------------------------- 3 files changed, 37 insertions(+), 37 deletions(-) diff --git a/Gemfile b/Gemfile index 054ed89..dc4515d 100644 --- a/Gemfile +++ b/Gemfile @@ -1,4 +1,4 @@ # DO NOT EDIT - This file is automatically generated # Make changes to Manifest.txt and/or Rakefile and regenerate -source "https://rubygems.org/" +source "https://rubygems.org" gemspec diff --git a/Rakefile b/Rakefile index 56eb181..cbc044b 100644 --- a/Rakefile +++ b/Rakefile @@ -9,10 +9,10 @@ This.homepage = "http://github.com/copiousfreetime/#{ This.name }" This.ruby_gemspec do |spec| spec.add_dependency( 'addressable', '~> 2.3') - spec.add_development_dependency( 'rake' , '~> 10.1') - spec.add_development_dependency( 'minitest' , '~> 5.0' ) - spec.add_development_dependency( 'rdoc' , '~> 4.1' ) - spec.add_development_dependency( 'simplecov', '~> 0.9' ) + spec.add_development_dependency( 'rake' , '~> 13.0') + spec.add_development_dependency( 'minitest' , '~> 5.14' ) + spec.add_development_dependency( 'rdoc' , '~> 6.2' ) + spec.add_development_dependency( 'simplecov', '~> 0.18' ) spec.licenses = ['ISC'] end diff --git a/launchy.gemspec b/launchy.gemspec index 88d179e..58f1d5e 100644 --- a/launchy.gemspec +++ b/launchy.gemspec @@ -4,47 +4,47 @@ # stub: launchy 2.4.3 ruby lib Gem::Specification.new do |s| - s.name = "launchy" + s.name = "launchy".freeze s.version = "2.4.3" - s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= - s.require_paths = ["lib"] - s.authors = ["Jeremy Hinegardner"] - s.date = "2015-02-18" - s.description = "Launchy is helper class for launching cross-platform applications in a fire and forget manner. There are application concepts (browser, email client, etc) that are common across all platforms, and they may be launched differently on each platform. Launchy is here to make a common approach to launching external application from within ruby programs." - s.email = "jeremy@copiousfreetime.org" - s.executables = ["launchy"] - s.extra_rdoc_files = ["CONTRIBUTING.md", "HISTORY.md", "Manifest.txt", "README.md"] - s.files = ["CONTRIBUTING.md", "HISTORY.md", "LICENSE", "Manifest.txt", "README.md", "Rakefile", "bin/launchy", "lib/launchy.rb", "lib/launchy/application.rb", "lib/launchy/applications/browser.rb", "lib/launchy/argv.rb", "lib/launchy/cli.rb", "lib/launchy/deprecated.rb", "lib/launchy/descendant_tracker.rb", "lib/launchy/detect.rb", "lib/launchy/detect/host_os.rb", "lib/launchy/detect/host_os_family.rb", "lib/launchy/detect/nix_desktop_environment.rb", "lib/launchy/detect/ruby_engine.rb", "lib/launchy/detect/runner.rb", "lib/launchy/error.rb", "lib/launchy/os_family.rb", "lib/launchy/version.rb", "spec/application_spec.rb", "spec/applications/browser_spec.rb", "spec/cli_spec.rb", "spec/detect/host_os_family_spec.rb", "spec/detect/host_os_spec.rb", "spec/detect/nix_desktop_environment_spec.rb", "spec/detect/ruby_engine_spec.rb", "spec/detect/runner_spec.rb", "spec/launchy_spec.rb", "spec/mock_application.rb", "spec/spec_helper.rb", "spec/tattle-host-os.yaml", "spec/version_spec.rb", "tasks/default.rake", "tasks/this.rb"] - s.homepage = "http://github.com/copiousfreetime/launchy" - s.licenses = ["ISC"] - s.rdoc_options = ["--main", "README.md", "--markup", "tomdoc"] - s.required_ruby_version = Gem::Requirement.new(">= 1.9.3") - s.rubygems_version = "2.4.6" - s.summary = "Launchy is helper class for launching cross-platform applications in a fire and forget manner." - s.test_files = ["spec/application_spec.rb", "spec/applications/browser_spec.rb", "spec/cli_spec.rb", "spec/detect/host_os_family_spec.rb", "spec/detect/host_os_spec.rb", "spec/detect/nix_desktop_environment_spec.rb", "spec/detect/ruby_engine_spec.rb", "spec/detect/runner_spec.rb", "spec/launchy_spec.rb", "spec/mock_application.rb", "spec/spec_helper.rb", "spec/tattle-host-os.yaml", "spec/version_spec.rb"] + s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version= + s.require_paths = ["lib".freeze] + s.authors = ["Jeremy Hinegardner".freeze] + s.date = "2020-02-27" + s.description = "Launchy is helper class for launching cross-platform applications in a fire and forget manner. There are application concepts (browser, email client, etc) that are common across all platforms, and they may be launched differently on each platform. Launchy is here to make a common approach to launching external applications from within ruby programs.".freeze + s.email = "jeremy@copiousfreetime.org".freeze + s.executables = ["launchy".freeze] + s.extra_rdoc_files = ["CONTRIBUTING.md".freeze, "HISTORY.md".freeze, "Manifest.txt".freeze, "README.md".freeze] + s.files = ["CONTRIBUTING.md".freeze, "HISTORY.md".freeze, "LICENSE".freeze, "Manifest.txt".freeze, "README.md".freeze, "Rakefile".freeze, "bin/launchy".freeze, "lib/launchy.rb".freeze, "lib/launchy/application.rb".freeze, "lib/launchy/applications/browser.rb".freeze, "lib/launchy/argv.rb".freeze, "lib/launchy/cli.rb".freeze, "lib/launchy/deprecated.rb".freeze, "lib/launchy/descendant_tracker.rb".freeze, "lib/launchy/detect.rb".freeze, "lib/launchy/detect/host_os.rb".freeze, "lib/launchy/detect/host_os_family.rb".freeze, "lib/launchy/detect/nix_desktop_environment.rb".freeze, "lib/launchy/detect/ruby_engine.rb".freeze, "lib/launchy/detect/runner.rb".freeze, "lib/launchy/error.rb".freeze, "lib/launchy/os_family.rb".freeze, "lib/launchy/version.rb".freeze, "spec/application_spec.rb".freeze, "spec/applications/browser_spec.rb".freeze, "spec/cli_spec.rb".freeze, "spec/detect/host_os_family_spec.rb".freeze, "spec/detect/host_os_spec.rb".freeze, "spec/detect/nix_desktop_environment_spec.rb".freeze, "spec/detect/ruby_engine_spec.rb".freeze, "spec/detect/runner_spec.rb".freeze, "spec/launchy_spec.rb".freeze, "spec/mock_application.rb".freeze, "spec/spec_helper.rb".freeze, "spec/tattle-host-os.yaml".freeze, "spec/version_spec.rb".freeze, "tasks/default.rake".freeze, "tasks/this.rb".freeze] + s.homepage = "http://github.com/copiousfreetime/launchy".freeze + s.licenses = ["ISC".freeze] + s.rdoc_options = ["--main".freeze, "README.md".freeze, "--markup".freeze, "tomdoc".freeze] + s.required_ruby_version = Gem::Requirement.new(">= 2.4.0".freeze) + s.rubygems_version = "3.0.3".freeze + s.summary = "Launchy is helper class for launching cross-platform applications in a fire and forget manner.".freeze + s.test_files = ["spec/application_spec.rb".freeze, "spec/applications/browser_spec.rb".freeze, "spec/cli_spec.rb".freeze, "spec/detect/host_os_family_spec.rb".freeze, "spec/detect/host_os_spec.rb".freeze, "spec/detect/nix_desktop_environment_spec.rb".freeze, "spec/detect/ruby_engine_spec.rb".freeze, "spec/detect/runner_spec.rb".freeze, "spec/launchy_spec.rb".freeze, "spec/mock_application.rb".freeze, "spec/spec_helper.rb".freeze, "spec/tattle-host-os.yaml".freeze, "spec/version_spec.rb".freeze] if s.respond_to? :specification_version then s.specification_version = 4 if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then - s.add_runtime_dependency(%q, ["~> 2.3"]) - s.add_development_dependency(%q, ["~> 10.1"]) - s.add_development_dependency(%q, ["~> 5.0"]) - s.add_development_dependency(%q, ["~> 4.1"]) - s.add_development_dependency(%q, ["~> 0.9"]) + s.add_runtime_dependency(%q.freeze, ["~> 2.3"]) + s.add_development_dependency(%q.freeze, ["~> 13.0"]) + s.add_development_dependency(%q.freeze, ["~> 5.14"]) + s.add_development_dependency(%q.freeze, ["~> 6.2"]) + s.add_development_dependency(%q.freeze, ["~> 0.18"]) else - s.add_dependency(%q, ["~> 2.3"]) - s.add_dependency(%q, ["~> 10.1"]) - s.add_dependency(%q, ["~> 5.0"]) - s.add_dependency(%q, ["~> 4.1"]) - s.add_dependency(%q, ["~> 0.9"]) + s.add_dependency(%q.freeze, ["~> 2.3"]) + s.add_dependency(%q.freeze, ["~> 13.0"]) + s.add_dependency(%q.freeze, ["~> 5.14"]) + s.add_dependency(%q.freeze, ["~> 6.2"]) + s.add_dependency(%q.freeze, ["~> 0.18"]) end else - s.add_dependency(%q, ["~> 2.3"]) - s.add_dependency(%q, ["~> 10.1"]) - s.add_dependency(%q, ["~> 5.0"]) - s.add_dependency(%q, ["~> 4.1"]) - s.add_dependency(%q, ["~> 0.9"]) + s.add_dependency(%q.freeze, ["~> 2.3"]) + s.add_dependency(%q.freeze, ["~> 13.0"]) + s.add_dependency(%q.freeze, ["~> 5.14"]) + s.add_dependency(%q.freeze, ["~> 6.2"]) + s.add_dependency(%q.freeze, ["~> 0.18"]) end end From b7cef9d7ca05258972b5b267a07254ce648d7f82 Mon Sep 17 00:00:00 2001 From: copiousfreetime Date: Wed, 26 Feb 2020 22:01:29 -0700 Subject: [PATCH 10/21] resolve minitest spec deprecation warnings --- spec/application_spec.rb | 14 ++++---- spec/applications/browser_spec.rb | 21 +++++++----- spec/cli_spec.rb | 20 ++++++------ spec/detect/host_os_family_spec.rb | 10 +++--- spec/detect/host_os_spec.rb | 6 ++-- spec/detect/nix_desktop_environment_spec.rb | 6 ++-- spec/detect/ruby_engine_spec.rb | 8 ++--- spec/detect/runner_spec.rb | 24 +++++++------- spec/launchy_spec.rb | 36 ++++++++++----------- spec/version_spec.rb | 6 ++-- 10 files changed, 79 insertions(+), 72 deletions(-) diff --git a/spec/application_spec.rb b/spec/application_spec.rb index ea18e2f..27c8fe0 100644 --- a/spec/application_spec.rb +++ b/spec/application_spec.rb @@ -14,30 +14,30 @@ def self.handles?( uri ) uri.scheme == "junk2" end end - Launchy::Application.children.must_include( Junk2App ) + _(Launchy::Application.children).must_include( Junk2App ) Launchy::Application.children.delete( Junk2App ) end it "can find an app" do - Launchy::Application.children.must_include( JunkApp ) - Launchy::Application.children.size.must_equal 3 + _(Launchy::Application.children).must_include( JunkApp ) + _(Launchy::Application.children.size).must_equal 3 uri = Addressable::URI.parse( "junk:///foo" ) - Launchy::Application.handling( uri ).must_equal( JunkApp ) + _(Launchy::Application.handling( uri )).must_equal( JunkApp ) end it "raises an error if an application cannot be found for the given scheme" do uri = Addressable::URI.parse( "foo:///bar" ) - lambda { Launchy::Application.handling( uri ) }.must_raise( Launchy::ApplicationNotFoundError ) + _(lambda { Launchy::Application.handling( uri ) }).must_raise( Launchy::ApplicationNotFoundError ) end it "can find open or curl or xdg-open" do found = %w[ open curl xdg-open ].any? do |app| Launchy::Application.find_executable( app ) end - found.must_equal true + _(found).must_equal true end it "does not find xyzzy" do - Launchy::Application.find_executable( "xyzzy" ).must_equal nil + _(Launchy::Application.find_executable( "xyzzy" )).must_be_nil end end diff --git a/spec/applications/browser_spec.rb b/spec/applications/browser_spec.rb index 497350d..20ba85b 100644 --- a/spec/applications/browser_spec.rb +++ b/spec/applications/browser_spec.rb @@ -18,11 +18,16 @@ 'cygwin' => 'cmd /C start "launchy" /b', # when running these tests on a linux box, this test will fail - 'linux' => nil }.each do |host_os, cmdline| + 'linux' => nil }.each do |host_os, expected| it "when host_os is '#{host_os}' the appropriate 'app_list' method is called" do Launchy.host_os = host_os browser = Launchy::Application::Browser.new - browser.app_list.first.must_equal cmdline + + if expected.nil? then + _(browser.app_list.first).must_be_nil + else + _(browser.app_list.first).must_equal expected + end end end @@ -32,14 +37,14 @@ Launchy.host_os = host_os browser = Launchy::Application::Browser.new cmd, args = browser.cmd_and_args( @test_url ) - cmd.must_equal "my_special_browser --new-tab 'http://example.com/'" - args.must_equal [] + _(cmd).must_equal "my_special_browser --new-tab 'http://example.com/'" + _(args).must_equal [] end end it "handles a file on the file system when there is no file:// scheme" do uri = Addressable::URI.parse( __FILE__ ) - Launchy::Application::Browser.handles?( uri ).must_equal true + _(Launchy::Application::Browser.handles?( uri )).must_equal true end it "handles the case where $BROWSER is set and no *nix desktop environment is found" do @@ -48,12 +53,12 @@ ENV['BROWSER'] = "do-this-instead" Launchy.host_os = 'linux' browser = Launchy::Application::Browser.new - browser.browser_cmdline.must_equal "do-this-instead" + _(browser.browser_cmdline).must_equal "do-this-instead" end # NOTE: Unable to figure out how capture the stderr from the child which has # moved it at least once. This test just serves the purpose of noting why - # something happens, and the proble we are attempting to fix. + # something happens, and the problem we are attempting to fix. it "When BROWSER is set to something that is not executable, error still appears on stderr" do ENV['BROWSER'] = "not-an-app" url = "http://example.com/" @@ -61,7 +66,7 @@ _, err = capture_subprocess_io do Launchy.open( url ) end - #err.must_match( /wibble/m ) + #_(err).must_match( /wibble/m ) err # something end end diff --git a/spec/cli_spec.rb b/spec/cli_spec.rb index 61c57c6..5913ba1 100644 --- a/spec/cli_spec.rb +++ b/spec/cli_spec.rb @@ -21,9 +21,9 @@ def cli_test( argv, env, exit_val, stderr_regex, stdout_regex ) begin Launchy::Cli.new.run( argv, env ) rescue SystemExit => se - se.status.must_equal exit_val - $stderr.string.must_match stderr_regex if stderr_regex - $stdout.string.must_match stdout_regex if stdout_regex + _(se.status).must_equal exit_val + _($stderr.string).must_match stderr_regex if stderr_regex + _($stdout.string).must_match stdout_regex if stdout_regex end end @@ -47,14 +47,14 @@ def cli_test( argv, env, exit_val, stderr_regex, stdout_regex ) l = Launchy::Cli.new argv = %w[ --debug --dry-run http://github.com/copiousfreetime/launchy ] l.parse( argv , {} ) - argv.size.must_equal 1 - argv[0].must_equal "http://github.com/copiousfreetime/launchy" + _(argv.size).must_equal 1 + _(argv[0]).must_equal "http://github.com/copiousfreetime/launchy" end it "prints the command on stdout when using --dry-run" do argv = %w[ --debug --dry-run http://github.com/copiousfreetime/launchy ] Launchy::Cli.new.good_run( argv, {} ) - $stdout.string.must_match %r[github.com] + _($stdout.string).must_match %r[github.com] end { @@ -65,10 +65,10 @@ def cli_test( argv, env, exit_val, stderr_regex, stdout_regex ) argv = [ opt, val[1], "http://github.com/copiousfreetime/launchy" ] l = Launchy::Cli.new rc = l.parse( argv, {} ) - rc.must_equal true - argv.size.must_equal 1 - argv[0].must_equal "http://github.com/copiousfreetime/launchy" - l.options[val[0]].must_equal val[1] + _(rc).must_equal true + _(argv.size).must_equal 1 + _(argv[0]).must_equal "http://github.com/copiousfreetime/launchy" + _(l.options[val[0]]).must_equal val[1] end end end diff --git a/spec/detect/host_os_family_spec.rb b/spec/detect/host_os_family_spec.rb index 36c149d..33ff056 100644 --- a/spec/detect/host_os_family_spec.rb +++ b/spec/detect/host_os_family_spec.rb @@ -13,7 +13,8 @@ YAML::load( IO.read( File.expand_path( "../../tattle-host-os.yaml", __FILE__ ) ) )['host_os'].keys.sort.each do |os| it "OS family of #{os} is detected" do - Launchy::Detect::HostOsFamily.detect( os ).must_be_kind_of Launchy::Detect::HostOsFamily + os_family = Launchy::Detect::HostOsFamily.detect( os ) + _(os_family).must_be_kind_of Launchy::Detect::HostOsFamily end end @@ -22,19 +23,20 @@ 'linux' => :nix?, 'cygwin' => :cygwin? }.each_pair do |os, method| it "#{method} returns true for #{os} " do - Launchy::Detect::HostOsFamily.detect( os ).send( method ).must_equal true + r = Launchy::Detect::HostOsFamily.detect( os ).send( method ) + _(r).must_equal true end end it "uses the global host_os overrides" do ENV['LAUNCHY_HOST_OS'] = "fake-os-2" - lambda { Launchy::Detect::HostOsFamily.detect }.must_raise Launchy::Detect::HostOsFamily::NotFoundError + _(lambda { Launchy::Detect::HostOsFamily.detect }).must_raise Launchy::Detect::HostOsFamily::NotFoundError 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 + _(lambda { Launchy::Detect::HostOsFamily.detect( 'dos' ) }).must_raise Launchy::Detect::HostOsFamily::NotFoundError end end diff --git a/spec/detect/host_os_spec.rb b/spec/detect/host_os_spec.rb index c6de254..53ffcff 100644 --- a/spec/detect/host_os_spec.rb +++ b/spec/detect/host_os_spec.rb @@ -3,16 +3,16 @@ 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'] + _(Launchy::Detect::HostOs.new.host_os).must_equal RbConfig::CONFIG['host_os'] end it "uses the passed in value as the host os" do - Launchy::Detect::HostOs.new( "fake-os-1").host_os.must_equal "fake-os-1" + _(Launchy::Detect::HostOs.new( "fake-os-1").host_os).must_equal "fake-os-1" end it "uses the environment variable LAUNCHY_HOST_OS to override ruby's config" do ENV['LAUNCHY_HOST_OS'] = "fake-os-2" - Launchy::Detect::HostOs.new.host_os.must_equal "fake-os-2" + _(Launchy::Detect::HostOs.new.host_os).must_equal "fake-os-2" ENV.delete('LAUNCHY_HOST_OS') end diff --git a/spec/detect/nix_desktop_environment_spec.rb b/spec/detect/nix_desktop_environment_spec.rb index 2f084d4..cb45449 100644 --- a/spec/detect/nix_desktop_environment_spec.rb +++ b/spec/detect/nix_desktop_environment_spec.rb @@ -12,7 +12,7 @@ it "returns false for XFCE if xprop is not found" do Launchy.host_os = "linux" - Launchy::Detect::NixDesktopEnvironment::Xfce.is_current_desktop_environment?.must_equal( false ) + _(Launchy::Detect::NixDesktopEnvironment::Xfce.is_current_desktop_environment?).must_equal( false ) end it "returns NotFound if it cannot determine the *nix desktop environment" do @@ -20,7 +20,7 @@ ENV.delete( "KDE_FULL_SESSION" ) ENV.delete( "GNOME_DESKTOP_SESSION_ID" ) not_found = Launchy::Detect::NixDesktopEnvironment.detect - not_found.must_equal( Launchy::Detect::NixDesktopEnvironment::NotFound ) - not_found.browser.must_equal( Launchy::Argv.new ) + _(not_found).must_equal( Launchy::Detect::NixDesktopEnvironment::NotFound ) + _(not_found.browser).must_equal( Launchy::Argv.new ) end end diff --git a/spec/detect/ruby_engine_spec.rb b/spec/detect/ruby_engine_spec.rb index e77b071..17c9373 100644 --- a/spec/detect/ruby_engine_spec.rb +++ b/spec/detect/ruby_engine_spec.rb @@ -12,18 +12,18 @@ %w[ ruby jruby rbx macruby ].each do |ruby| it "detects the #{ruby} RUBY_ENGINE" do - Launchy::Detect::RubyEngine.detect( ruby ).ancestors.must_include Launchy::Detect::RubyEngine + _(Launchy::Detect::RubyEngine.detect( ruby ).ancestors).must_include Launchy::Detect::RubyEngine end end it "uses the global ruby_engine overrides" do ENV['LAUNCHY_RUBY_ENGINE'] = "rbx" - Launchy::Detect::RubyEngine.detect.must_equal Launchy::Detect::RubyEngine::Rbx + _(Launchy::Detect::RubyEngine.detect).must_equal Launchy::Detect::RubyEngine::Rbx ENV.delete('LAUNCHY_RUBY_ENGINE') end it "does not find a ruby engine of 'foo'" do - lambda { Launchy::Detect::RubyEngine.detect( 'foo' ) }.must_raise Launchy::Detect::RubyEngine::NotFoundError + _(lambda { Launchy::Detect::RubyEngine.detect( 'foo' ) }).must_raise Launchy::Detect::RubyEngine::NotFoundError end { 'rbx' => :rbx?, @@ -31,7 +31,7 @@ 'macruby' => :macruby?, 'jruby' => :jruby? }.each_pair do |engine, method| it "#{method} returns true for #{engine} " do - Launchy::Detect::RubyEngine.detect( engine ).send( method ).must_equal true + _(Launchy::Detect::RubyEngine.detect( engine ).send( method )).must_equal true end end end diff --git a/spec/detect/runner_spec.rb b/spec/detect/runner_spec.rb index 78aef82..c323f36 100644 --- a/spec/detect/runner_spec.rb +++ b/spec/detect/runner_spec.rb @@ -13,17 +13,17 @@ it "raises an error when there is an unknown host os" do Launchy.host_os = "foo" - lambda{ Launchy::Detect::Runner.detect }.must_raise Launchy::Detect::HostOsFamily::NotFoundError + _(lambda{ Launchy::Detect::Runner.detect }).must_raise Launchy::Detect::HostOsFamily::NotFoundError end it "raises an error when there is an unknown ruby engine" do Launchy.ruby_engine = "wibble" - lambda{ Launchy::Detect::Runner.detect }.must_raise Launchy::Detect::RubyEngine::NotFoundError + _(lambda{ Launchy::Detect::Runner.detect }).must_raise Launchy::Detect::RubyEngine::NotFoundError end it "raises and error when there is no command found" do runner = Launchy::Detect::Runner.detect - lambda{ runner.run( nil, *%w[ arg1 arg2 arg 3] ) }.must_raise Launchy::CommandNotFoundError + _(lambda{ runner.run( nil, *%w[ arg1 arg2 arg 3] ) }).must_raise Launchy::CommandNotFoundError end # On anything that has fork, use Forkable @@ -33,7 +33,7 @@ Launchy.host_os = host_os Launchy.ruby_engine = engine_name engine = Launchy::Detect::Runner.detect - engine.must_be_instance_of Launchy::Detect::Runner::Forkable + _(engine).must_be_instance_of Launchy::Detect::Runner::Forkable end end end @@ -48,7 +48,7 @@ Launchy.host_os = host_os Launchy.ruby_engine = 'jruby' engine = Launchy::Detect::Runner.detect - engine.must_be_instance_of runner + _(engine).must_be_instance_of runner end end @@ -58,14 +58,14 @@ Launchy.host_os = "mingw" Launchy.ruby_engine = engine_name e = Launchy::Detect::Runner.detect - e.must_be_instance_of Launchy::Detect::Runner::Windows + _(e).must_be_instance_of Launchy::Detect::Runner::Windows end end it "Windows launches use the 'cmd' command" do win = Launchy::Detect::Runner::Windows.new cmd = win.dry_run( "not-really", [ "http://example.com" ] ) - cmd.must_equal 'cmd /c not-really http://example.com' + _(cmd).must_equal 'cmd /c not-really http://example.com' end %w[ & | ( ) < > ^ ].each do |reserved_char| @@ -75,29 +75,29 @@ url = parts.join( reserved_char ) output_url = parts.join( "^#{reserved_char}" ) - win.all_args( "not-really", [ url ] ).must_equal [ 'cmd', '/c', 'not-really', output_url ] + _(win.all_args( "not-really", [ url ] )).must_equal [ 'cmd', '/c', 'not-really', output_url ] cmd = win.dry_run( "not-really", [ url ] ) - cmd.must_equal "cmd /c not-really #{output_url}" + _(cmd).must_equal "cmd /c not-really #{output_url}" end end it "Jruby doesnot escapes '&' in urls" do jruby = Launchy::Detect::Runner::Jruby.new cmd = jruby.dry_run( "not-really", [ @test_url ]) - cmd.must_equal 'not-really http://example.com/?foo=bar&baz=wibble' + _(cmd).must_equal 'not-really http://example.com/?foo=bar&baz=wibble' end it "does not escape %38 items in urls" do l = Launchy::Detect::Runner::Forkable.new cmd = l.dry_run( "not-really", [ "http://ja.wikipedia.org/wiki/%E3%81%82" ] ) - cmd.must_equal( 'not-really http://ja.wikipedia.org/wiki/%E3%81%82' ) + _(cmd).must_equal( 'not-really http://ja.wikipedia.org/wiki/%E3%81%82' ) end it "can launch a utf8 url" do url = "http://ja.wikipedia.org/wiki/あ" l = Launchy::Detect::Runner::Forkable.new cmd = l.dry_run( "not-really", [ url ] ) - cmd.must_equal( "not-really #{url}" ) + _(cmd).must_equal( "not-really #{url}" ) end end diff --git a/spec/launchy_spec.rb b/spec/launchy_spec.rb index 2f32b26..04d65e6 100644 --- a/spec/launchy_spec.rb +++ b/spec/launchy_spec.rb @@ -23,7 +23,7 @@ old_stderr = $stderr $stderr = StringIO.new Launchy.log "This is a test log message" - $stderr.string.strip.must_equal "LAUNCHY_DEBUG: This is a test log message" + _($stderr.string.strip).must_equal "LAUNCHY_DEBUG: This is a test log message" $stderr = old_stderr ENV["LAUNCHY_DEBUG"] = nil end @@ -31,87 +31,87 @@ it "sets the global option :dry_run to true if LAUNCHY_DRY_RUN environment variable is 'true'" do ENV['LAUNCHY_DRY_RUN'] = 'true' Launchy.extract_global_options({}) - Launchy.dry_run?.must_equal true + _(Launchy.dry_run?).must_equal true ENV['LAUNCHY_DRY_RUN'] = nil end it "sets the global option :debug to true if LAUNCHY_DEBUG environment variable is 'true'" do ENV['LAUNCHY_DEBUG'] = 'true' Launchy.extract_global_options({}) - Launchy.debug?.must_equal true + _(Launchy.debug?).must_equal true ENV['LAUNCHY_DEBUG'] = nil end it "has the global option :debug" do Launchy.extract_global_options( { :debug => 'true' } ) - Launchy.debug?.must_equal true + _(Launchy.debug?).must_equal true Launchy.extract_global_options( { :debug => true } ) - Launchy.debug?.must_equal true + _(Launchy.debug?).must_equal true end it "has the global option :dry_run" do Launchy.extract_global_options( { :dry_run => 'true' } ) - Launchy.dry_run?.must_equal true + _(Launchy.dry_run?).must_equal true Launchy.extract_global_options( { :dry_run => true } ) - Launchy.dry_run?.must_equal true + _(Launchy.dry_run?).must_equal true end it "has the global option :application" do Launchy.extract_global_options( { :application => "wibble" } ) - Launchy.application.must_equal 'wibble' + _(Launchy.application).must_equal 'wibble' end it "has the global option :host_os" do Launchy.extract_global_options( { :host_os => "my-special-os-v2" } ) - Launchy.host_os.must_equal 'my-special-os-v2' + _(Launchy.host_os).must_equal 'my-special-os-v2' end it "has the global option :ruby_engine" do Launchy.extract_global_options( { :ruby_engine => "myruby" } ) - Launchy.ruby_engine.must_equal 'myruby' + _(Launchy.ruby_engine).must_equal 'myruby' end it "raises an exception if no scheme is found for the given uri" do - lambda { Launchy.open( @invalid_url ) }.must_raise Launchy::ApplicationNotFoundError + _(lambda { Launchy.open( @invalid_url ) }).must_raise Launchy::ApplicationNotFoundError end it "asssumes we open a local file if we have an exception if we have an invalid scheme and a valid path" do uri = "blah://example.com/#{__FILE__}" Launchy.open( uri , :dry_run => true ) - $stdout.string.strip.must_equal "/usr/bin/open #{uri}" + _($stdout.string.strip).must_equal "/usr/bin/open #{uri}" end it "opens a local file if we have a drive letter and a valid path on windows" do uri = "C:#{__FILE__}" Launchy.open( uri, :dry_run => true, :host_os => 'windows' ) - $stdout.string.strip.must_equal 'cmd /c start "launchy" /b ' + uri + _($stdout.string.strip).must_equal 'cmd /c start "launchy" /b ' + uri end it "calls the block if instead of raising an exception if there is an error" do Launchy.open( @invalid_url ) { $stderr.puts "oops had an error opening #{@invalid_url}" } - $stderr.string.strip.must_equal "oops had an error opening #{@invalid_url}" + _($stderr.string.strip).must_equal "oops had an error opening #{@invalid_url}" end it "calls the block with the values passed to launchy and the error" do options = { :dry_run => true } Launchy.open( @invalid_url, :dry_run => true ) { |e| $stderr.puts "had an error opening #{@invalid_url} with options #{options}: #{e}" } - $stderr.string.strip.must_equal "had an error opening #{@invalid_url} with options #{options}: No application found to handle '#{@invalid_url}'" + _($stderr.string.strip).must_equal "had an error opening #{@invalid_url} with options #{options}: No application found to handle '#{@invalid_url}'" end it "raises the error in the called block" do - lambda { Launchy.open( @invalid_url ) { raise StandardError, "KABOOM!" } }.must_raise StandardError + _(lambda { Launchy.open( @invalid_url ) { raise StandardError, "KABOOM!" } }).must_raise StandardError end [ 'www.example.com', 'www.example.com/foo/bar', "C:#{__FILE__}" ].each do |x| it "picks a Browser for #{x}" do app = Launchy.app_for_uri_string( x ) - app.must_equal( Launchy::Application::Browser ) + _(app).must_equal( Launchy::Application::Browser ) end end it "can use a Pathname as the URI" do path = Pathname.new( Dir.pwd ) app = Launchy.app_for_uri_string( path ) - app.must_equal( Launchy::Application::Browser ) + _(app).must_equal( Launchy::Application::Browser ) end end diff --git a/spec/version_spec.rb b/spec/version_spec.rb index d67a0d8..291e2ad 100644 --- a/spec/version_spec.rb +++ b/spec/version_spec.rb @@ -2,10 +2,10 @@ describe 'Launchy::VERSION' do it "should have a #.#.# format" do - Launchy::VERSION.must_match( /\d+\.\d+\.\d+/ ) - Launchy::Version.to_s.must_match( /\d+\.\d+\.\d+/ ) + _(Launchy::VERSION).must_match( /\d+\.\d+\.\d+/ ) + _(Launchy::Version.to_s).must_match( /\d+\.\d+\.\d+/ ) Launchy::Version.to_a.each do |n| - n.to_i.must_be :>=, 0 + _(n.to_i).must_be :>=, 0 end end end From f3e28b6b676872e754e56532ad11f70fdd3cc5d1 Mon Sep 17 00:00:00 2001 From: copiousfreetime Date: Wed, 26 Feb 2020 22:02:42 -0700 Subject: [PATCH 11/21] update travis config --- .travis.yml | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/.travis.yml b/.travis.yml index 27032e9..10d66fa 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,9 +1,17 @@ language: ruby rvm: - - 1.9.3 - - 2.0.0 - - 2.1 - - 2.2 - - jruby-18mode # JRuby in 1.8 mode - - jruby-19mode # JRuby in 1.9 mode - - rbx + - "2.4" + - "2.5" + - "2.6" + - "2.7" + - jruby-9.2.8.0 + - jruby-9.1.17.0 + - truffleruby + +before_script: + - "curl -H 'Cache-Control: no-cache' https://raw.githubusercontent.com/fossas/fossa-cli/master/install.sh | sudo bash" + +script: + - rake + - fossa init + - fossa analyze From 306dbf400f0a8d63799b29bc35db94ae3f0136e4 Mon Sep 17 00:00:00 2001 From: copiousfreetime Date: Wed, 26 Feb 2020 22:06:38 -0700 Subject: [PATCH 12/21] removing fossa script --- .travis.yml | 8 -------- 1 file changed, 8 deletions(-) diff --git a/.travis.yml b/.travis.yml index 10d66fa..6f96005 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,11 +7,3 @@ rvm: - jruby-9.2.8.0 - jruby-9.1.17.0 - truffleruby - -before_script: - - "curl -H 'Cache-Control: no-cache' https://raw.githubusercontent.com/fossas/fossa-cli/master/install.sh | sudo bash" - -script: - - rake - - fossa init - - fossa analyze From 6b549e646e1b0c58016d9c9b45310bd659e9c3cd Mon Sep 17 00:00:00 2001 From: copiousfreetime Date: Wed, 26 Feb 2020 22:30:25 -0700 Subject: [PATCH 13/21] have launchy keep a copy of then environmental path --- lib/launchy.rb | 9 +++++++++ lib/launchy/application.rb | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/launchy.rb b/lib/launchy.rb index f72e7f1..aa6d0e2 100644 --- a/lib/launchy.rb +++ b/lib/launchy.rb @@ -66,6 +66,7 @@ def reset_global_options Launchy.host_os = nil Launchy.ruby_engine = nil Launchy.dry_run = false + Launchy.path = ENV['PATH'] end def extract_global_options( options ) @@ -127,6 +128,14 @@ def log(msg) $stderr.puts "LAUNCHY_DEBUG: #{msg}" if Launchy.debug? end + def path + @path + end + + def path=(path) + @path = path + end + private def to_bool( arg ) if arg.is_a? String diff --git a/lib/launchy/application.rb b/lib/launchy/application.rb index 4986531..905808c 100644 --- a/lib/launchy/application.rb +++ b/lib/launchy/application.rb @@ -27,7 +27,7 @@ def handling( uri ) # # Find the given executable in the available paths def find_executable( bin, *paths ) - paths = ENV['PATH'].split( File::PATH_SEPARATOR ) if paths.empty? + paths = Launchy.path.split( File::PATH_SEPARATOR ) if paths.empty? paths.each do |path| file = File.join( path, bin ) if File.executable?( file ) then From a63c855b8ffc81ebc2305761753d6a5e09cf8bc6 Mon Sep 17 00:00:00 2001 From: copiousfreetime Date: Wed, 26 Feb 2020 22:30:58 -0700 Subject: [PATCH 14/21] make the tests run also on linux for travis ci --- spec/applications/browser_spec.rb | 17 +++++++++-------- spec/detect/nix_desktop_environment_spec.rb | 1 + spec/launchy_spec.rb | 4 +++- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/spec/applications/browser_spec.rb b/spec/applications/browser_spec.rb index 20ba85b..a7d752d 100644 --- a/spec/applications/browser_spec.rb +++ b/spec/applications/browser_spec.rb @@ -14,19 +14,20 @@ end { 'windows' => 'start "launchy" /b' , - 'darwin' => '/usr/bin/open', + 'darwin' => [ '/usr/bin/open', '/bin/open' ], # because running tests on linux 'cygwin' => 'cmd /C start "launchy" /b', - - # when running these tests on a linux box, this test will fail - 'linux' => nil }.each do |host_os, expected| + 'linux' => [nil, "xdg-open"], # because running tests on linux + }.each do |host_os, expected| it "when host_os is '#{host_os}' the appropriate 'app_list' method is called" do Launchy.host_os = host_os browser = Launchy::Application::Browser.new - if expected.nil? then - _(browser.app_list.first).must_be_nil - else - _(browser.app_list.first).must_equal expected + item = browser.app_list.first + case expected + when Array + _(expected).must_include item + when String + _(item).must_equal expected end end end diff --git a/spec/detect/nix_desktop_environment_spec.rb b/spec/detect/nix_desktop_environment_spec.rb index cb45449..42472fa 100644 --- a/spec/detect/nix_desktop_environment_spec.rb +++ b/spec/detect/nix_desktop_environment_spec.rb @@ -19,6 +19,7 @@ Launchy.host_os = "linux" ENV.delete( "KDE_FULL_SESSION" ) ENV.delete( "GNOME_DESKTOP_SESSION_ID" ) + Launchy.path = %w[ / /tmp ].join(File::PATH_SEPARATOR) not_found = Launchy::Detect::NixDesktopEnvironment.detect _(not_found).must_equal( Launchy::Detect::NixDesktopEnvironment::NotFound ) _(not_found.browser).must_equal( Launchy::Argv.new ) diff --git a/spec/launchy_spec.rb b/spec/launchy_spec.rb index 04d65e6..0138084 100644 --- a/spec/launchy_spec.rb +++ b/spec/launchy_spec.rb @@ -78,7 +78,9 @@ it "asssumes we open a local file if we have an exception if we have an invalid scheme and a valid path" do uri = "blah://example.com/#{__FILE__}" Launchy.open( uri , :dry_run => true ) - _($stdout.string.strip).must_equal "/usr/bin/open #{uri}" + parts = $stdout.string.strip.split + _(parts.size).must_be :>, 1 + _(parts.last).must_equal uri end it "opens a local file if we have a drive letter and a valid path on windows" do From 8a6f6dafe5aaf45a2047ea5df0f2ffbfad32f43c Mon Sep 17 00:00:00 2001 From: copiousfreetime Date: Wed, 26 Feb 2020 22:52:54 -0700 Subject: [PATCH 15/21] add byebug history to gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 2ac0902..b563f6a 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,4 @@ pkg/ .DS_Store *.lock .gem +.byebug_history From 8ecf3e71e86d8f05013f70bb97a617bb3f463a5e Mon Sep 17 00:00:00 2001 From: copiousfreetime Date: Wed, 26 Feb 2020 22:53:43 -0700 Subject: [PATCH 16/21] fix spec that failed when running on linux --- spec/applications/browser_spec.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/spec/applications/browser_spec.rb b/spec/applications/browser_spec.rb index a7d752d..8e4a278 100644 --- a/spec/applications/browser_spec.rb +++ b/spec/applications/browser_spec.rb @@ -23,6 +23,7 @@ browser = Launchy::Application::Browser.new item = browser.app_list.first + item = item.to_s if item.kind_of?(::Launchy::Argv) case expected when Array _(expected).must_include item From a2b2a809ca48255daebc870e1ab87b04f87dc50a Mon Sep 17 00:00:00 2001 From: copiousfreetime Date: Wed, 26 Feb 2020 23:26:06 -0700 Subject: [PATCH 17/21] remove need for spoon to support jruby --- Rakefile | 6 ------ launchy.gemspec | 22 ++++++++-------------- lib/launchy/detect/runner.rb | 4 ++-- 3 files changed, 10 insertions(+), 22 deletions(-) diff --git a/Rakefile b/Rakefile index cbc044b..d03da38 100644 --- a/Rakefile +++ b/Rakefile @@ -17,10 +17,4 @@ This.ruby_gemspec do |spec| spec.licenses = ['ISC'] end -This.java_gemspec( This.ruby_gemspec ) do |spec| - spec.add_dependency( 'spoon', '~> 0.0.1' ) - - spec.licenses = ['ISC'] -end - load 'tasks/default.rake' diff --git a/launchy.gemspec b/launchy.gemspec index 58f1d5e..77c3af8 100644 --- a/launchy.gemspec +++ b/launchy.gemspec @@ -20,26 +20,20 @@ Gem::Specification.new do |s| s.licenses = ["ISC".freeze] s.rdoc_options = ["--main".freeze, "README.md".freeze, "--markup".freeze, "tomdoc".freeze] s.required_ruby_version = Gem::Requirement.new(">= 2.4.0".freeze) - s.rubygems_version = "3.0.3".freeze + s.rubygems_version = "3.1.2".freeze s.summary = "Launchy is helper class for launching cross-platform applications in a fire and forget manner.".freeze s.test_files = ["spec/application_spec.rb".freeze, "spec/applications/browser_spec.rb".freeze, "spec/cli_spec.rb".freeze, "spec/detect/host_os_family_spec.rb".freeze, "spec/detect/host_os_spec.rb".freeze, "spec/detect/nix_desktop_environment_spec.rb".freeze, "spec/detect/ruby_engine_spec.rb".freeze, "spec/detect/runner_spec.rb".freeze, "spec/launchy_spec.rb".freeze, "spec/mock_application.rb".freeze, "spec/spec_helper.rb".freeze, "spec/tattle-host-os.yaml".freeze, "spec/version_spec.rb".freeze] if s.respond_to? :specification_version then s.specification_version = 4 + end - if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then - s.add_runtime_dependency(%q.freeze, ["~> 2.3"]) - s.add_development_dependency(%q.freeze, ["~> 13.0"]) - s.add_development_dependency(%q.freeze, ["~> 5.14"]) - s.add_development_dependency(%q.freeze, ["~> 6.2"]) - s.add_development_dependency(%q.freeze, ["~> 0.18"]) - else - s.add_dependency(%q.freeze, ["~> 2.3"]) - s.add_dependency(%q.freeze, ["~> 13.0"]) - s.add_dependency(%q.freeze, ["~> 5.14"]) - s.add_dependency(%q.freeze, ["~> 6.2"]) - s.add_dependency(%q.freeze, ["~> 0.18"]) - end + if s.respond_to? :add_runtime_dependency then + s.add_runtime_dependency(%q.freeze, ["~> 2.3"]) + s.add_development_dependency(%q.freeze, ["~> 13.0"]) + s.add_development_dependency(%q.freeze, ["~> 5.14"]) + s.add_development_dependency(%q.freeze, ["~> 6.2"]) + s.add_development_dependency(%q.freeze, ["~> 0.18"]) else s.add_dependency(%q.freeze, ["~> 2.3"]) s.add_dependency(%q.freeze, ["~> 13.0"]) diff --git a/lib/launchy/detect/runner.rb b/lib/launchy/detect/runner.rb index ab06eab..3a833a7 100644 --- a/lib/launchy/detect/runner.rb +++ b/lib/launchy/detect/runner.rb @@ -108,8 +108,8 @@ def wet_run( cmd, *args ) class Jruby < Runner def wet_run( cmd, *args ) - require 'spoon' - Spoon.spawnp( *shell_commands( cmd, *args ) ) + child_pid = spawn( *shell_commands( cmd, *args ) ) + Process.detach( child_pid ) end end From 07a82ce9a38774551c4de79c1c7a5a97f0de6a02 Mon Sep 17 00:00:00 2001 From: copiousfreetime Date: Wed, 26 Feb 2020 23:26:26 -0700 Subject: [PATCH 18/21] comment out test that is not fully implemented --- spec/applications/browser_spec.rb | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/spec/applications/browser_spec.rb b/spec/applications/browser_spec.rb index 8e4a278..000d2ef 100644 --- a/spec/applications/browser_spec.rb +++ b/spec/applications/browser_spec.rb @@ -61,15 +61,18 @@ # NOTE: Unable to figure out how capture the stderr from the child which has # moved it at least once. This test just serves the purpose of noting why # something happens, and the problem we are attempting to fix. - it "When BROWSER is set to something that is not executable, error still appears on stderr" do - ENV['BROWSER'] = "not-an-app" - url = "http://example.com/" + #it "When BROWSER is set to something that is not executable, error still appears on stderr" do + # ENV['BROWSER'] = "not-an-app" + # url = "http://example.com/" - _, err = capture_subprocess_io do - Launchy.open( url ) - end - #_(err).must_match( /wibble/m ) - err # something - end + # _, err = capture_subprocess_io do + # begin + # Launchy.open( url ) + # rescue => nil + # end + # end + # #_(err).must_match( /wibble/m ) + # err # something + #end end From 94dfcefb363919ac9dd68fce3acdd57f1d81b49b Mon Sep 17 00:00:00 2001 From: copiousfreetime Date: Wed, 26 Feb 2020 23:26:34 -0700 Subject: [PATCH 19/21] update travis jruby version --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 6f96005..5087aa0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,6 +4,6 @@ rvm: - "2.5" - "2.6" - "2.7" - - jruby-9.2.8.0 + - jruby-9.2.10.0 - jruby-9.1.17.0 - truffleruby From 392e141ecb923af395a6754238fe5ba00c86f5d5 Mon Sep 17 00:00:00 2001 From: copiousfreetime Date: Wed, 26 Feb 2020 23:35:25 -0700 Subject: [PATCH 20/21] removing jruby 9.1.17.0 from travis --- .travis.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 5087aa0..03195b0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,5 +5,4 @@ rvm: - "2.6" - "2.7" - jruby-9.2.10.0 - - jruby-9.1.17.0 - truffleruby From ac4dbc2261704e1110752d4d3c1d191724151b55 Mon Sep 17 00:00:00 2001 From: copiousfreetime Date: Wed, 26 Feb 2020 23:41:56 -0700 Subject: [PATCH 21/21] Merge in changes from #105 - unsure why this never made it in --- lib/launchy/detect/nix_desktop_environment.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/launchy/detect/nix_desktop_environment.rb b/lib/launchy/detect/nix_desktop_environment.rb index f4b91a7..7269c72 100644 --- a/lib/launchy/detect/nix_desktop_environment.rb +++ b/lib/launchy/detect/nix_desktop_environment.rb @@ -33,11 +33,11 @@ def self.browsers class Kde < NixDesktopEnvironment def self.is_current_desktop_environment? ENV['KDE_FULL_SESSION'] && - Launchy::Application.find_executable( 'kfmclient' ) + Launchy::Application.find_executable( 'kde-open' ) end def self.browser - ::Launchy::Argv.new( %w[ kfmclient openURL ] ) + ::Launchy::Argv.new( 'kde-open' ) end end