Skip to content

Commit

Permalink
fix constantizing the adapter
Browse files Browse the repository at this point in the history
  • Loading branch information
shaqq committed Feb 15, 2019
1 parent 019197e commit 39003fc
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
14 changes: 6 additions & 8 deletions lib/puma/plugin/runtime_env.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,10 @@
# Graciously, from https://github.com/rails/rails/blob/94b5cd3a20edadd6f6b8cf0bdf1a4d4919df86cb/activesupport/lib/active_support/inflector/methods.rb#L69
def camelize(term, uppercase_first_letter = true)
string = term.to_s
if uppercase_first_letter
string = string.sub(/^[a-z\d]*/) { |match| inflections.acronyms[match] || match.capitalize }
else
string = string.sub(inflections.acronyms_camelize_regex) { |match| match.downcase }
end
string.gsub!(/(?:_|(\/))([a-z\d]*)/i) { "#{$1}#{inflections.acronyms[$2] || $2.capitalize}" }

string = string.sub(/^[a-z\d]*/) { |match| match.capitalize }

string.gsub!(/(?:_|(\/))([a-z\d]*)/i) { "#{$1}#{$2.capitalize}" }
string.gsub!("/".freeze, "::".freeze)
string
end
Expand All @@ -27,8 +25,8 @@ def config(c)
return
end

adapter = "Puma::RuntimeEnv::#{camelize(adapter_name)}".new
poll_interval = Integer(ENV["PUMA_RUNTIME_ENV_INTERVAL"]) rescue 5
adapter = Puma::RuntimeEnv.const_get("#{camelize(adapter_name)}").new
poll_interval = Integer(ENV["PUMA_RUNTIME_ENV_INTERVAL"]) rescue 10

restricted_envs = ["PUMA_RUNTIME_ENV"]
other_restricted_envs = ENV.fetch("PUMA_RUNTIME_ENV_RESTRICTED", [])
Expand Down
2 changes: 1 addition & 1 deletion puma-runtime_env.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)

Gem::Specification.new do |spec|
spec.name = "puma-runtime_env"
spec.version = "0.0.1"
spec.version = "0.0.2"
spec.authors = ["shaker"]
spec.email = ["[email protected]"]

Expand Down

0 comments on commit 39003fc

Please sign in to comment.