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.22 recipes/analytics.rb
rails_apps_composer-3.0.21 recipes/analytics.rb
rails_apps_composer-3.0.20 recipes/analytics.rb
rails_apps_composer-3.0.19 recipes/analytics.rb
rails_apps_composer-3.0.18 recipes/analytics.rb
rails_apps_composer-3.0.17 recipes/analytics.rb
rails_apps_composer-3.0.16 recipes/analytics.rb
rails_apps_composer-3.0.15 recipes/analytics.rb
rails_apps_composer-3.0.14 recipes/analytics.rb
rails_apps_composer-3.0.13 recipes/analytics.rb
rails_apps_composer-3.0.12 recipes/analytics.rb
rails_apps_composer-3.0.11 recipes/analytics.rb
rails_apps_composer-3.0.10 recipes/analytics.rb