svc 0.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.
Files changed (8) hide show
  1. data/.gitignore +5 -0
  2. data/Gemfile +4 -0
  3. data/Rakefile +2 -0
  4. data/bin/svc +14 -0
  5. data/lib/svc.rb +66 -0
  6. data/lib/svc/version.rb +3 -0
  7. data/svc.gemspec +24 -0
  8. metadata +101 -0
@@ -0,0 +1,5 @@
1
+ pkg/*
2
+ *.gem
3
+ .bundle
4
+ Gemfile.lock
5
+ .DS_Store
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in svc.gemspec
4
+ gemspec
@@ -0,0 +1,2 @@
1
+ require 'bundler'
2
+ Bundler::GemHelper.install_tasks
data/bin/svc ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ begin
4
+ require 'thor'
5
+ require 'json'
6
+ require 'svc'
7
+ rescue LoadError
8
+ require 'rubygems'
9
+ require 'thor'
10
+ require 'json'
11
+ require 'svc'
12
+ end
13
+
14
+ Svc.start
@@ -0,0 +1,66 @@
1
+ class Svc < Thor
2
+ include Thor::Actions
3
+
4
+ PATH = File.expand_path("~/.svc")
5
+
6
+ desc "add <nickname> <path_to_plist>", "add a new service"
7
+ def add(nick, plist)
8
+ load_svc_hash
9
+ @hash[nick] = plist
10
+ save_svc_hash
11
+ puts "Added #{nick} to available services"
12
+ end
13
+
14
+ desc "delete <nickname>", "delete specified server"
15
+ def delete(nick)
16
+ load_svc_hash
17
+ @hash.delete(nick) {|k| puts "#{k} is not an available service" }
18
+ save_svc_hash
19
+ puts "Deleted #{nick} from available services"
20
+ end
21
+
22
+ desc "list", "lists all available services"
23
+ def list
24
+ load_svc_hash
25
+ if @hash.empty?
26
+ puts "There are no available services"
27
+ else
28
+ puts "Available services:"
29
+ @hash.each {|nick, plist| puts " #{nick}: #{plist}" }
30
+ end
31
+ end
32
+
33
+ desc "start <nickname>", "starts specified service"
34
+ def start(nick)
35
+ load_svc_hash
36
+ system("launchctl load -w #{@hash[nick]}")
37
+ end
38
+
39
+ desc "stop <nickname>", "stops specified service"
40
+ def stop(nick)
41
+ load_svc_hash
42
+ system("launchctl unload #{@hash[nick]}")
43
+ end
44
+
45
+ desc "restart <nickname>", "restarts specified service"
46
+ def restart(nick)
47
+ invoke :stop, [nick]
48
+ invoke :start, [nick]
49
+ end
50
+
51
+ no_tasks do
52
+ def load_svc_hash
53
+ path = File.expand_path(PATH)
54
+ create_file(PATH, "{}", :verbose => false) unless File.exist?(PATH)
55
+ f = File.open(PATH, "r")
56
+ @hash = JSON.parse(f.read)
57
+ f.close
58
+ end
59
+
60
+ def save_svc_hash
61
+ f = File.open(PATH, "w")
62
+ f.write(@hash.to_json)
63
+ f.close
64
+ end
65
+ end
66
+ end
@@ -0,0 +1,3 @@
1
+ module Svc
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,24 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "svc/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "svc"
7
+ s.version = Svc::VERSION
8
+ s.platform = Gem::Platform::RUBY
9
+ s.authors = ["Jamie Murai"]
10
+ s.email = ["murai.jamie@gmail.com"]
11
+ s.homepage = "https://github.com/jammur/svc"
12
+ s.description = %q{A ruby command line tool for starting and stopping launchd services}
13
+ s.summary = s.description
14
+
15
+ s.add_dependency "thor"
16
+ s.add_dependency "json"
17
+
18
+ s.rubyforge_project = "svc"
19
+
20
+ s.files = `git ls-files`.split("\n")
21
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
22
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
23
+ s.require_paths = ["lib"]
24
+ end
metadata ADDED
@@ -0,0 +1,101 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: svc
3
+ version: !ruby/object:Gem::Version
4
+ hash: 29
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 1
10
+ version: 0.0.1
11
+ platform: ruby
12
+ authors:
13
+ - Jamie Murai
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2011-01-01 00:00:00 -05:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: thor
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ hash: 3
30
+ segments:
31
+ - 0
32
+ version: "0"
33
+ type: :runtime
34
+ version_requirements: *id001
35
+ - !ruby/object:Gem::Dependency
36
+ name: json
37
+ prerelease: false
38
+ requirement: &id002 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ hash: 3
44
+ segments:
45
+ - 0
46
+ version: "0"
47
+ type: :runtime
48
+ version_requirements: *id002
49
+ description: A ruby command line tool for starting and stopping launchd services
50
+ email:
51
+ - murai.jamie@gmail.com
52
+ executables:
53
+ - svc
54
+ extensions: []
55
+
56
+ extra_rdoc_files: []
57
+
58
+ files:
59
+ - .gitignore
60
+ - Gemfile
61
+ - Rakefile
62
+ - bin/svc
63
+ - lib/svc.rb
64
+ - lib/svc/version.rb
65
+ - svc.gemspec
66
+ has_rdoc: true
67
+ homepage: https://github.com/jammur/svc
68
+ licenses: []
69
+
70
+ post_install_message:
71
+ rdoc_options: []
72
+
73
+ require_paths:
74
+ - lib
75
+ required_ruby_version: !ruby/object:Gem::Requirement
76
+ none: false
77
+ requirements:
78
+ - - ">="
79
+ - !ruby/object:Gem::Version
80
+ hash: 3
81
+ segments:
82
+ - 0
83
+ version: "0"
84
+ required_rubygems_version: !ruby/object:Gem::Requirement
85
+ none: false
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ hash: 3
90
+ segments:
91
+ - 0
92
+ version: "0"
93
+ requirements: []
94
+
95
+ rubyforge_project: svc
96
+ rubygems_version: 1.3.7
97
+ signing_key:
98
+ specification_version: 3
99
+ summary: A ruby command line tool for starting and stopping launchd services
100
+ test_files: []
101
+