Class: Indexmap::IndexNowConfiguration

Inherits:
Object
  • Object
show all
Defined in:
lib/indexmap/index_now_configuration.rb

Constant Summary collapse

DEFAULT_ENDPOINT =
"https://api.indexnow.org"
DEFAULT_MAX_URLS_PER_REQUEST =
500

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#dry_run=(value) ⇒ Object (writeonly)

Sets the attribute dry_run

Parameters:

  • value

    the value to set the attribute dry_run to.



8
9
10
# File 'lib/indexmap/index_now_configuration.rb', line 8

def dry_run=(value)
  @dry_run = value
end

#endpointObject



15
16
17
18
# File 'lib/indexmap/index_now_configuration.rb', line 15

def endpoint
  value = resolve(@endpoint)
  value.to_s.strip.empty? ? DEFAULT_ENDPOINT : value
end

#keyObject



20
21
22
# File 'lib/indexmap/index_now_configuration.rb', line 20

def key
  resolve(@key)
end

#key_path(public_path:, key: self.key) ⇒ Object



24
25
26
27
28
29
30
# File 'lib/indexmap/index_now_configuration.rb', line 24

def key_path(public_path:, key: self.key)
  configured_path = resolve(@key_path)
  return Pathname(configured_path) unless configured_path.to_s.strip.empty?
  return if key.to_s.strip.empty?

  Pathname(public_path).join("#{key}.txt")
end

#max_urls_per_requestObject



32
33
34
35
36
37
# File 'lib/indexmap/index_now_configuration.rb', line 32

def max_urls_per_request
  value = resolve(@max_urls_per_request)
  return DEFAULT_MAX_URLS_PER_REQUEST if value.nil?

  value.to_i
end

Instance Method Details

#dry_run?Boolean

Returns:

  • (Boolean)


10
11
12
13
# File 'lib/indexmap/index_now_configuration.rb', line 10

def dry_run?
  value = resolve(@dry_run)
  value == true || value.to_s == "1"
end