faktory_worker_ruby 1.1.1 → 1.2.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8ba3a7a6dbf71b034a2e9a209830f3049132c72b12105262b6ce971df9e602e6
4
- data.tar.gz: f0adb0757fdaed227ec36d13786dadf7a9e39b6854589f4c25e65a8c9101cf86
3
+ metadata.gz: 57f98beb553cb8d38e36d45b1721c15446201a30db101827d277ef7f3b9fb542
4
+ data.tar.gz: a0d82206d826d345bdcde2271ccf300c8af2ccb7ce4c2140900f00b0330ebeac
5
5
  SHA512:
6
- metadata.gz: 89471fb1dfd8624f9b562c773909378b4c40a4b52fd7dd198b7d2808199b2057a760b2cbcd919b8aa4494569979092c53762dd24e57be6ecfe7143a97540521d
7
- data.tar.gz: 734b8145a57e435ecac307006723608998958bd9952a194c804fe033681579530d0ccc84ed591ffe8cfbbc5393abe4bd6b95045c49d02ceb3c87f742f6027905
6
+ metadata.gz: ed5afdc2c7d07f54b90eb1230d50b1d0bdfb219d3ac6f12d4c2f35c05eb7f0b73c3990c84d65c77567f127c1c082f6e858480165aa0bf1e697bef6aa81517075
7
+ data.tar.gz: 01ea007ff63b7e91a94cc7134f57d783680b9a2ba88be5677b93a505eb55d8e39d2cec9f53a3503b5270b2cfcf8a16909569082b19c59c6439d7474f402da7db
@@ -2,16 +2,16 @@ name: CI
2
2
 
3
3
  on:
4
4
  push:
5
- branches: [ master ]
5
+ branches: [ main ]
6
6
  pull_request:
7
- branches: [ master ]
7
+ branches: [ main ]
8
8
 
9
9
  jobs:
10
10
  test:
11
11
  strategy:
12
12
  fail-fast: false
13
13
  matrix:
14
- ruby: [2.5, 2.6, 2.7, '3.0']
14
+ ruby: ["2.6", "2.7", "3.0", "3.1"]
15
15
  runs-on: ubuntu-latest
16
16
  services:
17
17
  faktory:
data/.standard.yml ADDED
@@ -0,0 +1,12 @@
1
+ ruby_version: 2.5.0
2
+ fix: true
3
+ parallel: true
4
+ ignore:
5
+ - test/**/*
6
+ - examples/**/*
7
+ - myapp/**/*
8
+ - 'lib/faktory.rb':
9
+ - Lint/InheritException
10
+ - 'lib/**/*':
11
+ - Lint/RescueException
12
+ - Style/GlobalVars
data/Changes.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Changes
2
2
 
3
+ ## 1.2.0
4
+
5
+ - Dup options before deep merging [#67]
6
+ - Provide default values for `jid` and `queue` if unset
7
+ - Integrate `standard` linter. Update codebase.
8
+
3
9
  ## 1.1.1
4
10
 
5
11
  - Fix OpenSSL error [#59]
data/Gemfile CHANGED
@@ -1,5 +1,8 @@
1
- source 'https://rubygems.org'
1
+ source "https://rubygems.org"
2
2
 
3
- gem 'simplecov', require: false, group: :test
3
+ gem "simplecov", require: false, group: :test
4
+ gem "standard", group: [:development, :test]
4
5
 
5
6
  gemspec
7
+
8
+ gem "activejob"
data/Gemfile.lock CHANGED
@@ -1,52 +1,78 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- faktory_worker_ruby (1.1.0)
4
+ faktory_worker_ruby (1.2.0)
5
5
  connection_pool (~> 2.2, >= 2.2.2)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
- activejob (6.1.3.2)
11
- activesupport (= 6.1.3.2)
10
+ activejob (7.0.4.2)
11
+ activesupport (= 7.0.4.2)
12
12
  globalid (>= 0.3.6)
13
- activesupport (6.1.3.2)
13
+ activesupport (7.0.4.2)
14
14
  concurrent-ruby (~> 1.0, >= 1.0.2)
15
15
  i18n (>= 1.6, < 2)
16
16
  minitest (>= 5.1)
17
17
  tzinfo (~> 2.0)
18
- zeitwerk (~> 2.3)
19
- concurrent-ruby (1.1.9)
20
- connection_pool (2.2.5)
18
+ ast (2.4.2)
19
+ concurrent-ruby (1.2.0)
20
+ connection_pool (2.3.0)
21
21
  docile (1.4.0)
22
- globalid (0.4.2)
23
- activesupport (>= 4.2.0)
24
- i18n (1.8.10)
22
+ globalid (1.1.0)
23
+ activesupport (>= 5.0)
24
+ i18n (1.12.0)
25
25
  concurrent-ruby (~> 1.0)
26
- minitest (5.14.4)
26
+ json (2.6.3)
27
+ language_server-protocol (3.17.0.3)
28
+ minitest (5.17.0)
27
29
  minitest-hooks (1.5.0)
28
30
  minitest (> 5.3)
29
- rake (13.0.3)
30
- simplecov (0.21.2)
31
+ parallel (1.22.1)
32
+ parser (3.2.0.0)
33
+ ast (~> 2.4.1)
34
+ rainbow (3.1.1)
35
+ rake (13.0.6)
36
+ regexp_parser (2.6.2)
37
+ rexml (3.2.5)
38
+ rubocop (1.42.0)
39
+ json (~> 2.3)
40
+ parallel (~> 1.10)
41
+ parser (>= 3.1.2.1)
42
+ rainbow (>= 2.2.2, < 4.0)
43
+ regexp_parser (>= 1.8, < 3.0)
44
+ rexml (>= 3.2.5, < 4.0)
45
+ rubocop-ast (>= 1.24.1, < 2.0)
46
+ ruby-progressbar (~> 1.7)
47
+ unicode-display_width (>= 1.4.0, < 3.0)
48
+ rubocop-ast (1.24.1)
49
+ parser (>= 3.1.1.0)
50
+ rubocop-performance (1.15.2)
51
+ rubocop (>= 1.7.0, < 2.0)
52
+ rubocop-ast (>= 0.4.0)
53
+ ruby-progressbar (1.11.0)
54
+ simplecov (0.22.0)
31
55
  docile (~> 1.1)
32
56
  simplecov-html (~> 0.11)
33
57
  simplecov_json_formatter (~> 0.1)
34
58
  simplecov-html (0.12.3)
35
- simplecov_json_formatter (0.1.3)
36
- tzinfo (2.0.4)
59
+ simplecov_json_formatter (0.1.4)
60
+ standard (1.22.1)
61
+ language_server-protocol (~> 3.17.0.2)
62
+ rubocop (= 1.42.0)
63
+ rubocop-performance (= 1.15.2)
64
+ tzinfo (2.0.6)
37
65
  concurrent-ruby (~> 1.0)
38
- zeitwerk (2.4.2)
66
+ unicode-display_width (2.4.2)
39
67
 
40
68
  PLATFORMS
41
69
  ruby
42
70
 
43
71
  DEPENDENCIES
44
- activejob (>= 5.2.0)
72
+ activejob
45
73
  faktory_worker_ruby!
46
74
  minitest (~> 5)
47
75
  minitest-hooks
48
76
  rake
49
77
  simplecov
50
-
51
- BUNDLED WITH
52
- 2.1.4
78
+ standard
data/Rakefile CHANGED
@@ -1,10 +1,11 @@
1
- require 'bundler/gem_tasks'
2
- require 'rake/testtask'
1
+ require "bundler/gem_tasks"
2
+ require "rake/testtask"
3
+ require "standard/rake"
3
4
 
4
5
  Rake::TestTask.new(:test) do |test|
5
6
  test.libs += ["test"]
6
7
  test.warning = true
7
- test.pattern = 'test/**/*_test.rb'
8
+ test.pattern = "test/**/*_test.rb"
8
9
  end
9
10
 
10
- task :default => :test
11
+ task default: ["standard:fix", :test]
@@ -1,19 +1,17 @@
1
- # -*- encoding: utf-8 -*-
2
- require File.expand_path('../lib/faktory/version', __FILE__)
1
+ require File.expand_path("../lib/faktory/version", __FILE__)
3
2
 
4
3
  Gem::Specification.new do |gem|
5
- gem.name = "faktory_worker_ruby"
6
- gem.authors = ["Mike Perham"]
7
- gem.email = ["mike@contribsys.com"]
8
- gem.summary = "Ruby worker for Faktory"
9
- gem.description = "Ruby worker for Faktory."
10
- gem.homepage = "https://github.com/contribsys/faktory_worker_ruby"
11
- gem.license = "LGPL-3.0"
4
+ gem.name = "faktory_worker_ruby"
5
+ gem.authors = ["Mike Perham"]
6
+ gem.email = ["mike@contribsys.com"]
7
+ gem.summary = "Ruby worker for Faktory"
8
+ gem.description = "Ruby worker for Faktory."
9
+ gem.homepage = "https://github.com/contribsys/faktory_worker_ruby"
10
+ gem.license = "LGPL-3.0"
12
11
 
13
- gem.executables = ['faktory-worker']
14
- gem.files = `git ls-files | grep -Ev '^(test|myapp|examples)'`.split("\n")
15
- gem.test_files = []
16
- gem.version = Faktory::VERSION
12
+ gem.executables = ["faktory-worker"]
13
+ gem.files = `git ls-files | grep -Ev '^(test|myapp|examples)'`.split("\n")
14
+ gem.version = Faktory::VERSION
17
15
  gem.required_ruby_version = ">= 2.5.0"
18
16
 
19
17
  gem.metadata = {
@@ -21,12 +19,12 @@ Gem::Specification.new do |gem|
21
19
  "bug_tracker_uri" => "https://github.com/contribsys/faktory_worker_ruby/issues",
22
20
  "documentation_uri" => "https://github.com/contribsys/faktory_worker_ruby/wiki",
23
21
  "changelog_uri" => "https://github.com/contribsys/faktory_worker_ruby/blob/master/Changes.md",
24
- "source_code_uri" => "https://github.com/contribsys/faktory_worker_ruby",
22
+ "source_code_uri" => "https://github.com/contribsys/faktory_worker_ruby"
25
23
  }
26
24
 
27
- gem.add_dependency 'connection_pool', '~> 2.2', ">= 2.2.2"
28
- gem.add_development_dependency 'activejob', '>= 5.2.0'
29
- gem.add_development_dependency 'minitest', '~> 5'
30
- gem.add_development_dependency 'minitest-hooks'
31
- gem.add_development_dependency 'rake'
25
+ gem.add_dependency "connection_pool", "~> 2.2", ">= 2.2.2"
26
+ gem.add_development_dependency "activejob", ">= 5.2.0"
27
+ gem.add_development_dependency "minitest", "~> 5"
28
+ gem.add_development_dependency "minitest-hooks"
29
+ gem.add_development_dependency "rake"
32
30
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'active_job'
3
+ require "active_job"
4
4
 
5
5
  module ActiveJob
6
6
  module QueueAdapters
@@ -10,21 +10,21 @@ module ActiveJob
10
10
  #
11
11
  # Rails.application.config.active_job.queue_adapter = :faktory
12
12
  class FaktoryAdapter
13
- def enqueue(job) #:nodoc:
13
+ def enqueue(job) # :nodoc:
14
14
  enqueue_at(job, nil)
15
15
  end
16
16
 
17
- def enqueue_at(job, timestamp) #:nodoc:
17
+ def enqueue_at(job, timestamp) # :nodoc:
18
18
  jid = SecureRandom.hex(12)
19
19
  job.provider_job_id = jid
20
20
  hash = {
21
- "jid" => jid,
21
+ "jid" => jid,
22
22
  "jobtype" => JobWrapper.to_s,
23
- "custom" => {
24
- "wrapped" => job.class.to_s,
23
+ "custom" => {
24
+ "wrapped" => job.class.to_s
25
25
  },
26
- "queue" => job.queue_name,
27
- "args" => [ job.serialize ],
26
+ "queue" => job.queue_name,
27
+ "args" => [job.serialize]
28
28
  }
29
29
  opts = job.faktory_options_hash.dup
30
30
  hash["at"] = Time.at(timestamp).utc.to_datetime.rfc3339(9) if timestamp
@@ -40,7 +40,7 @@ module ActiveJob
40
40
  end
41
41
  end
42
42
 
43
- class JobWrapper #:nodoc:
43
+ class JobWrapper # :nodoc:
44
44
  include Faktory::Job
45
45
 
46
46
  def perform(job_data)
@@ -55,7 +55,7 @@ module ActiveJob
55
55
  self.faktory_options_hash = {}
56
56
 
57
57
  def self.faktory_options(hsh)
58
- self.faktory_options_hash = self.faktory_options_hash.stringify_keys.merge(hsh.stringify_keys)
58
+ self.faktory_options_hash = faktory_options_hash.stringify_keys.merge(hsh.stringify_keys)
59
59
  end
60
60
  end
61
61
  end
data/lib/faktory/batch.rb CHANGED
@@ -87,7 +87,7 @@ module Faktory
87
87
  attr_reader :bid
88
88
  attr_accessor :description, :parent_bid
89
89
 
90
- def initialize(bid=nil)
90
+ def initialize(bid = nil)
91
91
  @bid = bid
92
92
  end
93
93
 
@@ -127,9 +127,9 @@ module Faktory
127
127
  def to_callback(val)
128
128
  case val
129
129
  when String
130
- basic_job.merge({ "jobtype" => val })
130
+ basic_job.merge({"jobtype" => val})
131
131
  when Class
132
- basic_job.merge({ "jobtype" => val })
132
+ basic_job.merge({"jobtype" => val})
133
133
  when Hash
134
134
  basic_job.merge(val)
135
135
  else
@@ -139,9 +139,9 @@ module Faktory
139
139
 
140
140
  def basic_job
141
141
  {
142
- "jid" => SecureRandom.hex(12),
143
- "args" => [],
144
- "queue" => "default",
142
+ "jid" => SecureRandom.hex(12),
143
+ "args" => [],
144
+ "queue" => "default"
145
145
  }
146
146
  end
147
147
  end
@@ -152,7 +152,7 @@ module Faktory
152
152
  end
153
153
 
154
154
  def hash
155
- @hash ||= Faktory.server{|c| c.batch_status(@bid) }
155
+ @hash ||= Faktory.server { |c| c.batch_status(@bid) }
156
156
  end
157
157
 
158
158
  def created_at
data/lib/faktory/cli.rb CHANGED
@@ -1,20 +1,20 @@
1
- # encoding: utf-8
2
1
  # frozen_string_literal: true
2
+
3
3
  $stdout.sync = true
4
4
 
5
- require 'yaml'
6
- require 'singleton'
7
- require 'optparse'
8
- require 'erb'
9
- require 'fileutils'
5
+ require "yaml"
6
+ require "singleton"
7
+ require "optparse"
8
+ require "erb"
9
+ require "fileutils"
10
10
 
11
11
  module Faktory
12
12
  class CLI
13
13
  end
14
14
  end
15
15
 
16
- require 'faktory'
17
- require 'faktory/util'
16
+ require "faktory"
17
+ require "faktory/util"
18
18
 
19
19
  module Faktory
20
20
  class CLI
@@ -30,7 +30,7 @@ module Faktory
30
30
  @code = nil
31
31
  end
32
32
 
33
- def parse(args=ARGV)
33
+ def parse(args = ARGV)
34
34
  @code = nil
35
35
 
36
36
  setup_options(args)
@@ -52,16 +52,14 @@ module Faktory
52
52
  print_banner
53
53
 
54
54
  self_read, self_write = IO.pipe
55
- sigs = %w(INT TERM TTIN TSTP)
55
+ sigs = %w[INT TERM TTIN TSTP]
56
56
 
57
57
  sigs.each do |sig|
58
- begin
59
- trap sig do
60
- self_write.puts(sig)
61
- end
62
- rescue ArgumentError
63
- puts "Signal #{sig} not supported"
58
+ trap sig do
59
+ self_write.puts(sig)
64
60
  end
61
+ rescue ArgumentError
62
+ puts "Signal #{sig} not supported"
65
63
  end
66
64
 
67
65
  logger.info "Running in #{RUBY_DESCRIPTION}"
@@ -77,23 +75,23 @@ module Faktory
77
75
  # Starting here the process will now have multiple threads running.
78
76
  fire_event(:startup)
79
77
 
80
- logger.debug { "Client Middleware: #{Faktory.client_middleware.map(&:klass).join(', ')}" }
81
- logger.debug { "Worker Middleware: #{Faktory.worker_middleware.map(&:klass).join(', ')}" }
78
+ logger.debug { "Client Middleware: #{Faktory.client_middleware.map(&:klass).join(", ")}" }
79
+ logger.debug { "Worker Middleware: #{Faktory.worker_middleware.map(&:klass).join(", ")}" }
82
80
 
83
- logger.info 'Starting processing, hit Ctrl-C to stop' if $stdout.tty?
81
+ logger.info "Starting processing, hit Ctrl-C to stop" if $stdout.tty?
84
82
 
85
- require 'faktory/launcher'
83
+ require "faktory/launcher"
86
84
  @launcher = Faktory::Launcher.new(options)
87
85
 
88
86
  begin
89
87
  launcher.run
90
88
 
91
- while readable_io = IO.select([self_read])
92
- signal = readable_io.first[0].gets.strip
89
+ while self_read.wait_readable
90
+ signal = self_read.gets.strip
93
91
  handle_signal(signal)
94
92
  end
95
93
  rescue Interrupt
96
- logger.info 'Shutting down'
94
+ logger.info "Shutting down"
97
95
  launcher.stop
98
96
  # Explicitly exit so busy Processor threads can't block
99
97
  # process shutdown.
@@ -103,7 +101,7 @@ module Faktory
103
101
  end
104
102
 
105
103
  def self.banner
106
- %q{
104
+ %q{
107
105
  ,,,,
108
106
  ,,,, | |
109
107
  | | | |
@@ -122,17 +120,17 @@ module Faktory
122
120
  def handle_signal(sig)
123
121
  Faktory.logger.debug "Got #{sig} signal"
124
122
  case sig
125
- when 'INT'
123
+ when "INT"
126
124
  raise Interrupt
127
- when 'TERM'
125
+ when "TERM"
128
126
  # Heroku sends TERM and then waits 30 seconds for process to exit.
129
127
  raise Interrupt
130
- when 'TSTP'
128
+ when "TSTP"
131
129
  Faktory.logger.info "Received TSTP, no longer accepting new work"
132
130
  launcher.quiet
133
- when 'TTIN'
131
+ when "TTIN"
134
132
  Thread.list.each do |thread|
135
- Faktory.logger.warn "Thread TID-#{thread.object_id.to_s(36)} #{thread['faktory_label']}"
133
+ Faktory.logger.warn "Thread TID-#{thread.object_id.to_s(36)} #{thread["faktory_label"]}"
136
134
  if thread.backtrace
137
135
  Faktory.logger.warn thread.backtrace.join("\n")
138
136
  else
@@ -146,15 +144,15 @@ module Faktory
146
144
 
147
145
  def print_banner
148
146
  # Print logo and banner for development
149
- if environment == 'development' && $stdout.tty?
150
- puts "\e[#{31}m"
147
+ if environment == "development" && $stdout.tty?
148
+ puts "\e[31m"
151
149
  puts Faktory::CLI.banner
152
150
  puts "\e[0m"
153
151
  end
154
152
  end
155
153
 
156
154
  def set_environment(cli_env)
157
- @environment = cli_env || ENV['RAILS_ENV'] || ENV['RACK_ENV'] || 'development'
155
+ @environment = cli_env || ENV["RAILS_ENV"] || ENV["RACK_ENV"] || "development"
158
156
  end
159
157
 
160
158
  alias_method :die, :exit
@@ -178,18 +176,18 @@ module Faktory
178
176
  end
179
177
 
180
178
  def boot_system
181
- ENV['RACK_ENV'] = ENV['RAILS_ENV'] = environment
179
+ ENV["RACK_ENV"] = ENV["RAILS_ENV"] = environment
182
180
 
183
181
  raise ArgumentError, "#{options[:require]} does not exist" unless File.exist?(options[:require])
184
182
 
185
183
  if File.directory?(options[:require])
186
- require 'rails'
187
- require 'faktory/rails'
184
+ require "rails"
185
+ require "faktory/rails"
188
186
  require File.expand_path("#{options[:require]}/config/environment.rb")
189
187
  options[:tag] ||= default_tag
190
188
  else
191
- not_required_message = "#{options[:require]} was not required, you should use an explicit path: " +
192
- "./#{options[:require]} or /path/to/#{options[:require]}"
189
+ not_required_message = "#{options[:require]} was not required, you should use an explicit path: " \
190
+ "./#{options[:require]} or /path/to/#{options[:require]}"
193
191
 
194
192
  require(options[:require]) || raise(ArgumentError, not_required_message)
195
193
  end
@@ -198,8 +196,8 @@ module Faktory
198
196
  def default_tag
199
197
  dir = ::Rails.root
200
198
  name = File.basename(dir)
201
- if name.to_i != 0 && prevdir = File.dirname(dir) # Capistrano release directory?
202
- if File.basename(prevdir) == 'releases'
199
+ if name.to_i != 0 && (prevdir = File.dirname(dir)) # Capistrano release directory?
200
+ if File.basename(prevdir) == "releases"
203
201
  return File.basename(File.dirname(prevdir))
204
202
  end
205
203
  end
@@ -207,10 +205,10 @@ module Faktory
207
205
  end
208
206
 
209
207
  def validate!
210
- options[:queues] << 'default' if options[:queues].empty?
208
+ options[:queues] << "default" if options[:queues].empty?
211
209
 
212
210
  if !File.exist?(options[:require]) ||
213
- (File.directory?(options[:require]) && !File.exist?("#{options[:require]}/config/application.rb"))
211
+ (File.directory?(options[:require]) && !File.exist?("#{options[:require]}/config/application.rb"))
214
212
  logger.info "=================================================================="
215
213
  logger.info " Please point Faktory to a Rails application or a Ruby file "
216
214
  logger.info " to load your worker classes with -r [DIR|FILE]."
@@ -228,19 +226,19 @@ module Faktory
228
226
  opts = {}
229
227
 
230
228
  @parser = OptionParser.new do |o|
231
- o.on '-c', '--concurrency INT', "processor threads to use" do |arg|
229
+ o.on "-c", "--concurrency INT", "processor threads to use" do |arg|
232
230
  opts[:concurrency] = Integer(arg)
233
231
  end
234
232
 
235
- o.on '-e', '--environment ENV', "Application environment" do |arg|
233
+ o.on "-e", "--environment ENV", "Application environment" do |arg|
236
234
  opts[:environment] = arg
237
235
  end
238
236
 
239
- o.on '-g', '--tag TAG', "Process tag for procline" do |arg|
237
+ o.on "-g", "--tag TAG", "Process tag for procline" do |arg|
240
238
  opts[:tag] = arg
241
239
  end
242
240
 
243
- o.on '-l', '--label LABEL', "Process label to use in Faktory UI" do |arg|
241
+ o.on "-l", "--label LABEL", "Process label to use in Faktory UI" do |arg|
244
242
  (opts[:labels] ||= []) << arg
245
243
  end
246
244
 
@@ -249,11 +247,11 @@ module Faktory
249
247
  parse_queue opts, queue, weight
250
248
  end
251
249
 
252
- o.on '-r', '--require [PATH|DIR]', "Location of Rails application with workers or file to require" do |arg|
250
+ o.on "-r", "--require [PATH|DIR]", "Location of Rails application with workers or file to require" do |arg|
253
251
  opts[:require] = arg
254
252
  end
255
253
 
256
- o.on '-t', '--timeout NUM', "Shutdown timeout" do |arg|
254
+ o.on "-t", "--timeout NUM", "Shutdown timeout" do |arg|
257
255
  opts[:timeout] = Integer(arg)
258
256
  end
259
257
 
@@ -261,11 +259,11 @@ module Faktory
261
259
  opts[:verbose] = arg
262
260
  end
263
261
 
264
- o.on '-C', '--config PATH', "path to YAML config file" do |arg|
262
+ o.on "-C", "--config PATH", "path to YAML config file" do |arg|
265
263
  opts[:config_file] = arg
266
264
  end
267
265
 
268
- o.on '-V', '--version', "Print version and exit" do |arg|
266
+ o.on "-V", "--version", "Print version and exit" do |arg|
269
267
  puts "Faktory #{Faktory::VERSION}"
270
268
  die(0)
271
269
  end
@@ -294,12 +292,10 @@ module Faktory
294
292
  def parse_config(cfile)
295
293
  opts = {}
296
294
  if File.exist?(cfile)
297
- opts = YAML.load(ERB.new(IO.read(cfile)).result) || opts
295
+ src = ERB.new(IO.read(cfile)).result
296
+ opts = YAML.safe_load(src, permitted_classes: [Symbol], aliases: true) || {}
298
297
  opts = opts.merge(opts.delete(environment) || {})
299
298
  parse_queues(opts, opts.delete(:queues) || [])
300
- else
301
- # allow a non-existent config file so Faktory
302
- # can be deployed by cap with just the defaults.
303
299
  end
304
300
  opts
305
301
  end
@@ -308,9 +304,9 @@ module Faktory
308
304
  queues_and_weights.each { |queue_and_weight| parse_queue(opts, *queue_and_weight) }
309
305
  end
310
306
 
311
- def parse_queue(opts, q, weight=nil)
307
+ def parse_queue(opts, q, weight = nil)
312
308
  [weight.to_i, 1].max.times do
313
- (opts[:queues] ||= []) << q
309
+ (opts[:queues] ||= []) << q
314
310
  end
315
311
  opts[:strict] = false if weight.to_i > 0
316
312
  end