dtachr 0.0.3 → 0.0.4
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.
- data/Rakefile +1 -1
- data/dtachr.gemspec +2 -2
- data/lib/dtachr.rb +21 -9
- metadata +4 -4
data/Rakefile
CHANGED
data/dtachr.gemspec
CHANGED
@@ -13,8 +13,8 @@ Gem::Specification.new do |s|
|
|
13
13
|
## If your rubyforge_project name is different, then edit it and comment out
|
14
14
|
## the sub! line in the Rakefile
|
15
15
|
s.name = 'dtachr'
|
16
|
-
s.version = '0.0.
|
17
|
-
s.date = '2013-11-
|
16
|
+
s.version = '0.0.4'
|
17
|
+
s.date = '2013-11-15'
|
18
18
|
s.rubyforge_project = 'dtachr'
|
19
19
|
|
20
20
|
## Make sure your summary is short. The description may be as long
|
data/lib/dtachr.rb
CHANGED
@@ -6,21 +6,23 @@ require 'docopt'
|
|
6
6
|
|
7
7
|
module Dtachr
|
8
8
|
|
9
|
-
VERSION = '0.0.
|
9
|
+
VERSION = '0.0.4'
|
10
10
|
NAME = 'dtachr'
|
11
11
|
|
12
12
|
DOC = <<-DOCOPT
|
13
13
|
dtachr
|
14
14
|
|
15
15
|
Usage:
|
16
|
-
#{Dtachr::NAME} [--socket=<sock>] <parts>...
|
16
|
+
#{Dtachr::NAME} [--socket=<sock>] [--title=<title>] [--message=<message>] <parts>...
|
17
17
|
#{Dtachr::NAME} -h | --help
|
18
18
|
#{Dtachr::NAME} -v | --version
|
19
19
|
|
20
20
|
Options:
|
21
|
-
-h --help
|
22
|
-
-v --version
|
23
|
-
-n --socket=<sock>
|
21
|
+
-h --help Show this screen
|
22
|
+
-v --version Show the version
|
23
|
+
-n --socket=<sock> Temporary file to use as socket for dtach command
|
24
|
+
-t --title=<title> Title to use for terminal-notifier
|
25
|
+
-m --message=<message> Message to use with terminal-notifier
|
24
26
|
|
25
27
|
DOCOPT
|
26
28
|
|
@@ -39,7 +41,7 @@ module Dtachr
|
|
39
41
|
|
40
42
|
def call
|
41
43
|
return unless @opts
|
42
|
-
execute("dtach -n #{@socket} #{@command} &&
|
44
|
+
execute("dtach -n #{@socket} #{@command} && #{notify_command}")
|
43
45
|
end
|
44
46
|
|
45
47
|
private
|
@@ -47,11 +49,21 @@ module Dtachr
|
|
47
49
|
def execute(command)
|
48
50
|
`#{command}`
|
49
51
|
end
|
50
|
-
|
52
|
+
|
51
53
|
def gen_socket
|
52
|
-
|
54
|
+
candidates = [('a'..'z'), ('A'..'Z'), (0..9)].map { |i| i.to_a }.flatten
|
55
|
+
name = (0...32).map { candidates[rand(candidates.length)] }.join
|
56
|
+
if (File.exists?(name)) then gen_socket else name end
|
57
|
+
end
|
58
|
+
|
59
|
+
def notify_command
|
60
|
+
notifier = "terminal-notifier"
|
61
|
+
message = '-message ' + (@opts['--message'] || "'`#{@command}` finished.'")
|
62
|
+
title = @opts['--title'].dup if !@opts['--title'].nil?
|
63
|
+
title.insert(0, '-title ') if !title.nil? && title.length > 0
|
64
|
+
[notifier, title, message].join(' ')
|
53
65
|
end
|
54
66
|
|
55
67
|
end
|
56
68
|
|
57
|
-
end
|
69
|
+
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dtachr
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 23
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 4
|
10
|
+
version: 0.0.4
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Bryan Swift
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2013-11-
|
18
|
+
date: 2013-11-15 00:00:00 -05:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|