Class: Middleman::GoogleAnalyticsExtension

Inherits:
Extension
  • Object
show all
Defined in:
lib/middleman-google-analytics/extension.rb

Instance Method Summary collapse

Instance Method Details

#after_configurationObject



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/middleman-google-analytics/extension.rb', line 18

def after_configuration
  options.test = true if legacy_development?

  unless options.tracking_id
    $stderr.puts 'Google Analytics: Please specify a property ID'
    raise ArgumentError, 'No property ID given' if app.build?
  end

  if options.allow_linker and not options.domain_name
    $stderr.puts 'Google Analytics: Please specify a domain_name when using allow_linker'
    raise ArgumentError, 'No domain_name given' if app.build?
  end

  unless [:html, :js].include?(options.output.try(:to_sym))
    $stderr.puts 'Google Analytics: Please specify a valid output type (html|js).'
    raise ArgumentError, 'Only "html" or "js" allowed' if app.build?
  end
end