M .rubocop.yml => .rubocop.yml +3 -0
@@ 55,6 55,9 @@ Layout/LineLength:
Exclude:
- Gemfile
+Layout/EndAlignment:
+ EnforcedStyleAlignWith: start_of_line
+
Layout/SpaceAroundEqualsInParameterDefault:
EnforcedStyle: no_space
M lib/customer_fwd.rb => lib/customer_fwd.rb +10 -6
@@ 7,14 7,18 @@ require "uri"
class CustomerFwd
def self.for(uri:, timeout:)
timeout = Timeout.new(timeout)
- return None.new(uri: uri, timeout: timeout) if !uri || timeout.zero?
- if uri =~ /\Asip:(.*)@sip.cheogram.com\Z/
- uri = "xmpp:#{$1.gsub(/%([0-9A-F]{2})/i) { $1.to_i(16).chr }}"
+ fwd = if uri
+ if uri =~ /\Asip:(.*)@sip.cheogram.com\Z/
+ uri = "xmpp:#{$1.gsub(/%([0-9A-F]{2})/i) { $1.to_i(16).chr }}"
+ end
+
+ URIS.fetch(uri.split(":", 2).first.to_sym) {
+ raise "Unknown forward URI: #{uri}"
+ }.new(uri: uri, timeout: timeout)
end
- URIS.fetch(uri.split(":", 2).first.to_sym) {
- raise "Unknown forward URI: #{uri}"
- }.new(uri: uri, timeout: timeout)
+
+ fwd && !timeout.zero? ? fwd : None.new(uri: uri, timeout: timeout)
end
class Timeout