dmon 0.0.1a
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +5 -0
- data/.rvmrc +1 -0
- data/.yardopts +5 -0
- data/MIT-LICENSE.txt +21 -0
- data/README.textile +35 -0
- data/Rakefile +2 -0
- data/lib/dmon.rb +5 -0
- data/lib/dmon/proc_or_object.rb +41 -0
- data/lib/dmon/process.rb +39 -0
- data/rakelib/checks.rake +29 -0
- data/rakelib/doc.rake +7 -0
- data/rakelib/gem.rake +77 -0
- data/rakelib/test.rake +10 -0
- data/test/unit/dmon/proc_or_object_test.rb +25 -0
- metadata +86 -0
data/.gitignore
ADDED
data/.rvmrc
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
rvm ree-1.8.7-2010.02@dmon
|
data/.yardopts
ADDED
data/MIT-LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2011 Ketan Padegaonkar (ketanpadegaonkar at gmail.com)
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.textile
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
h1. Introduction
|
2
|
+
|
3
|
+
Managing processes across windows and *nix platforms using both ruby and jruby is a PITA.
|
4
|
+
|
5
|
+
dmon is a ruby gem that provides a library for doing just this.
|
6
|
+
|
7
|
+
h1. Usage
|
8
|
+
|
9
|
+
TBD
|
10
|
+
|
11
|
+
h1. License
|
12
|
+
|
13
|
+
dmon is MIT Licensed.
|
14
|
+
|
15
|
+
The MIT License
|
16
|
+
|
17
|
+
Copyright (c) 2011 Ketan Padegaonkar (ketanpadegaonkar at gmail.com)
|
18
|
+
|
19
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
20
|
+
of this software and associated documentation files (the "Software"), to deal
|
21
|
+
in the Software without restriction, including without limitation the rights
|
22
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
23
|
+
copies of the Software, and to permit persons to whom the Software is
|
24
|
+
furnished to do so, subject to the following conditions:
|
25
|
+
|
26
|
+
The above copyright notice and this permission notice shall be included in
|
27
|
+
all copies or substantial portions of the Software.
|
28
|
+
|
29
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
30
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
31
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
32
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
33
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
34
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
35
|
+
THE SOFTWARE.
|
data/Rakefile
ADDED
data/lib/dmon.rb
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
# Copyright (c) 2011 Ketan Padegaonkar.
|
2
|
+
# Licenced under the MIT License (http://www.opensource.org/licenses/mit-license.php)
|
3
|
+
|
4
|
+
module Dmon
|
5
|
+
|
6
|
+
# Use in place of +attr_accessor+ that can use return values of procs
|
7
|
+
# class Person
|
8
|
+
# include Dmon::ProcOrObject
|
9
|
+
# proc_or_object :name
|
10
|
+
# end
|
11
|
+
#
|
12
|
+
# p = Person.new
|
13
|
+
# p.name = { 'joe' }
|
14
|
+
# p.name
|
15
|
+
# => joe
|
16
|
+
module ProcOrObject
|
17
|
+
|
18
|
+
module ClassMethods #nodoc:
|
19
|
+
#
|
20
|
+
def proc_or_object(*names)
|
21
|
+
names.each do |name|
|
22
|
+
class_eval(<<-EOS, __FILE__, __LINE__)
|
23
|
+
@@__#{name} = nil
|
24
|
+
def #{name}
|
25
|
+
@@__#{name}.respond_to?(:call) ? @@__#{name}.call : @@__#{name}
|
26
|
+
end
|
27
|
+
|
28
|
+
def #{name}=(value_or_proc)
|
29
|
+
@@__#{name} = value_or_proc
|
30
|
+
end
|
31
|
+
EOS
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
|
37
|
+
def self.included(receiver)
|
38
|
+
receiver.extend ClassMethods
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
data/lib/dmon/process.rb
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
# Copyright (c) 2011 Ketan Padegaonkar.
|
2
|
+
# Licenced under the MIT License (http://www.opensource.org/licenses/mit-license.php)
|
3
|
+
|
4
|
+
module Dmon
|
5
|
+
|
6
|
+
# An abstraction for a ruby process.
|
7
|
+
#
|
8
|
+
# Typical usage is:
|
9
|
+
#
|
10
|
+
# Process.new do |p|
|
11
|
+
# p.description = 'foo'
|
12
|
+
# # all fields accept procs or strings
|
13
|
+
# p.start_script = 'bin/start.sh'
|
14
|
+
# p.start_script = proc { running? ? 'bin/start.sh' : 'bin/restart.sh' }
|
15
|
+
# p.stop_script = 'bin/stop.sh'
|
16
|
+
# p.status_script = 'bin/status.sh'
|
17
|
+
# end
|
18
|
+
class Process
|
19
|
+
include ProcOrObject
|
20
|
+
|
21
|
+
# The description of the process
|
22
|
+
proc_or_object :description
|
23
|
+
|
24
|
+
# A proc or string describing how the process should start
|
25
|
+
proc_or_object :start_script
|
26
|
+
|
27
|
+
# A proc or string describing how a process should be stopped
|
28
|
+
proc_or_object :stop_script
|
29
|
+
|
30
|
+
# A proc or string describing how a process can return its status
|
31
|
+
proc_or_object :status_script
|
32
|
+
|
33
|
+
# Defines a new process and yields itself
|
34
|
+
def initialize(&block)
|
35
|
+
yield self if block_given?
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
data/rakelib/checks.rake
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# Copyright (c) 2011 Ketan Padegaonkar.
|
2
|
+
# Licenced under the MIT License (http://www.opensource.org/licenses/mit-license.php)
|
3
|
+
|
4
|
+
PROJECT_COPYRIGHT = [
|
5
|
+
"# Copyright (c) 2011 Ketan Padegaonkar.",
|
6
|
+
"# Licenced under the MIT License (http://www.opensource.org/licenses/mit-license.php)"
|
7
|
+
]
|
8
|
+
|
9
|
+
desc "Check copyright notice in all ruby scripts in the distribution"
|
10
|
+
task :copyright do
|
11
|
+
puts "** Verifying copyright notices on all ruby scripts in the distribution..."
|
12
|
+
need_copyright = []
|
13
|
+
|
14
|
+
Dir['{lib,rakelib,test}/**/*{.rb,rake}'].each do |file|
|
15
|
+
file = File.expand_path(file)
|
16
|
+
lines = File.readlines(file).map{|l| l.chomp}
|
17
|
+
unless lines.first(PROJECT_COPYRIGHT.size) == PROJECT_COPYRIGHT
|
18
|
+
need_copyright << file
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
unless need_copyright.empty?
|
23
|
+
require 'pp'
|
24
|
+
puts "** The following files are missing copyrights:"
|
25
|
+
need_copyright.each { |file| puts file }
|
26
|
+
raise 'Check failed!'
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
data/rakelib/doc.rake
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
# Copyright (c) 2011 Ketan Padegaonkar.
|
2
|
+
# Licenced under the MIT License (http://www.opensource.org/licenses/mit-license.php)
|
3
|
+
require 'yard'
|
4
|
+
YARD::Rake::YardocTask.new do |t|
|
5
|
+
t.files = ['lib/**/*.rb'] # optional
|
6
|
+
t.options = ['--any', '--extra', '--opts'] # optional
|
7
|
+
end
|
data/rakelib/gem.rake
ADDED
@@ -0,0 +1,77 @@
|
|
1
|
+
# Copyright (c) 2011 Ketan Padegaonkar.
|
2
|
+
# Licenced under the MIT License (http://www.opensource.org/licenses/mit-license.php)
|
3
|
+
|
4
|
+
require 'time'
|
5
|
+
|
6
|
+
namespace :release do
|
7
|
+
|
8
|
+
desc 'Update the changelog'
|
9
|
+
task :changelog do
|
10
|
+
File.open('CHANGELOG', 'w+') do |changelog|
|
11
|
+
`git log -z --abbrev-commit lib`.split("\0").each do |commit|
|
12
|
+
next if commit =~ /^Merge: \d*/
|
13
|
+
ref, author, time, _, title, _, message = commit.split("\n", 7)
|
14
|
+
ref = ref[/commit ([0-9a-f]+)/, 1]
|
15
|
+
author = author[/Author: (.*)/, 1].strip
|
16
|
+
time = Time.parse(time[/Date: (.*)/, 1]).utc
|
17
|
+
title.strip!
|
18
|
+
|
19
|
+
changelog.puts "[#{ref} | #{time}] #{author}"
|
20
|
+
changelog.puts '', " * #{title}"
|
21
|
+
changelog.puts '', message.rstrip if message
|
22
|
+
changelog.puts
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
desc 'Create the dmon gem'
|
28
|
+
task :gem => [:changelog, :copyright] do
|
29
|
+
files = ['README.textile', 'MIT-LICENSE.txt', 'CHANGELOG']
|
30
|
+
|
31
|
+
spec = Gem::Specification.new do |s|
|
32
|
+
s.name = "dmon"
|
33
|
+
s.version = "0.0.1a"
|
34
|
+
s.author = "Ketan Padegaonkar"
|
35
|
+
s.email = "ketanpadegaonkar@gmail.com"
|
36
|
+
s.homepage = "http://github.com/ketan/dmon"
|
37
|
+
s.platform = Gem::Platform::RUBY
|
38
|
+
s.summary = "Makes for easy process management across rubies and OSes"
|
39
|
+
s.description = "Makes for easy process management across rubies and OSes"
|
40
|
+
s.files = (`git ls-files`.split("\n") + ["#{s.name}.gemspec", "CHANGELOG"]).flatten.sort.uniq
|
41
|
+
s.has_rdoc = false
|
42
|
+
|
43
|
+
s.extra_rdoc_files = ["README.textile", "MIT-LICENSE.txt"]
|
44
|
+
end
|
45
|
+
File.open("#{spec.name}.gemspec", "w") { |f| f << spec.to_ruby }
|
46
|
+
|
47
|
+
sh "gem build #{spec.name}.gemspec"
|
48
|
+
|
49
|
+
rm_rf "pkg", :verbose => false
|
50
|
+
mkdir "pkg", :verbose => false
|
51
|
+
mv "#{spec.name}-#{spec.version}.gem", "pkg", :verbose => false
|
52
|
+
end
|
53
|
+
|
54
|
+
desc 'Push the gem out to gemcutter'
|
55
|
+
task :push => [:test, :gem] do
|
56
|
+
|
57
|
+
puts <<-INSTRUCTIONS
|
58
|
+
|
59
|
+
==============================================================
|
60
|
+
Instructions before you push out:
|
61
|
+
* Make sure everything is good
|
62
|
+
* Bump the version number in the `gem.rake' file
|
63
|
+
* Check in
|
64
|
+
* Run this task again to:
|
65
|
+
* verify everything is good
|
66
|
+
* generate a new gem with the new version number
|
67
|
+
* Create a tag in git:
|
68
|
+
$ git tag -a -m 'Tag for version X.Y.Z' 'vX.Y.Z'
|
69
|
+
$ gem push pkg/dmon-X.Y.Z.gem
|
70
|
+
==============================================================
|
71
|
+
INSTRUCTIONS
|
72
|
+
# sh("gem push pkg/*.gem") do |res, ok|
|
73
|
+
# raise 'Could not push gem' if !ok
|
74
|
+
# end
|
75
|
+
end
|
76
|
+
|
77
|
+
end
|
data/rakelib/test.rake
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
# Copyright (c) 2011 Ketan Padegaonkar.
|
2
|
+
# Licenced under the MIT License (http://www.opensource.org/licenses/mit-license.php)
|
3
|
+
|
4
|
+
require 'rake/testtask'
|
5
|
+
|
6
|
+
Rake::TestTask.new do |t|
|
7
|
+
t.libs << "test"
|
8
|
+
t.test_files = FileList['test/test*.rb']
|
9
|
+
t.verbose = true
|
10
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# Copyright (c) 2011 Ketan Padegaonkar.
|
2
|
+
# Licenced under the MIT License (http://www.opensource.org/licenses/mit-license.php)
|
3
|
+
|
4
|
+
require "rubygems"
|
5
|
+
gem "test-unit"
|
6
|
+
|
7
|
+
require "test/unit"
|
8
|
+
require 'dmon'
|
9
|
+
|
10
|
+
module Dmon
|
11
|
+
class ProcOrObjectTest < Test::Unit::TestCase
|
12
|
+
|
13
|
+
class Foo
|
14
|
+
include ProcOrObject
|
15
|
+
proc_or_object :some_property
|
16
|
+
end
|
17
|
+
|
18
|
+
test "should return result of proc when accessing property" do
|
19
|
+
f = Foo.new
|
20
|
+
f.some_property = proc {'foo'}
|
21
|
+
assert_equal 'foo', f.some_property
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
end
|
metadata
ADDED
@@ -0,0 +1,86 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: dmon
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 46
|
5
|
+
prerelease: 5
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 0
|
9
|
+
- 1
|
10
|
+
- a
|
11
|
+
version: 0.0.1a
|
12
|
+
platform: ruby
|
13
|
+
authors:
|
14
|
+
- Ketan Padegaonkar
|
15
|
+
autorequire:
|
16
|
+
bindir: bin
|
17
|
+
cert_chain: []
|
18
|
+
|
19
|
+
date: 2011-05-09 00:00:00 -07:00
|
20
|
+
default_executable:
|
21
|
+
dependencies: []
|
22
|
+
|
23
|
+
description: Makes for easy process management across rubies and OSes
|
24
|
+
email: ketanpadegaonkar@gmail.com
|
25
|
+
executables: []
|
26
|
+
|
27
|
+
extensions: []
|
28
|
+
|
29
|
+
extra_rdoc_files:
|
30
|
+
- README.textile
|
31
|
+
- MIT-LICENSE.txt
|
32
|
+
files:
|
33
|
+
- .gitignore
|
34
|
+
- .rvmrc
|
35
|
+
- .yardopts
|
36
|
+
- CHANGELOG
|
37
|
+
- MIT-LICENSE.txt
|
38
|
+
- README.textile
|
39
|
+
- Rakefile
|
40
|
+
- dmon.gemspec
|
41
|
+
- lib/dmon.rb
|
42
|
+
- lib/dmon/proc_or_object.rb
|
43
|
+
- lib/dmon/process.rb
|
44
|
+
- rakelib/checks.rake
|
45
|
+
- rakelib/doc.rake
|
46
|
+
- rakelib/gem.rake
|
47
|
+
- rakelib/test.rake
|
48
|
+
- test/unit/dmon/proc_or_object_test.rb
|
49
|
+
has_rdoc: true
|
50
|
+
homepage: http://github.com/ketan/dmon
|
51
|
+
licenses: []
|
52
|
+
|
53
|
+
post_install_message:
|
54
|
+
rdoc_options: []
|
55
|
+
|
56
|
+
require_paths:
|
57
|
+
- lib
|
58
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
59
|
+
none: false
|
60
|
+
requirements:
|
61
|
+
- - ">="
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
hash: 3
|
64
|
+
segments:
|
65
|
+
- 0
|
66
|
+
version: "0"
|
67
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
68
|
+
none: false
|
69
|
+
requirements:
|
70
|
+
- - ">"
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
hash: 25
|
73
|
+
segments:
|
74
|
+
- 1
|
75
|
+
- 3
|
76
|
+
- 1
|
77
|
+
version: 1.3.1
|
78
|
+
requirements: []
|
79
|
+
|
80
|
+
rubyforge_project:
|
81
|
+
rubygems_version: 1.6.2
|
82
|
+
signing_key:
|
83
|
+
specification_version: 3
|
84
|
+
summary: Makes for easy process management across rubies and OSes
|
85
|
+
test_files: []
|
86
|
+
|