pax_global_header00006660000000000000000000000064147561250050014517gustar00rootroot0000000000000052 comment=531d9d53fec158ada706db7eee635d5fa23237f9 launchy-3.1.1/000077500000000000000000000000001475612500500131645ustar00rootroot00000000000000launchy-3.1.1/.gitignore000066400000000000000000000003271475612500500151560ustar00rootroot00000000000000*.gem *.rbc *.log /.config/ /coverage/ /pkg/ /test/tmp/ /test/version_tmp/ /tmp/ /log/ # documentation /doc/ # editor *~ *.swp *.swo # environment normalization /.gem/ /.bundle/ /vendor/bundle/ /lib/bundler/man/ launchy-3.1.1/.rubocop.yml000066400000000000000000000034231475612500500154400ustar00rootroot00000000000000require: - rubocop-md - rubocop-minitest - rubocop-packaging - rubocop-performance - rubocop-rake - rubocop-thread_safety AllCops: NewCops: enable TargetRubyVersion: 3.1 Exclude: - 'coverage/**/*' - 'doc/**/*' - 'pkg/**/*' - 'tmp/**/*' - '*.gemspec' - 'vendor/bundle/**/*' Layout/ExtraSpacing: AllowBeforeTrailingComments: true Layout/LineLength: Max: 175 Layout/SpaceInsideHashLiteralBraces: EnforcedStyle: space Lint/DuplicateBranch: IgnoreLiteralBranches: true IgnoreConstantBranches: true Metrics/AbcSize: CountRepeatedAttributes: false Max: 25 Exclude: - 'spec/**/*' - 'tasks/**/*' Metrics/BlockLength: CountAsOne: - heredoc Max: 30 Exclude: - 'spec/**/*' - 'tasks/**/*' Metrics/ClassLength: Max: 175 CountAsOne: - heredoc - array Metrics/ModuleLength: Max: 175 CountAsOne: - heredoc - array Metrics/CyclomaticComplexity: Max: 10 Metrics/MethodLength: Max: 30 CountAsOne: - heredoc - array Exclude: - 'spec/**/*' Metrics/ParameterLists: CountKeywordArgs: false Naming/PredicateName: Enabled: false Style/Documentation: Exclude: - 'spec/**/*' Style/StringLiterals: Enabled: true EnforcedStyle: double_quotes ConsistentQuotesInMultiline: false Style/SafeNavigation: Enabled: false # this gem outputs to stderr on purpose Style/StderrPuts: Enabled: false Style/TernaryParentheses: EnforcedStyle: require_parentheses_when_complex Style/TrailingCommaInArrayLiteral: EnforcedStyleForMultiline: consistent_comma Style/TrailingCommaInHashLiteral: EnforcedStyleForMultiline: consistent_comma Style/TrivialAccessors: Exclude: - lib/launchy.rb ThreadSafety/ClassInstanceVariable: Enabled: false ThreadSafety/DirChdir: Enabled: false launchy-3.1.1/.ruby-version000066400000000000000000000000061475612500500156250ustar00rootroot000000000000003.4.1 launchy-3.1.1/.semaphore/000077500000000000000000000000001475612500500152255ustar00rootroot00000000000000launchy-3.1.1/.semaphore/ensure-bundle.sh000066400000000000000000000010611475612500500203270ustar00rootroot00000000000000# Ensure that the bundle is installed and cached # bundle config set --local deployment true bundle config set --local path vendor/bundle gem update --no-doc bundler gemfile_checksum=$(checksum Gemfile.lock) cache_key="${SEMAPHORE_AGENT_MACHINE_OS_IMAGE}-${RUBY_VERSION}-${gemfile_checksum}" if cache has_key "${cache_key}"; then echo "Bundle for ${RUBY_VERSION} and Gemfile.lock found in cache" cache restore "${cache_key}" else echo "Caching Bundle for ${RUBY_VERSION} and Gemfile.lock" bundle install cache store "${cache_key}" vendor/bundle fi launchy-3.1.1/.semaphore/ensure-ruby-build.sh000066400000000000000000000005171475612500500211410ustar00rootroot00000000000000# # Ensure that ruby-build is installed so we can have the right ruby version # if [ -d "$(rbenv root)/plugins/ruby-build" ]; then echo "Updating ruby-build" git -C "$(rbenv root)/plugins/ruby-build" pull else echo "Installing ruby-build" git clone https://github.com/rbenv/ruby-build.git "$(rbenv root)"/plugins/ruby-build fi launchy-3.1.1/.semaphore/ensure-ruby-version.sh000066400000000000000000000006661475612500500215340ustar00rootroot00000000000000# Ensure the correct Ruby version is installed and cached # cache_key="${SEMAPHORE_AGENT_MACHINE_OS_IMAGE}-${RUBY_VERSION}" if cache has_key "${cache_key}"; then echo "Ruby ${RUBY_VERSION} found in cache" cache restore "${cache_key}" sem-version ruby "${RUBY_VERSION}" -f else echo "Installing Ruby $RUBY_VERSION" sem-version ruby "${RUBY_VERSION}" -f cache store "${cache_key}" "${HOME}/.rbenv/versions/${RUBY_VERSION}" fi launchy-3.1.1/.semaphore/semaphore.yml000066400000000000000000000040761475612500500177420ustar00rootroot00000000000000version: v1.0 name: CI Pipeline agent: machine: type: e1-standard-2 os_image: ubuntu2004 auto_cancel: running: when: "branch != 'main'" blocks: - name: Run tests in Linux environment dependencies: [] task: prologue: commands: - checkout - sudo apt-get update && sudo apt-get install -y libyaml-dev - source .semaphore/ensure-ruby-build.sh epilogue: always: commands: - test-results publish --name ${RUBY_VERSION} ${TEST_RESULTS_FILE} jobs: - name: run tests matrix: - env_var: RUBY_VERSION values: - 3.1.6 - 3.2.7 - 3.3.7 - 3.4.2 - jruby-9.4.12.0 - truffleruby-24.1.2 commands: - source .semaphore/ensure-ruby-version.sh - source .semaphore/ensure-bundle.sh - mkdir -p tmp/test-results/ - bundle exec rake rubocop - export TEST_RESULTS_FILE=tmp/test-results/${RUBY_VERSION}.xml - A="--junit --junit-filename=${TEST_RESULTS_FILE}" bundle exec rake test - name: Run MacOS Tests dependencies: [] task: agent: machine: type: a2-standard-4 os_image: macos-xcode16 prologue: commands: - checkout - source .semaphore/ensure-ruby-build.sh jobs: - name: macos matrix test matrix: - env_var: RUBY_VERSION values: - 3.1.6 - 3.2.7 - 3.3.7 - 3.4.2 commands: - source .semaphore/ensure-ruby-version.sh - source .semaphore/ensure-bundle.sh - mkdir -p tmp/test-results/ - bundle exec rake rubocop - export TEST_RESULTS_FILE=tmp/test-results/${RUBY_VERSION}.xml - bundle exec rake test after_pipeline: task: jobs: - name: Publish Results commands: - test-results gen-pipeline-report launchy-3.1.1/CONTRIBUTING.md000066400000000000000000000053701475612500500154220ustar00rootroot00000000000000# 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-3.1.1/Gemfile000066400000000000000000000012221475612500500144540ustar00rootroot00000000000000# frozen_string_literal: true source "https://rubygems.org" gemspec # gem "debug", "~> 1.0", require: false gem "minitest", "~> 5.11" gem "minitest-focus", "~> 1.2" gem "minitest-junit", "~> 1.0" gem "rake" gem "rdoc", "~> 6.3", require: false gem "reek", require: false gem "rubocop", "~> 1.63", require: false gem "rubocop-minitest", "~> 0.35", require: false gem "rubocop-packaging", "~> 0.5", require: false gem "rubocop-performance", "~> 1.21", require: false gem "rubocop-rake", "~> 0.6", require: false gem "rubocop-thread_safety", "~> 0.6", require: false gem "rubocop-md", "~> 1.2", require: false gem "simplecov", "~> 0.22", require: false launchy-3.1.1/Gemfile.lock000066400000000000000000000207511475612500500154130ustar00rootroot00000000000000PATH remote: . specs: launchy (3.1.1) addressable (~> 2.8) childprocess (~> 5.0) logger (~> 1.6) GEM remote: https://rubygems.org/ specs: addressable (2.8.7) public_suffix (>= 2.0.2, < 7.0) ast (2.4.2) bigdecimal (3.1.9) bigdecimal (3.1.9-java) builder (3.3.0) childprocess (5.1.0) logger (~> 1.5) concurrent-ruby (1.3.5) date (3.4.1) date (3.4.1-java) docile (1.4.1) dry-configurable (1.3.0) dry-core (~> 1.1) zeitwerk (~> 2.6) dry-core (1.1.0) concurrent-ruby (~> 1.0) logger zeitwerk (~> 2.6) dry-inflector (1.2.0) dry-initializer (3.2.0) dry-logic (1.6.0) bigdecimal concurrent-ruby (~> 1.0) dry-core (~> 1.1) zeitwerk (~> 2.6) dry-schema (1.13.4) concurrent-ruby (~> 1.0) dry-configurable (~> 1.0, >= 1.0.1) dry-core (~> 1.0, < 2) dry-initializer (~> 3.0) dry-logic (>= 1.4, < 2) dry-types (>= 1.7, < 2) zeitwerk (~> 2.6) dry-types (1.8.1) bigdecimal (~> 3.0) concurrent-ruby (~> 1.0) dry-core (~> 1.0) dry-inflector (~> 1.0) dry-logic (~> 1.4) zeitwerk (~> 2.6) jar-dependencies (0.5.2) json (2.9.1) json (2.9.1-java) language_server-protocol (3.17.0.3) logger (1.6.5) minitest (5.25.4) minitest-focus (1.4.0) minitest (>= 4, < 6) minitest-junit (1.1.0) builder (~> 3.2) minitest (~> 5.11) parallel (1.26.3) parser (3.3.7.0) ast (~> 2.4.1) racc psych (5.2.3) date stringio psych (5.2.3-java) date jar-dependencies (>= 0.1.7) public_suffix (6.0.1) racc (1.8.1) racc (1.8.1-java) rainbow (3.1.1) rake (13.2.1) rdoc (6.11.0) psych (>= 4.0.0) reek (6.4.0) dry-schema (~> 1.13.0) logger (~> 1.6) parser (~> 3.3.0) rainbow (>= 2.0, < 4.0) rexml (~> 3.1) regexp_parser (2.10.0) rexml (3.4.0) rubocop (1.71.0) json (~> 2.3) language_server-protocol (>= 3.17.0) parallel (~> 1.10) parser (>= 3.3.0.2) rainbow (>= 2.2.2, < 4.0) regexp_parser (>= 2.9.3, < 3.0) rubocop-ast (>= 1.36.2, < 2.0) ruby-progressbar (~> 1.7) unicode-display_width (>= 2.4.0, < 4.0) rubocop-ast (1.37.0) parser (>= 3.3.1.0) rubocop-md (1.2.4) rubocop (>= 1.45) rubocop-minitest (0.36.0) rubocop (>= 1.61, < 2.0) rubocop-ast (>= 1.31.1, < 2.0) rubocop-packaging (0.5.2) rubocop (>= 1.33, < 2.0) rubocop-performance (1.23.1) rubocop (>= 1.48.1, < 2.0) rubocop-ast (>= 1.31.1, < 2.0) rubocop-rake (0.6.0) rubocop (~> 1.0) rubocop-thread_safety (0.6.0) rubocop (>= 1.48.1) ruby-progressbar (1.13.0) simplecov (0.22.0) docile (~> 1.1) simplecov-html (~> 0.11) simplecov_json_formatter (~> 0.1) simplecov-html (0.13.1) simplecov_json_formatter (0.1.4) stringio (3.1.2) unicode-display_width (3.1.4) unicode-emoji (~> 4.0, >= 4.0.4) unicode-emoji (4.0.4) zeitwerk (2.6.18) PLATFORMS arm64-darwin java ruby x86_64-linux DEPENDENCIES launchy! minitest (~> 5.11) minitest-focus (~> 1.2) minitest-junit (~> 1.0) rake rdoc (~> 6.3) reek rubocop (~> 1.63) rubocop-md (~> 1.2) rubocop-minitest (~> 0.35) rubocop-packaging (~> 0.5) rubocop-performance (~> 1.21) rubocop-rake (~> 0.6) rubocop-thread_safety (~> 0.6) simplecov (~> 0.22) CHECKSUMS addressable (2.8.7) sha256=462986537cf3735ab5f3c0f557f14155d778f4b43ea4f485a9deb9c8f7c58232 ast (2.4.2) sha256=1e280232e6a33754cde542bc5ef85520b74db2aac73ec14acef453784447cc12 bigdecimal (3.1.9) sha256=2ffc742031521ad69c2dfc815a98e426a230a3d22aeac1995826a75dabfad8cc bigdecimal (3.1.9-java) sha256=dd9b8f7c870664cd9538a1325ce385ba57a6627969177258c4f0e661a7be4456 builder (3.3.0) sha256=497918d2f9dca528fdca4b88d84e4ef4387256d984b8154e9d5d3fe5a9c8835f childprocess (5.1.0) sha256=9a8d484be2fd4096a0e90a0cd3e449a05bc3aa33f8ac9e4d6dcef6ac1455b6ec concurrent-ruby (1.3.5) sha256=813b3e37aca6df2a21a3b9f1d497f8cbab24a2b94cab325bffe65ee0f6cbebc6 date (3.4.1) sha256=bf268e14ef7158009bfeaec40b5fa3c7271906e88b196d958a89d4b408abe64f date (3.4.1-java) sha256=74740d914c65a922a15657c25ff0e203c16f1d0f7aa910a9ebed712afe9819c4 docile (1.4.1) sha256=96159be799bfa73cdb721b840e9802126e4e03dfc26863db73647204c727f21e dry-configurable (1.3.0) sha256=882d862858567fc1210d2549d4c090f34370fc1bb7c5c1933de3fe792e18afa8 dry-core (1.1.0) sha256=0903821a9707649a7da545a2cd88e20f3a663ab1c5288abd7f914fa7751ab195 dry-inflector (1.2.0) sha256=22f5d0b50fd57074ae57e2ca17e3b300e57564c218269dcf82ff3e42d3f38f2e dry-initializer (3.2.0) sha256=37d59798f912dc0a1efe14a4db4a9306989007b302dcd5f25d0a2a20c166c4e3 dry-logic (1.6.0) sha256=da6fedbc0f90fc41f9b0cc7e6f05f5d529d1efaef6c8dcc8e0733f685745cea2 dry-schema (1.13.4) sha256=caeb644de0be412d347eb4a6d91c56ceef8ec22cfceb98e80d03d354954b1d2a dry-types (1.8.1) sha256=3fe395835763c64fb76f1076b564d718e0c2519afbfddb8ab5609a4724d70a95 jar-dependencies (0.5.2) sha256=695b9f7cdcf77fc5a0a2b00af37668eae76170e7013a6802d28068ea487c0612 json (2.9.1) sha256=d2bdef4644052fad91c1785d48263756fe32fcac08b96a20bb15840e96550d11 json (2.9.1-java) sha256=88de8c79b54fee6ae1b4854bc48b8d7089f524cbacaf4596df24f86b10896ee8 language_server-protocol (3.17.0.3) sha256=3d5c58c02f44a20d972957a9febe386d7e7468ab3900ce6bd2b563dd910c6b3f launchy (3.1.1) logger (1.6.5) sha256=c3cfe56d01656490ddd103d38b8993d73d86296adebc5f58cefc9ec03741e56b minitest (5.25.4) sha256=9cf2cae25ac4dfc90c988ebc3b917f53c054978b673273da1bd20bcb0778f947 minitest-focus (1.4.0) sha256=4cf04bd2b5fe0649922db56f9f2ae30af91475a0f51e02c2baa33f5c5a47ff6c minitest-junit (1.1.0) sha256=036c7c29ed8d852424631c7240c5b9eaa76edbadff4a8b321c12cb77869e6032 parallel (1.26.3) sha256=d86babb7a2b814be9f4b81587bf0b6ce2da7d45969fab24d8ae4bf2bb4d4c7ef parser (3.3.7.0) sha256=7449011771e3e7881297859b849de26a6f4fccd515bece9520a87e7d2116119b psych (5.2.3) sha256=84a54bb952d14604fea22d99938348814678782f58b12648fcdfa4d2fce859ee psych (5.2.3-java) sha256=3e5425b9e8a2f41cc2707d5ef14fdc1ae908abbafb12fe45727bd63900056585 public_suffix (6.0.1) sha256=61d44e1cab5cbbbe5b31068481cf16976dd0dc1b6b07bd95617ef8c5e3e00c6f racc (1.8.1) sha256=4a7f6929691dbec8b5209a0b373bc2614882b55fc5d2e447a21aaa691303d62f racc (1.8.1-java) sha256=54f2e6d1e1b91c154013277d986f52a90e5ececbe91465d29172e49342732b98 rainbow (3.1.1) sha256=039491aa3a89f42efa1d6dec2fc4e62ede96eb6acd95e52f1ad581182b79bc6a rake (13.2.1) sha256=46cb38dae65d7d74b6020a4ac9d48afed8eb8149c040eccf0523bec91907059d rdoc (6.11.0) sha256=bec66fb9b019be64f7ba7d2cd2aecb283a3a01fef23a95b33e2349c6d1aa0040 reek (6.4.0) sha256=80f9a14979aa3ffaecfb2b8b10bdf87fcd8a0fca47c36823e2a4e1e62f1ddd47 regexp_parser (2.10.0) sha256=cb6f0ddde88772cd64bff1dbbf68df66d376043fe2e66a9ef77fcb1b0c548c61 rexml (3.4.0) sha256=efbea1efba7fa151158e0ee1e643525834da2d8eb4cf744aa68f6480bc9804b2 rubocop (1.71.0) sha256=e19679efd447346ac476122313d3788ae23c38214790bcf660e984c747608bf0 rubocop-ast (1.37.0) sha256=9513ac88aaf113d04b52912533ffe46475de1362d4aa41141b51b2455827c080 rubocop-md (1.2.4) sha256=3e481bb08e2d7479eeba3d02359737074f58dd5694f7a57de4ad8d807fdaf6ff rubocop-minitest (0.36.0) sha256=1d15850849c685ff4b6d64dd801ec2d13eb2fe56b6f7ce9aab93d1b0508e7b9f rubocop-packaging (0.5.2) sha256=a36753777573161318ab627a380510c80bfdef2ef2a5b55ad313f923efd20fc7 rubocop-performance (1.23.1) sha256=f22f86a795f5e6a6180aac2c6fc172534b173a068d6ed3396d6460523e051b82 rubocop-rake (0.6.0) sha256=56b6f22189af4b33d4f4e490a555c09f1281b02f4d48c3a61f6e8fe5f401d8db rubocop-thread_safety (0.6.0) sha256=234857694d77a20498e4aae25d87d13e6be462f27d59c40b2a277d67442baea5 ruby-progressbar (1.13.0) sha256=80fc9c47a9b640d6834e0dc7b3c94c9df37f08cb072b7761e4a71e22cff29b33 simplecov (0.22.0) sha256=fe2622c7834ff23b98066bb0a854284b2729a569ac659f82621fc22ef36213a5 simplecov-html (0.13.1) sha256=5dab0b7ee612e60e9887ad57693832fdf4695b4c0c859eaea5f95c18791ef10b simplecov_json_formatter (0.1.4) sha256=529418fbe8de1713ac2b2d612aa3daa56d316975d307244399fa4838c601b428 stringio (3.1.2) sha256=204f1828f85cdb39d57cac4abc6dc44b04505a223f131587f2e20ae3729ba131 unicode-display_width (3.1.4) sha256=8caf2af1c0f2f07ec89ef9e18c7d88c2790e217c482bfc78aaa65eadd5415ac1 unicode-emoji (4.0.4) sha256=2c2c4ef7f353e5809497126285a50b23056cc6e61b64433764a35eff6c36532a zeitwerk (2.6.18) sha256=bd2d213996ff7b3b364cd342a585fbee9797dbc1c0c6d868dc4150cc75739781 BUNDLED WITH 2.6.3 launchy-3.1.1/HISTORY.md000066400000000000000000000171011475612500500146470ustar00rootroot00000000000000# Launchy Changelog ## Version 3.1.1 - 2025-02-21 * Fix the quoted parameter for windows launching - ## Version 3.1.0 - 2025-01-23 * Fix the argv array when passing to ChildProcess on windows - * Update the ruby test matrix for 3.4 * Update the ruby test matrix to drop 3.0 ## Version 3.0.1 - 2024-05-03 * Added rubocop and fix all the warnings * Fix rubygem changelog_uri - Spone * Update the semaphore flow * Update the ruby test matrix * Change to Gemfile for development ## Version 3.0.0 - 2024-03-03 * Remove unused `deprecated.rb` file - * Update supported ruby version to be 3.x * use the `:application` parameter - * adjust the semaphore configuration to allow better caching * replace the homegrown process runner with [`childprocess`](https://rubygems.org/gems/childprocess) ## 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-3.1.1/LICENSE.txt000066400000000000000000000014451475612500500150130ustar00rootroot00000000000000ISC 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-3.1.1/Manifest.txt000066400000000000000000000007231475612500500154750ustar00rootroot00000000000000CONTRIBUTING.md HISTORY.md LICENSE.txt Manifest.txt README.md exe/launchy launchy.gemspec lib/launchy.rb lib/launchy/application.rb lib/launchy/applications/browser.rb lib/launchy/argv.rb lib/launchy/cli.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/error.rb lib/launchy/os_family.rb lib/launchy/runner.rb lib/launchy/version.rb launchy-3.1.1/README.md000066400000000000000000000112611475612500500144440ustar00rootroot00000000000000# 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 :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 ## 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-3.1.1/Rakefile000066400000000000000000000014441475612500500146340ustar00rootroot00000000000000# frozen_string_literal: true # 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_dependency("childprocess", "~> 5.0") spec.add_dependency("logger", "~> 1.6") spec.licenses = ["ISC"] spec.metadata = { "bug_tracker_uri" => "https://github.com/copiousfreetime/launchy/issues", "changelog_uri" => "https://github.com/copiousfreetime/launchy/blob/master/HISTORY.md", "homepage_uri" => "https://github.com/copiousfreetime/launchy", "source_code_uri" => "https://github.com/copiousfreetime/launchy", } end load "tasks/default.rake" launchy-3.1.1/bin/000077500000000000000000000000001475612500500137345ustar00rootroot00000000000000launchy-3.1.1/bin/setup000077500000000000000000000003701475612500500150220ustar00rootroot00000000000000#!/usr/bin/env ruby # frozen_string_literal: true require "pathname" require "fileutils" PROJECT_ROOT = Pathname.new(__dir__).parent.expand_path FileUtils.chdir(PROJECT_ROOT) do puts "Installing dependencies..." system("bundle install") end launchy-3.1.1/exe/000077500000000000000000000000001475612500500137455ustar00rootroot00000000000000launchy-3.1.1/exe/launchy000077500000000000000000000001451475612500500153360ustar00rootroot00000000000000#!/usr/bin/env ruby # frozen_string_literal: true require "launchy" Launchy::Cli.new.run(ARGV, ENV) launchy-3.1.1/launchy.gemspec000066400000000000000000000053441475612500500162020ustar00rootroot00000000000000# DO NOT EDIT - This file is automatically generated # Make changes to Manifest.txt and/or Rakefile and regenerate # -*- encoding: utf-8 -*- # stub: launchy 3.1.1 ruby lib Gem::Specification.new do |s| s.name = "launchy".freeze s.version = "3.1.1".freeze 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/HISTORY.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.bindir = "exe".freeze s.date = "2025-02-21" 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, "LICENSE.txt".freeze, "Manifest.txt".freeze, "README.md".freeze] s.files = ["CONTRIBUTING.md".freeze, "HISTORY.md".freeze, "LICENSE.txt".freeze, "Manifest.txt".freeze, "README.md".freeze, "exe/launchy".freeze, "launchy.gemspec".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/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/error.rb".freeze, "lib/launchy/os_family.rb".freeze, "lib/launchy/runner.rb".freeze, "lib/launchy/version.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.6.3".freeze s.summary = "Launchy is helper class for launching cross-platform applications in a fire and forget manner.".freeze s.specification_version = 4 s.add_runtime_dependency(%q.freeze, ["~> 2.8".freeze]) s.add_runtime_dependency(%q.freeze, ["~> 5.0".freeze]) s.add_runtime_dependency(%q.freeze, ["~> 1.6".freeze]) end launchy-3.1.1/lib/000077500000000000000000000000001475612500500137325ustar00rootroot00000000000000launchy-3.1.1/lib/launchy.rb000066400000000000000000000106261475612500500157270ustar00rootroot00000000000000# frozen_string_literal: true require "English" require "addressable/uri" require "shellwords" require "stringio" # # 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 # :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 = {}) leftover = extract_global_options(options) uri = string_to_uri(uri_s) if (name = options[:application]) app = app_for_name(name) end app = app_for_uri(uri) if app.nil? app.new.open(uri, leftover) rescue Launchy::Error => e raise e rescue StandardError => e msg = "Failure in opening uri #{uri_s.inspect} with options #{options.inspect}: #{e}" raise Launchy::Error, msg ensure if $ERROR_INFO && block_given? yield $ERROR_INFO # explicitly return here to swallow the errors if there was an error # and we yielded to the block # rubocop:disable Lint/EnsureReturn return # rubocop:enable Lint/EnsureReturn end end def app_for_uri(uri) Launchy::Application.handling(uri) end def app_for_name(name) Launchy::Application.for_name(name) rescue Launchy::ApplicationNotFoundError nil end def app_for_uri_string(str) app_for_uri(string_to_uri(str)) end def string_to_uri(str) str = str.to_s uri = Addressable::URI.parse(str) Launchy.log "URI parsing pass 1 : #{str} -> #{uri.to_hash}" unless uri.scheme uri = Addressable::URI.heuristic_parse(str) Launchy.log "URI parsing pass 2 : #{str} -> #{uri.to_hash}" end raise Launchy::ArgumentError, "Invalid URI given: #{str.inspect}" unless uri uri end def reset_global_options Launchy.debug = false Launchy.application = nil Launchy.host_os = nil Launchy.dry_run = false Launchy.path = ENV.fetch("PATH", nil) end def extract_global_options(options) leftover = options.dup Launchy.debug = leftover.delete(:debug) || ENV.fetch("LAUNCHY_DEBUG", nil) Launchy.application = leftover.delete(:application) || ENV.fetch("LAUNCHY_APPLICATION", nil) Launchy.host_os = leftover.delete(:host_os) || ENV.fetch("LAUNCHY_HOST_OS", nil) Launchy.dry_run = leftover.delete(:dry_run) || ENV.fetch("LAUNCHY_DRY_RUN", nil) end def debug=(enabled) @debug = to_bool(enabled) end # we may do logging before a call to 'open', hence the need to check # LAUNCHY_DEBUG here def debug? @debug || to_bool(ENV.fetch("LAUNCHY_DEBUG", nil)) end def application=(app) @application = app end def application @application || ENV.fetch("LAUNCHY_APPLICATION", nil) end def host_os=(host_os) @host_os = host_os end def host_os @host_os || ENV.fetch("LAUNCHY_HOST_OS", nil) end def dry_run=(dry_run) @dry_run = to_bool(dry_run) end def dry_run? @dry_run || to_bool(ENV.fetch("LAUNCHY_DRY_RUN", nil)) 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" else arg.is_a? TrueClass 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/runner" launchy-3.1.1/lib/launchy/000077500000000000000000000000001475612500500153755ustar00rootroot00000000000000launchy-3.1.1/lib/launchy/application.rb000066400000000000000000000045171475612500500202340ustar00rootroot00000000000000# frozen_string_literal: true require "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 application with the given name # # returns the Class that has the given name def for_name(name) klass = find_child(:has_name?, name) return klass if klass raise ApplicationNotFoundError, "No application found named '#{name}'" end # Find the given executable in the available paths # # returns the path to the executable or nil if not found 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) Launchy.log "#{name} : found executable #{file}" return file end end Launchy.log "#{name} : Unable to find `#{bin}' in #{paths.join(', ')}" nil end # Does this class have the given name-like string? # # returns true if the class has the given name def has_name?(qname) qname.to_s.downcase == name.split("::").last.downcase end end attr_reader :host_os_family, :runner def initialize @host_os_family = Launchy::Detect::HostOsFamily.detect @runner = Launchy::Runner.new 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-3.1.1/lib/launchy/applications/000077500000000000000000000000001475612500500200635ustar00rootroot00000000000000launchy-3.1.1/lib/launchy/applications/browser.rb000066400000000000000000000050041475612500500220720ustar00rootroot00000000000000# frozen_string_literal: true module Launchy class 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) true if File.exist?(uri.path) end # The escaped \\ is necessary so that when shellsplit is done later, # the "launchy", with quotes, goes through to the commandline, since that 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(&: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.empty? } 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) 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] cmd.gsub!("%s", args.shift) if cmd.include?("%s") [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 end launchy-3.1.1/lib/launchy/argv.rb000066400000000000000000000011421475612500500166570ustar00rootroot00000000000000# frozen_string_literal: true module Launchy # Internal: Ecapsulate the commandline argumens passed to 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? !blank? && executable? end def blank? @argv.empty? || @argv.first.strip.empty? end def executable? ::Launchy::Application.find_executable(@argv.first) end def ==(other) @argv == other.argv end end end launchy-3.1.1/lib/launchy/cli.rb000066400000000000000000000040351475612500500164730ustar00rootroot00000000000000# frozen_string_literal: true require "optparse" module Launchy # Internal: Command line interface for 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("-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) true rescue ::OptionParser::ParseError => e error_output(e) end def good_run(argv, env) return false unless parse(argv, env) Launchy.open(argv.shift, options) { |e| error_output(e) } true 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." false end def run(argv = ARGV, env = ENV) exit 1 unless good_run(argv, env) end end end launchy-3.1.1/lib/launchy/descendant_tracker.rb000066400000000000000000000020641475612500500215470ustar00rootroot00000000000000# frozen_string_literal: true require "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) super return unless klass.instance_of?(Class) children << klass end # # The list of children that are registered # def children @children = [] unless defined? @children @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-3.1.1/lib/launchy/detect.rb000066400000000000000000000004301475612500500171670ustar00rootroot00000000000000# frozen_string_literal: true module Launchy # Internal: Namespace for detecting the environment that Launchy is running in # module Detect end end require "launchy/detect/host_os" require "launchy/detect/host_os_family" require "launchy/detect/nix_desktop_environment" launchy-3.1.1/lib/launchy/detect/000077500000000000000000000000001475612500500166455ustar00rootroot00000000000000launchy-3.1.1/lib/launchy/detect/host_os.rb000066400000000000000000000013161475612500500206510ustar00rootroot00000000000000# frozen_string_literal: true require "rbconfig" module Launchy module Detect # Internal: Determine the host operating system that Launchy is running on # class HostOs attr_reader :host_os alias to_s host_os alias to_str host_os def initialize(host_os = nil) @host_os = host_os return if @host_os if (@host_os = override_host_os) Launchy.log "Using LAUNCHY_HOST_OS override value of '#{Launchy.host_os}'" else @host_os = default_host_os end end def default_host_os ::RbConfig::CONFIG["host_os"].downcase end def override_host_os Launchy.host_os end end end end launchy-3.1.1/lib/launchy/detect/host_os_family.rb000066400000000000000000000043441475612500500222160ustar00rootroot00000000000000# frozen_string_literal: true module Launchy module 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|msys|windows)/i end def app_list(app) app.windows_app_list end end # Mac OS X family class Darwin < HostOsFamily def self.matching_regex /(darwin|mac os)/i end def app_list(app) app.darwin_app_list end end # All the *nix family of operating systems, and BSDs class Nix < HostOsFamily def self.matching_regex /(linux|bsd|aix|solaris|sunos|dragonfly)/i end def app_list(app) app.nix_app_list end end # Cygwin - if anyone is still using that class Cygwin < HostOsFamily def self.matching_regex /cygwin/i end def app_list(app) app.cygwin_app_list end end end end end launchy-3.1.1/lib/launchy/detect/nix_desktop_environment.rb000066400000000000000000000054351475612500500241540ustar00rootroot00000000000000# frozen_string_literal: true module Launchy module 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 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 #--------------------------------------- # KDE desktop environment class Kde < NixDesktopEnvironment def self.is_current_desktop_environment? ENV.fetch("KDE_FULL_SESSION", nil) && Launchy::Application.find_executable("kde-open") end def self.browser ::Launchy::Argv.new("kde-open") end end # Gnome desktop environment class Gnome < NixDesktopEnvironment def self.is_current_desktop_environment? ENV.fetch("GNOME_DESKTOP_SESSION_ID", nil) && Launchy::Application.find_executable("gnome-open") end def self.browser ::Launchy::Argv.new("gnome-open") end end # Xfce desktop environment class Xfce < NixDesktopEnvironment def self.is_current_desktop_environment? if Launchy::Application.find_executable("xprop") `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 end launchy-3.1.1/lib/launchy/error.rb000066400000000000000000000003221475612500500170500ustar00rootroot00000000000000# frozen_string_literal: true module Launchy class Error < ::StandardError; end class ApplicationNotFoundError < Error; end class CommandNotFoundError < Error; end class ArgumentError < Error; end end launchy-3.1.1/lib/launchy/os_family.rb000066400000000000000000000002521475612500500177030ustar00rootroot00000000000000# frozen_string_literal: true module Launchy # # Model all the Operating system families that can exist. # class OSFamily extend DescendantTracker end end launchy-3.1.1/lib/launchy/runner.rb000066400000000000000000000027561475612500500172450ustar00rootroot00000000000000# frozen_string_literal: true require "childprocess" module Launchy # Internal: Run a command in a child process # class Runner def run(cmd, *args) unless cmd raise Launchy::CommandNotFoundError, "No command found to run with args '#{args.join(' ')}'. If this is unexpected, #{Launchy.bug_report_message}" end if Launchy.dry_run? $stdout.puts dry_run(cmd, *args) else wet_run(cmd, *args) end end def wet_run(cmd, *args) argv = shell_commands(cmd, args) Launchy.log "ChildProcess: argv => #{argv.inspect}" process = ChildProcess.build(*argv) process.io.inherit! process.leader = true process.detach = true process.start end def dry_run(cmd, *args) shell_commands(cmd, args).join(" ") 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 the 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(&:to_s) commandline_normalize(cmdline) end def commandline_normalize(cmdline) c = cmdline.flatten! c = c.find_all { |a| !a.nil? and a.size.positive? } Launchy.log "commandline_normalized => #{c.join(' ')}" c end end end launchy-3.1.1/lib/launchy/version.rb000066400000000000000000000005551475612500500174140ustar00rootroot00000000000000# frozen_string_literal: true module Launchy VERSION = "3.1.1" # Internal: Version number of Launchy 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-3.1.1/spec/000077500000000000000000000000001475612500500141165ustar00rootroot00000000000000launchy-3.1.1/spec/application_spec.rb000066400000000000000000000025311475612500500177610ustar00rootroot00000000000000# frozen_string_literal: true require "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 # rubocop:disable Lint/ConstantDefinitionInBlock class Junk2App < Launchy::Application def self.handles?(uri) uri.scheme == "junk2" end end # rubocop:enable Lint/ConstantDefinitionInBlock _(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") _(-> { 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-3.1.1/spec/applications/000077500000000000000000000000001475612500500166045ustar00rootroot00000000000000launchy-3.1.1/spec/applications/browser_spec.rb000066400000000000000000000045431475612500500216340ustar00rootroot00000000000000# frozen_string_literal: true require "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-3.1.1/spec/cli_spec.rb000066400000000000000000000040531475612500500162260ustar00rootroot00000000000000# frozen_string_literal: true require "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) Launchy::Cli.new.run(argv, env) rescue SystemExit => e _(e.status).must_equal exit_val _($stderr.string).must_match stderr_regex if stderr_regex _($stdout.string).must_match stdout_regex if stdout_regex 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(/github.com/) end { "--application" => [:application, "Browser"], "--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-3.1.1/spec/detect/000077500000000000000000000000001475612500500153665ustar00rootroot00000000000000launchy-3.1.1/spec/detect/host_os_family_spec.rb000066400000000000000000000022301475612500500217410ustar00rootroot00000000000000# frozen_string_literal: true require "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_file(File.expand_path("../tattle-host-os.yaml", __dir__))["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" _(-> { 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 _(-> { Launchy::Detect::HostOsFamily.detect("dos") }).must_raise Launchy::Detect::HostOsFamily::NotFoundError end end launchy-3.1.1/spec/detect/host_os_spec.rb000066400000000000000000000011311475612500500203770ustar00rootroot00000000000000# frozen_string_literal: true require "spec_helper" describe Launchy::Detect::HostOs do it "uses the defult host os from ruby's config" do _(Launchy::Detect::HostOs.new.host_os).must_equal RbConfig::CONFIG["host_os"] end 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-3.1.1/spec/detect/nix_desktop_environment_spec.rb000066400000000000000000000015231475612500500237010ustar00rootroot00000000000000# frozen_string_literal: true require "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-3.1.1/spec/launchy_spec.rb000066400000000000000000000110641475612500500171220ustar00rootroot00000000000000# frozen_string_literal: true require "spec_helper" require "pathname" require "mock_application" 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 "raises an exception if no scheme is found for the given uri" do _(-> { 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 "start \"launchy\" /b #{uri}" end it "opens a data url with a forced browser application" do uri = "data:text/html,hello%20world" Launchy.open(uri, dry_run: true, application: "browser") _($stdout.string.strip).must_match(/open/) # /usr/bin/open or xdg-open 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) do |e| $stderr.puts "had an error opening #{@invalid_url} with options #{options}: #{e}" end _($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 _(-> { Launchy.open(@invalid_url) { raise StandardError, "KABOOM!" } }).must_raise StandardError end it "can force a specific application to be used" do result = Launchy.open("http://example.com", application: "mockapplication") _(result).must_equal "MockApplication opened http://example.com" 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 %w[BROWSER bRoWsEr browser Browser].each do |x| it "can find the browser by name #{x}" do app = Launchy.app_for_name(x) _(app).must_equal(Launchy::Application::Browser) end end end launchy-3.1.1/spec/mock_application.rb000066400000000000000000000004131475612500500177550ustar00rootroot00000000000000# frozen_string_literal: true class MockApplication < Launchy::Application def self.schemes %w[mock mockother] end def self.handles?(uri) schemes.include?(uri.scheme) end def open(uri, _options = {}) "MockApplication opened #{uri}" end end launchy-3.1.1/spec/spec_helper.rb000066400000000000000000000001701475612500500167320ustar00rootroot00000000000000# frozen_string_literal: true require "launchy" require "stringio" require "minitest/autorun" require "minitest/pride" launchy-3.1.1/spec/tattle-host-os.yaml000066400000000000000000000220131475612500500176670ustar00rootroot00000000000000# 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-3.1.1/spec/version_spec.rb000066400000000000000000000004761475612500500171510ustar00rootroot00000000000000# frozen_string_literal: true require "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-3.1.1/tasks/000077500000000000000000000000001475612500500143115ustar00rootroot00000000000000launchy-3.1.1/tasks/default.rake000066400000000000000000000203631475612500500166050ustar00rootroot00000000000000# frozen_string_literal: true # vim: syntax=ruby require "rake/clean" require "digest" #------------------------------------------------------------------------------ # Minitest - standard TestTask #------------------------------------------------------------------------------ begin require "minitest/test_task" Minitest::TestTask.create(:test) do |t| t.libs << "spec" t.warning = true t.test_globs = "{test,spec}/**/{test_*,*_spec}.rb" end desc "Run the requirements for the tests" task "test:requirements" desc "and the requirements" task test: "test:requirements" task default: :test rescue LoadError This.task_warning("test") end #------------------------------------------------------------------------------ # Coverage - integrated with minitest #------------------------------------------------------------------------------ begin require "simplecov" desc "Run tests with code coverage" Minitest::TestTask.create(:coverage) do |t| t.test_prelude = 'require "simplecov"; SimpleCov.start;' t.libs << "spec" t.warning = true t.test_globs = "{test,spec}/**/{test_*,*_spec}.rb" end CLOBBER << "coverage" if File.directory?("coverage") rescue LoadError This.task_warning("simplecov") 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 #------------------------------------------------------------------------------ # Reek - static code analysis #------------------------------------------------------------------------------ begin require "reek/rake/task" Reek::Rake::Task.new rescue LoadError This.task_warning("reek") end #------------------------------------------------------------------------------ # Rubocop - static code analysis #------------------------------------------------------------------------------ begin require "rubocop/rake_task" RuboCop::RakeTask.new rescue LoadError This.task_warning("rubocop") end def git_files IO.popen(%w[git ls-files -z], chdir: This.project_root, err: IO::NULL) do |ls| ls.readlines("\x0", chomp: true) end 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["**/*", ".*"].to_a.sort files = files.select { |f| (f =~ This.include_in_manifest) && 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 = git_files.grep(This.include_in_manifest) files.sort! File.open("Manifest.txt", "w") do |f| f.puts files.join("\n") end end end #------------------------------------------------------------------------------ # Fixme - look for fixmes and report them #------------------------------------------------------------------------------ def fixme_project_root This.project_path("../fixme") end def fixme_project_path(subtree) fixme_project_root.join(subtree) end def local_fixme_files local_files = Dir.glob("tasks/**/*") local_files.concat(Dir.glob(".semaphore/*")) local_files.concat(Dir.glob(".rubocop.yml")) local_files.concat(Dir.glob("bin/*")) end def upstream_fixme_files fixme_project_root.glob("{tasks/**/*,.semaphore/*,.rubocop.yml,bin/*}") end def outdated_fixme_files local_fixme_files.select do |local| upstream = fixme_project_path(local) if upstream.exist? if File.exist?(local) (Digest::SHA256.file(local) != Digest::SHA256.file(upstream)) else true end end end end def fixme_up_to_date? outdated_fixme_files.empty? end namespace :fixme do task default: "manifest:check" do This.manifest.each do |file| next if file == __FILE__ next unless /(txt|rb|md|rdoc|css|html|xml|css)\Z/.match?(file) puts "FIXME: Rename #{file}" if /fixme/i.match?(file) File.readlines(file).each_with_index do |line, idx| prefix = "FIXME: #{file}:#{idx + 1}".ljust(42) puts "#{prefix} => #{line.strip}" if /fixme/i.match?(line) end end end desc "See the local fixme files" task :local_files do local_fixme_files.each do |f| puts f end end desc "See the upstream fixme files" task :upstream_files do upstream_fixme_files.each do |f| puts f end end desc "See if the fixme tools are outdated" task :outdated do if fixme_up_to_date? puts "Fixme files are up to date." else outdated_fixme_files.each do |f| puts "#{f} is outdated" end end end desc "Show the diff between the local and upstream fixme files" task :diff do outdated_fixme_files.each do |f| upstream = fixme_project_path(f) puts "===> Start Diff for #{f}" output = `diff -du #{upstream} #{f}` puts output unless output.empty? puts "===> End Diff for #{f}" puts end end desc "Update outdated fixme files" task :update do if fixme_up_to_date? 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 << "**/*.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 #------------------------------------------------------------------------------ desc "Check to make sure we are ready to release" task :release_check do abort "You must be on the main branch to release!" unless /^\* main/.match?(`git branch`) abort "Nope, sorry, you have unfinished business" unless /^nothing to commit/m.match?(`git status`) 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-3.1.1/tasks/this.rb000066400000000000000000000133221475612500500156060ustar00rootroot00000000000000# frozen_string_literal: true require "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 include in the manifest attr_accessor :include_in_manifest # The hash of Gem::Specifications keyed' by platform attr_accessor :gemspecs # List of cross platforms to build the gem for attr_accessor :cross_platforms # Public: Initialize ThisProject # # Yields self def initialize @include_in_manifest = Regexp.union(/\Alib/, /\Aexe/, /\Aext/, %r{\A[^/]+\.(gemspec|txt|md|rdoc|adoc)\Z}) @gemspecs = {} 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*.*/] return line.match(/.*VERSION\s*=\s*['"](.*)['"]/)[1] if line 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..] parts.map!(&:strip) sections = {} Hash[*parts].each do |k, v| sections[k] = v.split("\n\n") end 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 'bin/setup'" 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(&: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.bindir = "exe" spec.executables = spec.files.grep(/^exe/) { |f| File.basename(f) } spec.test_files = [] 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, &) yielding_gemspec("ruby", core, &) end # Internal: Return the gemspec for the jruby platform def java_gemspec(core = core_gemspec, &) yielding_gemspec("java", core, &) 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? 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.txt") 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