opengraphplus 0.1.10 → 0.1.11
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 +4 -4
- data/lib/opengraphplus/configuration.rb +5 -0
- data/lib/opengraphplus/signature/url.rb +9 -10
- data/lib/opengraphplus/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: ccee4b54a3e8c28fa2c495ed9aec3f00c8ac772956454e515cfa914f08991c3f
|
|
4
|
+
data.tar.gz: 4bc72536524a668219f58afd5fde7e4108458c026f1604a85cb45e29d889bd99
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 6eb2e090b249de41cd61a88afbb3aaf5a144b73c5a4f66958b9d5f6a3142a4d7370bd7af502df67037f2cbae1a451f86acc257d7f7ef065b6f8da12d95eb3168
|
|
7
|
+
data.tar.gz: d1e8d614f9d047acb2afd2e9481e8b692a3742a7ddde4ac389b731e69df0fb656e9167d765b406d40dc0eaa19b36b08fabd30f99d07b7cdedd2814c749ceae1e
|
|
@@ -5,26 +5,25 @@ require "uri"
|
|
|
5
5
|
module OpenGraphPlus
|
|
6
6
|
module Signature
|
|
7
7
|
class URL
|
|
8
|
-
|
|
8
|
+
attr_reader :base
|
|
9
|
+
alias :base_url :base
|
|
9
10
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
def initialize(base_url: nil)
|
|
13
|
-
@base_uri = URI.parse(base_url || ENV.fetch("OGPLUS_URL", DEFAULT_BASE_URL))
|
|
11
|
+
def initialize(url: OpenGraphPlus.configuration.url)
|
|
12
|
+
@base = URI.parse(url)
|
|
14
13
|
end
|
|
15
14
|
|
|
16
15
|
def signed_path(prefix, api_key)
|
|
17
|
-
SignedPath.new(prefix:, api_key:,
|
|
16
|
+
SignedPath.new(prefix:, api_key:, base_url:)
|
|
18
17
|
end
|
|
19
18
|
end
|
|
20
19
|
|
|
21
20
|
class SignedPath
|
|
22
|
-
attr_reader :prefix, :api_key, :
|
|
21
|
+
attr_reader :prefix, :api_key, :base_url
|
|
23
22
|
|
|
24
|
-
def initialize(prefix:, api_key:,
|
|
23
|
+
def initialize(prefix:, api_key:, base_url:)
|
|
25
24
|
@prefix = prefix
|
|
26
25
|
@api_key = api_key
|
|
27
|
-
@
|
|
26
|
+
@base_url = base_url
|
|
28
27
|
end
|
|
29
28
|
|
|
30
29
|
def generator
|
|
@@ -36,7 +35,7 @@ module OpenGraphPlus
|
|
|
36
35
|
path_and_query = params.empty? ? signed_path : "#{signed_path}?#{URI.encode_www_form(params)}"
|
|
37
36
|
signature = generator.generate(path_and_query)
|
|
38
37
|
|
|
39
|
-
|
|
38
|
+
base_url.dup.tap do |uri|
|
|
40
39
|
uri.path = File.join(prefix, signature, *segments.map(&:to_s))
|
|
41
40
|
uri.query = URI.encode_www_form(params) unless params.empty?
|
|
42
41
|
end.to_s
|