launchy 0.4.0 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) hide show
  1. data/.autotest +28 -0
  2. data/HISTORY +15 -0
  3. data/LICENSE +1 -1
  4. data/NOTES +1 -0
  5. data/README +6 -6
  6. data/Rakefile +47 -51
  7. data/bin/launchy +2 -10
  8. data/lib/launchy.rb +96 -30
  9. data/lib/launchy/application.rb +55 -152
  10. data/lib/launchy/applications/browser.rb +68 -0
  11. data/lib/launchy/cli.rb +70 -0
  12. data/lib/launchy/descendant_tracker.rb +49 -0
  13. data/lib/launchy/detect.rb +10 -0
  14. data/lib/launchy/detect/host_os.rb +31 -0
  15. data/lib/launchy/detect/host_os_family.rb +71 -0
  16. data/lib/launchy/detect/nix_desktop_environment.rb +60 -0
  17. data/lib/launchy/detect/ruby_engine.rb +78 -0
  18. data/lib/launchy/detect/runner.rb +96 -0
  19. data/lib/launchy/error.rb +4 -0
  20. data/lib/launchy/os_family.rb +8 -0
  21. data/lib/launchy/version.rb +8 -7
  22. data/spec/application_spec.rb +26 -47
  23. data/spec/detect/host_os_family_spec.rb +40 -0
  24. data/spec/detect/host_os_spec.rb +19 -0
  25. data/spec/detect/nix_desktop_environment_spec.rb +13 -0
  26. data/spec/detect/ruby_engine_spec.rb +37 -0
  27. data/spec/launchy_spec.rb +29 -5
  28. data/spec/mock_scheme.rb +5 -0
  29. data/spec/spec_helper.rb +3 -3
  30. data/spec/{tattle-host-os.yml → tattle-host-os.yaml} +0 -0
  31. data/spec/version_spec.rb +4 -5
  32. metadata +67 -78
  33. data/gemspec.rb +0 -46
  34. data/lib/launchy/browser.rb +0 -98
  35. data/lib/launchy/command_line.rb +0 -48
  36. data/lib/launchy/paths.rb +0 -53
  37. data/spec/browser_spec.rb +0 -62
  38. data/spec/paths_spec.rb +0 -15
  39. data/tasks/announce.rake +0 -39
  40. data/tasks/config.rb +0 -107
  41. data/tasks/distribution.rake +0 -46
  42. data/tasks/documentation.rake +0 -32
  43. data/tasks/rspec.rake +0 -25
  44. data/tasks/rubyforge.rake +0 -52
  45. data/tasks/utils.rb +0 -80
@@ -0,0 +1,4 @@
1
+ module Launchy
2
+ class Error < ::StandardError; end
3
+ class SchemeNotFoundError < Error; end
4
+ end
@@ -0,0 +1,8 @@
1
+ module Launchy
2
+ #
3
+ # Model all the Operating system families that can exist.
4
+ #
5
+ class OSFamily
6
+ extend DescendantTracker
7
+ end
8
+ end
@@ -1,17 +1,18 @@
1
1
  module Launchy
2
+ VERSION = "2.0.0"
3
+
2
4
  module Version
3
- MAJOR = 0
4
- MINOR = 4
5
- BUILD = 0
5
+
6
+ MAJOR = Integer(VERSION.split('.')[0])
7
+ MINOR = Integer(VERSION.split('.')[1])
8
+ PATCH = Integer(VERSION.split('.')[2])
6
9
 
7
10
  def self.to_a
8
- [MAJOR, MINOR, BUILD]
11
+ [MAJOR, MINOR, PATCH]
9
12
  end
10
13
 
11
14
  def self.to_s
12
- to_a.join(".")
15
+ VERSION
13
16
  end
14
- STRING = Version.to_s
15
17
  end
16
- VERSION = Version.to_s
17
18
  end
@@ -1,62 +1,41 @@
1
- require File.join(File.dirname(__FILE__),"spec_helper.rb")
2
- require 'yaml'
1
+ require 'spec_helper'
2
+ require 'mock_scheme'
3
3
 
4
- describe Launchy::Application do
5
- before(:each) do
6
- yml = YAML::load(IO.read(File.join(File.dirname(__FILE__),"tattle-host-os.yml")))
7
- @host_os = yml['host_os']
8
- @app = Launchy::Application.new
4
+ class JunkApp < Launchy::Application
5
+ def self.schemes
6
+ %w[ junk ]
9
7
  end
8
+ end
10
9
 
11
- YAML::load(IO.read(File.join(File.dirname(__FILE__), "tattle-host-os.yml")))['host_os'].keys.sort.each do |os|
12
- it "#{os} should be a found os" do
13
- Launchy::Application::known_os_families.should include(@app.my_os_family(os))
10
+ describe Launchy::Application do
11
+ it 'registers inherited classes' do
12
+ class Junk2App < Launchy::Application
13
+ def self.schemes
14
+ %w[ junk2 ]
15
+ end
14
16
  end
17
+ Launchy::Application.children.must_include( Junk2App )
18
+ Launchy::Application.children.delete( Junk2App )
15
19
  end
16
20
 
17
- it "should not find os of 'dos'" do
18
- @app.my_os_family('dos').should eql(:unknown)
21
+ it "can find an app" do
22
+ Launchy::Application.children.must_include( JunkApp )
23
+ Launchy::Application.scheme_list.size.must_equal 7
24
+ Launchy::Application.for_scheme( "junk" ).must_equal( JunkApp )
19
25
  end
20
26
 
21
- it "my os should have a value" do
22
- @app.my_os.should_not eql('')
23
- @app.my_os.should_not eql(nil)
27
+ it "raises an error if an application cannot be found for the given scheme" do
28
+ lambda { Launchy::Application.for_scheme( "foo" ) }.must_raise( Launchy::SchemeNotFoundError )
24
29
  end
25
30
 
26
- it "should find open or curl" do
27
- r = "found open or curl"
28
- found = %w[ open curl ].collect do |app|
29
- @app.find_executable(app).nil?
31
+ it "can find open or curl" do
32
+ found = %w[ open curl ].any? do |app|
33
+ Launchy::Application.find_executable( app )
30
34
  end
31
- found.should be_include( false )
32
- end
33
-
34
- it "should not find app xyzzy" do
35
- @app.find_executable('xyzzy').should eql(nil)
36
- end
37
-
38
- it "should find the correct class to launch an ftp url" do
39
- Launchy::Application.find_application_class_for("ftp://ftp.ruby-lang.org/pub/ruby/").should == Launchy::Browser
40
- end
41
-
42
- it "knows when it cannot find an application class" do
43
- Launchy::Application.find_application_class_for("xyzzy:stuff,things").should == nil
35
+ found.must_equal true
44
36
  end
45
37
 
46
- it "allows for environmental override of host_os" do
47
- ENV["LAUNCHY_HOST_OS"] = "hal-9000"
48
- Launchy::Application.my_os.should eql("hal-9000")
49
- ENV["LAUNCHY_HOST_OS"] = nil
50
- end
51
-
52
- { "KDE_FULL_SESSION" => :kde,
53
- "KDE_SESSION_UID" => :kde,
54
- "GNOME_DESKTOP_SESSION_ID" => :gnome }.each_pair do |k,v|
55
- it "can detect the desktop environment of a *nix machine using #{k}" do
56
- @app.nix_desktop_environment.should eql(:generic)
57
- ENV[k] = "launchy-test"
58
- Launchy::Application.new.nix_desktop_environment.should eql(v)
59
- ENV[k] = nil
60
- end
38
+ it "does not find xyzzy" do
39
+ Launchy::Application.find_executable( "xyzzy" ).must_equal nil
61
40
  end
62
41
  end
@@ -0,0 +1,40 @@
1
+ require 'spec_helper'
2
+ require 'yaml'
3
+
4
+ describe Launchy::Detect::HostOsFamily do
5
+
6
+ before do
7
+ Launchy.reset_global_options
8
+ end
9
+
10
+ after do
11
+ Launchy.reset_global_options
12
+ end
13
+
14
+ YAML::load( IO.read( File.expand_path( "../../tattle-host-os.yaml", __FILE__ ) ) )['host_os'].keys.sort.each do |os|
15
+ it "OS family of #{os} is detected" do
16
+ Launchy::Detect::HostOsFamily.detect( os ).must_be_kind_of Launchy::Detect::HostOsFamily
17
+ end
18
+ end
19
+
20
+ { 'mswin' => :windows?,
21
+ 'darwin' => :darwin?,
22
+ 'linux' => :nix?,
23
+ 'cygwin' => :cygwin? }.each_pair do |os, method|
24
+ it "#{method} returns true for #{os} " do
25
+ Launchy::Detect::HostOsFamily.detect( os ).send( method ).must_equal true
26
+ end
27
+ end
28
+
29
+ it "uses the global host_os overrides" do
30
+ ENV['LAUNCHY_HOST_OS'] = "fake-os-2"
31
+ lambda { Launchy::Detect::HostOsFamily.detect }.must_raise Launchy::Detect::HostOsFamily::NotFoundError
32
+ ENV.delete('LAUNCHY_HOST_OS')
33
+ end
34
+
35
+
36
+ it "does not find an os of 'dos'" do
37
+ lambda { Launchy::Detect::HostOsFamily.detect( 'dos' ) }.must_raise Launchy::Detect::HostOsFamily::NotFoundError
38
+ end
39
+
40
+ end
@@ -0,0 +1,19 @@
1
+ require 'spec_helper'
2
+
3
+ describe Launchy::Detect::HostOs do
4
+
5
+ it "uses the defult host os from ruby's config" do
6
+ Launchy::Detect::HostOs.new.host_os.must_equal RbConfig::CONFIG['host_os']
7
+ end
8
+
9
+ it "uses the passed in value as the host os" do
10
+ Launchy::Detect::HostOs.new( "fake-os-1").host_os.must_equal "fake-os-1"
11
+ end
12
+
13
+ it "uses the environment variable LAUNCHY_HOST_OS to override ruby's config" do
14
+ ENV['LAUNCHY_HOST_OS'] = "fake-os-2"
15
+ Launchy::Detect::HostOs.new.host_os.must_equal "fake-os-2"
16
+ ENV.delete('LAUNCHY_HOST_OS')
17
+ end
18
+
19
+ end
@@ -0,0 +1,13 @@
1
+ require 'spec_helper'
2
+
3
+ describe Launchy::Detect::NixDesktopEnvironment do
4
+
5
+ { "KDE_FULL_SESSION" => Launchy::Detect::NixDesktopEnvironment::Kde,
6
+ "GNOME_DESKTOP_SESSION_ID" => Launchy::Detect::NixDesktopEnvironment::Gnome }.each_pair do |k,v|
7
+ it "can detect the desktop environment of a *nix machine using ENV[#{k}]" do
8
+ ENV[k] = "launchy-test"
9
+ Launchy::Detect::NixDesktopEnvironment.detect.must_equal v
10
+ ENV.delete( k )
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,37 @@
1
+ require 'spec_helper'
2
+
3
+ describe Launchy::Detect::RubyEngine do
4
+
5
+ before do
6
+ Launchy.reset_global_options
7
+ end
8
+
9
+ after do
10
+ Launchy.reset_global_options
11
+ end
12
+
13
+ %w[ ruby jruby rbx macruby ].each do |ruby|
14
+ it "detects the #{ruby} RUBY_ENGINE" do
15
+ Launchy::Detect::RubyEngine.detect( ruby ).ancestors.must_include Launchy::Detect::RubyEngine
16
+ end
17
+ end
18
+
19
+ it "uses the global ruby_engine overrides" do
20
+ ENV['LAUNCHY_RUBY_ENGINE'] = "rbx"
21
+ Launchy::Detect::RubyEngine.detect.must_equal Launchy::Detect::RubyEngine::Rbx
22
+ ENV.delete('LAUNCHY_RUBY_ENGINE')
23
+ end
24
+
25
+ it "does not find a ruby engine of 'foo'" do
26
+ lambda { Launchy::Detect::RubyEngine.detect( 'foo' ) }.must_raise Launchy::Detect::RubyEngine::NotFoundError
27
+ end
28
+
29
+ { 'rbx' => :rbx?,
30
+ 'ruby' => :mri?,
31
+ 'macruby' => :macruby?,
32
+ 'jruby' => :jruby? }.each_pair do |engine, method|
33
+ it "#{method} returns true for #{engine} " do
34
+ Launchy::Detect::RubyEngine.detect( engine ).send( method ).must_equal true
35
+ end
36
+ end
37
+ end
@@ -1,9 +1,13 @@
1
- require File.join(File.dirname(__FILE__),"spec_helper.rb")
2
- require 'stringio'
1
+ require 'spec_helper'
3
2
 
4
3
  describe Launchy do
5
- it "instantiates an instance of Launchy::CommandLine for commandline" do
6
- Launchy.command_line.class.should eql(Launchy::CommandLine)
4
+
5
+ before do
6
+ Launchy.reset_global_options
7
+ end
8
+
9
+ after do
10
+ Launchy.reset_global_options
7
11
  end
8
12
 
9
13
  it "logs to stderr when LAUNCHY_DEBUG environment variable is set" do
@@ -11,8 +15,28 @@ describe Launchy do
11
15
  old_stderr = $stderr
12
16
  $stderr = StringIO.new
13
17
  Launchy.log "This is a test log message"
14
- $stderr.string.strip.should eql("LAUNCHY_DEBUG: This is a test log message")
18
+ $stderr.string.strip.must_equal "LAUNCHY_DEBUG: This is a test log message"
15
19
  $stderr = old_stderr
16
20
  ENV["LAUNCHY_DEBUG"] = nil
17
21
  end
22
+
23
+ it "has the global option :debug" do
24
+ Launchy.extract_global_options( { :debug => 'true' } )
25
+ Launchy.debug?.must_equal true
26
+ end
27
+
28
+ it "has the global option :application" do
29
+ Launchy.extract_global_options( { :application => "wibble" } )
30
+ Launchy.application.must_equal 'wibble'
31
+ end
32
+
33
+ it "has the global option :host_os" do
34
+ Launchy.extract_global_options( { :host_os => "my-special-os-v2" } )
35
+ Launchy.host_os.must_equal 'my-special-os-v2'
36
+ end
37
+
38
+ it "has the global option :ruby_engine" do
39
+ Launchy.extract_global_options( { :ruby_engine => "myruby" } )
40
+ Launchy.ruby_engine.must_equal 'myruby'
41
+ end
18
42
  end
@@ -0,0 +1,5 @@
1
+ class MockScheme < Launchy::Application
2
+ def self.schemes
3
+ %w[ mock mockother ]
4
+ end
5
+ end
@@ -1,5 +1,5 @@
1
1
  require 'rubygems'
2
- require 'rspec'
3
-
4
- $: << File.expand_path(File.join(File.dirname(__FILE__),"..","lib"))
2
+ require 'minitest/autorun'
3
+ require 'minitest/pride'
5
4
  require 'launchy'
5
+ require 'stringio'
@@ -1,11 +1,10 @@
1
- require File.join(File.dirname(__FILE__),"spec_helper.rb")
2
- require 'yaml'
1
+ require 'spec_helper'
3
2
 
4
- describe "Launchy::VERSION" do
3
+ describe 'Launchy::VERSION' do
5
4
  it "should have a #.#.# format" do
6
- Launchy::VERSION.should =~ /\d+\.\d+\.\d+/
5
+ Launchy::VERSION.must_match /\d+\.\d+\.\d+/
7
6
  Launchy::Version.to_a.each do |n|
8
- n.to_i.should >= 0
7
+ n.to_i.must_be :>=, 0
9
8
  end
10
9
  end
11
10
  end
metadata CHANGED
@@ -4,10 +4,10 @@ version: !ruby/object:Gem::Version
4
4
  hash: 15
5
5
  prerelease:
6
6
  segments:
7
+ - 2
7
8
  - 0
8
- - 4
9
9
  - 0
10
- version: 0.4.0
10
+ version: 2.0.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Jeremy Hinegardner
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-02-27 00:00:00 -07:00
18
+ date: 2011-07-16 00:00:00 -06:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -24,81 +24,65 @@ dependencies:
24
24
  requirement: &id001 !ruby/object:Gem::Requirement
25
25
  none: false
26
26
  requirements:
27
- - - ">="
27
+ - - ~>
28
28
  - !ruby/object:Gem::Version
29
- hash: 61
29
+ hash: 63
30
30
  segments:
31
31
  - 0
32
- - 8
33
- - 1
34
- version: 0.8.1
35
- type: :runtime
32
+ - 9
33
+ - 2
34
+ version: 0.9.2
35
+ type: :development
36
36
  version_requirements: *id001
37
37
  - !ruby/object:Gem::Dependency
38
- name: configuration
38
+ name: minitest
39
39
  prerelease: false
40
40
  requirement: &id002 !ruby/object:Gem::Requirement
41
41
  none: false
42
42
  requirements:
43
- - - ">="
43
+ - - ~>
44
44
  - !ruby/object:Gem::Version
45
- hash: 21
45
+ hash: 1
46
46
  segments:
47
- - 0
48
- - 0
49
- - 5
50
- version: 0.0.5
51
- type: :runtime
47
+ - 2
48
+ - 3
49
+ - 1
50
+ version: 2.3.1
51
+ type: :development
52
52
  version_requirements: *id002
53
53
  - !ruby/object:Gem::Dependency
54
- name: rake
54
+ name: bones
55
55
  prerelease: false
56
56
  requirement: &id003 !ruby/object:Gem::Requirement
57
57
  none: false
58
58
  requirements:
59
59
  - - ~>
60
60
  - !ruby/object:Gem::Version
61
- hash: 49
61
+ hash: 27
62
62
  segments:
63
- - 0
64
- - 8
63
+ - 3
65
64
  - 7
66
- version: 0.8.7
65
+ - 0
66
+ version: 3.7.0
67
67
  type: :development
68
68
  version_requirements: *id003
69
69
  - !ruby/object:Gem::Dependency
70
- name: configuration
70
+ name: bones
71
71
  prerelease: false
72
72
  requirement: &id004 !ruby/object:Gem::Requirement
73
73
  none: false
74
74
  requirements:
75
- - - ~>
75
+ - - ">="
76
76
  - !ruby/object:Gem::Version
77
- hash: 31
77
+ hash: 27
78
78
  segments:
79
- - 1
80
- - 2
79
+ - 3
80
+ - 7
81
81
  - 0
82
- version: 1.2.0
82
+ version: 3.7.0
83
83
  type: :development
84
84
  version_requirements: *id004
85
- - !ruby/object:Gem::Dependency
86
- name: rspec-core
87
- prerelease: false
88
- requirement: &id005 !ruby/object:Gem::Requirement
89
- none: false
90
- requirements:
91
- - - ~>
92
- - !ruby/object:Gem::Version
93
- hash: 25
94
- segments:
95
- - 2
96
- - 5
97
- - 1
98
- version: 2.5.1
99
- type: :development
100
- version_requirements: *id005
101
- description: |-
85
+ description: |
102
86
  Launchy is helper class for launching cross-platform applications in a
103
87
  fire and forget manner.
104
88
 
@@ -106,56 +90,55 @@ description: |-
106
90
  common across all platforms, and they may be launched differently on
107
91
  each platform. Launchy is here to make a common approach to launching
108
92
  external application from within ruby programs.
93
+
109
94
  email: jeremy@copiousfreetime.org
110
95
  executables:
111
96
  - launchy
112
97
  extensions: []
113
98
 
114
99
  extra_rdoc_files:
115
- - README
116
100
  - HISTORY
117
101
  - LICENSE
118
- - lib/launchy/application.rb
119
- - lib/launchy/browser.rb
120
- - lib/launchy/command_line.rb
121
- - lib/launchy/paths.rb
122
- - lib/launchy/version.rb
123
- - lib/launchy.rb
102
+ - README
103
+ - bin/launchy
124
104
  files:
105
+ - .autotest
106
+ - HISTORY
107
+ - LICENSE
108
+ - NOTES
109
+ - README
110
+ - Rakefile
125
111
  - bin/launchy
112
+ - lib/launchy.rb
126
113
  - lib/launchy/application.rb
127
- - lib/launchy/browser.rb
128
- - lib/launchy/command_line.rb
129
- - lib/launchy/paths.rb
114
+ - lib/launchy/applications/browser.rb
115
+ - lib/launchy/cli.rb
116
+ - lib/launchy/descendant_tracker.rb
117
+ - lib/launchy/detect.rb
118
+ - lib/launchy/detect/host_os.rb
119
+ - lib/launchy/detect/host_os_family.rb
120
+ - lib/launchy/detect/nix_desktop_environment.rb
121
+ - lib/launchy/detect/ruby_engine.rb
122
+ - lib/launchy/detect/runner.rb
123
+ - lib/launchy/error.rb
124
+ - lib/launchy/os_family.rb
130
125
  - lib/launchy/version.rb
131
- - lib/launchy.rb
132
126
  - spec/application_spec.rb
133
- - spec/browser_spec.rb
127
+ - spec/detect/host_os_family_spec.rb
128
+ - spec/detect/host_os_spec.rb
129
+ - spec/detect/nix_desktop_environment_spec.rb
130
+ - spec/detect/ruby_engine_spec.rb
134
131
  - spec/launchy_spec.rb
135
- - spec/paths_spec.rb
132
+ - spec/mock_scheme.rb
136
133
  - spec/spec_helper.rb
134
+ - spec/tattle-host-os.yaml
137
135
  - spec/version_spec.rb
138
- - spec/tattle-host-os.yml
139
- - README
140
- - HISTORY
141
- - LICENSE
142
- - tasks/announce.rake
143
- - tasks/distribution.rake
144
- - tasks/documentation.rake
145
- - tasks/rspec.rake
146
- - tasks/rubyforge.rake
147
- - tasks/config.rb
148
- - tasks/utils.rb
149
- - Rakefile
150
- - gemspec.rb
151
136
  has_rdoc: true
152
- homepage: http://copiousfreetime.rubyforge.org/launchy/
137
+ homepage: http://www.copiousfreetime.org/projects/launchy
153
138
  licenses: []
154
139
 
155
140
  post_install_message:
156
141
  rdoc_options:
157
- - --line-numbers
158
- - --inline-source
159
142
  - --main
160
143
  - README
161
144
  require_paths:
@@ -180,10 +163,16 @@ required_rubygems_version: !ruby/object:Gem::Requirement
180
163
  version: "0"
181
164
  requirements: []
182
165
 
183
- rubyforge_project: copiousfreetime
166
+ rubyforge_project: launchy
184
167
  rubygems_version: 1.5.2
185
168
  signing_key:
186
169
  specification_version: 3
187
- summary: Launchy is helper class for launching cross-platform applications in a fire and forget manner
188
- test_files: []
189
-
170
+ summary: Launchy is helper class for launching cross-platform applications in a fire and forget manner.
171
+ test_files:
172
+ - spec/application_spec.rb
173
+ - spec/detect/host_os_family_spec.rb
174
+ - spec/detect/host_os_spec.rb
175
+ - spec/detect/nix_desktop_environment_spec.rb
176
+ - spec/detect/ruby_engine_spec.rb
177
+ - spec/launchy_spec.rb
178
+ - spec/version_spec.rb