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.
@@ -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.task :launchd, :bin => 'jello', :arguments => ['-D', 'shortener', 'grabup']
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.
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{launchdr}
5
- s.version = "0"
5
+ s.version = "1"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["elliottcable"]
@@ -6,12 +6,10 @@ def LaunchDr label, opts = {}
6
6
  LaunchDr.create label, opts, &Proc.new
7
7
  end
8
8
  module LaunchDr
9
- extend self
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
@@ -1,18 +1,23 @@
1
+ require 'launchdr'
2
+
1
3
  module LaunchDr
2
4
 
3
- def task name = :launchd, opts = {}
4
- raise "`LaunchDr.task`'s options must include the name of the binary for your gem!" unless opts[:bin]
5
- opts = {:desc => 'Creates a launchd property list for this gem', :arguments => []}.merge opts
6
-
7
- desc opts[:desc] unless opts[:no_desc]
8
- task name do
9
- LaunchDr label do |plist|
10
- plist[:program_arguments] = [File.join('/usr/local/bin', opts[:bin]), opts[:arguments]].flatten
11
- plist[:keep_alive] = true
12
- plist[:run_at_load] = true
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: elliottcable-launchdr
3
3
  version: !ruby/object:Gem::Version
4
- version: "0"
4
+ version: "1"
5
5
  platform: ruby
6
6
  authors:
7
7
  - elliottcable