Class: Journeybook::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/journeybook/configuration.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/journeybook/configuration.rb', line 8

def initialize
  @default_layout = "application"
  @admin_authenticator = ->(_controller) { false }
  @ai_provider = :openai
  @openai_api_key = nil
  @openai_model = "gpt-5.4-mini"
  @postmark_api_key = nil
  @form_from = nil
  @form_to = nil
  @form_action = "/journeybook/form"
  @form_delivery_method = :postmark
  @s3_bucket = nil
  @s3_region = nil
  @s3_access_key_id = nil
  @s3_secret_access_key = nil
  @s3_prefix = "journeybook/#{Rails.env}"
  @s3_public_base_url = nil
  @components = ComponentRegistry.new
  @templates = PageTemplateRegistry.new
end

Instance Attribute Details

#admin_authenticatorObject

Returns the value of attribute admin_authenticator.



3
4
5
# File 'lib/journeybook/configuration.rb', line 3

def admin_authenticator
  @admin_authenticator
end

#ai_providerObject

Returns the value of attribute ai_provider.



3
4
5
# File 'lib/journeybook/configuration.rb', line 3

def ai_provider
  @ai_provider
end

#componentsObject (readonly)

Returns the value of attribute components.



6
7
8
# File 'lib/journeybook/configuration.rb', line 6

def components
  @components
end

#default_layoutObject

Returns the value of attribute default_layout.



3
4
5
# File 'lib/journeybook/configuration.rb', line 3

def default_layout
  @default_layout
end

#form_actionObject

Returns the value of attribute form_action.



3
4
5
# File 'lib/journeybook/configuration.rb', line 3

def form_action
  @form_action
end

#form_delivery_methodObject

Returns the value of attribute form_delivery_method.



3
4
5
# File 'lib/journeybook/configuration.rb', line 3

def form_delivery_method
  @form_delivery_method
end

#form_fromObject

Returns the value of attribute form_from.



3
4
5
# File 'lib/journeybook/configuration.rb', line 3

def form_from
  @form_from
end

#form_toObject

Returns the value of attribute form_to.



3
4
5
# File 'lib/journeybook/configuration.rb', line 3

def form_to
  @form_to
end

#openai_api_keyObject

Returns the value of attribute openai_api_key.



3
4
5
# File 'lib/journeybook/configuration.rb', line 3

def openai_api_key
  @openai_api_key
end

#openai_modelObject

Returns the value of attribute openai_model.



3
4
5
# File 'lib/journeybook/configuration.rb', line 3

def openai_model
  @openai_model
end

#postmark_api_keyObject

Returns the value of attribute postmark_api_key.



3
4
5
# File 'lib/journeybook/configuration.rb', line 3

def postmark_api_key
  @postmark_api_key
end

#s3_access_key_idObject

Returns the value of attribute s3_access_key_id.



3
4
5
# File 'lib/journeybook/configuration.rb', line 3

def s3_access_key_id
  @s3_access_key_id
end

#s3_bucketObject

Returns the value of attribute s3_bucket.



3
4
5
# File 'lib/journeybook/configuration.rb', line 3

def s3_bucket
  @s3_bucket
end

#s3_prefixObject

Returns the value of attribute s3_prefix.



3
4
5
# File 'lib/journeybook/configuration.rb', line 3

def s3_prefix
  @s3_prefix
end

#s3_public_base_urlObject

Returns the value of attribute s3_public_base_url.



3
4
5
# File 'lib/journeybook/configuration.rb', line 3

def s3_public_base_url
  @s3_public_base_url
end

#s3_regionObject

Returns the value of attribute s3_region.



3
4
5
# File 'lib/journeybook/configuration.rb', line 3

def s3_region
  @s3_region
end

#s3_secret_access_keyObject

Returns the value of attribute s3_secret_access_key.



3
4
5
# File 'lib/journeybook/configuration.rb', line 3

def s3_secret_access_key
  @s3_secret_access_key
end

#templatesObject (readonly)

Returns the value of attribute templates.



6
7
8
# File 'lib/journeybook/configuration.rb', line 6

def templates
  @templates
end

Instance Method Details

#admin_basic_auth(username:, password:, realm: "Journeybook") ⇒ Object



37
38
39
40
41
42
43
44
45
46
47
# File 'lib/journeybook/configuration.rb', line 37

def admin_basic_auth(username:, password:, realm: "Journeybook")
  @admin_authenticator = lambda do |controller|
    expected_username = username.to_s
    expected_password = password.to_s

    controller.authenticate_or_request_with_http_basic(realm) do |provided_username, provided_password|
      expected_username.present? && expected_password.present? &&
        secure_compare(provided_username, expected_username) && secure_compare(provided_password, expected_password)
    end
  end
end

#component(name, component_class, **metadata) ⇒ Object

Parameters:

  • name (String, Symbol)
  • component_class (Class)
  • metadata (Hash)

Returns:

  • (Object)


33
34
35
# File 'lib/journeybook/configuration.rb', line 33

def component(name, component_class, **)
  components.register(name, component_class, **)
end