class Middleman::GoogleAnalyticsExtension

Public Instance Methods

after_configuration() click to toggle source
# 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

Private Instance Methods

legacy_development?() click to toggle source
# File lib/middleman-google-analytics/extension.rb, line 43
def legacy_development?
  return false if ENV['TEST'] == 'true'

  # Middleman 3.4
  is_development = try(:development?)
  return is_development unless is_development.nil?

  # Middleman 4.x
  app.development?
end