opengraphplus 0.1.10 → 0.1.12

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: 0d5e0af7ba91d92d1f9c20380bd19c0d684eb68e65fb7f90bfdb803b051c3d4a
4
- data.tar.gz: 4bc63ce1ff20de87a5101edea02ffa931875a8231bed0047cc90ee69cede2a6f
3
+ metadata.gz: 59d43457f38a2e621e03a796fbc55ca6fa033fa8681e8e6f58d0fcd6c026abb6
4
+ data.tar.gz: b025ca10c79443b4c3103b530e5c8acc66d7518d7b3b01684a3e16dcfd02a9e9
5
5
  SHA512:
6
- metadata.gz: 5f4d532d192695beb6fd9565e3cf8a12e5e478cb72fdebc7467a26122810eeedf5d75fd9bee5e78cbd74f8879de040ccae1d2c4352ca099308a311f6cbe99ee9
7
- data.tar.gz: b238b9d0ac0aff9bf41164d8d9b9a8b882557c6e57f57bd1d2230b36d03a8ea6a20ab8c0d9302a828c6083141f9d6fa9b8b2d39a66b01306f2d42ab74af4c9cb
6
+ metadata.gz: e7113d1cd959a637765999dceca6e175f5fea0a3d2554b5eb6aefd603aae37e375c3372c04a23a4870e3b26c74d912b82c463b89d906d311283d6b6edc6de592
7
+ data.tar.gz: 195c57c98b685a908fff4d2029ebb70467e61fdf4417903968ef0c08a41f682d5fb688c828ec05a98a1347b1a2fb43c52829c60be35c118612c110ec004322be
@@ -2,8 +2,13 @@
2
2
 
3
3
  module OpenGraphPlus
4
4
  class Configuration
5
+ DEFAULT_URL = "https://opengraphplus.com"
6
+
7
+ attr_accessor :url
8
+
5
9
  def initialize
6
10
  @api_key = nil
11
+ @url = DEFAULT_URL
7
12
  end
8
13
 
9
14
  def api_key
@@ -21,6 +21,11 @@ module OpenGraphPlus
21
21
  kwargs.each { |key, value| public_send(:"#{key}=", value) }
22
22
  self
23
23
  end
24
+
25
+ def tag_for(property)
26
+ find { |tag| tag.property == property }
27
+ end
28
+ alias_method :[], :tag_for
24
29
  end
25
30
 
26
31
  class Image < Base
@@ -5,26 +5,25 @@ require "uri"
5
5
  module OpenGraphPlus
6
6
  module Signature
7
7
  class URL
8
- DEFAULT_BASE_URL = "https://opengraphplus.com"
8
+ attr_reader :base
9
+ alias :base_url :base
9
10
 
10
- attr_reader :base_uri
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:, base_uri:)
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, :base_uri
21
+ attr_reader :prefix, :api_key, :base_url
23
22
 
24
- def initialize(prefix:, api_key:, base_uri:)
23
+ def initialize(prefix:, api_key:, base_url:)
25
24
  @prefix = prefix
26
25
  @api_key = api_key
27
- @base_uri = base_uri
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
- base_uri.dup.tap do |uri|
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
@@ -23,6 +23,10 @@ module OpenGraphPlus
23
23
  meta
24
24
  end
25
25
 
26
+ def ==(other)
27
+ other.is_a?(Tag) && property == other.property && content == other.content
28
+ end
29
+
26
30
  private
27
31
 
28
32
  def escape(content)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module OpenGraphPlus
4
- VERSION = "0.1.10"
4
+ VERSION = "0.1.12"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: opengraphplus
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.10
4
+ version: 0.1.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brad Gessler