multi_scheduler 0.1.0
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.
- checksums.yaml +15 -0
- data/Gemfile +18 -0
- data/LICENSE.txt +20 -0
- data/README.md +15 -0
- data/VERSION +1 -0
- data/lib/multi_scheduler.rb +37 -0
- data/lib/multi_scheduler/launchd.rb +40 -0
- data/lib/multi_scheduler/whenever.rb +27 -0
- metadata +179 -0
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
YWNjNDFkNjUyMDllOWI0MWNjNDY4YmI0Njg1YTU4OGVlNDFhNDYwYg==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
ZjhhMTY0NzU2ZjNmNDc3YzZmZmI0ZTE1NWRhODNhYmNjMTJiZDhmZg==
|
7
|
+
SHA512:
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
ZDYwNDk3M2ZjY2Y1MmU0ZDZmYmI4NWJhNGQyYTI1NzQ3YmExZmYwMDRmZmEx
|
10
|
+
MjRiMzlkMmY2OTE0MWZiNGJhMWI3ZmY0MDgxNmY2ZDhhYzE4MjBlZTczMzM0
|
11
|
+
YTM5MTU3MmMyYWU2MGU5ZDE2NWVlOTk3NTA2MTJlMDQ5N2ZmNWU=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
OWEyODIyMWI0OGY1YzQ3ZmFjNDc1ODc2ZWMzZjlhOWViYTYxYzg5MmJhMWEz
|
14
|
+
Njg4ZDg5ZDhiMDhiZDkyNWNiYWFlOWQ3YzdlMTc3Yzk1MDQwNDNjNmIyMjE5
|
15
|
+
YTUyOTI1ODRmMDUwYTRiOGFiZDk0MTQzYzA3YTFjNWE5NzE3Nzg=
|
data/Gemfile
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
source "https://rubygems.org"
|
2
|
+
|
3
|
+
gem 'launchdr', '3'
|
4
|
+
#gem 'whenever', '~> 0.8.2'
|
5
|
+
#gem 'whenever', :git => 'git@github.com:AlphaHydrae/whenever.git', :branch => 'block-config'
|
6
|
+
|
7
|
+
# Add dependencies to develop your gem here.
|
8
|
+
# Include everything needed to run rake, tests, features, etc.
|
9
|
+
group :development do
|
10
|
+
gem 'bundler'
|
11
|
+
gem 'rake'
|
12
|
+
gem 'rspec'
|
13
|
+
gem 'jeweler'
|
14
|
+
gem 'gem-release'
|
15
|
+
gem 'rake-version'
|
16
|
+
gem 'simplecov'
|
17
|
+
gem 'coveralls', require: false
|
18
|
+
end
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2013 Simon Oulevay (Alpha Hydrae)
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
# Multi Scheduler
|
2
|
+
|
3
|
+
**Scheduler to execute commands on Linux and OS X.**
|
4
|
+
|
5
|
+
[](http://badge.fury.io/rb/multi_scheduler)
|
6
|
+
[](https://gemnasium.com/AlphaHydrae/multi_scheduler)
|
7
|
+
[](http://travis-ci.org/AlphaHydrae/multi_scheduler)
|
8
|
+
[](https://coveralls.io/r/AlphaHydrae/multi_scheduler?branch=master)
|
9
|
+
|
10
|
+
Runs launchd jobs on OS X with [LaunchDR](https://github.com/elliottcable/launchdr) and cron jobs on Linux with [whenever](https://github.com/javan/whenever).
|
11
|
+
|
12
|
+
## Meta
|
13
|
+
|
14
|
+
* **Author:** Simon Oulevay (Alpha Hydrae)
|
15
|
+
* **License:** MIT (see [LICENSE.txt](https://raw.github.com/AlphaHydrae/multi_scheduler/master/LICENSE.txt))
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.1.0
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
module MultiScheduler
|
4
|
+
VERSION = '0.1.0'
|
5
|
+
|
6
|
+
def schedule options = {}
|
7
|
+
scheduler(options).start
|
8
|
+
end
|
9
|
+
|
10
|
+
def unschedule id
|
11
|
+
scheduler({ identifier: id }).stop
|
12
|
+
end
|
13
|
+
|
14
|
+
def scheduler options = {}
|
15
|
+
case RbConfig::CONFIG['host_os']
|
16
|
+
when /darwin/i
|
17
|
+
Launchd.new options
|
18
|
+
else
|
19
|
+
Whenever.new options
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
class Scheduler
|
24
|
+
|
25
|
+
def initialize options = {}
|
26
|
+
|
27
|
+
@identifier = options[:id]
|
28
|
+
raise ":id is required" unless @identifier
|
29
|
+
|
30
|
+
@command_arguments = options[:args] || []
|
31
|
+
@command = options[:command] || @command_arguments.shift
|
32
|
+
raise ":command is required" unless @command
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
Dir[File.join File.dirname(__FILE__), File.basename(__FILE__, '.*'), '*.rb'].each{ |lib| require lib }
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require 'launchdr'
|
2
|
+
require 'fileutils'
|
3
|
+
|
4
|
+
module MultiScheduler
|
5
|
+
|
6
|
+
class Launchd < Scheduler
|
7
|
+
|
8
|
+
def start
|
9
|
+
stop
|
10
|
+
plist.dump USER_AGENT
|
11
|
+
plist.load!
|
12
|
+
end
|
13
|
+
|
14
|
+
def stop
|
15
|
+
return false unless plist_exists?
|
16
|
+
plist.unload!
|
17
|
+
FileUtils.rm_f plist.file
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
USER_AGENT = LaunchDr::Launchd::Paths[:user_agent]
|
23
|
+
|
24
|
+
def plist_exists?
|
25
|
+
begin
|
26
|
+
File.exists? plist.file
|
27
|
+
rescue
|
28
|
+
false
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def plist
|
33
|
+
@plist ||= LaunchDr::Launchd.new(@identifier).tap do |plist|
|
34
|
+
plist[:ProgramArguments] = @command_arguments.dup.unshift(@command)
|
35
|
+
plist[:RunAtLoad] = true
|
36
|
+
plist[:EnvironmentVariables] = { 'PATH' => ENV['PATH'] } # TODO: add path option
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
#require 'whenever'
|
2
|
+
|
3
|
+
module MultiScheduler
|
4
|
+
|
5
|
+
class Whenever < Scheduler
|
6
|
+
|
7
|
+
def start
|
8
|
+
raise 'Not yet implemented on this operating system'
|
9
|
+
::Whenever::CommandLine.execute block: mount_schedule, write: true, identifier: @identifier
|
10
|
+
end
|
11
|
+
|
12
|
+
def stop
|
13
|
+
raise 'Not yet implemented on this operating system'
|
14
|
+
::Whenever::CommandLine.execute block: mount_schedule, clear: true, identifier: @identifier
|
15
|
+
end
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
def self.mount_schedule
|
20
|
+
Proc.new do
|
21
|
+
every 1.minute do
|
22
|
+
command 'echo $(date) > /tmp/bar.txt'
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
metadata
ADDED
@@ -0,0 +1,179 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: multi_scheduler
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- AlphaHydrae
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-10-03 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: launchdr
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '3'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '3'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ! '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ! '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ! '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ! '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: jeweler
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ! '>='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ! '>='
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: gem-release
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ! '>='
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ! '>='
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: rake-version
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ! '>='
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ! '>='
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: simplecov
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ! '>='
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ! '>='
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: coveralls
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - ! '>='
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - ! '>='
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0'
|
139
|
+
description: Schedules commands to be run with cron jobs on Linux or launchd on OS
|
140
|
+
X.
|
141
|
+
email: hydrae.alpha@gmail.com
|
142
|
+
executables: []
|
143
|
+
extensions: []
|
144
|
+
extra_rdoc_files:
|
145
|
+
- LICENSE.txt
|
146
|
+
- README.md
|
147
|
+
files:
|
148
|
+
- Gemfile
|
149
|
+
- LICENSE.txt
|
150
|
+
- README.md
|
151
|
+
- VERSION
|
152
|
+
- lib/multi_scheduler.rb
|
153
|
+
- lib/multi_scheduler/launchd.rb
|
154
|
+
- lib/multi_scheduler/whenever.rb
|
155
|
+
homepage: http://github.com/AlphaHydrae/multi_scheduler
|
156
|
+
licenses:
|
157
|
+
- MIT
|
158
|
+
metadata: {}
|
159
|
+
post_install_message:
|
160
|
+
rdoc_options: []
|
161
|
+
require_paths:
|
162
|
+
- lib
|
163
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
164
|
+
requirements:
|
165
|
+
- - ! '>='
|
166
|
+
- !ruby/object:Gem::Version
|
167
|
+
version: '0'
|
168
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
169
|
+
requirements:
|
170
|
+
- - ! '>='
|
171
|
+
- !ruby/object:Gem::Version
|
172
|
+
version: '0'
|
173
|
+
requirements: []
|
174
|
+
rubyforge_project:
|
175
|
+
rubygems_version: 2.1.5
|
176
|
+
signing_key:
|
177
|
+
specification_version: 4
|
178
|
+
summary: OS X & Linux command scheduler.
|
179
|
+
test_files: []
|