opener 0.0.1 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (5) hide show
  1. checksums.yaml +7 -0
  2. data/README.markdown +22 -12
  3. data/lib/opener.rb +33 -12
  4. data/opener.gemspec +3 -3
  5. metadata +9 -10
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 2c64531e6a4a66e2067c67b6786eeffbd67d61a9
4
+ data.tar.gz: 3869ec0ef55e75688f64db302f8f3f2158ca4c0a
5
+ SHA512:
6
+ metadata.gz: aedd2c106bd827ba82c035ab1db64b8a08f9b77c69066c466badbbb63d9c40328026737e9a08247f52ed9508670fa4905d88dc06499ba9e9bc6dde5ea0d70a21
7
+ data.tar.gz: 503415abca7e70597ace5d9a3ca80433f4814ab3e1db2aa5791e5c2eeef67881c177e3a6c56163f3c8eaa908009f47ea4f3d46ddbf7617da98bcd78bfbe49bc3
@@ -2,7 +2,7 @@
2
2
 
3
3
  Opener is a Ruby library for opening things in an cross-platform way.
4
4
 
5
- It is a tiny (28 lines of code) alternative to Ruby's [launchy] gem.
5
+ It is a tiny (33 lines of code) alternative to the [launchy] library.
6
6
 
7
7
  [launchy]: http://rubygems.org/gems/launchy
8
8
 
@@ -30,29 +30,39 @@ Open something in the foreground (blocking call):
30
30
 
31
31
  Opener.system(thing_to_open_in_foreground)
32
32
 
33
- Open something in the foreground while suppressing output:
33
+ Open something in the background (non-blocking call):
34
34
 
35
- Opener.system(thing_to_open_in_foreground, 1 => :close)
35
+ Opener.spawn(thing_to_open_in_background)
36
36
 
37
- Open something in the foreground while suppressing errors:
37
+ Open something in place of the current process:
38
38
 
39
- Opener.system(thing_to_open_in_foreground, 2 => :close)
39
+ Opener.exec(thing_to_open_in_place)
40
40
 
41
- Open something in the background (non-blocking call):
41
+ Reveal the OS-specific command that is opening things:
42
42
 
43
- Opener.spawn(thing_to_open_in_background)
43
+ puts Opener.command()
44
44
 
45
- Open something in the background while suppressing output:
45
+ ### Suppression
46
46
 
47
+ Open something while detaching terminal (close STDIN):
48
+
49
+ Opener.system(thing_to_open_in_foreground, 0 => :close)
50
+ Opener.spawn(thing_to_open_in_background, 0 => :close)
51
+ Opener.exec(thing_to_open_in_place, 0 => :close)
52
+
53
+ Open something while suppressing output (close STDOUT):
54
+
55
+ Opener.system(thing_to_open_in_foreground, 1 => :close)
47
56
  Opener.spawn(thing_to_open_in_background, 1 => :close)
57
+ Opener.exec(thing_to_open_in_place, 1 => :close)
48
58
 
49
- Open something in the background while suppressing errors:
59
+ Open something while suppressing errors (close STDERR):
50
60
 
61
+ Opener.system(thing_to_open_in_foreground, 2 => :close)
51
62
  Opener.spawn(thing_to_open_in_background, 2 => :close)
63
+ Opener.exec(thing_to_open_in_place, 2 => :close)
52
64
 
53
- Reveal the OS-specific command that is opening things:
54
-
55
- puts Opener.command()
65
+ See Kernel#spawn() documentation for more tips and tricks.
56
66
 
57
67
  ## License
58
68
 
@@ -13,29 +13,39 @@ require 'rbconfig'
13
13
  #
14
14
  # Opener.system(thing_to_open_in_foreground)
15
15
  #
16
- # Open something in the foreground while suppressing output:
16
+ # Open something in the background (non-blocking call):
17
17
  #
18
- # Opener.system(thing_to_open_in_foreground, 1 => :close)
18
+ # Opener.spawn(thing_to_open_in_background)
19
19
  #
20
- # Open something in the foreground while suppressing errors:
20
+ # Open something in place of the current process:
21
21
  #
22
- # Opener.system(thing_to_open_in_foreground, 2 => :close)
22
+ # Opener.exec(thing_to_open_in_place)
23
23
  #
24
- # Open something in the background (non-blocking call):
24
+ # Reveal the OS-specific command that is opening things:
25
25
  #
26
- # Opener.spawn(thing_to_open_in_background)
26
+ # puts Opener.command()
27
+ #
28
+ # === Suppression
27
29
  #
28
- # Open something in the background while suppressing output:
30
+ # Open something while detaching terminal (close STDIN):
29
31
  #
32
+ # Opener.system(thing_to_open_in_foreground, 0 => :close)
33
+ # Opener.spawn(thing_to_open_in_background, 0 => :close)
34
+ # Opener.exec(thing_to_open_in_place, 0 => :close)
35
+ #
36
+ # Open something while suppressing output (close STDOUT):
37
+ #
38
+ # Opener.system(thing_to_open_in_foreground, 1 => :close)
30
39
  # Opener.spawn(thing_to_open_in_background, 1 => :close)
40
+ # Opener.exec(thing_to_open_in_place, 1 => :close)
31
41
  #
32
- # Open something in the background while suppressing errors:
42
+ # Open something while suppressing errors (close STDERR):
33
43
  #
44
+ # Opener.system(thing_to_open_in_foreground, 2 => :close)
34
45
  # Opener.spawn(thing_to_open_in_background, 2 => :close)
46
+ # Opener.exec(thing_to_open_in_place, 2 => :close)
35
47
  #
36
- # Reveal the OS-specific command that is opening things:
37
- #
38
- # puts Opener.command()
48
+ # See Kernel#spawn() documentation for more tips and tricks.
39
49
  #
40
50
  # == License
41
51
  #
@@ -57,12 +67,13 @@ module Opener
57
67
  #
58
68
  def command
59
69
  @command ||=
60
- case RbConfig::CONFIG['host_os']
70
+ case host_os = RbConfig::CONFIG['host_os']
61
71
  when /darwin/i then 'open'
62
72
  when /cygwin/i then 'cygstart'
63
73
  when /linux|bsd/i then 'xdg-open'
64
74
  when /mswin|mingw/i then 'start'
65
75
  when /sunos|solaris/i then '/usr/dt/bin/sdtwebclient'
76
+ else raise NotImplementedError, host_os
66
77
  end
67
78
  end
68
79
 
@@ -86,6 +97,16 @@ module Opener
86
97
  super
87
98
  end
88
99
 
100
+ #
101
+ # Opens the given things in place of the current process.
102
+ #
103
+ # @see Kernel#exec()
104
+ #
105
+ def exec *arguments
106
+ insert_command_into_arguments! arguments
107
+ super
108
+ end
109
+
89
110
  private
90
111
 
91
112
  #
@@ -1,11 +1,11 @@
1
1
  # coding: utf-8
2
2
  Gem::Specification.new do |spec|
3
3
  spec.name = 'opener'
4
- spec.version = '0.0.1'
4
+ spec.version = '0.1.0'
5
5
  spec.author = 'Suraj N. Kurapati'
6
6
  spec.email = 'sunaku@gmail.com'
7
- spec.description = 'Library for opening things in an cross-platform way.'
8
- spec.summary = "A 28-line alternative to Ruby's launchy gem."
7
+ spec.description = 'A 33-line alternative to the popular launchy library.'
8
+ spec.summary = 'Library for opening things in an cross-platform way.'
9
9
  spec.homepage = 'https://github.com/sunaku/opener'
10
10
  spec.license = 'Ruby'
11
11
 
metadata CHANGED
@@ -1,8 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: opener
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
5
- prerelease:
4
+ version: 0.1.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Suraj N. Kurapati
@@ -11,7 +10,7 @@ bindir: bin
11
10
  cert_chain: []
12
11
  date: 2013-05-08 00:00:00.000000000 Z
13
12
  dependencies: []
14
- description: Library for opening things in an cross-platform way.
13
+ description: A 33-line alternative to the popular launchy library.
15
14
  email: sunaku@gmail.com
16
15
  executables: []
17
16
  extensions: []
@@ -23,26 +22,26 @@ files:
23
22
  homepage: https://github.com/sunaku/opener
24
23
  licenses:
25
24
  - Ruby
25
+ metadata: {}
26
26
  post_install_message:
27
27
  rdoc_options: []
28
28
  require_paths:
29
29
  - lib
30
30
  required_ruby_version: !ruby/object:Gem::Requirement
31
- none: false
32
31
  requirements:
33
- - - ! '>='
32
+ - - '>='
34
33
  - !ruby/object:Gem::Version
35
34
  version: '0'
36
35
  required_rubygems_version: !ruby/object:Gem::Requirement
37
- none: false
38
36
  requirements:
39
- - - ! '>='
37
+ - - '>='
40
38
  - !ruby/object:Gem::Version
41
39
  version: '0'
42
40
  requirements: []
43
41
  rubyforge_project:
44
- rubygems_version: 1.8.25
42
+ rubygems_version: 2.0.0
45
43
  signing_key:
46
- specification_version: 3
47
- summary: A 28-line alternative to Ruby's launchy gem.
44
+ specification_version: 4
45
+ summary: Library for opening things in an cross-platform way.
48
46
  test_files: []
47
+ has_rdoc: