Class: Landable::Configuration

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

Defined Under Namespace

Classes: CORS, Screenshots

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config_path = nil) ⇒ Configuration

Returns a new instance of Configuration.



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/landable/configuration.rb', line 18

def initialize(config_path = nil)
  begin
    # let's keep this feature optional. Not all apps
    # will be using external configs for landable
    app_config = Figgy.build do |config_data|
      config_data.root = config_path

      config_data.define_overlay :default, nil
      config_data.define_overlay(:environment) { Rails.env }
    end

    # map our new configs into our local object.
    config_keys(config_path).each do |key|
      self[key] = app_config[key] unless app_config[key].nil?
    end
  end unless config_path.nil?
end

Instance Attribute Details

#amqp_configurationObject

Returns the value of attribute amqp_configuration.



5
6
7
# File 'lib/landable/configuration.rb', line 5

def amqp_configuration
  @amqp_configuration
end

#amqp_event_mappingObject



179
180
181
# File 'lib/landable/configuration.rb', line 179

def amqp_event_mapping
  @amqp_event_mapping ||= {}
end

#amqp_messaging_service=(value) ⇒ Object (writeonly)

Sets the attribute amqp_messaging_service

Parameters:

  • value

    the value to set the attribute amqp_messaging_service to.



16
17
18
# File 'lib/landable/configuration.rb', line 16

def amqp_messaging_service=(value)
  @amqp_messaging_service = value
end

#amqp_service_enabledObject



183
184
185
# File 'lib/landable/configuration.rb', line 183

def amqp_service_enabled
  amqp_configuration[:enabled] && amqp_configuration[:messaging_service]
end

#amqp_site_segmentObject



175
176
177
# File 'lib/landable/configuration.rb', line 175

def amqp_site_segment
  @amqp_site_segment ||= Rails.application.class.parent_name
end

#api_hostObject



58
59
60
# File 'lib/landable/configuration.rb', line 58

def api_host
  @api_host ||= api_uri.try(:host)
end

#api_namespaceObject



62
63
64
# File 'lib/landable/configuration.rb', line 62

def api_namespace
  @api_namespace ||= (api_uri.try(:path).presence || '/api/landable')
end

#api_urlObject

Returns the value of attribute api_url.



5
6
7
# File 'lib/landable/configuration.rb', line 5

def api_url
  @api_url
end

#audit_flagsObject



74
75
76
# File 'lib/landable/configuration.rb', line 74

def audit_flags
  @audit_flags ||= []
end

#blank_user_agent_stringObject



162
163
164
# File 'lib/landable/configuration.rb', line 162

def blank_user_agent_string
  @blank_user_agent_string ||= 'blank'
end

#categoriesObject



90
91
92
93
94
95
96
97
98
99
100
# File 'lib/landable/configuration.rb', line 90

def categories
  # default categories
  @categories ||= {
    'Affiliates' => '',
    'PPC' => 'Pay-per-click',
    'SEO' => 'Search engine optimization',
    'Social' => '',
    'Email' => '',
    'Traditional' => ''
  }
end

#database_schema_prefixObject



82
83
84
# File 'lib/landable/configuration.rb', line 82

def database_schema_prefix
  @database_schema_prefix ||= ''
end

#dnt_enabledObject



170
171
172
173
# File 'lib/landable/configuration.rb', line 170

def dnt_enabled
  return true if @dnt_enabled.nil?
  @dnt_enabled
end

#partials_to_templatesObject



102
103
104
# File 'lib/landable/configuration.rb', line 102

def partials_to_templates
  @partials_to_templates ||= []
end

#public_hostObject



70
71
72
# File 'lib/landable/configuration.rb', line 70

def public_host
  @public_host ||= public_uri.try(:host)
end

#public_namespaceObject



78
79
80
# File 'lib/landable/configuration.rb', line 78

def public_namespace
  @public_namespace ||= (public_uri.try(:path).presence || '')
end

#public_urlObject

Returns the value of attribute public_url.



5
6
7
# File 'lib/landable/configuration.rb', line 5

def public_url
  @public_url
end

#publicist_urlObject



50
51
52
# File 'lib/landable/configuration.rb', line 50

def publicist_url
  @publicist_url ||= 'publicist.dev'
end

#reserved_pathsObject



106
107
108
# File 'lib/landable/configuration.rb', line 106

def reserved_paths
  @reserved_paths ||= []
end

#screenshots_enabledObject



122
123
124
# File 'lib/landable/configuration.rb', line 122

def screenshots_enabled
  @screenshots_enabled ||= false
end

#sitemap_additional_pathsObject



114
115
116
# File 'lib/landable/configuration.rb', line 114

def sitemap_additional_paths
  @sitemap_additional_paths ||= []
end

#sitemap_exclude_categoriesObject



110
111
112
# File 'lib/landable/configuration.rb', line 110

def sitemap_exclude_categories
  @sitemap_exclude_categories ||= []
end

#sitemap_hostObject

Returns the value of attribute sitemap_host.



5
6
7
# File 'lib/landable/configuration.rb', line 5

def sitemap_host
  @sitemap_host
end

#sitemap_protocolObject



118
119
120
# File 'lib/landable/configuration.rb', line 118

def sitemap_protocol
  @sitemap_protocol ||= 'http'
end

#traffic_enabledObject



126
127
128
# File 'lib/landable/configuration.rb', line 126

def traffic_enabled
  @traffic_enabled ||= false
end

#untracked_pathsObject



166
167
168
# File 'lib/landable/configuration.rb', line 166

def untracked_paths
  @untracked_paths ||= []
end

Instance Method Details

#api_uriObject



54
55
56
# File 'lib/landable/configuration.rb', line 54

def api_uri
  @api_uri ||= URI(api_url) if api_url.present?
end

#authenticatorsObject



40
41
42
# File 'lib/landable/configuration.rb', line 40

def authenticators
  @authenticators || fail('No Landable authenticator configured.')
end

#authenticators=(authenticators) ⇒ Object Also known as: authenticator=



44
45
46
# File 'lib/landable/configuration.rb', line 44

def authenticators=(authenticators)
  @authenticators = Array(authenticators)
end

#corsObject



135
136
137
# File 'lib/landable/configuration.rb', line 135

def cors
  @cors ||= CORS.new
end

#cors=(bool) ⇒ Object



139
140
141
142
# File 'lib/landable/configuration.rb', line 139

def cors=(bool)
  fail(ArgumentError, "Landable::Configuration#cors should be assigned 'false' to disable CORS support") if bool != false
  cors.origins = []
end

#public_uriObject



66
67
68
# File 'lib/landable/configuration.rb', line 66

def public_uri
  @public_uri ||= URI(public_url) if public_url.present?
end

#screenshotsObject



158
159
160
# File 'lib/landable/configuration.rb', line 158

def screenshots
  @screenshots ||= Screenshots.new
end