Class: PreactGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Defined in:
lib/generators/preact_generator.rb

Instance Method Summary collapse

Instance Method Details

#create_config_fileObject



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/generators/preact_generator.rb', line 17

def create_config_file
  create_file "config/preact.yml", <<-FILE
# Preact Logging Configs
production: &defaults

# your Preact API credentials
code: "#{project_code}"
secret: "#{api_secret}"

# automatically log controller actions for authed users
# disable this if you want to only log manual events
autolog: true

# specify controller#action items that you want to ignore and not log to Preact.
# default is to not log sessions#create beacuse if you're using Devise, we get that already
autolog_ignored_actions:
  - "sessions#create"
  - "devise/sessions#create"

# specify how to retrieve the current user and account from within the application controller
# you may use either an instance variable (prefixed with @) or a method name
#current_user_getter: "current_user"
#current_account_getter: "@current_account"

development:
<<: *defaults

# we usually suggest that you use a different project for development, to keep
# those events separate from production events
#code: "DEV_CODE"
#secret: "DEV_SECRET"

# you may also completely disable event logging in development
#disabled: false

staging:
<<: *defaults

# if you want to log staging events separately as well
#code: "STAGING_CODE"
#secret: "STAGING_SECRET"

# you may also completely disable event logging in staging
#disabled: false
FILE
end

#create_initializer_fileObject



6
7
8
9
10
11
12
13
14
15
# File 'lib/generators/preact_generator.rb', line 6

def create_initializer_file
  create_file "config/initializers/preact.rb", <<-FILE
# Preact Logging Configuration
# see documentation about configuration options here: https://github.com/preact/preact-ruby
Preact.configure do |config|
# all standard configuration is done in the config/preact.yml file
# if you need to do smarter things during configuration, do them here
end
FILE
end