Class: Meerstats::Installer

Inherits:
Object
  • Object
show all
Defined in:
lib/meerstats/installer.rb

Class Method Summary collapse

Class Method Details

.performObject



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/meerstats/installer.rb', line 3

def self.perform
  if defined?(Rails)
    file_path = Rails.root.join('config', 'initializers', 'meerstats.rb')
  else
    file_path = Dir.pwd + '/config/initializers/meerstats.rb'
  end

  file_contents = <<-FILE
Meerstats.configure do |config|
  config.access_token = ENV['MEERSTATS_TOKEN']
end

# Sample usage:
# Meerstats.add_daily :confirmed_users,  -> { User.confirmed }
# Meerstats.add_daily :unpaid_orders,    -> { Order.unpaid }
# Meerstats.add_cumulative :total_users, -> { User }
FILE

  File.write(file_path, file_contents)
end