Sha256: a7fd742cbbb6ce76c5623dd0f1236dfa2ab7f381b15c671ebfbed19e962c54bc

Contents?: true

Size: 1.37 KB

Versions: 53

Compression:

Stored size: 1.37 KB

Contents

# Application template recipe for the rails_apps_composer. Change the recipe here:
# https://github.com/RailsApps/rails_apps_composer/blob/master/recipes/analytics.rb

prefs[:analytics] = multiple_choice "Install page-view analytics?", [["None", "none"],
  ["Google Analytics", "ga"],
  ["Segment.io", "segmentio"]] unless prefs.has_key? :analytics
case prefs[:analytics]
  when 'ga'
    ga_id = ask_wizard('Google Analytics ID?')
  when 'segmentio'
    segmentio_api_key = ask_wizard('Segment.io API key?')
end

stage_two do
  say_wizard "recipe stage two"
  unless prefer :analytics, 'none'
    # don't add the gem if it has already been added by the railsapps recipe
    add_gem 'rails_apps_pages', :group => :development unless prefs[:apps4]
  end
  case prefs[:analytics]
    when 'ga'
      generate 'analytics:google -f'
      gsub_file 'app/assets/javascripts/google_analytics.js.coffee', /UA-XXXXXXX-XX/, ga_id
    when 'segmentio'
      generate 'analytics:segmentio -f'
      gsub_file 'app/assets/javascripts/segmentio.js', /SEGMENTIO_API_KEY/, segmentio_api_key
  end
  ### GIT ###
  git :add => '-A' if prefer :git, true
  git :commit => '-qm "rails_apps_composer: add analytics"' if prefer :git, true
end

__END__

name: analytics
description: "Add JavaScript files for Segment.io or Google Analytics"
author: RailsApps

requires: [setup, gems]
run_after: [setup, gems, init]
category: other

Version data entries

53 entries across 53 versions & 1 rubygems

Version Path
rails_apps_composer-3.0.42 recipes/analytics.rb
rails_apps_composer-3.0.41 recipes/analytics.rb
rails_apps_composer-3.0.40 recipes/analytics.rb
rails_apps_composer-3.0.39 recipes/analytics.rb
rails_apps_composer-3.0.38 recipes/analytics.rb
rails_apps_composer-3.0.37 recipes/analytics.rb
rails_apps_composer-3.0.36 recipes/analytics.rb
rails_apps_composer-3.0.35 recipes/analytics.rb
rails_apps_composer-3.0.34 recipes/analytics.rb
rails_apps_composer-3.0.33 recipes/analytics.rb
rails_apps_composer-3.0.32 recipes/analytics.rb
rails_apps_composer-3.0.31 recipes/analytics.rb
rails_apps_composer-3.0.30 recipes/analytics.rb
rails_apps_composer-3.0.29 recipes/analytics.rb
rails_apps_composer-3.0.28 recipes/analytics.rb
rails_apps_composer-3.0.27 recipes/analytics.rb
rails_apps_composer-3.0.26 recipes/analytics.rb
rails_apps_composer-3.0.25 recipes/analytics.rb
rails_apps_composer-3.0.24 recipes/analytics.rb
rails_apps_composer-3.0.23 recipes/analytics.rb