pax_global_header00006660000000000000000000000064143527407520014523gustar00rootroot0000000000000052 comment=b1d64600644a14120436560c78e9edfe7a51011b launchy-2.5.2/000077500000000000000000000000001435274075200131745ustar00rootroot00000000000000launchy-2.5.2/.gitignore000066400000000000000000000001211435274075200151560ustar00rootroot00000000000000*~ *.swo *.swp doc/ coverage/ pkg/ .rvmrc .DS_Store .gem .byebug_history vendor/ launchy-2.5.2/.semaphore/000077500000000000000000000000001435274075200152355ustar00rootroot00000000000000launchy-2.5.2/.semaphore/semaphore.yml000066400000000000000000000031321435274075200177420ustar00rootroot00000000000000version: v1.0 name: Ruby agent: machine: type: e1-standard-2 os_image: ubuntu2004 blocks: - name: Run tests in Linux environment dependencies: [] task: jobs: - name: run tests matrix: - env_var: RUBY_VERSION values: - 2.6.10 - 2.7.7 - 3.0.5 - 3.1.3 - 3.2.0 - jruby-9.3.9.0 - jruby-9.4.0.0 - truffleruby-22.3.0 - truffleruby+graalvm-22.3.0 commands: - checkout - sem-version ruby ${RUBY_VERSION} - bundle config set --local deployment true - bundle config set --local path vendor/bundle - gem install bundler:2.4.1 - bundle install - bundle exec rake test - name: Run tests in macOS environment dependencies: [] task: agent: machine: type: a1-standard-4 os_image: macos-xcode14 jobs: - name: macos matrix test matrix: - env_var: RUBY_VERSION values: - 2.7.7 - 3.0.5 - 3.1.3 - 3.2.0 commands: - checkout - git -C /Users/semaphore/.rbenv/plugins/ruby-build pull - sem-version ruby ${RUBY_VERSION} - bundle config set --local deployment true - bundle config set --local path vendor/bundle - gem install bundler:2.4.1 - bundle install - bundle exec rake test launchy-2.5.2/CONTRIBUTING.md000066400000000000000000000053701435274075200154320ustar00rootroot00000000000000# Hi there! I see you are interested in contributing. That is wonderful. I love contributions. I guarantee that there are bugs in this software. And I guarantee that there is a feature you want that is not in here yet. As such, any and all bugs reports are gratefully accepted, bugfixes even more so. Helping out with bugs is the easiest way to contribute. ## The Quick Version * Have a [GitHub Account][]. * Search the [GitHub Issues][] and see if your issue already present. If so add your comments, :thumbsup:, etc. * Issue not there? Not a problem, open up a [new issue][]. * **Bug reports** please be as detailed as possible. Include: * full ruby engine and version: `ruby -e 'puts RUBY_DESCRIPTION'` * operating system and version * version of launchy `ruby -rubygems -Ilib -e "require 'launchy'; puts Launchy::VERSION"` * as much detail about the bug as possible so I can replicate it. Feel free to link in a [gist][] * **New Feature** * What the new feature should do. * What benefit the new feature brings to the project. * 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 * `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][]. # Contributors * [Jeremy Hinegardner](https://github.com/copiousfreetime) * [Mike Farmer](https://github.com/mikefarmer) * [Suraj N. Kurapati](https://github.com/sunaku) * [Postmodern](https://github.com/postmodern) * [Stephen Judkins](https://github.com/stephenjudkins) * [Mariusz Pietrzyk](https://github.com/wijet) * [Bogdan Gusiev](https://github.com/bogdan) * [Miquel Rodríguez Telep](https://github.com/mrtorrent) * [Chris Schmich](https://github.com/schmich) * [Gioele Barabucci](https://github.com/gioele) * [Colin Noel Bell](https://github.com/colbell) * [Mark J. Lehman](https://github.com/supremebeing7) * [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) * [Jamie Donnelly](https://github.com/JamieKDonnelly) [GitHub Account]: https://github.com/signup/free "GitHub Signup" [GitHub Issues]: https://github.com/copiousfreetime/launchy/issues "Launchy Issues" [new issue]: https://github.com/copiousfreetime/launchy/issues/new "New Launchy Issue" [gist]: https://gist.github.com/ "New Gist" [repo]: https://github.com/copiousfreetime/launchy "Launchy Repo" [pull request]: https://help.github.com/articles/using-pull-requests "Using Pull Requests" launchy-2.5.2/Gemfile000066400000000000000000000002311435274075200144630ustar00rootroot00000000000000# DO NOT EDIT - This file is automatically generated # Make changes to Manifest.txt and/or Rakefile and regenerate source "https://rubygems.org" gemspec launchy-2.5.2/Gemfile.lock000066400000000000000000000014101435274075200154120ustar00rootroot00000000000000PATH remote: . specs: launchy (2.5.2) addressable (~> 2.8) GEM remote: https://rubygems.org/ specs: addressable (2.8.1) public_suffix (>= 2.0.2, < 6.0) docile (1.4.0) jar-dependencies (0.4.1) minitest (5.15.0) psych (4.0.3) stringio psych (4.0.3-java) jar-dependencies (>= 0.1.7) public_suffix (5.0.1) rake (13.0.1) rdoc (6.4.0) psych (>= 4.0.0) simplecov (0.21.2) docile (~> 1.1) simplecov-html (~> 0.11) simplecov_json_formatter (~> 0.1) simplecov-html (0.12.3) simplecov_json_formatter (0.1.4) stringio (3.0.1) PLATFORMS java ruby DEPENDENCIES launchy! minitest (~> 5.15) rake (~> 13.0) rdoc (~> 6.4) simplecov (~> 0.21) BUNDLED WITH 2.4.1 launchy-2.5.2/HISTORY.md000066400000000000000000000151401435274075200146600ustar00rootroot00000000000000# Launchy Changelog ## Version 2.5.2 - 2022-12-27 * Update Addressable - - JamieKDonnelly * Fix deprecated usage of `Object#=~` - - marcrohloff * Move to sempahore for matrix builds and macos tests ## Version 2.5.0 - 2020-02-27 * Update depedencies * Update minimum ruby level * Move to `kde-open` on KDE - - wstephenson * Applied some grammer / spelling fixes - - jeremymoritz * `Pathname` instances do not raise exceptions when opening local files - - dmke * Add a fallback console browsers - - trejkaz ## Version 2.4.3 - 2014-11-03 * Update documentation - - supremebeing7 * Fix launching of `exo-open` for XFCE - - dsandstrom * Add iceweasel as a fallback browser - - jackturnbull * Reopen $stderr in really bad situation - - infertux ## Version 2.4.2 - 2013-11-28 * Fix kde issue - - colbell ## Version 2.4.1 - 2013-11-26 * Abstract out the argv of the commandline - ## Version 2.4.0 - 2013-11-12 * Support `Launchy.open( url, :debug => true )` - - schmich * Fix inconsistencies in `debug?` and `dry_run?` methods - - schmich * Fix detection of missing *nix desktops - * Fix running tests in bare Linux environment - - gioele * Fix mistaking windows drive as uri schema - * Attempt fixing windows `start` command oddities, again - ## Version 2.3.0 - 2013-04-11 * Add the option to call a block on error instead of raising an exception ## Version 2.2.0 - 2013-02-06 * Change XFCE detection to not depend on grep - bogdan * Suppress forked process output * Display help/usage if no url is given * Detect the fluxbox environment * Automatically detect `http` url's if they are missing the `http://` * Update to latest project management rake tasks ## Version 2.1.2 - 2012-08-06 * Fix where HostOS would fail to convert to string on JRuby in 1.9 mode ## Version 2.1.1 - 2012-07-28 * Update addressable runtime dependency * Bring minitest and ffi development dependencies up to date ## Version 2.1.0 - 2012-03-18 * Fix raising exception when no browser program found * Add `LAUNCHY_DRY_RUN` environment variable (Mariusz Pietrzyk / wijet) * Update dependencies ## Version 2.0.5 - 2011-07-24 * Fix the case where `$BROWSER` is set and no *nix desktop was found ## Version 2.0.4 - 2011-07-23 * Fix windows `start` commandline * Add capability to open local files with no file: scheme present * Added `rake how_to_contribute` task * Make better decisions on when to do shell escaping * Switch to Addressable::URI so UTF-8 urls may be parsed. ## Version 2.0.3 - 2011-07-17 * Add in Deprecated API wrappers that warn the user ## Version 2.0.2 - 2011-07-17 * Typo fixes from @mtorrent * Documentation updates explicitly stating the Public API * Increase test coverage ## Version 2.0.1 - 2011-07-16 * Almost a complete rewrite * JRuby Support * Organization is such that it will be easier to add additional applications * Windows behavior possibly fixed, again ## Version 1.0.0 - 2011-03-17 * Add JRuby support (Stephen Judkins) * Remove unused Paths module * Switch to using bones * Switch to use minitest * NOTE, this version was never released. ## Version 0.4.0 - 2011-01-27 * Add support for `file:///` schema (postmodern) ## Version 0.3.7 - 2010-07-19 * Fix launchy on windows (mikefarmer) ## Version 0.3.6 - 2010-02-22 * add a test:spec task to run tests without rcov support * added `testing` os family for running tests ## Version 0.3.5 - 2009-12-17 * clarify that launchy is under ISC license * fix missing data file in released gem needed for running specs ## Version 0.3.3 - 2009-02-19 * pass command line as discrete items to system() to avoid string interpretation by the system shell. (Suraj N. Kurapati) * rework project layout and tasks ## Version 0.3.2 - 2008-05-21 * detect aix and mingw as known operating systems. ## Version 0.3.1 - 2007-09-08 * finalize the command line wrapper around the launchy library. * added more tests ## Version 0.3.0 - 2007-08-30 * reorganize the code structure, removing Spawnable namespace * removed `do_magic` method, changed it to `open` * added override environment variable LAUNCHY_HOST_OS for testing * fix broken cygwin support [Bug #13472] ## Version 0.2.1 - 2007-08-18 * fix inability to find windows executables [Bug #13132] ## Version 0.2.0 - 2007-08-11 * rework browser finding * manual override with `LAUNCHY_BROWSER` environment variable * on *nix use desktop application launcher with fallback to list of browsers * On windows, switch to 'start' command and remove dependency on win32-process * removed win32 gem * Add debug output by setting `LAUNCHY_DEBUG` environment variable to `true` ## Version 0.1.2 - 2007-08-11 * forked child exits without calling `at_exit` handlers ## Version 0.1.1 * fixed rubyforge task to release mswin32 gem also ## Version 0.1.0 * Initial public release * switched to using fork to spawn process and `require 'win32/process'` if on windows ## Version 0.0.2 * First attempt at using systemu to spawn processes ## Version 0.0.1 * Initially working release launchy-2.5.2/LICENSE000066400000000000000000000014451435274075200142050ustar00rootroot00000000000000ISC LICENSE - https://opensource.org/licenses/isc-license.txt Copyright (c) 2007-2020 Jeremy Hinegardner Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. launchy-2.5.2/Manifest.txt000066400000000000000000000016161435274075200155070ustar00rootroot00000000000000CONTRIBUTING.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 launchy-2.5.2/README.md000066400000000000000000000142471435274075200144630ustar00rootroot00000000000000# launchy [![Build Status](https://copiousfreetime.semaphoreci.com/badges/launchy/branches/main.svg)](https://copiousfreetime.semaphoreci.com/projects/launchy) * [Homepage](https://github.com/copiousfreetime/launchy) * [Github Project](https://github.com/copiousfreetime/launchy) ## 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. ## FEATURES 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. ### Commandline % launchy https://www.ruby-lang.org/ 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 fallback 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. 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("https://www.ruby-lang.org/")` then Launchy will try, in order: * `/usr/local/bin/firefox-bin -new-tab 'https://www.ruby-lang.org'` * `/usr/local/bin/google-chrome-stable https://www.ruby-lang.org` Additional links on the use of `BROWSER` as an environment variable. * http://www.catb.org/esr/BROWSER/index.html * https://help.ubuntu.com/community/EnvironmentVariables * https://wiki.archlinux.org/index.php/environment_variables ### 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: 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: 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: context "signin" do it "lets a user sign in" do visit root_path click_link signin_path save_and_open_page page.should have_content "Enter your login information" end end ### Public API In the vein of [Semantic Versioning](https://semver.org), this is the sole supported public API. Launchy.open( uri, options = {} ) { |exception| } At the moment, the only available options are: :debug Turn on debugging output :application Explicitly state what application class is going to be used :host_os Explicitly state what host operating system to pretend to be :ruby_engine Explicitly state what ruby engine to pretend to be under :dry_run Do nothing and print the command that would be executed on $stdout If `Launchy.open` is invoked with a block, then no exception will be thrown, and the block will be called with the parameters passed to `#open` along with the exception that was raised. ### An example of using the public API: Launchy.open( "https://www.ruby-lang.org" ) ### An example of using the public API and using the error block: uri = "https://www.ruby-lang.org" Launchy.open( uri ) do |exception| puts "Attempted to open #{uri} and failed because #{exception}" end ## UPGRADING from versions before 2.0.0 The previously published version of Launchy before the 2.0.0 series was 0.4.0. There have been so many changes, and a mistaken tag at 1.0.0, that I have decided to bump all the way to 2.x.y. I have attempted to keep backward compatibility with the previous examples. The previous API examples of: Launchy::Browser.run("https://www.ruby-lang.org/") and Launchy::Browser.new.visit("https://www.ruby-lang.org/") will still work, and you will get a deprecation notice, along with the line of code you should probably update. For example, this is what would print out in the github gem if it was updated to use 2.0.x but not use the supported API. % gh home WARNING: You made a call to a deprecated Launchy API. This call should be changed to 'Launchy.open( uri )' WARNING: I think I was able to find the location that needs to be fixed. Please go look at: WARNING: WARNING: /Users/jeremy/.rvm/gems/ruby-1.8.7-p334/gems/github-0.6.2/lib/commands/helpers.rb:275:in `open' WARNING: helper :open do |url| WARNING: has_launchy? proc { WARNING: Launchy::Browser.new.visit url WARNING: } WARNING: end WARNING: WARNING: If this is not the case, please file a bug. Please file a bug at https://github.com/copiousfreetime/launchy/issues/new These deprecation notices will go away with version 3.0 and the only available API will be the documented one. ## ISC LICENSE https://opensource.org/licenses/isc-license.txt Copyright (c) 2007-2020 Jeremy Hinegardner Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. launchy-2.5.2/Rakefile000066400000000000000000000016411435274075200146430ustar00rootroot00000000000000# vim: syntax=ruby load 'tasks/this.rb' This.name = "launchy" This.author = "Jeremy Hinegardner" This.email = "jeremy@copiousfreetime.org" This.homepage = "https://github.com/copiousfreetime/#{ This.name }" This.ruby_gemspec do |spec| spec.add_dependency( 'addressable', '~> 2.8') spec.add_development_dependency( 'rake' , '~> 13.0') spec.add_development_dependency( 'minitest' , '~> 5.15' ) spec.add_development_dependency( 'rdoc' , '~> 6.4' ) spec.add_development_dependency( 'simplecov', '~> 0.21' ) spec.licenses = ['ISC'] spec.metadata = { "bug_tracker_uri" => "https://github.com/copiousfreetime/launchy/issues", "changelog_uri" => "https://github.com/copiousfreetime/launchy/blob/master/README.md", "homepage_uri" => "https://github.com/copiousfreetime/launchy", "source_code_uri" => "https://github.com/copiousfreetime/launchy", } end load 'tasks/default.rake' launchy-2.5.2/bin/000077500000000000000000000000001435274075200137445ustar00rootroot00000000000000launchy-2.5.2/bin/launchy000077500000000000000000000001111435274075200153260ustar00rootroot00000000000000#!/usr/bin/env ruby require 'launchy' Launchy::Cli.new.run( ARGV, ENV ) launchy-2.5.2/launchy.gemspec000066400000000000000000000075641435274075200162200ustar00rootroot00000000000000# DO NOT EDIT - This file is automatically generated # Make changes to Manifest.txt and/or Rakefile and regenerate # -*- encoding: utf-8 -*- # stub: launchy 2.5.2 ruby lib Gem::Specification.new do |s| s.name = "launchy".freeze s.version = "2.5.2" s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version= s.metadata = { "bug_tracker_uri" => "https://github.com/copiousfreetime/launchy/issues", "changelog_uri" => "https://github.com/copiousfreetime/launchy/blob/master/README.md", "homepage_uri" => "https://github.com/copiousfreetime/launchy", "source_code_uri" => "https://github.com/copiousfreetime/launchy" } if s.respond_to? :metadata= s.require_paths = ["lib".freeze] s.authors = ["Jeremy Hinegardner".freeze] s.date = "2022-12-28" 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 = "https://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.3.0".freeze) s.rubygems_version = "3.4.1".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] s.specification_version = 4 s.add_runtime_dependency(%q.freeze, ["~> 2.8"]) s.add_development_dependency(%q.freeze, ["~> 13.0"]) s.add_development_dependency(%q.freeze, ["~> 5.15"]) s.add_development_dependency(%q.freeze, ["~> 6.4"]) s.add_development_dependency(%q.freeze, ["~> 0.21"]) end launchy-2.5.2/lib/000077500000000000000000000000001435274075200137425ustar00rootroot00000000000000launchy-2.5.2/lib/launchy.rb000066400000000000000000000104461435274075200157370ustar00rootroot00000000000000require 'addressable/uri' # # The entry point into Launchy. This is the sole supported public API. # # Launchy.open( uri, options = {} ) # # The currently defined global options are: # # :debug Turn on debugging output # :application Explicitly state what application class is going to be used. # This must be a child class of Launchy::Application # :host_os Explicitly state what host operating system to pretend to be # :ruby_engine Explicitly state what ruby engine to pretend to be under # :dry_run Do nothing and print the command that would be executed on $stdout # # Other options may be used, and those will be passed directly to the # application class # module Launchy class << self # # Launch an application for the given uri string # def open(uri_s, options = {}, &error_block ) leftover = extract_global_options( options ) uri = string_to_uri( uri_s ) app = app_for_uri( uri ) app.new.open( uri, leftover ) rescue Launchy::Error => le raise le rescue Exception => e msg = "Failure in opening uri #{uri_s.inspect} with options #{options.inspect}: #{e}" raise Launchy::Error, msg ensure if $! and block_given? then yield $! return # explicitly swallow the errors end end def app_for_uri( uri ) Launchy::Application.handling( uri ) end def app_for_uri_string( s ) app_for_uri( string_to_uri( s ) ) end def string_to_uri( s ) s = s.to_s uri = Addressable::URI.parse( s ) Launchy.log "URI parsing pass 1 : #{s} -> #{uri.to_hash}" if not uri.scheme then uri = Addressable::URI.heuristic_parse( 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 def reset_global_options Launchy.debug = false Launchy.application = nil Launchy.host_os = nil Launchy.ruby_engine = nil Launchy.dry_run = false Launchy.path = ENV['PATH'] end def extract_global_options( options ) leftover = options.dup Launchy.debug = leftover.delete( :debug ) || ENV['LAUNCHY_DEBUG'] Launchy.application = leftover.delete( :application ) || ENV['LAUNCHY_APPLICATION'] Launchy.host_os = leftover.delete( :host_os ) || ENV['LAUNCHY_HOST_OS'] Launchy.ruby_engine = leftover.delete( :ruby_engine ) || ENV['LAUNCHY_RUBY_ENGINE'] Launchy.dry_run = leftover.delete( :dry_run ) || ENV['LAUNCHY_DRY_RUN'] end def debug=( d ) @debug = to_bool( d ) end # we may do logging before a call to 'open', hence the need to check # LAUNCHY_DEBUG here def debug? @debug || to_bool( ENV['LAUNCHY_DEBUG'] ) end def application=( app ) @application = app end def application @application || ENV['LAUNCHY_APPLICATION'] end def host_os=( host_os ) @host_os = host_os end def host_os @host_os || ENV['LAUNCHY_HOST_OS'] end def ruby_engine=( ruby_engine ) @ruby_engine = ruby_engine end def ruby_engine @ruby_engine || ENV['LAUNCHY_RUBY_ENGINE'] end def dry_run=( dry_run ) @dry_run = to_bool( dry_run ) end def dry_run? @dry_run || to_bool( ENV['LAUNCHY_DRY_RUN'] ) end def bug_report_message "Please rerun with environment variable LAUNCHY_DEBUG=true or the '-d' commandline option and file a bug at https://github.com/copiousfreetime/launchy/issues/new" end 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 arg == 'true' elsif arg.is_a? TrueClass true else # All other values mapped to false. false end end end # Iniitialize the global options to sane defaults during parse time. Launchy.reset_global_options end require 'launchy/version' require 'launchy/argv' require 'launchy/cli' require 'launchy/descendant_tracker' require 'launchy/error' require 'launchy/application' require 'launchy/detect' require 'launchy/deprecated' launchy-2.5.2/lib/launchy/000077500000000000000000000000001435274075200154055ustar00rootroot00000000000000launchy-2.5.2/lib/launchy/application.rb000066400000000000000000000036101435274075200202350ustar00rootroot00000000000000require 'set' module Launchy # # Application is the base class of all the application types that launchy may # invoke. It essentially defines the public api of the launchy system. # # Every class that inherits from Application must define: # # 1. A constructor taking no parameters # 2. An instance method 'open' taking a string or URI as the first parameter and a # hash as the second # 3. A class method 'handles?' that takes a String and returns true if that # class can handle the input. class Application extend DescendantTracker class << self # Find the application that handles the given uri. # # returns the Class that can handle the uri def handling( uri ) klass = find_child( :handles?, uri ) return klass if klass raise ApplicationNotFoundError, "No application found to handle '#{uri}'" end # # Find the given executable in the available paths def find_executable( bin, *paths ) paths = Launchy.path.split( File::PATH_SEPARATOR ) if paths.empty? paths.each do |path| file = File.join( path, bin ) if File.executable?( file ) then Launchy.log "#{self.name} : found executable #{file}" return file end end Launchy.log "#{self.name} : Unable to find `#{bin}' in #{paths.join(", ")}" return nil end end attr_reader :host_os_family attr_reader :ruby_engine attr_reader :runner def initialize @host_os_family = Launchy::Detect::HostOsFamily.detect @ruby_engine = Launchy::Detect::RubyEngine.detect @runner = Launchy::Detect::Runner.detect end def find_executable( bin, *paths ) Application.find_executable( bin, *paths ) end def run( cmd, *args ) runner.run( cmd, *args ) end end end require 'launchy/applications/browser' launchy-2.5.2/lib/launchy/applications/000077500000000000000000000000001435274075200200735ustar00rootroot00000000000000launchy-2.5.2/lib/launchy/applications/browser.rb000066400000000000000000000043641435274075200221120ustar00rootroot00000000000000class Launchy::Application # # The class handling the browser application and all of its schemes # class Browser < Launchy::Application def self.schemes %w[ http https ftp file ] end def self.handles?( uri ) return true if schemes.include?( uri.scheme ) return true if File.exist?( uri.path ) end def windows_app_list [ 'start "launchy" /b' ] end def cygwin_app_list [ 'cmd /C start "launchy" /b' ] end # hardcode this to open? def darwin_app_list [ find_executable( "open" ) ] end def nix_app_list nix_de = Launchy::Detect::NixDesktopEnvironment.detect list = nix_de.browsers list.find_all { |argv| argv.valid? } end # use a call back mechanism to get the right app_list that is decided by the # host_os_family class. def app_list host_os_family.app_list( self ) end 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) } return browser_env end # Get the full commandline of what we are going to add the uri to def browser_cmdline browser_env.each do |p| Launchy.log "#{self.class.name} : possibility from BROWSER environment variable : #{p}" end app_list.each do |p| Launchy.log "#{self.class.name} : possibility from app_list : #{p}" end possibilities = (browser_env + app_list).flatten if browser = possibilities.shift then Launchy.log "#{self.class.name} : Using browser value '#{browser}'" return browser end raise Launchy::CommandNotFoundError, "Unable to find a browser command. If this is unexpected, #{Launchy.bug_report_message}" end def cmd_and_args( uri, options = {} ) cmd = browser_cmdline.to_s args = [ uri.to_s ] if cmd =~ /%s/ then cmd.gsub!( /%s/, args.shift ) end [cmd, args] end # final assembly of the command and do %s substitution # http://www.catb.org/~esr/BROWSER/index.html def open( uri, options = {} ) cmd, args = cmd_and_args( uri, options ) run( cmd, args ) end end end launchy-2.5.2/lib/launchy/argv.rb000066400000000000000000000010121435274075200166630ustar00rootroot00000000000000module Launchy class Argv attr_reader :argv def initialize( *args ) @argv = args.flatten end def to_s @argv.join(' ') end def to_str to_s end def [](idx) @argv[idx] end def valid? (not blank?) && executable? end def blank? @argv.empty? || (@argv.first.strip.size == 0) end def executable? ::Launchy::Application.find_executable( @argv.first ) end def ==( other ) @argv == other.argv end end end launchy-2.5.2/lib/launchy/cli.rb000066400000000000000000000043311435274075200165020ustar00rootroot00000000000000require 'optparse' module Launchy class Cli attr_reader :options def initialize @options = {} end def parser @parser ||= OptionParser.new do |op| op.banner = "Usage: launchy [options] thing-to-launch" op.separator "" op.separator "Launch Options:" op.on( "-a", "--application APPLICATION", "Explicitly specify the application class to use in the launch") do |app| @options[:application] = app end op.on( "-d", "--debug", "Force debug. Output lots of information.") do |d| @options[:debug] = true end op.on( "-e", "--engine RUBY_ENGINE", "Force launchy to behave as if it was on a particular ruby engine.") do |e| @options[:ruby_engine] = e end op.on( "-n", "--dry-run", "Don't launchy, print the command to be executed on stdout" ) do |x| @options[:dry_run] = true end op.on( "-o", "--host-os HOST_OS", "Force launchy to behave as if it was on a particular host os.") do |os| @options[:host_os] = os end op.separator "" op.separator "Standard Options:" op.on( "-h", "--help", "Print this message.") do |h| $stdout.puts op.to_s exit 0 end op.on( "-v", "--version", "Output the version of Launchy") do |v| $stdout.puts "Launchy version #{Launchy::VERSION}" exit 0 end end end def parse( argv, env ) parser.parse!( argv ) return true rescue ::OptionParser::ParseError => pe error_output( pe ) end def good_run( argv, env ) if parse( argv, env ) then Launchy.open( argv.shift, options ) { |e| error_output( e ) } return true else return false end end def error_output( error ) $stderr.puts "ERROR: #{error}" Launchy.log "ERROR: #{error}" error.backtrace.each do |bt| Launchy.log bt end $stderr.puts "Try `#{parser.program_name} --help' for more information." return false end def run( argv = ARGV, env = ENV ) exit 1 unless good_run( argv, env ) end end end launchy-2.5.2/lib/launchy/deprecated.rb000066400000000000000000000025241435274075200200350ustar00rootroot00000000000000module Launchy # # This class is deprecated and will be removed # class Browser def self.run( *args ) Browser.new.visit( args[0] ) end def visit( url ) _warn "You made a call to a deprecated Launchy API. This call should be changed to 'Launchy.open( uri )'" report_caller_context( caller ) ::Launchy.open( url ) end private def find_caller_context( stack ) caller_file = stack.find do |line| not line.index( __FILE__ ) end if caller_file then caller_fname, caller_line, _ = caller_file.split(":") if File.readable?( caller_fname ) then caller_lines = IO.readlines( caller_fname ) context = [ caller_file ] context << caller_lines[(caller_line.to_i)-3, 5] return context.flatten end end return [] end def report_caller_context( stack ) context = find_caller_context( stack ) if context.size > 0 then _warn "I think I was able to find the location that needs to be fixed. Please go look at:" _warn context.each do |line| _warn line.rstrip end _warn _warn "If this is not the case, please file a bug. #{Launchy.bug_report_message}" end end def _warn( msg = "" ) warn "WARNING: #{msg}" end end end launchy-2.5.2/lib/launchy/descendant_tracker.rb000066400000000000000000000020711435274075200215550ustar00rootroot00000000000000require 'set' module Launchy # # Use by either # # class Foo # extend DescendantTracker # end # # or # # class Foo # class << self # include DescendantTracker # end # end # # It will track all the classes that inherit from the extended class and keep # them in a Set that is available via the 'children' method. # module DescendantTracker def inherited( klass ) return unless klass.instance_of?( Class ) self.children << klass end # # The list of children that are registered # def children unless defined? @children @children = Array.new end return @children end # # Find one of the child classes by calling the given method # and passing all the rest of the parameters to that method in # each child def find_child( method, *args ) children.find do |child| Launchy.log "Checking if class #{child} is the one for #{method}(#{args.join(', ')})}" child.send( method, *args ) end end end end launchy-2.5.2/lib/launchy/detect.rb000066400000000000000000000003511435274075200172010ustar00rootroot00000000000000module Launchy module Detect end end require 'launchy/detect/host_os' require 'launchy/detect/host_os_family' require 'launchy/detect/ruby_engine' require 'launchy/detect/nix_desktop_environment' require 'launchy/detect/runner' launchy-2.5.2/lib/launchy/detect/000077500000000000000000000000001435274075200166555ustar00rootroot00000000000000launchy-2.5.2/lib/launchy/detect/host_os.rb000066400000000000000000000010701435274075200206560ustar00rootroot00000000000000require 'rbconfig' module Launchy::Detect class HostOs attr_reader :host_os alias to_s host_os alias to_str host_os def initialize( host_os = nil ) @host_os = host_os if not @host_os then if @host_os = override_host_os then Launchy.log "Using LAUNCHY_HOST_OS override value of '#{Launchy.host_os}'" else @host_os = default_host_os end end end def default_host_os ::RbConfig::CONFIG['host_os'] end def override_host_os Launchy.host_os end end end launchy-2.5.2/lib/launchy/detect/host_os_family.rb000066400000000000000000000034431435274075200222250ustar00rootroot00000000000000module Launchy::Detect # Detect the current host os family # # If the current host familiy cannot be detected then return # HostOsFamily::Unknown class HostOsFamily 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 def matches?( host_os ) matching_regex.match( host_os.to_s ) end def windows?() self == Windows; end def darwin?() self == Darwin; end 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 #--------------------------- # All known host os families #--------------------------- # class Windows < HostOsFamily def self.matching_regex /(mingw|mswin|windows)/i end def app_list( app ) app.windows_app_list; end end class Darwin < HostOsFamily def self.matching_regex /(darwin|mac os)/i end def app_list( app ) app.darwin_app_list; end end class Nix < HostOsFamily def self.matching_regex /(linux|bsd|aix|solaris)/i end def app_list( app ) app.nix_app_list; end end class Cygwin < HostOsFamily def self.matching_regex /cygwin/i end def app_list( app ) app.cygwin_app_list; end end end end launchy-2.5.2/lib/launchy/detect/nix_desktop_environment.rb000066400000000000000000000050161435274075200241570ustar00rootroot00000000000000module Launchy::Detect # # Detect the current desktop environment for *nix machines # Currently this is Linux centric. The detection is based upon the detection # used by xdg-open from http://portland.freedesktop.org/ class NixDesktopEnvironment class NotFoundError < Launchy::Error; end extend ::Launchy::DescendantTracker # Detect the current *nix desktop environment # # If the current dekstop environment be detected, the return # NixDekstopEnvironment::Unknown def self.detect found = find_child( :is_current_desktop_environment? ) Launchy.log("Current Desktop environment not found. #{Launchy.bug_report_message}") unless found return found end def self.fallback_browsers %w[ firefox iceweasel seamonkey opera mozilla netscape galeon links lynx ].map { |x| ::Launchy::Argv.new( x ) } end def self.browsers [ browser, fallback_browsers ].flatten end #--------------------------------------- # The list of known desktop environments #--------------------------------------- class Kde < NixDesktopEnvironment def self.is_current_desktop_environment? ENV['KDE_FULL_SESSION'] && Launchy::Application.find_executable( 'kde-open' ) end def self.browser ::Launchy::Argv.new( 'kde-open' ) end end class Gnome < NixDesktopEnvironment def self.is_current_desktop_environment? ENV['GNOME_DESKTOP_SESSION_ID'] && Launchy::Application.find_executable( 'gnome-open' ) end def self.browser ::Launchy::Argv.new( 'gnome-open' ) end end class Xfce < NixDesktopEnvironment def self.is_current_desktop_environment? if Launchy::Application.find_executable( 'xprop' ) then %x[ xprop -root _DT_SAVE_MODE].include?("xfce") else false end end def self.browser ::Launchy::Argv.new( %w[ exo-open --launch WebBrowser ] ) end end # Fall back environment as the last case class Xdg < NixDesktopEnvironment def self.is_current_desktop_environment? Launchy::Application.find_executable( browser ) end def self.browser ::Launchy::Argv.new( 'xdg-open' ) end end # The one that is found when all else fails. And this must be declared last class NotFound < NixDesktopEnvironment def self.is_current_desktop_environment? true end def self.browser ::Launchy::Argv.new end end end end launchy-2.5.2/lib/launchy/detect/ruby_engine.rb000066400000000000000000000041571435274075200215170ustar00rootroot00000000000000module Launchy::Detect class RubyEngine class NotFoundError < Launchy::Error; end extend ::Launchy::DescendantTracker # Detect the current ruby engine. # # If the current ruby engine cannot be detected, the return # RubyEngine::Unknown def self.detect( ruby_engine = RubyEngine.new ) found = find_child( :is_current_engine?, ruby_engine.to_s ) return found if found raise NotFoundError, "#{ruby_engine_error_message( ruby_engine )} #{Launchy.bug_report_message}" end def self.ruby_engine_error_message( ruby_engine ) msg = "Unkonwn RUBY_ENGINE " if ruby_engine then msg += " '#{ruby_engine}'." elsif defined?( RUBY_ENGINE ) then msg += " '#{RUBY_ENGINE}'." else msg = "RUBY_ENGINE not defined for #{RUBY_DESCRIPTION}." end return msg end def self.is_current_engine?( ruby_engine ) return ruby_engine == self.engine_name end def self.mri?() self == Mri; end def self.jruby?() self == Jruby; end def self.rbx?() self == Rbx; end def self.macruby?() self == MacRuby; end attr_reader :ruby_engine alias to_s ruby_engine def initialize( ruby_engine = Launchy.ruby_engine ) if ruby_engine then @ruby_engine = ruby_engine else @ruby_engine = defined?( RUBY_ENGINE ) ? RUBY_ENGINE : "ruby" end end #------------------------------- # The list of known ruby engines #------------------------------- # # This is the ruby engine if the RUBY_ENGINE constant is not defined class Mri < RubyEngine def self.engine_name() "ruby"; end def self.is_current_engine?( ruby_engine ) if ruby_engine then super( ruby_engine ) else return true if not Launchy.ruby_engine and not defined?( RUBY_ENGINE ) end end end class Jruby < RubyEngine def self.engine_name() "jruby"; end end class Rbx < RubyEngine def self.engine_name() "rbx"; end end class MacRuby < RubyEngine def self.engine_name() "macruby"; end end end end launchy-2.5.2/lib/launchy/detect/runner.rb000066400000000000000000000106311435274075200205140ustar00rootroot00000000000000require 'shellwords' require 'stringio' module Launchy::Detect class Runner class NotFoundError < Launchy::Error; end extend ::Launchy::DescendantTracker # Detect the current command runner # # This will return an instance of the Runner to be used to do the # application launching. # # If a runner cannot be detected then raise Runner::NotFoundError # # The runner rules are, in order: # # 1) If you are on windows, you use the Windows Runner no matter what # 2) If you are using the jruby engine, use the Jruby Runner. Unless rule # (1) took effect # 3) Use Forkable (barring rules (1) and (2)) def self.detect host_os_family = Launchy::Detect::HostOsFamily.detect ruby_engine = Launchy::Detect::RubyEngine.detect return Windows.new if host_os_family.windows? if ruby_engine.jruby? then return Jruby.new end return Forkable.new end # # cut it down to just the shell commands that will be passed to exec or # posix_spawn. The cmd argument is split according to shell rules and the # args are not escaped because they whole set is passed to system as *args # and in that case system shell escaping rules are not done. # def shell_commands( cmd, args ) cmdline = [ cmd.to_s.shellsplit ] cmdline << args.flatten.collect{ |a| a.to_s } return commandline_normalize( cmdline ) end def commandline_normalize( cmdline ) c = cmdline.flatten! c = c.find_all { |a| (not a.nil?) and ( a.size > 0 ) } Launchy.log "commandline_normalized => #{c.join(' ')}" return c end def dry_run( cmd, *args ) shell_commands(cmd, args).join(" ") end 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 wet_run( cmd, *args ) end end #--------------------------------------- # The list of known runners #--------------------------------------- class Windows < Runner def all_args( cmd, *args ) args = [ 'cmd', '/c', *shell_commands( cmd, *args ) ] Launchy.log "Windows: all_args => #{args.inspect}" return args end def dry_run( cmd, *args ) all_args( cmd, *args ).join(" ") end # escape the reserved shell characters in windows command shell # http://technet.microsoft.com/en-us/library/cc723564.aspx # # Also make sure that the item after 'start' is guaranteed to be quoted. # https://github.com/copiousfreetime/launchy/issues/62 def shell_commands( cmd, *args ) parts = cmd.shellsplit if start_idx = parts.index('start') then title_idx = start_idx + 1 title = parts[title_idx] title = title.sub(/^/,'"') unless title[0] == '"' title = title.sub(/$/,'"') unless title[-1] == '"' parts[title_idx] = title end cmdline = [ parts ] cmdline << args.flatten.collect { |a| a.to_s.gsub(/([&|()<>^])/, "^\\1") } return commandline_normalize( cmdline ) end def wet_run( cmd, *args ) system( *all_args( cmd, *args ) ) end end class Jruby < Runner def wet_run( cmd, *args ) child_pid = spawn( *shell_commands( cmd, *args ) ) Process.detach( child_pid ) end end class Forkable < Runner attr_reader :child_pid def wet_run( cmd, *args ) @child_pid = fork do close_file_descriptors unless Launchy.debug? Launchy.log("wet_run: before exec in child process") exec_or_raise( cmd, *args ) exit! end Process.detach( @child_pid ) end private # attaching to a StringIO instead of reopening so we don't loose the # STDERR, needed for exec_or_raise. def close_file_descriptors $stdin.reopen( "/dev/null") @saved_stdout = $stdout @saved_stderr = $stderr $stdout = StringIO.new $stderr = StringIO.new end def exec_or_raise( cmd, *args ) exec( *shell_commands( cmd, *args )) rescue Exception => e $stderr = @saved_stderr $stdout = @saved_stdout raise e end end end end launchy-2.5.2/lib/launchy/error.rb000066400000000000000000000002631435274075200170640ustar00rootroot00000000000000module Launchy class Error < ::StandardError; end class ApplicationNotFoundError < Error; end class CommandNotFoundError < Error; end class ArgumentError < Error; end end launchy-2.5.2/lib/launchy/os_family.rb000066400000000000000000000002131435274075200177100ustar00rootroot00000000000000module Launchy # # Model all the Operating system families that can exist. # class OSFamily extend DescendantTracker end end launchy-2.5.2/lib/launchy/version.rb000066400000000000000000000004471435274075200174240ustar00rootroot00000000000000module Launchy VERSION = "2.5.2" module Version MAJOR = Integer(VERSION.split('.')[0]) MINOR = Integer(VERSION.split('.')[1]) PATCH = Integer(VERSION.split('.')[2]) def self.to_a [MAJOR, MINOR, PATCH] end def self.to_s VERSION end end end launchy-2.5.2/spec/000077500000000000000000000000001435274075200141265ustar00rootroot00000000000000launchy-2.5.2/spec/application_spec.rb000066400000000000000000000023621435274075200177730ustar00rootroot00000000000000require 'spec_helper' require 'mock_application' class JunkApp < Launchy::Application def self.handles?( uri ) uri.scheme == "junk" end end describe Launchy::Application do it 'registers inherited classes' do class Junk2App < Launchy::Application def self.handles?( uri ) uri.scheme == "junk2" end end _(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 uri = Addressable::URI.parse( "junk:///foo" ) _(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 ) 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 end it "does not find xyzzy" do _(Launchy::Application.find_executable( "xyzzy" )).must_be_nil end end launchy-2.5.2/spec/applications/000077500000000000000000000000001435274075200166145ustar00rootroot00000000000000launchy-2.5.2/spec/applications/browser_spec.rb000066400000000000000000000045331435274075200216430ustar00rootroot00000000000000require 'spec_helper' describe Launchy::Application::Browser do before do Launchy.reset_global_options ENV['KDE_FULL_SESSION'] = "launchy" @test_url = "http://example.com/" end after do Launchy.reset_global_options ENV.delete( 'KDE_FULL_SESSION' ) ENV.delete( 'BROWSER' ) end { 'windows' => 'windows_app_list', 'darwin' => 'darwin_app_list', 'cygwin' => 'cygwin_app_list', 'linux' => 'nix_app_list', }.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 browser.stub(called_method, [:called_me]) do item = browser.app_list.first _(item).must_equal :called_me end end end %w[ linux windows darwin cygwin ].each do |host_os| it "the BROWSER environment variable overrides any host defaults on '#{host_os}'" do ENV['BROWSER'] = "my_special_browser --new-tab '%s'" 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 [] 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 end it "handles the case where $BROWSER is set and no *nix desktop environment is found" do ENV.delete( "KDE_FULL_SESSION" ) ENV.delete( "GNOME_DESKTOP_SESSION_ID" ) ENV['BROWSER'] = "do-this-instead" Launchy.host_os = 'linux' browser = Launchy::Application::Browser.new _(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 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/" # _, err = capture_subprocess_io do # begin # Launchy.open( url ) # rescue => nil # end # end # #_(err).must_match( /wibble/m ) # err # something #end end launchy-2.5.2/spec/cli_spec.rb000066400000000000000000000042031435274075200162330ustar00rootroot00000000000000require 'spec_helper' describe Launchy::Cli do before do @old_stderr = $stderr $stderr = StringIO.new @old_stdout = $stdout $stdout = StringIO.new Launchy.reset_global_options end after do Launchy.reset_global_options $stderr = @old_stderr $stdout = @old_stdout end 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 end end it "exits 1 when invalid options are given" do cli_test( %w[ -z foo ], {}, 1, /invalid option/, nil ) end %w[ -h --help ].each do |opt| it "output help and exits 0 when using #{opt}" do cli_test( [ opt ], {}, 0, nil, /Print this message/m ) end end %w[ -v --version ].each do |opt| it "outputs version and exits 0 when using #{opt}" do cli_test( [ opt ], {}, 0, nil, /Launchy version/ ) end end it "leaves the url on argv after parsing" do l = Launchy::Cli.new argv = %w[ --debug --dry-run https://github.com/copiousfreetime/launchy ] l.parse( argv , {} ) _(argv.size).must_equal 1 _(argv[0]).must_equal "https://github.com/copiousfreetime/launchy" end it "prints the command on stdout when using --dry-run" do argv = %w[ --debug --dry-run https://github.com/copiousfreetime/launchy ] Launchy::Cli.new.good_run( argv, {} ) _($stdout.string).must_match %r[github.com] end { '--application' => [ :application, 'Browser'], '--engine' => [ :ruby_engine, 'rbx'], '--host-os' => [ :host_os, 'cygwin'] }.each_pair do |opt, val| it "the commandline option #{opt} sets the program option #{val[0]}" do argv = [ opt, val[1], "https://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 "https://github.com/copiousfreetime/launchy" _(l.options[val[0]]).must_equal val[1] end end end launchy-2.5.2/spec/detect/000077500000000000000000000000001435274075200153765ustar00rootroot00000000000000launchy-2.5.2/spec/detect/host_os_family_spec.rb000066400000000000000000000022341435274075200217550ustar00rootroot00000000000000require 'spec_helper' require 'yaml' describe Launchy::Detect::HostOsFamily do before do Launchy.reset_global_options end after do Launchy.reset_global_options end 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 os_family = Launchy::Detect::HostOsFamily.detect( os ) _(os_family).must_be_kind_of Launchy::Detect::HostOsFamily end end { 'mswin' => :windows?, 'darwin' => :darwin?, 'linux' => :nix?, 'cygwin' => :cygwin? }.each_pair do |os, method| it "#{method} returns true for #{os} " do 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 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 launchy-2.5.2/spec/detect/host_os_spec.rb000066400000000000000000000010751435274075200204160ustar00rootroot00000000000000require '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 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" 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" ENV.delete('LAUNCHY_HOST_OS') end end launchy-2.5.2/spec/detect/nix_desktop_environment_spec.rb000066400000000000000000000015011435274075200237050ustar00rootroot00000000000000require 'spec_helper' describe Launchy::Detect::NixDesktopEnvironment do before do Launchy.reset_global_options end after do Launchy.reset_global_options end 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 ) end it "returns NotFound if it cannot determine the *nix desktop environment" do 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 ) end end launchy-2.5.2/spec/detect/ruby_engine_spec.rb000066400000000000000000000020301435274075200212360ustar00rootroot00000000000000require 'spec_helper' describe Launchy::Detect::RubyEngine do before do Launchy.reset_global_options end after do Launchy.reset_global_options end %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 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 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 end { 'rbx' => :rbx?, 'ruby' => :mri?, '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 end end end launchy-2.5.2/spec/detect/runner_spec.rb000066400000000000000000000071321435274075200202510ustar00rootroot00000000000000# coding: utf-8 require 'spec_helper' describe Launchy::Detect::Runner do before do Launchy.reset_global_options @test_url = "http://example.com/?foo=bar&baz=wibble" end after do Launchy.reset_global_options end 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 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 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 end # On anything that has fork, use Forkable %w[ linux darwin cygwin ].each do |host_os| %w[ ruby rbx macruby ].each do |engine_name| it "engine '#{engine_name}' on OS '#{host_os}' uses runner Forkable" do Launchy.host_os = host_os Launchy.ruby_engine = engine_name engine = Launchy::Detect::Runner.detect _(engine).must_be_instance_of Launchy::Detect::Runner::Forkable end end end # Jruby always uses the Jruby runner except on Windows { 'mingw' => Launchy::Detect::Runner::Windows, 'linux' => Launchy::Detect::Runner::Jruby, 'darwin' => Launchy::Detect::Runner::Jruby, 'cygwin' => Launchy::Detect::Runner::Jruby, }.each_pair do |host_os, runner| it "engine 'jruby' on OS '#{host_os}' uses runner #{runner.name}" do Launchy.host_os = host_os Launchy.ruby_engine = 'jruby' engine = Launchy::Detect::Runner.detect _(engine).must_be_instance_of runner end end # If you are on windows, no matter what engine, you use the windows runner %w[ ruby rbx jruby macruby ].each do |engine_name| it "uses a Windows runner when the engine is '#{engine_name}'" do Launchy.host_os = "mingw" Launchy.ruby_engine = engine_name e = Launchy::Detect::Runner.detect _(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' end %w[ & | ( ) < > ^ ].each do |reserved_char| it "Windows escapes '#{reserved_char}' in urls" do win = Launchy::Detect::Runner::Windows.new parts = [ 'http://example.com/?foo=bar', 'baz=wibble' ] 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 ] cmd = win.dry_run( "not-really", [ 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' end it "does not escape %38 items in urls" do l = Launchy::Detect::Runner::Forkable.new cmd = l.dry_run( "not-really", [ "https://ja.wikipedia.org/wiki/%E3%81%82" ] ) _(cmd).must_equal( 'not-really https://ja.wikipedia.org/wiki/%E3%81%82' ) end it "can launch a utf8 url" do url = "https://ja.wikipedia.org/wiki/あ" l = Launchy::Detect::Runner::Forkable.new cmd = l.dry_run( "not-really", [ url ] ) _(cmd).must_equal( "not-really #{url}" ) end end launchy-2.5.2/spec/launchy_spec.rb000066400000000000000000000101331435274075200171260ustar00rootroot00000000000000require 'spec_helper' require 'pathname' describe Launchy do before do Launchy.reset_global_options @stderr = $stderr $stderr = StringIO.new @stdout = $stdout $stdout = StringIO.new @invalid_url = 'blah://example.com/invalid' end after do Launchy.reset_global_options $stderr = @stderr $stdout = @stdout end it "logs to stderr when LAUNCHY_DEBUG environment variable is set" do ENV["LAUNCHY_DEBUG"] = 'true' 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 = old_stderr ENV["LAUNCHY_DEBUG"] = nil end 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 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 ENV['LAUNCHY_DEBUG'] = nil end it "has the global option :debug" do Launchy.extract_global_options( { :debug => 'true' } ) _(Launchy.debug?).must_equal true Launchy.extract_global_options( { :debug => 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.extract_global_options( { :dry_run => 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' 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' end it "has the global option :ruby_engine" do Launchy.extract_global_options( { :ruby_engine => "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 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 ) 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 uri = "C:#{__FILE__}" Launchy.open( uri, :dry_run => true, :host_os => 'windows' ) _($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}" 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}'" end it "raises the error in the called block" do _(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 ) 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 ) end end launchy-2.5.2/spec/mock_application.rb000066400000000000000000000002501435274075200177640ustar00rootroot00000000000000class MockApplication < Launchy::Application def self.schemes %w[ mock mockother ] end def self.handles?( uri ) schemes.include?( uri.scheme ) end end launchy-2.5.2/spec/spec_helper.rb000066400000000000000000000003411435274075200167420ustar00rootroot00000000000000if RUBY_VERSION >= '1.9.2' then require 'simplecov' puts "Using coverage!" SimpleCov.start if ENV['COVERAGE'] end gem 'minitest' require 'launchy' require 'stringio' require 'minitest/autorun' require 'minitest/pride' launchy-2.5.2/spec/tattle-host-os.yaml000066400000000000000000000220131435274075200176770ustar00rootroot00000000000000# SOURCE: http://tattle.rubygarden.org --- ruby_version: 1.8.4: 506 1.8.5: 842 1.8.6: 270 1.9.0: 1 1.8.1: 9 1.8.2: 36 host_vendor: "": 1 mandrake: 1 sun: 18 apple: 619 mandriva: 1 slackware: 1 portbld: 27 pc: 858 ibm: 1 suse: 5 Apple Computer, Inc.: 13 Sun Microsystems Inc.: 6 unknown: 45 redhat: 70 ruby_install_name: jruby.bat: 2 ruby185: 1 jruby: 17 ruby18: 175 ruby1.8: 222 ruby1.8.4: 1 ruby: 1248 build: sparc-sun-solaris2.9: 8 i686-apple-darwin8.6.1: 81 i686-apple-darwin8.5.2: 11 java1.5: 3 i386-unknown-freebsd4.11: 1 powerpc-apple-darwin8.2.0: 3 i386-pc-solaris2.8: 2 x86_64-suse-linux-gnu: 2 x86_64-pc-linux-gnu: 89 i686-apple-darwin8.7.1: 31 i686-apple-darwin8.6.2: 15 java1.6: 6 i686-apple-darwin8.5.3: 4 i686-pc-mswin32: 375 i386-pc-linux-gnu: 2 i386-pc-linux: 3 powerpc-apple-darwin8.3.0: 3 i686-apple-darwin8.8.1: 140 i686-redhat-linux-gnu: 30 i686-apple-darwin8.7.2: 2 powerpc-apple-darwin8.4.0: 6 amd64-portbld-freebsd6: 2 i686-apple-darwin8.8.2: 53 i686-apple-darwin8.9.1: 27 i686-apple-darwin8.7.3: 3 x86_64-unknown-linux-gnu: 29 i686-suse-linux-gnu: 2 powerpc-apple-darwin8.10.0: 2 i686-apple-darwin8.8.3: 15 powerpc-apple-darwin7.9.0: 12 powerpc-apple-darwin8.5.0: 8 i386-mingw32: 1 i686-apple-darwin8.9.3: 1 i686-apple-darwin8.8.4: 5 x86_64-redhat-linux-gnu: 7 powerpc-apple-darwin8.6.0: 25 sparc-sun-solaris2.10: 7 i686-apple-darwin8.9.4: 3 i686-apple-darwin8.8.5: 3 powerpc-apple-darwin8.7.0: 39 powerpc-apple-darwin8.11.0: 1 powerpc-ibm-aix5.3.0.0: 1 powerpc-apple-darwin8.8.0: 53 i386-unknown-netbsdelf3.1.: 1 powerpc-unknown-linux-gnu: 3 powerpc-apple-darwin8.8.1: 1 i486-slackware-linux: 1 i386-pc-solaris2.10: 7 powerpc-apple-darwin8.9.0: 8 i686-pc-cygwin: 14 x86_64-unknown-openbsd4.0: 4 i686-pc-linux-gnu: 343 java: 8 i586-mandrake-linux-gnu: 1 i386-redhat-linux-gnu: 33 i686-apple-darwin9.0: 29 i586-mandriva-linux-gnu: 1 i386-portbld-freebsd5: 3 powerpc-apple-darwin8.0: 10 i386-unknown-freebsd6.0: 2 i486-pc-linux-gnu: 22 i686-suse-linux: 1 i686-apple-darwin: 1 i386-portbld-freebsd6: 20 powerpc-apple-darwin9.0: 5 i386-unknown-freebsd6.1: 1 x86_64-unknown-openbsd3.9: 1 i686-apple-darwin8.10.1: 13 i386-portbld-freebsd7: 2 i686-apple-darwin9.1.0: 1 i686-apple-darwin8.4.1: 1 i686-apple-darwin8.11.1: 2 powerpc64-unknown-linux-gnu: 2 i686-apple-darwin8.5.1: 1 i686-apple-darwin8.10.3: 1 java1.4: 2 sparc-sun-solaris2.8: 3 i386-unknown-openbsd4.0: 2 arch: x86-java1.5: 1 i686-darwin8.8.1: 140 i686-darwin8.7.2: 2 i386-mswin32: 375 i686-darwin8.8.2: 53 i686-darwin8.9.1: 27 i686-darwin8.7.3: 3 x86-java1.6: 1 i686-darwin8.8.3: 15 i686-darwin8.9.3: 1 i686-darwin8.8.4: 5 amd64-freebsd6: 2 sparc-solaris2.8: 3 x86_64-openbsd4.0: 4 powerpc-aix5.3.0.0: 1 powerpc-darwin8.2.0: 3 sparc-solaris2.9: 8 i386-netbsdelf: 1 i386-mingw32: 1 powerpc-darwin8.3.0: 3 i686-darwin8.9.4: 3 i686-darwin8.8.5: 3 i386-linux-gnu: 8 powerpc-darwin8.10.0: 2 i586-linux-gnu: 2 powerpc-darwin8.4.0: 6 powerpc-darwin8.11.0: 1 powerpc-darwin8.5.0: 8 i386-freebsd5: 3 powerpc-darwin8.6.0: 25 i386-linux: 71 i386-freebsd6: 20 powerpc-darwin8.7.0: 39 i486-linux: 188 x86_64-linux: 127 i386-freebsd7: 2 powerpc-darwin8.8.0: 53 i586-linux: 3 java: 8 i386-freebsd4.11: 1 powerpc-darwin8.9.0: 8 powerpc-darwin8.8.1: 1 x86_64-openbsd3.9: 1 i686-darwin: 1 powerpc-darwin8.0: 7 sparc-solaris2.10: 7 universal-darwin8.0: 5 powerpc-linux: 3 i386-freebsd6.0: 2 powerpc64-linux: 2 universal-darwin9.0: 34 i386-cygwin: 14 powerpc-darwin7.9.0: 12 i386-freebsd6.1: 1 i386-solaris2.10: 7 i386-java1.5: 2 i386-openbsd4.0: 2 i686-darwin8.4.1: 1 i686-darwin8.10.1: 11 i386-solaris2.8: 2 i686-darwin9.1.0: 1 i686-darwin8.5.1: 1 i686-darwin8.11.1: 2 i386-java1.6: 7 i686-darwin8.6.1: 81 i686-darwin8.5.2: 11 i686-darwin8.10.3: 1 i686-linux: 167 i686-darwin8.7.1: 31 i686-darwin8.6.2: 15 i686-darwin8.5.3: 4 target_cpu: x86: 2 powerpc64: 2 i686: 610 powerpc: 180 amd64: 2 x86_64: 132 i386: 527 i486: 188 i586: 5 sparc: 18 host_os: freebsd6.1: 1 darwin8.11.1: 2 darwin8.5.3: 4 solaris2.9: 8 darwin7.9.0: 12 darwin8.6.2: 15 darwin8.7.1: 31 darwin8.8.0: 53 darwin8.10.3: 1 freebsd4.11: 1 darwin9.1.0: 1 darwin8.7.2: 2 darwin8.9.0: 8 darwin8.0: 10 darwin8.8.1: 141 darwin8.7.3: 3 linux: 9 darwin8.9.1: 27 darwin9.0: 34 darwin8.8.2: 53 openbsd3.9: 1 Windows XP: 2 cygwin: 14 darwin8.8.3: 15 darwin8.9.3: 1 darwin8.2.0: 3 darwin8.8.4: 5 darwin8.8.5: 3 darwin8.9.4: 3 darwin8.3.0: 3 openbsd4.0: 6 Mac OS X: 13 aix5.3.0.0: 1 darwin: 1 freebsd5: 3 darwin8.4.0: 6 darwin8.4.1: 1 darwin8.10.0: 2 darwin8.5.0: 8 freebsd6: 22 netbsdelf: 1 darwin8.5.1: 1 darwin8.11.0: 1 freebsd7: 2 darwin8.10.1: 13 darwin8.6.0: 25 freebsd6.0: 2 solaris2.8: 5 darwin8.5.2: 11 solaris2.10: 14 darwin8.7.0: 39 darwin8.6.1: 81 mswin32: 376 linux-gnu: 566 rubygems_version: 1.1.0: 11 0.9.3: 11 0.9.0.8: 16 1.0.1: 71 0.8.5: 2 0.8.10: 12 1.1.1: 16 0.9.0.9: 21 0.9.4: 95 0.9.5: 6 0.8.11: 235 0.9.4.7: 1 0.8.8: 1 0.9.0.10: 5 0.9.0: 912 0.9.1: 78 0.9.0.6: 5 0.9.2: 162 0.9.0.7: 2 1.0.0: 2 SHELL: /bin/bash: 75 /bin/sh: 1212 $(COMSPEC): 375 cmd.exe: 2 /usr/local/bin/bash: 2 host_cpu: powerpc64: 2 x86: 2 i686: 1208 powerpc: 180 amd64: 2 x86_64: 132 i386: 97 i486: 23 i586: 2 sparc: 18 LIBRUBY: libruby.so.1.8.6: 9 libruby1.8.4.1.8.4.dylib: 1 libruby18.so.1.8.4: 3 libruby185-static.a: 1 libruby1.8.so.1.8.2: 7 libruby18.so.1.8.5: 127 libruby18.so.1.8.6: 17 libruby.1.8.5.dylib: 166 jruby: 8 libruby.1.8.6.dylib: 41 libruby.so.1.9.0: 1 libruby.so.1.8.1: 8 libruby1.8.so.1.8.4: 125 libruby.so.1.8.2: 1 libruby18.so.18.5: 1 libruby.so.1.84: 2 jruby.jar: 11 libruby1.8.so.1.8.5: 62 libmsvcrt-ruby18.dll.a: 1 libruby.so.1.85: 1 libruby1.8-static.a: 1 libruby.so.1: 4 libruby.1.8.2.dylib: 5 libruby1.8.so.1.8.6: 26 libruby.dll.a: 14 libruby.so.1.8.4: 15 libruby.1.dylib: 43 libruby-static.a: 454 libruby.1.8.4.dylib: 50 libruby.so.1.8.5: 59 msvcrt-ruby18.lib: 375 libruby18.so.18: 27 LIBRUBY_SO: libruby.so.1.8.6: 47 libruby1.8.4.1.8.4.dylib: 1 libruby18.so.1.8.4: 3 libruby1.8.so.1.8.2: 7 libruby18.so.1.8.5: 127 libruby18.so.1.8.6: 17 libruby.1.8.5.dylib: 166 jruby: 8 libruby.1.8.6.dylib: 41 libruby.so.1.9.0: 1 libruby.so.1.8.1: 9 libruby1.8.so.1.8.4: 125 libruby18.so.18.5: 1 libruby.so.1.84: 2 libruby.so.1.8.2: 3 jruby.jar: 11 libruby1.8.so.1.8.5: 63 libruby.so.1.85: 1 libruby.so.1: 4 libruby.1.8.2.dylib: 5 libruby1.8.so.1.8.6: 26 libruby185.so.1.8.5: 1 cygruby18.dll: 14 libruby.1.dylib: 43 libruby.so.1.8.4: 253 msvcrt-ruby18.dll: 376 libruby.1.8.4.dylib: 50 libruby.so.1.8.5: 234 libruby18.so.18: 27 target: sparc-sun-solaris2.9: 8 i686-apple-darwin8.6.1: 81 i686-apple-darwin8.5.2: 11 i386--netbsdelf: 1 powerpc-apple-darwin8.2.0: 3 i386-unknown-freebsd4.11: 1 i386-pc-solaris2.8: 2 x86_64-pc-linux-gnu: 105 i686-apple-darwin8.7.1: 31 i686-apple-darwin8.6.2: 15 i686-apple-darwin8.5.3: 4 x86_64-suse-linux: 2 i386-pc-linux-gnu: 2 i386-pc-linux: 15 powerpc-apple-darwin8.3.0: 3 i686-apple-darwin8.8.1: 140 i686-apple-darwin8.7.2: 2 powerpc-apple-darwin8.4.0: 6 amd64-portbld-freebsd6: 2 i686-apple-darwin8.8.2: 53 i686-apple-darwin8.9.1: 27 i686-apple-darwin8.7.3: 3 x86_64-unknown-linux-gnu: 13 powerpc-apple-darwin8.10.0: 2 i686-apple-darwin8.8.3: 15 powerpc-apple-darwin7.9.0: 12 powerpc-apple-darwin8.5.0: 8 i386-mingw32: 1 i686-apple-darwin8.9.3: 1 i586-suse-linux: 3 i686-apple-darwin8.8.4: 5 x86_64-redhat-linux-gnu: 7 powerpc-apple-darwin8.6.0: 25 powerpc-apple-darwin8.11.0: 1 sparc-sun-solaris2.10: 7 i686-apple-darwin8.9.4: 3 i686-apple-darwin8.8.5: 3 powerpc-apple-darwin8.7.0: 39 powerpc-ibm-aix5.3.0.0: 1 i386-redhat-linux: 1 powerpc-apple-darwin8.8.0: 53 powerpc-unknown-linux-gnu: 3 i486-slackware-linux: 1 i386-pc-solaris2.10: 7 powerpc-apple-darwin8.9.0: 8 powerpc-apple-darwin8.8.1: 1 i686-pc-cygwin: 14 x86_64-unknown-openbsd4.0: 4 i686-pc-linux-gnu: 166 java: 8 i586-mandrake-linux-gnu: 1 i386-redhat-linux-gnu: 61 i586-mandriva-linux-gnu: 1 i686-apple-darwin9.0: 29 i386-portbld-freebsd5: 3 powerpc-apple-darwin8.0: 10 i386-unknown-freebsd6.0: 2 i486-pc-linux-gnu: 187 i686-apple-darwin: 1 i386-portbld-freebsd6: 20 powerpc-apple-darwin9.0: 5 i386-unknown-freebsd6.1: 1 x86_64-unknown-openbsd3.9: 1 i686-redhat-linux: 1 i686-apple-darwin8.10.1: 13 i386-portbld-freebsd7: 2 i686-apple-darwin9.1.0: 1 i686-apple-darwin8.4.1: 1 i686-apple-darwin8.11.1: 2 powerpc64-unknown-linux-gnu: 2 i386-pc-mswin32: 375 i686-apple-darwin8.5.1: 1 java1.4: 11 sparc-sun-solaris2.8: 3 i386-unknown-openbsd4.0: 2 i686-apple-darwin8.10.3: 1 launchy-2.5.2/spec/version_spec.rb000066400000000000000000000004431435274075200171530ustar00rootroot00000000000000require 'spec_helper' 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.to_a.each do |n| _(n.to_i).must_be :>=, 0 end end end launchy-2.5.2/tasks/000077500000000000000000000000001435274075200143215ustar00rootroot00000000000000launchy-2.5.2/tasks/default.rake000066400000000000000000000174361435274075200166240ustar00rootroot00000000000000# vim: syntax=ruby require 'rake/clean' require 'digest' #------------------------------------------------------------------------------ # If you want to Develop on this project just run 'rake develop' and you'll # have all you need to get going. If you want to use bundler for development, # then run 'rake develop:using_bundler' #------------------------------------------------------------------------------ namespace :develop do # Install all the development and runtime dependencies of this gem using the # gemspec. task :default => 'Gemfile' do require 'rubygems/dependency_installer' installer = ::Gem::DependencyInstaller.new puts "Installing bundler..." installer.install 'bundler' sh 'bundle install' puts "\n\nNow run 'rake test'" end # Create a Gemfile that just references the gemspec file 'Gemfile' => :gemspec 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 'gemspec' end end end desc "Bootstrap development" task :develop => "develop:default" #------------------------------------------------------------------------------ # Minitest - standard TestTask #------------------------------------------------------------------------------ begin require 'rake/testtask' Rake::TestTask.new( :test ) do |t| t.ruby_opts = %w[ -w ] t.libs = %w[ lib spec test ] t.pattern = "{test,spec}/**/{test_*,*_spec}.rb" end task :test_requirements task :test => :test_requirements task :default => :test rescue LoadError This.task_warning( 'test' ) end #------------------------------------------------------------------------------ # RDoc - standard rdoc rake task, although we must make sure to use a more # recent version of rdoc since it is the one that has 'tomdoc' markup #------------------------------------------------------------------------------ begin gem 'rdoc' # otherwise we get the wrong task from stdlib require 'rdoc/task' RDoc::Task.new do |t| t.markup = 'tomdoc' t.rdoc_dir = 'doc' t.main = 'README.md' t.title = "#{This.name} #{This.version}" t.rdoc_files.include( FileList['*.{rdoc,md,txt}'], FileList['ext/**/*.c'], FileList['lib/**/*.rb'] ) end rescue StandardError, LoadError This.task_warning( 'rdoc' ) end #------------------------------------------------------------------------------ # Coverage - optional code coverage, rcov for 1.8 and simplecov for 1.9, so # for the moment only rcov is listed. #------------------------------------------------------------------------------ begin require 'simplecov' desc 'Run tests with code coverage' task :coverage do ENV['COVERAGE'] = 'true' Rake::Task[:test].execute end CLOBBER << 'coverage' if File.directory?( 'coverage' ) rescue LoadError This.task_warning( 'simplecov' ) end #------------------------------------------------------------------------------ # Manifest - We want an explicit list of thos files that are to be packaged in # the gem. Most of this is from Hoe. #------------------------------------------------------------------------------ namespace 'manifest' do desc "Check the manifest" task :check => :clean do files = FileList["**/*", ".*"].exclude( This.exclude_from_manifest ).to_a.sort files = files.select{ |f| File.file?( f ) } tmp = "Manifest.tmp" File.open( tmp, 'w' ) do |f| f.puts files.join("\n") end begin sh "diff -du Manifest.txt #{tmp}" ensure rm tmp end puts "Manifest looks good" end desc "Generate the manifest" task :generate => :clean do files = %x[ git ls-files ].split("\n").sort files.reject! { |f| f =~ This.exclude_from_manifest } File.open( "Manifest.txt", "w" ) do |f| f.puts files.join("\n") end end end #------------------------------------------------------------------------------ # Fixme - look for fixmes and report them #------------------------------------------------------------------------------ namespace :fixme do task :default => 'manifest:check' do This.manifest.each do |file| next if file == __FILE__ next unless file =~ %r/(txt|rb|md|rdoc|css|html|xml|css)\Z/ puts "FIXME: Rename #{file}" if file =~ /fixme/i IO.readlines( file ).each_with_index do |line, idx| prefix = "FIXME: #{file}:#{idx+1}".ljust(42) puts "#{prefix} => #{line.strip}" if line =~ /fixme/i end end end def fixme_project_root This.project_path( '../fixme' ) end def fixme_project_path( subtree ) fixme_project_root.join( subtree ) end def local_fixme_files This.manifest.select { |p| p =~ %r|^tasks/| } end def outdated_fixme_files local_fixme_files.select do |local| upstream = fixme_project_path( local ) upstream.exist? && ( Digest::SHA256.file( local ) != Digest::SHA256.file( upstream ) ) end end def fixme_up_to_date? outdated_fixme_files.empty? end desc "See if the fixme tools are outdated" task :outdated => :release_check do if fixme_up_to_date? then puts "Fixme files are up to date." else outdated_fixme_files.each do |f| puts "#{f} is outdated" end end end desc "Update outdated fixme files" task :update => :release_check do if fixme_up_to_date? then puts "Fixme files are already up to date." else puts "Updating fixme files:" outdated_fixme_files.each do |local| upstream = fixme_project_path( local ) puts " * #{local}" FileUtils.cp( upstream, local ) end puts "Use your git commands as appropriate." end end end desc "Look for fixmes and report them" task :fixme => "fixme:default" #------------------------------------------------------------------------------ # Gem Specification #------------------------------------------------------------------------------ # Really this is only here to support those who use bundler desc "Build the #{This.name}.gemspec file" task :gemspec do File.open( This.gemspec_file, "wb+" ) 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.write This.platform_gemspec.to_ruby end end # .rbc files from ruby 2.0 CLOBBER << FileList["**/*.rbc"] # The standard gem packaging task, everyone has it. require 'rubygems/package_task' ::Gem::PackageTask.new( This.platform_gemspec ) do # nothing end #------------------------------------------------------------------------------ # Release - the steps we go through to do a final release, this is pulled from # a compbination of mojombo's rakegem, hoe and hoe-git # # 1) make sure we are on the main branch # 2) make sure there are no uncommitted items # 3) check the manifest and make sure all looks good # 4) build the gem # 5) do an empty commit to have the commit message of the version # 6) tag that commit as the version # 7) push main # 8) push the tag # 7) pus the gem #------------------------------------------------------------------------------ task :release_check do unless `git branch` =~ /^\* main$/ abort "You must be on the main branch to release!" end unless `git status` =~ /^nothing to commit/m abort "Nope, sorry, you have unfinished business" end end desc "Create tag v#{This.version}, build and push #{This.platform_gemspec.full_name} to rubygems.org" task :release => [ :release_check, 'manifest:check', :gem ] do sh "git commit --allow-empty -a -m 'Release #{This.version}'" sh "git tag -a -m 'v#{This.version}' v#{This.version}" sh "git push origin main" sh "git push origin v#{This.version}" sh "gem push pkg/#{This.platform_gemspec.full_name}.gem" end launchy-2.5.2/tasks/this.rb000066400000000000000000000137031435274075200156210ustar00rootroot00000000000000require 'pathname' # Public: A Class containing all the metadata and utilities needed to manage a # ruby project. class ThisProject # The name of this project attr_accessor :name # The author's name attr_accessor :author # The email address of the author(s) attr_accessor :email # The homepage of this project attr_accessor :homepage # The regex of files to exclude from the manifest attr_accessor :exclude_from_manifest # The hash of Gem::Specifications keyed' by platform attr_accessor :gemspecs # Public: Initialize ThisProject # # Yields self 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|byebug_history)$/, /~$/) @gemspecs = Hash.new yield self if block_given? end # Public: return the version of ThisProject # # Search the ruby files in the project looking for the one that has the # version string in it. This does not eval any code in the project, it parses # the source code looking for the string. # # Returns a String version def version [ "lib/#{ name }.rb", "lib/#{ name }/version.rb" ].each do |v| path = project_path( v ) line = path.read[/^\s*VERSION\s*=\s*.*/] if line then return line.match(/.*VERSION\s*=\s*['"](.*)['"]/)[1] end end end # Internal: Return a section of an RDoc file with the given section name # # path - the relative path in the project of the file to parse # section_name - the section out of the file from which to parse data # # Retuns the text of the section as an array of paragrphs. def section_of( file, section_name ) re = /^[=#]+ (.*)$/ sectional = project_path( file ) parts = sectional.read.split( re )[1..-1] parts.map! { |p| p.strip } sections = Hash.new Hash[*parts].each do |k,v| sections[k] = v.split("\n\n") end return sections[section_name] end # Internal: print out a warning about the give task def task_warning( task ) warn "WARNING: '#{task}' tasks are not defined. Please run 'rake develop'" end # Internal: Return the full path to the file that is relative to the project # root. # # path - the relative path of the file from the project root # # Returns the Pathname of the file def project_path( *relative_path ) project_root.join( *relative_path ) end # Internal: The absolute path of this file # # Returns the Pathname of this file. def this_file_path Pathname.new( __FILE__ ).expand_path end # Internal: The root directory of this project # # This is defined as being the directory that is in the path of this project # that has the first Rakefile # # Returns the Pathname of the directory def project_root this_file_path.ascend do |p| rakefile = p.join( 'Rakefile' ) return p if rakefile.exist? end end # Internal: Returns the contents of the Manifest.txt file as an array # # Returns an Array of strings def manifest manifest_file = project_path( "Manifest.txt" ) abort "You need a Manifest.txt" unless manifest_file.readable? manifest_file.readlines.map { |l| l.strip } end # Internal: Return the files that define the extensions # # Returns an Array def extension_conf_files manifest.grep( /extconf.rb\Z/ ) end # Internal: Returns the gemspace associated with the current ruby platform def platform_gemspec gemspecs.fetch(platform) { This.ruby_gemspec } end def core_gemspec Gem::Specification.new do |spec| spec.name = name spec.version = version spec.author = author spec.email = email spec.homepage = homepage spec.summary = summary spec.description = description spec.license = license spec.files = manifest spec.executables = spec.files.grep(/^bin/) { |f| File.basename(f) } spec.test_files = spec.files.grep(/^spec/) spec.extra_rdoc_files += spec.files.grep(/(txt|rdoc|md)$/) spec.rdoc_options = [ "--main" , 'README.md', "--markup", "tomdoc" ] spec.required_ruby_version = '>= 2.3.0' end end # Internal: Return the gemspec for the ruby platform def ruby_gemspec( core = core_gemspec, &block ) yielding_gemspec( 'ruby', core, &block ) end # Internal: Return the gemspec for the jruby platform def java_gemspec( core = core_gemspec, &block ) yielding_gemspec( 'java', core, &block ) end # Internal: give an initial spec and a key, create a new gemspec based off of # it. # # This will force the new gemspecs 'platform' to be that of the key, since the # only reason you would have multiple gemspecs at this point is to deal with # different platforms. def yielding_gemspec( key, core ) spec = gemspecs[key] ||= core.dup spec.platform = key yield spec if block_given? return spec end # Internal: Return the platform of ThisProject at the current moment in time. def platform (RUBY_PLATFORM == "java") ? 'java' : Gem::Platform::RUBY end # Internal: Return the DESCRIPTION section of the README.rdoc file def description_section section_of( 'README.md', 'DESCRIPTION') end # Internal: Return the summary text from the README def summary description_section.first end # Internal: Return the full description text from the README def description description_section.join(" ").tr("\n", ' ').gsub(/[{}]/,'').gsub(/\[[^\]]+\]/,'') # strip rdoc end def license license_file = project_path("LICENSE") line = license_file.readlines.first line.split(/\s+/).first end # Internal: The path to the gemspec file def gemspec_file project_path( "#{ name }.gemspec" ) end end This = ThisProject.new