elliottcable-launchdr 0 → 1
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/README.markdown +1 -1
- data/launchdr.gemspec +1 -1
- data/lib/launchdr.rb +4 -6
- data/lib/launchdr/task.rb +16 -11
- metadata +1 -1
data/README.markdown
CHANGED
@@ -49,7 +49,7 @@ wraps the last method inside a rake task. This method is really great if you
|
|
49
49
|
want to provide a way to let users make your gem's binary run all the time:
|
50
50
|
|
51
51
|
require 'launchdr/task'
|
52
|
-
LaunchDr.
|
52
|
+
LaunchDr::Task.new :launchd, :bin => 'jello', :arguments => ['-D', 'shortener', 'grabup']
|
53
53
|
|
54
54
|
This isn't very flexible, but it's not very complicated either. If you need
|
55
55
|
more control over the plist, just use the second method inside a `task` block.
|
data/launchdr.gemspec
CHANGED
data/lib/launchdr.rb
CHANGED
@@ -6,12 +6,10 @@ def LaunchDr label, opts = {}
|
|
6
6
|
LaunchDr.create label, opts, &Proc.new
|
7
7
|
end
|
8
8
|
module LaunchDr
|
9
|
-
|
10
|
-
|
11
|
-
Version = 0
|
9
|
+
Version = 1
|
12
10
|
Options = Hash.new
|
13
11
|
|
14
|
-
def create label, opts = {}
|
12
|
+
def self.create label, opts = {}
|
15
13
|
plist = Launchd.new label
|
16
14
|
|
17
15
|
yield plist if block_given?
|
@@ -25,11 +23,11 @@ module LaunchDr
|
|
25
23
|
plist.load!
|
26
24
|
end
|
27
25
|
|
28
|
-
def allow_system_agents!
|
26
|
+
def self.allow_system_agents!
|
29
27
|
Options[:system_agents_allowed] = true
|
30
28
|
end
|
31
29
|
|
32
|
-
def allow_system_daemons!
|
30
|
+
def self.allow_system_daemons!
|
33
31
|
raise "You must allow System-owned agents to allow System-owned daemons!" unless Options[:system_agents_allowed]
|
34
32
|
Options[:system_daemon_allowed] = true
|
35
33
|
end
|
data/lib/launchdr/task.rb
CHANGED
@@ -1,18 +1,23 @@
|
|
1
|
+
require 'launchdr'
|
2
|
+
|
1
3
|
module LaunchDr
|
2
4
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
5
|
+
module Task
|
6
|
+
def self.new name = :launchd, opts = {}
|
7
|
+
raise "`LaunchDr.task`'s options must include the name of the binary for your gem!" unless opts[:bin]
|
8
|
+
opts = {:desc => 'Creates a launchd property list for this gem', :arguments => []}.merge opts
|
9
|
+
|
10
|
+
desc opts[:desc] unless opts[:no_desc]
|
11
|
+
task name do
|
12
|
+
LaunchDr "rb.launchdr.#{opts[:bin]}" do |plist|
|
13
|
+
plist[:program_arguments] = [File.join('/usr/local/bin', opts[:bin]), opts[:arguments]].flatten
|
14
|
+
plist[:keep_alive] = true
|
15
|
+
plist[:run_at_load] = true
|
16
|
+
end
|
17
|
+
puts "** `#{[opts[:bin], opts[:arguments]].flatten.join(' ')}` will now be run on startup!"
|
13
18
|
end
|
19
|
+
|
14
20
|
end
|
15
|
-
|
16
21
|
end
|
17
22
|
|
18
23
|
end
|