opengraphplus 0.1.9 → 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 54b7d84e954c55e6ba849b802b923d7e167ec9190a6c1cc19f6ac76a1251ea45
4
- data.tar.gz: 912f50347ee1ffd7de4a01ed1e92b2ed63646512b2a4987b8b148f8ad8fdbb45
3
+ metadata.gz: ccee4b54a3e8c28fa2c495ed9aec3f00c8ac772956454e515cfa914f08991c3f
4
+ data.tar.gz: 4bc72536524a668219f58afd5fde7e4108458c026f1604a85cb45e29d889bd99
5
5
  SHA512:
6
- metadata.gz: 6c0dce1160417409c38262b31da5d92678890c4ac34b94351e7e09ba65c6a56bd5b063923ffffcb60fe2b9d8d70d86a35c0f15aa3f28e24af7f2c9626371e7d0
7
- data.tar.gz: 87b21217de703b737150ccf352462d018a371c875119151259cdefbaa402db3827b8fb02193290218f47485f8b084c4f3e07a11d31b9233974e7ec8557346f1c
6
+ metadata.gz: 6eb2e090b249de41cd61a88afbb3aaf5a144b73c5a4f66958b9d5f6a3142a4d7370bd7af502df67037f2cbae1a451f86acc257d7f7ef065b6f8da12d95eb3168
7
+ data.tar.gz: d1e8d614f9d047acb2afd2e9481e8b692a3742a7ddde4ac389b731e69df0fb656e9167d765b406d40dc0eaa19b36b08fabd30f99d07b7cdedd2814c749ceae1e
data/README.md CHANGED
@@ -27,27 +27,27 @@ Sign up at [og.plus](https://og.plus) to get your API key.
27
27
  #### Using environment variables
28
28
 
29
29
  ```bash
30
- rails g opengraphplus:env ogp_live_████████████████████
30
+ rails g opengraphplus:env ogplus_live_████████████████████
31
31
  ```
32
32
 
33
33
  This will:
34
- - Append `OPENGRAPHPLUS__API_KEY=ogp_live_████████████████████` to your `.env` file (or the first env file found)
34
+ - Append `OGPLUS__API_KEY=ogplus_live_████████████████████` to your `.env` file (or the first env file found)
35
35
  - Create `config/initializers/opengraphplus.rb`
36
36
 
37
37
  To specify a different env file:
38
38
 
39
39
  ```bash
40
- rails g opengraphplus:env ogp_live_████████████████████ -e .envrc
40
+ rails g opengraphplus:env ogplus_live_████████████████████ -e .envrc
41
41
  ```
42
42
 
43
43
  #### Using Rails credentials
44
44
 
45
45
  ```bash
46
- rails g opengraphplus:credentials ogp_live_████████████████████
46
+ rails g opengraphplus:credentials ogplus_live_████████████████████
47
47
  ```
48
48
 
49
49
  This will:
50
- - Add `opengraphplus.api_key` to your encrypted `credentials.yml.enc`
50
+ - Add `ogplus.api_key` to your encrypted `credentials.yml.enc`
51
51
  - Create `config/initializers/opengraphplus.rb`
52
52
 
53
53
  #### Manual configuration
@@ -62,9 +62,9 @@ Then configure manually in `config/initializers/opengraphplus.rb`:
62
62
 
63
63
  ```ruby
64
64
  OpenGraphPlus.configure do |config|
65
- config.api_key = ENV["OPENGRAPHPLUS__API_KEY"]
65
+ config.api_key = ENV["OGPLUS__API_KEY"]
66
66
  # or
67
- config.api_key = Rails.application.credentials.opengraphplus.api_key
67
+ config.api_key = Rails.application.credentials.ogplus.api_key
68
68
  end
69
69
  ```
70
70
 
@@ -5,14 +5,14 @@ require "rails/generators"
5
5
  module Opengraphplus
6
6
  module Generators
7
7
  class BaseGenerator < Rails::Generators::Base
8
- API_KEY_PREFIX = "ogp_"
8
+ API_KEY_PREFIXES = %w[ogp_ ogplus_].freeze
9
9
 
10
10
  argument :api_key, type: :string, required: true,
11
11
  desc: "Your OpenGraphPlus API key"
12
12
 
13
13
  def validate_api_key
14
- unless api_key.start_with?(API_KEY_PREFIX)
15
- say_status :error, "Invalid API key: must start with '#{API_KEY_PREFIX}'", :red
14
+ unless API_KEY_PREFIXES.any? { |prefix| api_key.start_with?(prefix) }
15
+ say_status :error, "Invalid API key: must start with '#{API_KEY_PREFIXES.join("' or '")}'", :red
16
16
  raise SystemExit
17
17
  end
18
18
  end
@@ -23,11 +23,11 @@ module Opengraphplus
23
23
  yaml_content = credentials.read.presence || ""
24
24
  config = parse_yaml(yaml_content)
25
25
 
26
- config["opengraphplus"] ||= {}
27
- config["opengraphplus"]["api_key"] = api_key
26
+ config["ogplus"] ||= {}
27
+ config["ogplus"]["api_key"] = api_key
28
28
 
29
29
  credentials.write(yaml_dump(config))
30
- say_status :insert, "credentials.yml.enc (opengraphplus.api_key)", :green
30
+ say_status :insert, "credentials.yml.enc (ogplus.api_key)", :green
31
31
  end
32
32
 
33
33
  def create_initializer
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  OpenGraphPlus.configure do |config|
4
- config.api_key = Rails.application.credentials.opengraphplus.api_key
4
+ config.api_key = Rails.application.credentials.ogplus.api_key
5
5
  end
@@ -13,7 +13,7 @@ module Opengraphplus
13
13
  desc: "Specific env file to write to (e.g., .env, .envrc)"
14
14
 
15
15
  ENV_FILES = %w[.env .env.local .env.development .env.development.local .envrc].freeze
16
- ENV_VAR_NAME = "OPENGRAPHPLUS__API_KEY"
16
+ ENV_VAR_NAME = "OGPLUS__API_KEY"
17
17
 
18
18
  def append_to_env_file
19
19
  if options[:envfile]
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  OpenGraphPlus.configure do |config|
4
- config.api_key = ENV["OPENGRAPHPLUS__API_KEY"]
4
+ config.api_key = ENV["OGPLUS__API_KEY"]
5
5
  end
@@ -3,8 +3,8 @@
3
3
  # Get your API key at https://opengraphplus.com/dashboard
4
4
  OpenGraphPlus.configure do |config|
5
5
  # Use Rails credentials.
6
- config.api_key = Rails.application.credentials.opengraphplus_api_key
6
+ config.api_key = Rails.application.credentials.ogplus_api_key
7
7
 
8
8
  # Or use ENV:
9
- # config.api_key = ENV["OPENGRAPHPLUS_API_KEY"]
9
+ # config.api_key = ENV["OGPLUS__API_KEY"]
10
10
  end
@@ -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
@@ -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("OPENGRAPHPLUS_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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module OpenGraphPlus
4
- VERSION = "0.1.9"
4
+ VERSION = "0.1.11"
5
5
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: opengraphplus
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.9
4
+ version: 0.1.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brad Gessler
8
8
  bindir: exe
9
9
  cert_chain: []
10
- date: 2026-01-10 00:00:00.000000000 Z
10
+ date: 2026-01-16 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: activesupport