dtachr 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data/Rakefile +1 -1
  2. data/dtachr.gemspec +2 -2
  3. data/lib/dtachr.rb +21 -9
  4. metadata +4 -4
data/Rakefile CHANGED
@@ -93,7 +93,7 @@ task :release do
93
93
  puts "You must be on the master branch to release!"
94
94
  exit!
95
95
  end
96
- sh "git tag v#{version}"
96
+ sh "git tag -a -s v#{version}"
97
97
  end
98
98
 
99
99
  desc "Push #{gem_file} to Rubygems"
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.3'
17
- s.date = '2013-11-14'
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.3'
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 Show this screen
22
- -v --version Show the version
23
- -n --socket=<sock> Temporary file to use as socket for dtach command
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} && terminal-notifier -message '`#{@command}` finished.'")
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
- "tmp"
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: 25
4
+ hash: 23
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 3
10
- version: 0.0.3
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-14 00:00:00 -05:00
18
+ date: 2013-11-15 00:00:00 -05:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency