jobly 0.2.3 → 0.2.4
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 +4 -4
- data/lib/jobly.rb +1 -0
- data/lib/jobly/api.rb +4 -3
- data/lib/jobly/cli.rb +3 -1
- data/lib/jobly/commands/base.rb +1 -1
- data/lib/jobly/commands/init.rb +42 -0
- data/lib/jobly/commands/run.rb +1 -1
- data/lib/jobly/commands/send.rb +1 -1
- data/lib/jobly/commands/server.rb +1 -1
- data/lib/jobly/commands/worker.rb +3 -3
- data/lib/jobly/polyfills/hash.rb +19 -0
- data/lib/jobly/templates/full/app/job.rb +3 -0
- data/lib/jobly/templates/full/config/jobly.rb +14 -0
- data/lib/jobly/templates/full/jobs/hello.rb +15 -0
- data/lib/jobly/templates/full/jobs/ping.rb +6 -0
- data/lib/jobly/templates/minimal/jobs/ping.rb +6 -0
- data/lib/jobly/version.rb +1 -1
- metadata +10 -17
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8ae475c6e56a6ae45f56aa9443c03310aabdc484ce847a1120e1399813ccc249
|
4
|
+
data.tar.gz: a7121f335d1af02eaee5e2bbbfcc04c578b93e6fdab51579f88f93bb423e69e1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 760e95ca01b7b218d88d73722b1bfdeaf4e997783f1795daaa2b466cd9cb33890f002a5cbdd6030b07820d5bc314faa83acedf53b1de3117c1c50aa4fe973ce2
|
7
|
+
data.tar.gz: 01b58bcdbdbbe85bdba0d0a7411125516e4acbc354028d78009730b7321c21ff143c1ab32d47aea590d359fc353f4223489d3259bc80050453c7c067db5b0d0d
|
data/lib/jobly.rb
CHANGED
data/lib/jobly/api.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'jobly'
|
2
|
+
require 'jobly/version'
|
2
3
|
require 'sinatra/base'
|
3
4
|
require 'sinatra/reloader'
|
4
5
|
require 'sinatra/custom_logger'
|
@@ -24,9 +25,9 @@ module Jobly
|
|
24
25
|
|
25
26
|
get '/' do
|
26
27
|
{
|
27
|
-
version: VERSION,
|
28
|
+
version: Jobly::VERSION,
|
28
29
|
message: %Q["I'm gonna live till I die" - Frank Sinatra]
|
29
|
-
}.to_json
|
30
|
+
}.to_json + "\n"
|
30
31
|
end
|
31
32
|
|
32
33
|
get '/*' do
|
@@ -73,7 +74,7 @@ module Jobly
|
|
73
74
|
}
|
74
75
|
|
75
76
|
logger.debug "[jobly server] Job received (#{job})"
|
76
|
-
response.to_json
|
77
|
+
response.to_json + "\n"
|
77
78
|
end
|
78
79
|
end
|
79
80
|
end
|
data/lib/jobly/cli.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'mister_bin'
|
2
|
+
require 'jobly/version'
|
2
3
|
requires 'commands/base', 'commands'
|
3
4
|
|
4
5
|
module Jobly
|
@@ -6,10 +7,11 @@ module Jobly
|
|
6
7
|
# Command line interface router. This is called by bin/jobly.
|
7
8
|
class CLI
|
8
9
|
def self.router
|
9
|
-
router = MisterBin::Runner.new version: VERSION,
|
10
|
+
router = MisterBin::Runner.new version: Jobly::VERSION,
|
10
11
|
header: "Jobly",
|
11
12
|
footer: "Run !txtpur!jobly COMMAND --help!txtrst! for more information"
|
12
13
|
|
14
|
+
router.route 'init', to: Commands::InitCmd
|
13
15
|
router.route 'server', to: Commands::ServerCmd
|
14
16
|
router.route 'worker', to: Commands::WorkerCmd
|
15
17
|
router.route 'send', to: Commands::SendCmd
|
data/lib/jobly/commands/base.rb
CHANGED
@@ -0,0 +1,42 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
|
3
|
+
module Jobly
|
4
|
+
module Commands
|
5
|
+
class InitCmd < Base
|
6
|
+
summary "Create an initial jobs workspace"
|
7
|
+
usage "jobly init NAME [--minimal]"
|
8
|
+
usage "jobly init (-h|--help)"
|
9
|
+
param "NAME", "The name of the folder to create"
|
10
|
+
option "-m --minimal", "Create a minimal workspace"
|
11
|
+
example "jobly init test"
|
12
|
+
example "jobly init myjobs --minimal"
|
13
|
+
|
14
|
+
def run
|
15
|
+
raise ArgumentError, "#{target_dir} already exists" if File.exist? target_dir
|
16
|
+
|
17
|
+
FileUtils.copy_entry source_dir, target_dir
|
18
|
+
|
19
|
+
say "Created #{template} workspace in #{target_dir}:"
|
20
|
+
files.each { |file| say "- #{file}" }
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
def template
|
26
|
+
args['--minimal'] ? 'minimal' : 'full'
|
27
|
+
end
|
28
|
+
|
29
|
+
def target_dir
|
30
|
+
args['NAME']
|
31
|
+
end
|
32
|
+
|
33
|
+
def source_dir
|
34
|
+
File.expand_path "../templates/#{template}", __dir__
|
35
|
+
end
|
36
|
+
|
37
|
+
def files
|
38
|
+
Dir["#{target_dir}/**/{*,.*}"].sort.reject { |f| File.directory? f }
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
data/lib/jobly/commands/run.rb
CHANGED
@@ -7,7 +7,7 @@ module Jobly
|
|
7
7
|
summary "Run a job locally"
|
8
8
|
usage "jobly run [--later] JOB [PARAMS...]"
|
9
9
|
usage "jobly run (-h|--help)"
|
10
|
-
option "-l
|
10
|
+
option "-l --later", "Schedule the job to be executed later by a worker instead of running it immediately"
|
11
11
|
param "JOB", "Job name"
|
12
12
|
param "PARAMS", "Parameters to pass to the job as key:value"
|
13
13
|
example "jobly run Greet name:Bob"
|
data/lib/jobly/commands/send.rb
CHANGED
@@ -4,7 +4,7 @@ module Jobly
|
|
4
4
|
summary "Start the server"
|
5
5
|
usage "jobly server [--port NUMBER]"
|
6
6
|
usage "jobly server (-h|--help)"
|
7
|
-
option "-p
|
7
|
+
option "-p --port NUMBER", "Set the port number [default: 3000]"
|
8
8
|
|
9
9
|
def run
|
10
10
|
port = args['--port']
|
@@ -4,9 +4,9 @@ module Jobly
|
|
4
4
|
summary "Start a job worker"
|
5
5
|
usage "jobly worker [-c COUNT -C PATH (-q NAME)...]"
|
6
6
|
usage "jobly worker (-h|--help)"
|
7
|
-
option "-c
|
8
|
-
option "-C
|
9
|
-
option "-q
|
7
|
+
option "-c --concurrency COUNT", "Number of parallel jobs [default: 4]"
|
8
|
+
option "-C --config PATH", "Specify a path to a YAML config file. The provided path should be relative to the global config_path directory and without the yml extension"
|
9
|
+
option "-q --queue NAME[,WEIGHT]", "Specify one or more queues that this worker should handle"
|
10
10
|
|
11
11
|
example "jobly worker --concurrency 10"
|
12
12
|
example "jobly worker -q critical -q default -q low"
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# :nocov:
|
2
|
+
|
3
|
+
# Required for Ruby < 2.4
|
4
|
+
if !{}.respond_to? :transform_values
|
5
|
+
class Hash
|
6
|
+
def transform_values
|
7
|
+
self.each { |k, v| self[k] = yield v }
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
# Required for Ruby < 2.5
|
13
|
+
if !{}.respond_to? :transform_keys
|
14
|
+
class Hash
|
15
|
+
def transform_keys
|
16
|
+
self.map { |k, v| [(yield k), v] }.to_h
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
Jobly.configure do |config|
|
2
|
+
# Configuration can be placed here or by using environment variables
|
3
|
+
# ---
|
4
|
+
# config.environment = 'development'
|
5
|
+
# config.api_url = 'http://localhost:3000/do'
|
6
|
+
# config.app_path = 'app'
|
7
|
+
# config.jobs_path = 'jobs'
|
8
|
+
# config.config_path = 'config'
|
9
|
+
# config.redis_url = 'redis://localhost:6379/0'
|
10
|
+
# config.status_expiration = 30
|
11
|
+
# config.jobs_namespace = 'Jobs'
|
12
|
+
# config.log = 'log/%s.log'
|
13
|
+
# config.auth = 'admin:secret'
|
14
|
+
end
|
data/lib/jobly/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jobly
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Danny Ben Shitrit
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-03-
|
11
|
+
date: 2019-03-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mister_bin
|
@@ -52,20 +52,6 @@ dependencies:
|
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '4.0'
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: lp
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - "~>"
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '0.1'
|
62
|
-
type: :runtime
|
63
|
-
prerelease: false
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
66
|
-
- - "~>"
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: '0.1'
|
69
55
|
- !ruby/object:Gem::Dependency
|
70
56
|
name: puma
|
71
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -193,6 +179,7 @@ files:
|
|
193
179
|
- lib/jobly/cli.rb
|
194
180
|
- lib/jobly/commands/base.rb
|
195
181
|
- lib/jobly/commands/config.rb
|
182
|
+
- lib/jobly/commands/init.rb
|
196
183
|
- lib/jobly/commands/run.rb
|
197
184
|
- lib/jobly/commands/send.rb
|
198
185
|
- lib/jobly/commands/server.rb
|
@@ -207,12 +194,18 @@ files:
|
|
207
194
|
- lib/jobly/jobs.rb
|
208
195
|
- lib/jobly/log.rb
|
209
196
|
- lib/jobly/module_functions.rb
|
197
|
+
- lib/jobly/polyfills/hash.rb
|
210
198
|
- lib/jobly/refinements/argument_converters.rb
|
211
199
|
- lib/jobly/refinements/convert_to_typed.rb
|
212
200
|
- lib/jobly/refinements/keyword_args.rb
|
213
201
|
- lib/jobly/refinements/to_slug.rb
|
214
202
|
- lib/jobly/server.rb
|
215
203
|
- lib/jobly/sidekiq.rb
|
204
|
+
- lib/jobly/templates/full/app/job.rb
|
205
|
+
- lib/jobly/templates/full/config/jobly.rb
|
206
|
+
- lib/jobly/templates/full/jobs/hello.rb
|
207
|
+
- lib/jobly/templates/full/jobs/ping.rb
|
208
|
+
- lib/jobly/templates/minimal/jobs/ping.rb
|
216
209
|
- lib/jobly/version.rb
|
217
210
|
homepage: https://github.com/dannyben/jobly
|
218
211
|
licenses:
|
@@ -226,7 +219,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
226
219
|
requirements:
|
227
220
|
- - ">="
|
228
221
|
- !ruby/object:Gem::Version
|
229
|
-
version: 2.
|
222
|
+
version: 2.3.0
|
230
223
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
231
224
|
requirements:
|
232
225
|
- - ">="
|