jobly 0.2.3 → 0.2.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8ee66973f52902d8ddc90c2b2d6547d05b8dcef25f3639754ce3fb41006b618e
4
- data.tar.gz: 07b1a0d259b813db4e7f5ccd36e9f5759ed97c9460f05e49a2a726216a5ed8c2
3
+ metadata.gz: 8ae475c6e56a6ae45f56aa9443c03310aabdc484ce847a1120e1399813ccc249
4
+ data.tar.gz: a7121f335d1af02eaee5e2bbbfcc04c578b93e6fdab51579f88f93bb423e69e1
5
5
  SHA512:
6
- metadata.gz: 0dcbb539e7cafc9ebf44d58b8fe07e8df36d8e4209f431f26051e6db780c79df98ec3b099f66439597d84b0b3a987bcd33670c5f5962afe33545d615ca1ad461
7
- data.tar.gz: 44a0d0305abd84288abef22a631cce2927f0df1b2daefa494da0192a6476deaaf35e338019a2d7a7e97fe48f0f806e4dff65f17bf8764abf89cb271d99499f83
6
+ metadata.gz: 760e95ca01b7b218d88d73722b1bfdeaf4e997783f1795daaa2b466cd9cb33890f002a5cbdd6030b07820d5bc314faa83acedf53b1de3117c1c50aa4fe973ce2
7
+ data.tar.gz: 01b58bcdbdbbe85bdba0d0a7411125516e4acbc354028d78009730b7321c21ff143c1ab32d47aea590d359fc353f4223489d3259bc80050453c7c067db5b0d0d
@@ -1,6 +1,7 @@
1
1
  require 'requires'
2
2
  require 'byebug' if ENV['BYEBUG']
3
3
 
4
+ requires 'jobly/polyfills'
4
5
  requires 'jobly/extensions'
5
6
  requires 'jobly/refinements'
6
7
  requires 'jobly/job_extensions'
@@ -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
@@ -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
@@ -1,6 +1,6 @@
1
1
  require 'mister_bin'
2
2
  require 'colsole'
3
- require 'lp'
3
+ require 'yaml'
4
4
 
5
5
  module Jobly
6
6
  module Commands
@@ -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
@@ -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, --later", "Schedule the job to be executed later by a worker instead of running it immediately"
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"
@@ -26,7 +26,7 @@ module Jobly
26
26
  raise HTTPError, "#{response.code} #{response.reason}" unless response.status.ok?
27
27
 
28
28
  say "!txtgrn!#{response.code} #{response.reason}"
29
- lp response.parse
29
+ puts response.parse.to_yaml
30
30
  end
31
31
 
32
32
  private
@@ -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, --port NUMBER", "Set the port number [default: 3000]"
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, --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"
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,3 @@
1
+ class Job < Jobly::Job
2
+ # Put your common Job methods here
3
+ 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
@@ -0,0 +1,15 @@
1
+ class Hello < Job
2
+ def execute(name: 'Bob')
3
+ total 2
4
+
5
+ at 0, "Initializing"
6
+ sleep rand 3.0..8.0
7
+
8
+ at 1, "Preparing to say Hi"
9
+ sleep rand 3.0..8.0
10
+
11
+ logger.info "Hi #{name}!"
12
+
13
+ at 2, "Done"
14
+ end
15
+ end
@@ -0,0 +1,6 @@
1
+ class Ping < Jobly::Job
2
+ def execute(response: 'PONG')
3
+ at 100, response
4
+ logger.info response
5
+ end
6
+ end
@@ -0,0 +1,6 @@
1
+ class Ping < Jobly::Job
2
+ def execute(response: 'PONG')
3
+ at 100, response
4
+ logger.info response
5
+ end
6
+ end
@@ -1,3 +1,3 @@
1
1
  module Jobly
2
- VERSION = "0.2.3"
2
+ VERSION = "0.2.4"
3
3
  end
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.3
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-18 00:00:00.000000000 Z
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.5.0
222
+ version: 2.3.0
230
223
  required_rubygems_version: !ruby/object:Gem::Requirement
231
224
  requirements:
232
225
  - - ">="