lib/terminalwire/client/entitlement.rb in terminalwire-0.1.16 vs lib/terminalwire/client/entitlement.rb in terminalwire-0.1.17

- old
+ new

@@ -165,19 +165,19 @@ } end end class RootPolicy < Policy - HOST = "terminalwire.com".freeze + AUTHORITY = "terminalwire.com".freeze # Ensure the binary stubs are executable. This increases the # file mode entitlement so that stubs created in ./bin are executable. BINARY_PATH_FILE_MODE = 0o755 def initialize(*, **, &) # Make damn sure the authority is set to Terminalwire. - super(*, authority: HOST, **, &) + super(*, authority: AUTHORITY, **, &) # Now setup special permitted paths. @paths.permit root_path @paths.permit root_pattern @@ -200,27 +200,15 @@ def binary_pattern binary_path.join("*") end end - def self.from_url(url) - url = URI(url) - - case url.host - when RootPolicy::HOST - RootPolicy.new + def self.resolve(*, authority:, **, &) + case authority + when RootPolicy::AUTHORITY + RootPolicy.new(*, **, &) else - Policy.new authority: url_authority(url) - end - end - - def self.url_authority(url) - # I had to lift this from URI::HTTP because `ws://` doesn't - # have an authority method. - if url.port == url.default_port - url.host - else - "#{url.host}:#{url.port}" + Policy.new *, authority:, **, & end end end end