jobly 0.4.4 → 0.4.5

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 58e109a2e288e0d56bf80e4a02a16cb9204bdcdfae3ce2eb5c8738965e3615d4
4
- data.tar.gz: e0d84850f934656c1a63ed7ca54c31109c7554cfd5af0e61d4450b2066abb647
3
+ metadata.gz: bdebbdae8332039a2a9e2d2ca269d22b62bd9e98218facda2cde2c3adbc0f3c7
4
+ data.tar.gz: d79979c42b1c4f531261ccc10ee1474abe1cb3db3f0dcdda42bb43e2d493bc9a
5
5
  SHA512:
6
- metadata.gz: 43836699c613de62c9149a90493c1f139d543b9f1bed028c36c123b2b8f1520a91b75f66f216f359f0874ea5e56f898949e49cdcb7250e6e37658c0814986df9
7
- data.tar.gz: 5fd4e5998e387f495423e5121a940ebecdf0d723dfc4127f8b35117681437145ca0c9cb86c846da71c8d12de43fda8b13ad9b7776f6cc9105d3a48fcb8dc6e30
6
+ metadata.gz: 322b257413156fdced8f3b0c50e4c68702bf2f079ae9180ada468749356b8452526c067bf3a84b2cfb6361545f4c7cfeaf10cf15102e068b93fdd46579d0ee50
7
+ data.tar.gz: e9933a533455045f3df1d90c1127d983cc9b0865f763e70af975674041f5328de548ff78f43c34293cdbb2ba278c840877d0fb10b4893a9a0ff1cccf3f687c97
@@ -7,13 +7,16 @@ module Jobly
7
7
  end
8
8
 
9
9
  def logger!
10
- if !Jobly.log
10
+ logger = if !Jobly.log
11
11
  Sidekiq.logger
12
12
  elsif Jobly.log.is_a? Logger
13
13
  Jobly.log
14
14
  else
15
15
  Log.new Jobly.log, self.class.name.to_slug
16
16
  end
17
+
18
+ logger.level = Jobly.log_level if logger and logger.respond_to? :level
19
+ logger
17
20
  end
18
21
  end
19
22
  end
@@ -14,7 +14,7 @@ module Jobly
14
14
  if target.start_with? 'syslog://'
15
15
  remote_syslog_logger target
16
16
  else
17
- Logger.new target
17
+ Logger.new File.expand_path(target, Jobly.root)
18
18
  end
19
19
  end
20
20
 
@@ -1,85 +1,92 @@
1
1
  module Jobly
2
- def self.configure
3
- yield self
4
- end
2
+ class << self
3
+ def configure
4
+ yield self
5
+ end
5
6
 
6
- def self.load_custom_config
7
- require config_file if File.exist? config_file
8
- end
7
+ def load_custom_config
8
+ require config_file if File.exist? config_file
9
+ end
9
10
 
10
- def self.default_options
11
- {
12
- environment: ENV['JOBLY_ENVIRONMENT'] || 'development',
13
- api_url: ENV['JOBLY_API_URL'] || 'http://localhost:3000/do',
14
- app_path: ENV['JOBLY_APP_PATH'] || 'app',
15
- jobs_path: ENV['JOBLY_JOBS_PATH'] || "jobs",
16
- config_path: ENV['JOBLY_CONFIG_PATH'] || "config",
17
- redis_url: ENV['JOBLY_REDIS_URL'] || "redis://localhost:6379/0",
18
- status_expiration: ENV['JOBLY_STATUS_EXPIRATION']&.to_i || 30,
19
- jobs_namespace: ENV['JOBLY_JOBS_NAMESPACE'],
20
- slack_webhook: ENV['JOBLY_SLACK_WEBHOOK'],
21
- slack_channel: ENV['JOBLY_SLACK_CHANNEL'] || "#general",
22
- slack_user: ENV['JOBLY_SLACK_USER'] || "Jobly",
23
- log: ENV['JOBLY_LOG'],
24
- auth: ENV['JOBLY_AUTH'],
25
- mounts: nil,
26
- }
27
- end
11
+ def default_options
12
+ {
13
+ root: Dir.pwd,
14
+ environment: ENV['JOBLY_ENVIRONMENT'] || 'development',
15
+ api_url: ENV['JOBLY_API_URL'] || 'http://localhost:3000/do',
16
+ app_path: ENV['JOBLY_APP_PATH'] || 'app',
17
+ jobs_path: ENV['JOBLY_JOBS_PATH'] || "jobs",
18
+ config_path: ENV['JOBLY_CONFIG_PATH'] || "config",
19
+ redis_url: ENV['JOBLY_REDIS_URL'] || "redis://localhost:6379/0",
20
+ status_expiration: ENV['JOBLY_STATUS_EXPIRATION']&.to_i || 30,
21
+ jobs_namespace: ENV['JOBLY_JOBS_NAMESPACE'],
22
+ slack_webhook: ENV['JOBLY_SLACK_WEBHOOK'],
23
+ slack_channel: ENV['JOBLY_SLACK_CHANNEL'] || "#general",
24
+ slack_user: ENV['JOBLY_SLACK_USER'] || "Jobly",
25
+ log: ENV['JOBLY_LOG'],
26
+ log_level: ENV['JOBLY_LOG_LEVEL'] || 'info',
27
+ auth: ENV['JOBLY_AUTH'],
28
+ mounts: nil,
29
+ }
30
+ end
28
31
 
29
- def self.method_missing(method, args=nil, &_block)
30
- key = method.to_s
31
- assign = key[-1] == "="
32
- key = key.chomp('=') if assign
33
- key = key.to_sym
32
+ def method_missing(method, args=nil, &_block)
33
+ key = method.to_s
34
+ assign = key[-1] == "="
35
+ key = key.chomp('=') if assign
36
+ key = key.to_sym
34
37
 
35
- if options.has_key? key
36
- assign ? options[key] = args : options[key]
37
- else
38
- super
38
+ if options.has_key? key
39
+ assign ? options[key] = args : options[key]
40
+ else
41
+ super
42
+ end
39
43
  end
40
- end
41
44
 
42
- def self.respond_to_missing?(method, include_private=false)
43
- key = method.to_s.chomp('=').to_sym
44
- options.has_key?(key) ? true : super
45
- end
45
+ def respond_to_missing?(method, include_private=false)
46
+ key = method.to_s.chomp('=').to_sym
47
+ options.has_key?(key) ? true : super
48
+ end
46
49
 
47
- def self.options
48
- @options ||= default_options.dup
49
- end
50
+ def options
51
+ @options ||= default_options.dup
52
+ end
50
53
 
51
- def self.logger
52
- @logger
53
- end
54
+ def logger
55
+ @logger
56
+ end
57
+
58
+ def log=(target)
59
+ options[:log] = target
60
+ @logger = if target.is_a? Logger
61
+ target
62
+ elsif target
63
+ Log.new target, :jobly
64
+ else
65
+ nil
66
+ end
54
67
 
55
- def self.log=(target)
56
- options[:log] = target
57
- @logger = if target.is_a? Logger
58
- target
59
- elsif target
60
- Log.new target, :jobly
61
- else
62
- nil
68
+ @logger.level = log_level if @logger and @logger.respond_to? :level
69
+ @logger
63
70
  end
64
- end
65
71
 
66
- def self.full_app_path
67
- File.expand_path app_path
68
- end
72
+ def full_app_path
73
+ File.expand_path app_path, root
74
+ end
69
75
 
70
- def self.full_jobs_path
71
- File.expand_path jobs_path
72
- end
76
+ def full_jobs_path
77
+ File.expand_path jobs_path, root
78
+ end
73
79
 
74
- def self.full_config_path
75
- File.expand_path config_path
76
- end
80
+ def full_config_path
81
+ File.expand_path config_path, root
82
+ end
77
83
 
78
- def self.config_file
79
- File.expand_path 'jobly.rb', self.config_path
80
- end
84
+ def config_file
85
+ File.expand_path 'jobly.rb', full_config_path
86
+ end
81
87
 
82
- def self.custom_config?
83
- File.exist? config_file
88
+ def custom_config?
89
+ File.exist? config_file
90
+ end
84
91
  end
85
92
  end
@@ -10,6 +10,7 @@ Jobly.configure do |config|
10
10
  # config.status_expiration = 30
11
11
  # config.jobs_namespace = 'Jobs'
12
12
  # config.log = 'log/%s.log'
13
+ # config.log_level = 'info'
13
14
  # config.slack_webhook = 'https://hooks.slack.com/services/...'
14
15
  # config.slack_channel = '#debug'
15
16
  # config.slack_user = 'Botly'
@@ -1,3 +1,3 @@
1
1
  module Jobly
2
- VERSION = "0.4.4"
2
+ VERSION = "0.4.5"
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.4.4
4
+ version: 0.4.5
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-12-27 00:00:00.000000000 Z
11
+ date: 2019-12-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: http