Class: Gricer::Config
- Inherits:
-
Object
- Object
- Gricer::Config
- Defined in:
- lib/gricer/config.rb
Overview
The configuration object for Gricer
Instance Attribute Summary collapse
-
#admin_layout ⇒ String
Configure to use another layout than the application default for Gricer controllers.
-
#admin_menu ⇒ Array
Configure the structure of Gricer’s admin menu.
-
#admin_prefix ⇒ String
Configure the prefix for admin pages paths.
-
#exclude_paths ⇒ Regexp
Configure page urls matching this Expression to be excluded from being tracked in Gricer statistics Default is to exclude the admin pages.
-
#geoip_dat ⇒ String
Configure the data file used by GeoIP If you configure #geoip_db this property will be ignored.
-
#geoip_db ⇒ GeoIP::City
Configure the database instance used by GeoIP.
-
#max_session_duration ⇒ Integer
Configure after which time of inactivity the Gricer::Session should expire.
-
#model_type ⇒ Symbol
Configure which type of models should be used in Gricer.
-
#table_name_prefix ⇒ String
The prefix for table names of gricer database tables.
Instance Method Summary collapse
- #agent_model ⇒ Object
-
#configure {|config| ... } ⇒ Gricer::Config
Configure your Gricer Rails Engine with the given parameters in the block.
-
#initialize(&block) ⇒ Gricer::Config
constructor
A new instance of Gricer::Config.
- #request_model ⇒ Object
- #session_model ⇒ Object
Constructor Details
#initialize(&block) ⇒ Gricer::Config
A new instance of Gricer::Config.
Configure options can be passed in a block.
20 21 22 |
# File 'lib/gricer/config.rb', line 20 def initialize(&block) configure(&block) if block_given? end |
Instance Attribute Details
#admin_layout ⇒ String
Configure to use another layout than the application default for Gricer controllers
Default value is nil
53 54 55 |
# File 'lib/gricer/config.rb', line 53 def admin_layout @admin_layout end |
#admin_menu ⇒ Array
Configure the structure of Gricer’s admin menu
Default value see source
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/gricer/config.rb', line 61 def @admin_menu ||= [ ['overview', :dashboard, {controller: 'gricer/dashboard', action: 'overview'}], ['visitors', :menu, [ ['entry_pages', :spread, {controller: 'gricer/requests', action: 'spread_stats', field: 'entry_path'}], ['referers', :spread, {controller: 'gricer/requests', action: 'spread_stats', field: 'referer_host'}], ['search_engines', :spread, {controller: 'gricer/requests', action: 'spread_stats', field: 'search_engine'}], ['search_terms', :spread, {controller: 'gricer/requests', action: 'spread_stats', field: 'search_query'}], ['countries', :spread, {controller: 'gricer/sessions', action: 'spread_stats', field: 'country'}], ['domains', :spread, {controller: 'gricer/sessions', action: 'spread_stats', field: 'domain'}], ['locales', :spread, {controller: 'gricer/sessions', action: 'spread_stats', field: 'requested_locale_major'}] ] ], ['pages', :menu, [ ['views', :spread, {controller: 'gricer/requests', action: 'spread_stats', field: 'path'}], ['hosts', :spread, {controller: 'gricer/requests', action: 'spread_stats', field: 'host'}], ['methods', :spread, {controller: 'gricer/requests', action: 'spread_stats', field: 'method'}], ['protocols', :spread, {controller: 'gricer/requests', action: 'spread_stats', field: 'protocol'}], ] ], ['browsers', :menu, [ ['browsers', :spread, {controller: 'gricer/sessions', action: 'spread_stats', field: 'agent.name'}], ['operating_systems', :spread, {controller: 'gricer/sessions', action: 'spread_stats', field: 'agent.os'}], ['engines', :spread, {controller: 'gricer/sessions', action: 'spread_stats', field: 'agent.engine_name'}], ['javascript', :spread, {controller: 'gricer/sessions', action: 'spread_stats', field: 'javascript'}], ['java', :spread, {controller: 'gricer/sessions', action: 'spread_stats', field: 'java'}], ['silverlight', :spread, {controller: 'gricer/sessions', action: 'spread_stats', field: 'silverlight_major_version'}], ['flash', :spread, {controller: 'gricer/sessions', action: 'spread_stats', field: 'flash_major_version'}], ['screen_sizes', :spread, {controller: 'gricer/sessions', action: 'spread_stats', field: 'screen_size'}], ['color_depths', :spread, {controller: 'gricer/sessions', action: 'spread_stats', field: 'screen_depth'}] ] ] ] end |
#admin_prefix ⇒ String
Configure the prefix for admin pages paths
Default value is ‘gricer’
45 46 47 |
# File 'lib/gricer/config.rb', line 45 def admin_prefix @admin_prefix.blank? ? 'gricer' : @admin_prefix end |
#exclude_paths ⇒ Regexp
Configure page urls matching this Expression to be excluded from being tracked in Gricer statistics Default is to exclude the admin pages
96 97 98 |
# File 'lib/gricer/config.rb', line 96 def exclude_paths @exclude_paths ||= /^#{admin_prefix}$/ end |
#geoip_dat ⇒ String
Configure the data file used by GeoIP If you configure #geoip_db this property will be ignored.
Default is no data file given.
105 106 107 |
# File 'lib/gricer/config.rb', line 105 def geoip_dat @geoip_dat end |
#geoip_db ⇒ GeoIP::City
Configure the database instance used by GeoIP
Default is none GeoIP database configured
113 114 115 |
# File 'lib/gricer/config.rb', line 113 def geoip_db @geoip_db ||= geoip_dat ? GeoIP::City.new(geoip_dat, :index, false) : nil end |
#max_session_duration ⇒ Integer
Configure after which time of inactivity the Gricer::Session should expire
Default is 15 minutes
121 122 123 |
# File 'lib/gricer/config.rb', line 121 def max_session_duration @max_session_duration ||= 15.minutes end |
#model_type ⇒ Symbol
Configure which type of models should be used in Gricer
Set to :ActiveRecord or :Mongoid
Default is :ActiveRecord
131 132 133 |
# File 'lib/gricer/config.rb', line 131 def model_type @model_type ||= :ActiveRecord end |
#table_name_prefix ⇒ String
The prefix for table names of gricer database tables.
Default value is ‘gricer_’
37 38 39 |
# File 'lib/gricer/config.rb', line 37 def table_name_prefix @table_name_prefix ||= 'gricer_' end |
Instance Method Details
#agent_model ⇒ Object
143 144 145 |
# File 'lib/gricer/config.rb', line 143 def agent_model "Gricer::#{model_type}::Agent".constantize end |
#configure {|config| ... } ⇒ Gricer::Config
Configure your Gricer Rails Engine with the given parameters in the block. For possible options see Instance Attributes.
29 30 31 |
# File 'lib/gricer/config.rb', line 29 def configure(&block) yield(self) end |
#request_model ⇒ Object
139 140 141 |
# File 'lib/gricer/config.rb', line 139 def request_model "Gricer::#{model_type}::Request".constantize end |
#session_model ⇒ Object
135 136 137 |
# File 'lib/gricer/config.rb', line 135 def session_model "Gricer::#{model_type}::Session".constantize end |