wijet-launchy 2.0.6

Sign up to get free protection for your applications and to get access to all the features.
data/HISTORY ADDED
@@ -0,0 +1,111 @@
1
+ = Launchy Changlog
2
+ == Version 2.0.5 - 2011-07-24
3
+
4
+ * Fix the case where $BROWSER is set and no *nix desktop was found (copiousfreetime/launchy#33)
5
+
6
+ == Version 2.0.4 - 2011-07-23
7
+
8
+ * Fix windows 'start' commandline (copiousfreetime/launchy#5)
9
+ * Add capability to open local files with no file: scheme present (copiousfreetime/launchy#29)
10
+ * Added 'rake how_to_contribute' task (copiousfreetime/launchy#30)
11
+ * Make better decisions on when to do shell escaping (copiousfreetime/launchy#31)
12
+ * Switch to Addressable::URI so UTF-8 urls may be parsed. (copiousfreetime/launchy#32)
13
+
14
+ == Version 2.0.3 - 2011-07-17
15
+
16
+ * Add in Deprecated API wrappers that warn the user
17
+
18
+ == Version 2.0.2 - 2011-07-17
19
+
20
+ * Typo fixes from @mtorrent
21
+ * Documentation updates explicitly stating the Public API
22
+ * Increase test coverage
23
+
24
+ == Version 2.0.1 - 2011-07-16
25
+
26
+ * Almost a complete rewrite
27
+ * JRuby Support
28
+ * Organization is such that it will be easier to add additional applications
29
+ * Windows behavior possibly fixed, again
30
+
31
+ == Version 1.0.0 - 2011-03-17
32
+
33
+ * Add JRuby support (Stephen Judkins)
34
+ * Remove unused Paths module
35
+ * Switch to using bones
36
+ * Switch to use minitest
37
+ * NOTE, this version was never released.
38
+
39
+ == Version 0.4.0 - 2011-01-27
40
+
41
+ * Add support for file:/// schema (postmodern)
42
+
43
+ == Version 0.3.7 - 2010-07-19
44
+
45
+ * Fix launchy on windows (mikefarmer)
46
+
47
+ == Version 0.3.6 - 2010-02-22
48
+
49
+ * add a test:spec task to run tests without rcov support
50
+ * added 'testing' os family for running tests
51
+
52
+ == Version 0.3.5 - 2009-12-17
53
+
54
+ * clarify that launchy is under ISC license
55
+ * fix missing data file in released gem needed for running specs
56
+
57
+ == Version 0.3.3 - 2009-02-19
58
+
59
+ * pass command line as discrete items to system() to avoid string
60
+ interpretation by the system shell. (Suraj N. Kurapati)
61
+ * rework project layout and tasks
62
+
63
+ == Version 0.3.2 - 2008-05-21
64
+
65
+ * detect aix and mingw as known operating systems.
66
+
67
+ == Version 0.3.1 - 2007-09-08
68
+
69
+ * finalize the command line wrapper around the launchy library.
70
+ * added more tests
71
+
72
+ == Version 0.3.0 - 2007-08-30
73
+
74
+ * reorganize the code structure, removing Spawnable namespace
75
+ * removed 'do_magic' method, changed it to 'open'
76
+ * added override environment variable LAUNCHY_HOST_OS for testing
77
+ * fix broken cygwin support [Bug #13472]
78
+
79
+ == Version 0.2.1 - 2007-08-18
80
+
81
+ * fix inability to find windows executables [Bug #13132]
82
+
83
+ == Version 0.2.0 - 2007-08-11
84
+
85
+ * rework browser finding
86
+ * manual override with LAUNCHY_BROWSER environment variable
87
+ * on *nix use desktop application launcher with fallback to list of browsers
88
+ * On windows, switch to 'start' command and remove dependency on win32-process
89
+ * removed win32 gem
90
+ * Add debug output by setting LAUNCHY_DEBUG environment variable to 'true'
91
+
92
+ == Version 0.1.2 - 2007-08-11
93
+
94
+ * forked child exits without calling at_exit handlers
95
+
96
+ == Version 0.1.1
97
+
98
+ * fixed rubyforge task to release mswin32 gem also
99
+
100
+ == Version 0.1.0
101
+
102
+ * Initial public release
103
+ * switched to using fork to spawn process and require 'win32/process' if on windows
104
+
105
+ == Version 0.0.2
106
+
107
+ * First attempt at using systemu to spawn processes
108
+
109
+ == Version 0.0.1
110
+
111
+ * Initially working release
data/LICENSE ADDED
@@ -0,0 +1,16 @@
1
+ ISC LICENSE - http://opensource.org/licenses/isc-license.txt
2
+
3
+ Copyright (c) 2007-2011 Jeremy Hinegardner
4
+
5
+ Permission to use, copy, modify, and/or distribute this software for any
6
+ purpose with or without fee is hereby granted, provided that the above
7
+ copyright notice and this permission notice appear in all copies.
8
+
9
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10
+ WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11
+ MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12
+ ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13
+ WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14
+ ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15
+ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16
+
data/NOTES ADDED
@@ -0,0 +1 @@
1
+ * Allow for new tab/ new window for opening a browser
data/README ADDED
@@ -0,0 +1,100 @@
1
+ == launchy
2
+
3
+ * Homepage[http://www.copiousfreetime.org/projects/launchy/]
4
+ * {Github Project}[http://github.com/copiousfreetime/launchy]
5
+ * email jeremy at hinegardner dot org
6
+
7
+ == DESCRIPTION
8
+
9
+ Launchy is helper class for launching cross-platform applications in a
10
+ fire and forget manner.
11
+
12
+ There are application concepts (browser, email client, etc) that are
13
+ common across all platforms, and they may be launched differently on
14
+ each platform. Launchy is here to make a common approach to launching
15
+ external application from within ruby programs.
16
+
17
+ == FEATURES
18
+
19
+ Currently only launching a browser is supported.
20
+
21
+ == SYNOPSIS
22
+
23
+ You can use launchy on the commandline, or via its API.
24
+
25
+ === Commandline
26
+
27
+ % launchy http://www.ruby-lang.org/
28
+
29
+ There are additional commandline options, use 'launchy --help' to see them.
30
+
31
+ === Public API
32
+
33
+ In the vein of {Semantic Versioning}[http://semver.org], starting with version 2.0.0, this is the
34
+ sole supported public API.
35
+
36
+ Launchy.open( uri, options = {} )
37
+
38
+ At the moment, the only available options are:
39
+
40
+ :debug Turn on debugging output
41
+ :application Explicitly state what application class is going to be used
42
+ :host_os Explicitly state what host operating system to pretend to be
43
+ :ruby_engine Explicitly state what ruby engine to pretend to be under
44
+ :dry_run Do nothing and print the command that would be executed on $stdout
45
+
46
+ An example of using the public API:
47
+
48
+ Launchy.open( "http://www.ruby-lang.org" )
49
+
50
+ == UPGRADING
51
+
52
+ The previously published version of Launchy was 0.4.0. There have been so many
53
+ changes, and a mistaken tag at 1.0.0, that I have decided to bump all the way
54
+ to 2.0.x.
55
+
56
+ I have attempted to keep backward compatibility with the previous examples. The
57
+ previous API examples of:
58
+
59
+ Launchy::Browser.run("http://www.ruby-lang.org/")
60
+
61
+ and
62
+
63
+ Launchy::Browser.new.visit("http://www.ruby-lang.org/")
64
+
65
+ will still work, and you will get a deprecation notice, along with the line
66
+ of code you should probably update. For example, this is what would print out
67
+ in the github gem if it was updated to use 2.0.x but not use the supported API.
68
+
69
+ % gh home
70
+ WARNING: You made a call to a deprecated Launchy API. This call should be changed to 'Launchy.open( uri )'
71
+ WARNING: I think I was able to find the location that needs to be fixed. Please go look at:
72
+ WARNING:
73
+ WARNING: /Users/jeremy/.rvm/gems/ruby-1.8.7-p334/gems/github-0.6.2/lib/commands/helpers.rb:275:in `open'
74
+ WARNING: helper :open do |url|
75
+ WARNING: has_launchy? proc {
76
+ WARNING: Launchy::Browser.new.visit url
77
+ WARNING: }
78
+ WARNING: end
79
+ WARNING:
80
+ WARNING: If this is not the case, please file a bug. Please file a bug at https://github.com/copiousfreetime/launchy/issues/new
81
+
82
+ == ISC LICENSE
83
+
84
+ http://opensource.org/licenses/isc-license.txt
85
+
86
+ Copyright (c) 2007-2011 Jeremy Hinegardner
87
+
88
+ Permission to use, copy, modify, and/or distribute this software for any
89
+ purpose with or without fee is hereby granted, provided that the above
90
+ copyright notice
91
+ and this permission notice appear in all copies.
92
+
93
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
94
+ WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
95
+ MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
96
+ ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
97
+ WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
98
+ ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
99
+ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
100
+
@@ -0,0 +1,70 @@
1
+ #--
2
+ # Copyright (c) 2007 Jeremy Hinegardner
3
+ # All rights reserved. See LICENSE and/or COPYING for details.
4
+ #++
5
+
6
+ begin
7
+ USING_BONES_VERSION = '3.7.0'
8
+ require 'bones'
9
+ rescue LoadError
10
+ load 'tasks/contribute.rake'
11
+ Rake.application.invoke_task( :help )
12
+ end
13
+
14
+ task :default => 'test:run'
15
+ task 'gem:release' => 'test:run'
16
+
17
+ $:.unshift( "lib" )
18
+ require 'launchy/version'
19
+
20
+ Bones {
21
+ name "wijet-launchy"
22
+ authors "Jeremy Hinegardner"
23
+ email "jeremy@copiousfreetime.org"
24
+ url 'http://www.copiousfreetime.org/projects/launchy'
25
+ version Launchy::VERSION
26
+
27
+ ruby_opts %w[ -W0 -rubygems ]
28
+ readme_file 'README'
29
+ ignore_file '.gitignore'
30
+ history_file 'HISTORY'
31
+
32
+ rdoc.include << "README" << "HISTORY" << "LICENSE"
33
+
34
+ summary 'Launchy is helper class for launching cross-platform applications in a fire and forget manner.'
35
+ description <<_
36
+ Launchy is helper class for launching cross-platform applications in a
37
+ fire and forget manner.
38
+
39
+ There are application concepts (browser, email client, etc) that are
40
+ common across all platforms, and they may be launched differently on
41
+ each platform. Launchy is here to make a common approach to launching
42
+ external application from within ruby programs.
43
+ _
44
+
45
+ if RUBY_PLATFORM == "java" then
46
+ depend_on "spoon" , "~> 0.0.1"
47
+ depend_on 'ffi' , "~> 1.0.9"
48
+ gem.extras = { :platform => Gem::Platform.new( "java" ) }
49
+ end
50
+
51
+ depend_on "addressable", "~> 2.2.6"
52
+
53
+ depend_on "rake" , "~> 0.9.2", :development => true
54
+ depend_on "minitest" , "~> 2.3.1", :development => true
55
+ depend_on 'bones' , "~> #{USING_BONES_VERSION}", :development => true
56
+ depend_on 'bones-rcov', "~> 1.0.1", :development => true
57
+ depend_on 'rcov' , "~> 0.9.9", :development => true
58
+ depend_on "spoon" , "~> 0.0.1", :development => true
59
+ depend_on 'ffi' , "~> 1.0.9", :development => true
60
+
61
+ test.files = FileList["spec/**/*_spec.rb"]
62
+ test.opts << "-w -Ilib:spec"
63
+
64
+ rcov.opts << "--exclude gems"
65
+ }
66
+
67
+ # Sorry Tim, I need to manage my own bones version
68
+ ::Bones.config.gem._spec.dependencies.delete_if do |d|
69
+ d.name == 'bones' and d.requirement.to_s =~ /^>=/
70
+ end
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'launchy'
4
+ Launchy::Cli.new.run( ARGV, ENV )
@@ -0,0 +1,115 @@
1
+ require 'addressable/uri'
2
+
3
+ #
4
+ # The entry point into Launchy. This is the sole supported public API.
5
+ #
6
+ # Launchy.open( uri, options = {} )
7
+ #
8
+ # The currently defined global options are:
9
+ #
10
+ # :debug Turn on debugging output
11
+ # :application Explicitly state what application class is going to be used
12
+ # :host_os Explicitly state what host operating system to pretend to be
13
+ # :ruby_engine Explicitly state what ruby engine to pretend to be under
14
+ # :dry_run Do nothing and print the command that would be executed on $stdout
15
+ #
16
+ # Other options may be used, and those will be passed directly to the
17
+ # application class
18
+ #
19
+ module Launchy
20
+
21
+ class << self
22
+ #
23
+ # Convenience method to launch an item
24
+ #
25
+ def open(uri, options = {} )
26
+ begin
27
+ extract_global_options( options )
28
+ uri = Addressable::URI.parse( uri )
29
+ app = Launchy::Application.handling( uri )
30
+ app.new.open( uri, options )
31
+ rescue Exception => e
32
+ msg = "Failure in opening #{uri} with options #{options.inspect}: #{e}"
33
+ Launchy.log "#{self.name} : #{msg}"
34
+ e.backtrace.each do |bt|
35
+ Launchy.log bt
36
+ end
37
+ $stderr.puts msg
38
+ end
39
+ end
40
+
41
+ def reset_global_options
42
+ Launchy.debug = false
43
+ Launchy.application = nil
44
+ Launchy.host_os = nil
45
+ Launchy.ruby_engine = nil
46
+ Launchy.dry_run = false
47
+ end
48
+
49
+ def extract_global_options( options )
50
+ Launchy.debug = options.delete( :debug ) || ENV['LAUNCHY_DEBUG']
51
+ Launchy.application = options.delete( :application ) || ENV['LAUNCHY_APPLICATION']
52
+ Launchy.host_os = options.delete( :host_os ) || ENV['LAUNCHY_HOST_OS']
53
+ Launchy.ruby_engine = options.delete( :ruby_engine ) || ENV['LAUNCHY_RUBY_ENGINE']
54
+ Launchy.dry_run = options.delete( :dry_run ) || ENV['LAUNCHY_DRY_RUN']
55
+ end
56
+
57
+ def debug=( d )
58
+ @debug = (d == "true")
59
+ end
60
+
61
+ # we may do logging before a call to 'open', hence the need to check
62
+ # LAUNCHY_DEBUG here
63
+ def debug?
64
+ @debug || (ENV['LAUNCHY_DEBUG'] == 'true')
65
+ end
66
+
67
+ def application=( app )
68
+ @application = app
69
+ end
70
+
71
+ def application
72
+ @application || ENV['LAUNCHY_APPLICATION']
73
+ end
74
+
75
+ def host_os=( host_os )
76
+ @host_os = host_os
77
+ end
78
+
79
+ def host_os
80
+ @host_os || ENV['LAUNCHY_HOST_OS']
81
+ end
82
+
83
+ def ruby_engine=( ruby_engine )
84
+ @ruby_engine = ruby_engine
85
+ end
86
+
87
+ def ruby_engine
88
+ @ruby_engine || ENV['LAUNCHY_RUBY_ENGINE']
89
+ end
90
+
91
+ def dry_run=( dry_run )
92
+ @dry_run = dry_run
93
+ end
94
+
95
+ def dry_run?
96
+ @dry_run
97
+ end
98
+
99
+ def bug_report_message
100
+ "Please file a bug at https://github.com/copiousfreetime/launchy/issues/new"
101
+ end
102
+
103
+ def log(msg)
104
+ $stderr.puts "LAUNCHY_DEBUG: #{msg}" if Launchy.debug?
105
+ end
106
+ end
107
+ end
108
+
109
+ require 'launchy/version'
110
+ require 'launchy/cli'
111
+ require 'launchy/descendant_tracker'
112
+ require 'launchy/error'
113
+ require 'launchy/application'
114
+ require 'launchy/detect'
115
+ require 'launchy/deprecated'
@@ -0,0 +1,62 @@
1
+ require 'set'
2
+ module Launchy
3
+ #
4
+ # Application is the base class of all the application types that launchy may
5
+ # invoke. It essentially defines the public api of the launchy system.
6
+ #
7
+ # Every class that inherits from Application must define:
8
+ #
9
+ # 1. A constructor taking no parameters
10
+ # 2. An instance method 'open' taking a string or URI as the first parameter and a
11
+ # hash as the second
12
+ # 3. A class method 'handles?' that takes a String and returns true if that
13
+ # class can handle the input.
14
+ class Application
15
+ extend DescendantTracker
16
+
17
+ class << self
18
+ # Find the application that handles the given uri.
19
+ #
20
+ # returns the Class that can handle the uri
21
+ def handling( uri )
22
+ klass = find_child( :handles?, uri )
23
+ return klass if klass
24
+ raise ApplicationNotFoundError, "No application found to handle '#{uri}'"
25
+ end
26
+
27
+ #
28
+ # Find the given executable in the available paths
29
+ def find_executable( bin, *paths )
30
+ paths = ENV['PATH'].split( File::PATH_SEPARATOR ) if paths.empty?
31
+ paths.each do |path|
32
+ file = File.join( path, bin )
33
+ if File.executable?( file ) then
34
+ Launchy.log "#{self.name} : found executable #{file}"
35
+ return file
36
+ end
37
+ end
38
+ Launchy.log "#{self.name} : Unable to find `#{bin}' in #{paths.join(", ")}"
39
+ return nil
40
+ end
41
+ end
42
+
43
+ attr_reader :host_os_family
44
+ attr_reader :ruby_engine
45
+ attr_reader :runner
46
+
47
+ def initialize
48
+ @host_os_family = Launchy::Detect::HostOsFamily.detect
49
+ @ruby_engine = Launchy::Detect::RubyEngine.detect
50
+ @runner = Launchy::Detect::Runner.detect
51
+ end
52
+
53
+ def find_executable( bin, *paths )
54
+ Application.find_executable( bin, *paths )
55
+ end
56
+
57
+ def run( cmd, *args )
58
+ runner.run( cmd, *args )
59
+ end
60
+ end
61
+ end
62
+ require 'launchy/applications/browser'